selectProduce.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="选择" @clickLeft="backAdd">
  4. <!--右菜单-->
  5. <template slot="right">
  6. <u-button type="success" size="small" class="u-reset-button" @click="$refs.treePicker._show()"
  7. text="选择分类"></u-button>
  8. </template>
  9. </uni-nav-bar>
  10. <view class="searchBox">
  11. <input v-model="searchVal" placeholder="请输入编码/名称" class="searchInput" />
  12. <u-button type="icon-shixiangxinzeng" size="30" @click="doSearch" data-icon="Search" class="searchBtn">
  13. <view class="iconfont icon-sousuo"></view>
  14. <view class="text">搜索</view>
  15. </u-button>
  16. </view>
  17. <view class="wrapper">
  18. <u-list @scrolltolower="scrolltolower" class="listContent">
  19. <checkbox-group v-for="(item, index) in listData" :key="index" @change="e => selectVal(e, item, index)">
  20. <label>
  21. <view class="listBox">
  22. <view class="listBox-sel">
  23. <checkbox :value="item.code" color="#fff" :disabled="item.disabled"
  24. :checked="item.checked" />
  25. </view>
  26. <view class="listBox-con">
  27. <view class="listBox-top">
  28. <view class="listBox-name">
  29. {{ item.name }}
  30. </view>
  31. <view class="listBox-code">
  32. {{ item.code }}
  33. </view>
  34. </view>
  35. <view class="listBox-bottom">
  36. <view>牌号:{{ item.brandNum }}</view>
  37. <view>型号:{{ item.modelType }}</view>
  38. <view>规格:{{ item.specification }}</view>
  39. <view>计量单位:{{ item.measuringUnit }}</view>
  40. <view>包装单位:{{ item.packingUnit }}</view>
  41. <view>重量单位:{{ item.weightUnit }}</view>
  42. <view>操作:
  43. <u-button :plain="true" :hairline="true" size='mini' type="primary" text="选择PBom" @click="action(item)"></u-button>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </label>
  49. </checkbox-group>
  50. <u-empty class="noDate" style="margin-top: 20vh" v-if="!listData.length"></u-empty>
  51. </u-list>
  52. </view>
  53. <view class="footer">
  54. <view class="bottom" v-if="this.isAll==1">
  55. <checkbox v-if="!seletedAll" color="#fff" :checked="seletedAll" @tap="_seletedAll">全选</checkbox>
  56. <checkbox class="select-all" color="#fff" v-else :checked="seletedAll" @tap="_seletedAll">取消全选
  57. </checkbox>
  58. </view>
  59. <u-button type="success" size="small" class="u-reset-button" :disabled="!checkListLen" @click="jumpAdd">
  60. <view class="selBtn">选择( {{ checkListLen }} )</view>
  61. </u-button>
  62. </view>
  63. <ba-tree-picker ref="treePicker" key="verify" :multiple="false" @select-change="confirm" title="选择分类"
  64. :localdata="classificationList" valueKey="id" textKey="name" />
  65. </view>
  66. </template>
  67. <script>
  68. import {
  69. getProduceTreeByPid,
  70. getCategoryList,
  71. getCategoryPackageDisposition
  72. } from '@/api/warehouseManagement'
  73. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  74. import { contactQueryByCategoryIdsAPI } from '@/api/warehouseManagement/index'
  75. import { getInventoryTotal } from '@/api/pda/workOrder'
  76. export default {
  77. components: {
  78. baTreePicker
  79. },
  80. data() {
  81. return {
  82. page: 1,
  83. size: 20,
  84. isEnd: true,
  85. searchVal: '',
  86. pickTabIndex: 1,
  87. popupShow: false, //右侧搜索窗
  88. typeIndex: 1,
  89. listData: [], //列表数据
  90. classificationList: [], //分类数据
  91. seletedAll: false, //全选状态,
  92. isAll: ''
  93. }
  94. },
  95. //选择的列表长度
  96. computed: {
  97. checkListLen() {
  98. return this.listData.filter(el => el.checked).length
  99. },
  100. },
  101. created() {
  102. uni.$off('setPBom');
  103. uni.$on('setPBom', async (data) => {
  104. let list = data;
  105. //获取供应商
  106. // if (this.isSupplier) {
  107. let supplierList = await this.getSupplierObj(list, 'categoryId');
  108. list.forEach((item) => {
  109. item['supplierList'] = supplierList[item.categoryId]?.map(i => {
  110. return {
  111. ...i,
  112. text: i.name,
  113. value: i.id
  114. }
  115. }) || [];
  116. // item['entrustedEnterpriseIdList'] = supplierList[item.categoryId];
  117. if (supplierList[item.categoryId]?.length) {
  118. // item['entrustedEnterpriseId'] = supplierList[item.id][0].id;
  119. item['supplierCode'] = supplierList[item.categoryId][0].code;
  120. item['supplierId'] = supplierList[item.categoryId][0].id;
  121. item['supplierName'] = supplierList[item.categoryId][0].name;
  122. }
  123. });
  124. // }
  125. uni.$emit(
  126. 'setPBomList',
  127. list
  128. )
  129. uni.navigateBack()
  130. })
  131. },
  132. onUnload() {
  133. uni.$off('setPBom')
  134. },
  135. onLoad({
  136. isAll
  137. }) {
  138. this.isAll = isAll //1多选 2单选
  139. this.getClassify()
  140. },
  141. onShow() {},
  142. methods: {
  143. async getSupplierObj(productList, queryName) {
  144. try {
  145. let categoryIds = productList
  146. .filter((item) => item[queryName])
  147. .map((item) => item[queryName]);
  148. if (categoryIds.length > 0) {
  149. return await contactQueryByCategoryIdsAPI({
  150. categoryIds
  151. });
  152. } else {
  153. return Promise.resolve({});
  154. }
  155. } catch (e) {
  156. return Promise.resolve({});
  157. }
  158. },
  159. scrolltolower() {
  160. if (this.isEnd) {
  161. return
  162. }
  163. // 显示加载图标
  164. uni.showLoading({
  165. title: '数据加载中'
  166. })
  167. //获取更多数据
  168. this.page++
  169. this.getList()
  170. },
  171. //列表数据
  172. async getList() {
  173. this.isEnd = false
  174. this._getClassifyList()
  175. },
  176. async _getClassifyList() {
  177. uni.showLoading({
  178. title: '数据加载中'
  179. })
  180. const params = {
  181. pageNum: this.page,
  182. size: this.size,
  183. searchKey: this.searchVal,
  184. categoryLevelId: this.categoryLevelId
  185. }
  186. getCategoryList(params).then(res => {
  187. uni.hideLoading()
  188. if (this.page == 1) {
  189. this.listData = []
  190. }
  191. this.listData = this.listData.concat(res.list)
  192. this.isEnd = this.listData.length >= res.count
  193. })
  194. },
  195. confirm([id]) {
  196. this.categoryLevelId = id
  197. this.page = 1
  198. this.getList()
  199. },
  200. async getClassify() {
  201. getProduceTreeByPid({
  202. type: 1
  203. }).then(res => {
  204. this.classificationList = res
  205. this.page = 1
  206. this.getList()
  207. });
  208. },
  209. doSearch() {
  210. this.page = 1
  211. this.getList()
  212. },
  213. //勾选
  214. selectVal(e, val, index) {
  215. this.$set(this.listData[index], 'checked', !this.listData[index].checked)
  216. if (this.isAll != 1) {
  217. this.listData.forEach((item, i) => {
  218. if (item.id != val.id) {
  219. this.$set(this.listData[i], 'checked', false)
  220. }
  221. })
  222. } else {
  223. this.seletedAll = !this.listData.some(item => !item.checked)
  224. }
  225. },
  226. //全选按钮
  227. _seletedAll() {
  228. if (!this.seletedAll) {
  229. this.seletedAll = true
  230. this.listData.map(item => {
  231. this.$set(item, 'checked', true)
  232. })
  233. } else {
  234. this.seletedAll = false
  235. this.listData.map(item => {
  236. this.$set(item, 'checked', false)
  237. })
  238. }
  239. },
  240. //跳转回添加页面
  241. async jumpAdd() {
  242. let list = this.listData.filter(item => item.checked)
  243. let codeList = list.map((item) => item.code);
  244. let idList = list.map((item) => item.id);
  245. //获取仓库库存
  246. // if (this.isGetInventoryTotal) {
  247. let inventoryTotalList = await getInventoryTotal(codeList);
  248. list.forEach((item) => {
  249. let find =
  250. inventoryTotalList.find((key) => key.code == item.code) || {};
  251. item.availableCountBase = find.availableCountBase;
  252. });
  253. // }
  254. //获取供应商
  255. // if (this.isSupplier) {
  256. let supplierList = await this.getSupplierObj(list, 'id');
  257. list.forEach((item) => {
  258. item['supplierList'] = supplierList[item.id]?.map(i => {
  259. return {
  260. ...i,
  261. text: i.name,
  262. value: i.id
  263. }
  264. }) || [];
  265. item['entrustedEnterpriseIdList'] = supplierList[item.id]?.map(i => {
  266. return {
  267. ...i,
  268. text: i.name,
  269. value: i.id
  270. }
  271. }) || [];
  272. if (supplierList[item.id]?.length) {
  273. item['entrustedEnterpriseId'] = supplierList[item.id][0].id;
  274. item['supplierCode'] = supplierList[item.id][0].code;
  275. item['supplierId'] = supplierList[item.id][0].id;
  276. item['supplierName'] = supplierList[item.id][0].name;
  277. }
  278. });
  279. // }
  280. // 获取包装规格
  281. let packingSpecification = await getCategoryPackageDisposition({
  282. categoryIds: idList
  283. });
  284. list.forEach((item) => {
  285. item['packageDispositionList'] = packingSpecification
  286. .filter((ite) => item.id == ite.categoryId && ite.conversionUnit)
  287. .sort((a, b) => a.sort - b.sort);
  288. if (item.level) {
  289. item['goodsLevel'] = levelList.find(
  290. (val) => val.label == item.level
  291. )?.value;
  292. }
  293. });
  294. // 获取包装规格
  295. // let packingSpecification = await getCategoryPackageDisposition({
  296. // categoryIds: list.map(item => item.id)
  297. // });
  298. // list.forEach((item) => {
  299. // item['packageDispositionList'] = packingSpecification
  300. // .filter((ite) => item.id == ite.categoryId && ite.conversionUnit)
  301. // .sort((a, b) => a.sort - b.sort);
  302. // });
  303. uni.$emit(
  304. 'setProduceList',
  305. list
  306. )
  307. uni.navigateBack()
  308. },
  309. //返回添加页
  310. backAdd() {
  311. uni.navigateBack()
  312. },
  313. action(item) {
  314. uni.navigateTo({
  315. url: '/pages/purchasingManage/components/selectPBom?isAll=' + 2 + '&id=' + item.id
  316. })
  317. },
  318. }
  319. }
  320. </script>
  321. <style lang="scss" scoped>
  322. .mainBox {
  323. height: 100vh;
  324. display: flex;
  325. flex-direction: column;
  326. .wrapper {
  327. flex: 1;
  328. overflow: hidden;
  329. }
  330. .searchBox {
  331. padding: 10rpx 0;
  332. box-sizing: border-box;
  333. background-color: #dedede;
  334. height: 90rpx;
  335. width: 100%;
  336. line-height: 90rpx;
  337. display: flex;
  338. justify-content: space-around;
  339. align-items: center;
  340. input {
  341. height: 78rpx;
  342. width: 65%;
  343. background: #f9f9f9 !important;
  344. margin: 0 10rpx;
  345. padding: 0 10rpx;
  346. box-sizing: border-box;
  347. border-radius: 5rpx;
  348. }
  349. .searchBtn {
  350. height: 80rpx;
  351. background: #f9f9f9 !important;
  352. color: #676767;
  353. font-size: 28rpx;
  354. padding: 0 42rpx;
  355. box-sizing: border-box;
  356. outline: none;
  357. border: none;
  358. width: 260rpx;
  359. .icon-sousuo {
  360. font-size: 22px;
  361. }
  362. .text {
  363. font-size: 16px;
  364. margin-left: 10px;
  365. }
  366. }
  367. }
  368. .tab-title {
  369. position: fixed;
  370. top: 190rpx;
  371. z-index: 99;
  372. width: 100%;
  373. display: flex;
  374. justify-content: space-between;
  375. align-items: center;
  376. height: $tab-height;
  377. line-height: $tab-height;
  378. background-color: #ffffff;
  379. border-bottom: 2rpx solid #f2f2f2;
  380. box-sizing: border-box;
  381. .tab-item {
  382. width: 25%;
  383. text-align: center;
  384. font-size: 32rpx;
  385. color: $uni-text-color-grey;
  386. }
  387. .tab-item.active {
  388. color: $j-primary-border-green;
  389. border-bottom: 1px solid $j-primary-border-green;
  390. font-weight: bold;
  391. }
  392. .tab-item.filter {
  393. flex: 1;
  394. padding: 0px 30rpx;
  395. .uni-icons {
  396. display: flex;
  397. padding-top: 5px;
  398. }
  399. }
  400. .screenIcon {
  401. display: flex;
  402. width: 80px;
  403. justify-content: center;
  404. .screenText {
  405. font-size: 32rpx;
  406. color: $uni-text-color-grey;
  407. }
  408. }
  409. }
  410. .listContent {
  411. height: 100% !important;
  412. .listBox {
  413. display: flex;
  414. // height: 180rpx;
  415. padding: 20rpx 0;
  416. border-bottom: 2rpx solid #e5e5e5;
  417. .listBox-sel {
  418. height: 90rpx;
  419. width: 80rpx;
  420. // line-height: 90rpx;
  421. text-align: center;
  422. checkbox {
  423. transform: scale(1.2);
  424. }
  425. }
  426. .listBox-con {
  427. width: 100%;
  428. // display: flex;
  429. // flex-wrap: wrap;
  430. // justify-content: space-between;
  431. align-items: center;
  432. padding: 0 18rpx 0 0;
  433. .listBox-top {
  434. width: 100%;
  435. display: flex;
  436. justify-content: space-between;
  437. padding-bottom: 10rpx;
  438. .listBox-name,
  439. .listBox-code {
  440. display: inline-block;
  441. font-size: $uni-font-size-sm;
  442. font-weight: bold;
  443. }
  444. }
  445. .listBox-bottom {
  446. width: 100%;
  447. display: flex;
  448. justify-content: space-between;
  449. font-size: $uni-font-size-sm;
  450. flex-wrap: wrap;
  451. >view {
  452. width: 50%;
  453. overflow: hidden;
  454. white-space: nowrap;
  455. text-overflow: ellipsis;
  456. }
  457. }
  458. }
  459. }
  460. .noDate {
  461. height: 100%;
  462. }
  463. }
  464. //底部按钮
  465. .footer {
  466. height: 90rpx;
  467. position: relative;
  468. display: flex;
  469. justify-content: space-between;
  470. align-items: center;
  471. bottom: 0;
  472. width: 100%;
  473. height: 100rpx;
  474. border-top: 1rpx solid #eeecec;
  475. background-color: #ffffff;
  476. z-index: 999;
  477. .bottom {
  478. margin-left: 10rpx;
  479. }
  480. .u-reset-button {
  481. position: absolute;
  482. right: 10rpx;
  483. top: 20rpx;
  484. width: 150rpx;
  485. }
  486. }
  487. .text-color {
  488. color: #409eff;
  489. }
  490. }
  491. </style>