materialDialog.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <u-popup :show="searchVisible" mode="bottom" @close="searchVisible = false">
  3. <view class="main-box">
  4. <view class="wrapper">
  5. <view class="searchBox">
  6. <input
  7. v-model="searchKey"
  8. placeholder="请输入关键字搜索"
  9. class="searchInput"
  10. />
  11. <u-button
  12. type="icon-shixiangxinzeng"
  13. size="30"
  14. @click="doSearch"
  15. data-icon="Search"
  16. class="searchBtn"
  17. >
  18. <view class="iconfont icon-sousuo"> </view>
  19. <view class="text"> 搜索 </view>
  20. </u-button>
  21. </view>
  22. </view>
  23. <view class="listContent">
  24. <checkbox-group
  25. v-for="(item, index) in listData"
  26. :key="index"
  27. @change="(e) => selectVal(e, item, index)"
  28. >
  29. <label>
  30. <view class="listBox">
  31. <view class="listBox-sel">
  32. <checkbox
  33. :value="item.code"
  34. color="#fff"
  35. :disabled="item.disabled"
  36. :checked="item.checked"
  37. />
  38. </view>
  39. <view class="listBox-con">
  40. <view class="listBox-top">
  41. <view class="listBox-name">
  42. {{ item.assetName }}
  43. </view>
  44. <view class="listBox-code">
  45. {{ item.assetCode }}
  46. </view>
  47. </view>
  48. <view class="listBox-bottom">
  49. <view class="items"> 编码:{{ item.categoryCode }} </view>
  50. <view class="items"> 名称:{{ item.categoryName }} </view>
  51. <view class="items"> 牌号:{{ item.brandNum }} </view>
  52. <view class="items"> 型号:{{ item.model }} </view>
  53. </view>
  54. </view>
  55. </view>
  56. </label>
  57. </checkbox-group>
  58. <u-empty style="margin-top: 20vh" v-if="!listData.length"> </u-empty>
  59. </view>
  60. <view class="footer">
  61. <view class="footer-cancel" @click="close">关闭</view>
  62. <view class="footer-comfirm" @click="handleComfirm">选择</view>
  63. </view>
  64. </view>
  65. </u-popup>
  66. </template>
  67. <script>
  68. import { bomSubListByVersionId } from "@/api/classifyManage/itemInformation";
  69. export default {
  70. props: {
  71. chooseList: {
  72. type: Array,
  73. default: function () {
  74. return [];
  75. },
  76. },
  77. params: {
  78. type: Object,
  79. default: function () {
  80. return {};
  81. },
  82. },
  83. },
  84. data() {
  85. return {
  86. searchVisible: false,
  87. searchKey: "",
  88. curId: "",
  89. listData: [],
  90. memoList: [],
  91. };
  92. },
  93. methods: {
  94. //勾选
  95. selectVal(e, val, index) {
  96. this.listData[index].checked = !this.listData[index].checked;
  97. this.seletedAll = !this.listData.some((item) => !item.checked);
  98. const idx = this.memoList.findIndex(
  99. (item) => item.curId === this.listData[index].curId
  100. );
  101. if (this.listData[index].checked) {
  102. if (idx === -1) {
  103. this.memoList.push(this.listData[index]);
  104. }
  105. } else {
  106. if (idx > -1) {
  107. this.memoList.splice(idx, 1);
  108. }
  109. }
  110. },
  111. async getList() {
  112. const res = await bomSubListByVersionId(this.params);
  113. this.listData = res;
  114. for (var i = 0; i < this.listData.length; i++) {
  115. for (var j = 0; j < this.chooseList.length; j++) {
  116. if (this.listData[i].id == this.chooseList[j].id) {
  117. this.listData[i].checked = true;
  118. }
  119. }
  120. }
  121. // console.log(res);
  122. },
  123. doSearch() {
  124. page = 1;
  125. this.getList();
  126. },
  127. handleComfirm() {
  128. this.$emit("affirm", this.memoList);
  129. this.close();
  130. },
  131. open() {
  132. this.searchVisible = true;
  133. this.getList();
  134. },
  135. close() {
  136. this.searchVisible = false;
  137. },
  138. select(list) {
  139. this.$emit("affirm", list);
  140. this.searchVisible = false;
  141. },
  142. },
  143. };
  144. </script>
  145. <style scoped lang="scss">
  146. .title {
  147. line-height: 80rpx;
  148. font-size: $uni-font-size-lg;
  149. text-align: center;
  150. font-weight: bold;
  151. position: relative;
  152. .choose-box {
  153. position: absolute;
  154. right: 10rpx;
  155. top: 0;
  156. font-weight: normal;
  157. font-size: $uni-font-size-sm;
  158. color: $j-primary-green;
  159. }
  160. }
  161. .main-box {
  162. height: 90vh;
  163. display: flex;
  164. flex-direction: column;
  165. }
  166. .wrapper {
  167. padding-top: 50px;
  168. position: relative;
  169. }
  170. .searchBox {
  171. position: absolute;
  172. top: 0;
  173. z-index: 99;
  174. background-color: #dedede;
  175. height: 50px;
  176. width: 100%;
  177. line-height: 50px;
  178. display: flex;
  179. justify-content: space-around;
  180. align-items: center;
  181. input {
  182. height: 40px;
  183. width: 65%;
  184. background: #f9f9f9 !important;
  185. margin-left: 20rpx;
  186. padding-left: 10rpx;
  187. border-radius: 5rpx;
  188. }
  189. .searchBtn {
  190. height: 40px;
  191. background: #f9f9f9 !important;
  192. color: #676767;
  193. font-size: 28rpx;
  194. width: 260rpx;
  195. padding: 0 42rpx;
  196. outline: none;
  197. border: none;
  198. .icon-sousuo {
  199. font-size: 22px;
  200. }
  201. .text {
  202. font-size: 16px;
  203. margin-left: 10px;
  204. }
  205. }
  206. }
  207. .listContent {
  208. // margin-top: 100rpx;
  209. padding-bottom: 100rpx;
  210. flex: 1;
  211. overflow-x: scroll;
  212. .listBox {
  213. display: flex;
  214. // height: 180rpx;
  215. padding: 20rpx 0;
  216. border-bottom: 2rpx solid #e5e5e5;
  217. .listBox-sel {
  218. height: 90rpx;
  219. width: 80rpx;
  220. line-height: 90rpx;
  221. text-align: center;
  222. checkbox {
  223. transform: scale(1.2);
  224. }
  225. }
  226. .listBox-con {
  227. width: 100%;
  228. // display: flex;
  229. // flex-wrap: wrap;
  230. // justify-content: space-between;
  231. align-items: center;
  232. padding: 0 18rpx 0 0;
  233. .listBox-top {
  234. width: 100%;
  235. display: flex;
  236. justify-content: space-between;
  237. padding-bottom: 10rpx;
  238. .listBox-name,
  239. .listBox-code {
  240. display: inline-block;
  241. font-size: $uni-font-size-sm;
  242. font-weight: bold;
  243. }
  244. .listBox-code {
  245. }
  246. }
  247. .listBox-bottom {
  248. width: 100%;
  249. display: flex;
  250. justify-content: space-between;
  251. flex-wrap: wrap;
  252. font-size: $uni-font-size-sm;
  253. .items {
  254. width: 50%;
  255. margin-bottom: 10rpx;
  256. }
  257. .bot-left,
  258. .bot-right {
  259. display: inline-block;
  260. color: $uni-text-color-grey;
  261. }
  262. .bot-right {
  263. }
  264. }
  265. }
  266. }
  267. }
  268. .footer {
  269. display: flex;
  270. align-items: center;
  271. justify-content: space-around;
  272. .footer-cancel {
  273. width: 50%;
  274. font-size: 36rpx;
  275. color: #fff;
  276. background: #ccc;
  277. text-align: center;
  278. line-height: 90rpx;
  279. }
  280. .footer-comfirm {
  281. width: 50%;
  282. font-size: 36rpx;
  283. color: #fff;
  284. background: #33cc66;
  285. text-align: center;
  286. line-height: 90rpx;
  287. }
  288. }
  289. </style>