contentBox.vue 7.0 KB

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