contentBox.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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="item.code + '-' + !!item.checked"
  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-bottom">
  44. <view class="items"> 名称:{{ item.category.name }} </view>
  45. <view class="items"> 固资编码:{{ item.fixCode }} </view>
  46. <view class="items"> 编号:{{ item.codeNumber }} </view>
  47. <view class="items"> 编码:{{ item.code }} </view>
  48. <view class="items"> 使用人:{{ item.usePerson }} </view>
  49. <view class="items"> 使用岗位:{{ item.postName }} </view>
  50. <view class="items"> 片区负责人负责人:{{ item.areaPersonInChargeUserName }} </view>
  51. <view class="items"> 型号:{{ item.category.modelType }} </view>
  52. <view class="items"> 规格:{{ item.category.specification }} </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="$emit('handleCancel')">关闭</view>
  62. <view class="footer-comfirm" @click="handleComfirm">选择</view>
  63. </view>
  64. <classificationPicker
  65. :warehousingType="warehousingType"
  66. ref="classificationRef"
  67. @confirm="classificationConfirm"
  68. />
  69. </view>
  70. </template>
  71. <script>
  72. import classificationPicker from "./classification-picker.vue";
  73. import { getAssetList } from "@/api/classifyManage/itemInformation";
  74. let page = 1;
  75. export default {
  76. components: { classificationPicker },
  77. props: {
  78. warehousingType: {
  79. type: [String, Number],
  80. default: "0", //默认原料
  81. },
  82. chooseList: {
  83. type: Array,
  84. default: function () {
  85. return [];
  86. },
  87. },
  88. multiple: {
  89. type: Boolean,
  90. default: false,
  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. if (this.multiple) {
  105. // 多选模式
  106. this.$set(this.listData[index], 'checked', !this.listData[index].checked);
  107. this.seletedAll = !this.listData.some((item) => !item.checked);
  108. const idx = this.memoList.findIndex(
  109. (item) => item.curId === this.listData[index].curId
  110. );
  111. if (this.listData[index].checked) {
  112. if (idx === -1) {
  113. this.memoList.push(this.listData[index]);
  114. }
  115. } else {
  116. if (idx > -1) {
  117. this.memoList.splice(idx, 1);
  118. }
  119. }
  120. } else {
  121. // 单选模式:清空其他选中,仅保留当前项
  122. this.listData.forEach((item, i) => {
  123. this.$set(item, 'checked', i === index ? !item.checked : false);
  124. });
  125. if (this.listData[index].checked) {
  126. this.memoList = [this.listData[index]];
  127. } else {
  128. this.memoList = [];
  129. }
  130. }
  131. },
  132. handleClassification() {
  133. this.$refs.classificationRef.show();
  134. },
  135. classificationConfirm([id], name) {
  136. this.curId = id;
  137. page = 1;
  138. this.getList();
  139. },
  140. async getList() {
  141. const res = await getAssetList({
  142. pageNum: page,
  143. size: -1,
  144. categoryLevelId: this.curId,
  145. searchKey: this.searchKey,
  146. });
  147. this.listData = res.list;
  148. for (var i = 0; i < this.listData.length; i++) {
  149. this.$set(this.listData[i], 'checked', false);
  150. for (var j = 0; j < this.chooseList.length; j++) {
  151. if (this.listData[i].id == this.chooseList[j].id) {
  152. this.$set(this.listData[i], 'checked', true);
  153. }
  154. }
  155. }
  156. // console.log(res);
  157. },
  158. doSearch() {
  159. page = 1;
  160. this.getList();
  161. },
  162. handleComfirm() {
  163. this.$emit("pick", this.memoList);
  164. },
  165. },
  166. };
  167. </script>
  168. <style scoped lang="scss">
  169. .title {
  170. line-height: 80rpx;
  171. font-size: $uni-font-size-lg;
  172. text-align: center;
  173. font-weight: bold;
  174. position: relative;
  175. .choose-box {
  176. position: absolute;
  177. right: 10rpx;
  178. top: 0;
  179. font-weight: normal;
  180. font-size: $uni-font-size-sm;
  181. color: $j-primary-green;
  182. }
  183. }
  184. .main-box {
  185. height: 90vh;
  186. display: flex;
  187. flex-direction: column;
  188. }
  189. .wrapper {
  190. padding-top: 50px;
  191. position: relative;
  192. }
  193. .searchBox {
  194. position: absolute;
  195. top: 0;
  196. z-index: 99;
  197. background-color: #dedede;
  198. height: 50px;
  199. width: 100%;
  200. line-height: 50px;
  201. display: flex;
  202. justify-content: space-around;
  203. align-items: center;
  204. input {
  205. height: 40px;
  206. width: 65%;
  207. background: #f9f9f9 !important;
  208. margin-left: 20rpx;
  209. padding-left: 10rpx;
  210. border-radius: 5rpx;
  211. }
  212. .searchBtn {
  213. height: 40px;
  214. background: #f9f9f9 !important;
  215. color: #676767;
  216. font-size: 28rpx;
  217. width: 260rpx;
  218. padding: 0 42rpx;
  219. outline: none;
  220. border: none;
  221. .icon-sousuo {
  222. font-size: 22px;
  223. }
  224. .text {
  225. font-size: 16px;
  226. margin-left: 10px;
  227. }
  228. }
  229. }
  230. .listContent {
  231. // margin-top: 100rpx;
  232. padding-bottom: 100rpx;
  233. flex: 1;
  234. overflow-x: scroll;
  235. .listBox {
  236. display: flex;
  237. // height: 180rpx;
  238. padding: 20rpx 0;
  239. border-bottom: 2rpx solid #e5e5e5;
  240. .listBox-sel {
  241. height: 90rpx;
  242. width: 80rpx;
  243. line-height: 90rpx;
  244. text-align: center;
  245. checkbox {
  246. transform: scale(1.2);
  247. }
  248. }
  249. .listBox-con {
  250. width: 100%;
  251. // display: flex;
  252. // flex-wrap: wrap;
  253. // justify-content: space-between;
  254. align-items: center;
  255. padding: 0 18rpx 0 0;
  256. .listBox-top {
  257. width: 100%;
  258. display: flex;
  259. justify-content: space-between;
  260. padding-bottom: 10rpx;
  261. .listBox-name,
  262. .listBox-code {
  263. display: inline-block;
  264. font-size: $uni-font-size-sm;
  265. font-weight: bold;
  266. }
  267. .listBox-code {
  268. }
  269. }
  270. .listBox-bottom {
  271. width: 100%;
  272. display: flex;
  273. justify-content: space-between;
  274. flex-wrap: wrap;
  275. font-size: $uni-font-size-sm;
  276. .items {
  277. width: 50%;
  278. margin-bottom: 10rpx;
  279. }
  280. .bot-left,
  281. .bot-right {
  282. display: inline-block;
  283. color: $uni-text-color-grey;
  284. }
  285. .bot-right {
  286. }
  287. }
  288. }
  289. }
  290. }
  291. .footer {
  292. display: flex;
  293. align-items: center;
  294. justify-content: space-around;
  295. .footer-cancel {
  296. width: 50%;
  297. font-size: 36rpx;
  298. color: #fff;
  299. background: #ccc;
  300. text-align: center;
  301. line-height: 90rpx;
  302. }
  303. .footer-comfirm {
  304. width: 50%;
  305. font-size: 36rpx;
  306. color: #fff;
  307. background: #33cc66;
  308. text-align: center;
  309. line-height: 90rpx;
  310. }
  311. }
  312. </style>