selectOutType.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. <template>
  2. <view class="mainBox">
  3. <view class="main">
  4. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="`选择${warehousingName}`"
  5. @clickLeft="backAdd">
  6. <!--右菜单-->
  7. <template slot="right">
  8. <u-button type="success" size="small" class="u-reset-button" @click="$refs.treePicker._show()"
  9. text="选择分类"></u-button>
  10. </template>
  11. </uni-nav-bar>
  12. <view class="top-wrapper">
  13. <uni-section>
  14. <uni-easyinput prefixIcon="search" style="width: 460rpx" v-model="searchVal" placeholder="请输入编码/名称">
  15. </uni-easyinput>
  16. </uni-section>
  17. <view style="display: flex;">
  18. <button class="search_btn" @click="doSearch">搜索</button>
  19. <view class="more_search">
  20. <image src="~@/static/moreSearch.svg" mode="" @click="searchVisible = true"></image>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="wrapper">
  25. <u-list @scrolltolower="scrolltolower" class="listContent">
  26. <checkbox-group v-for="(item, index) in listData" :key="index"
  27. @change.stop="e => selectVal(e, item, index)">
  28. <label>
  29. <view class="listBox">
  30. <view class="listBox-sel">
  31. <checkbox :value="item.code" color="#fff" :disabled="item.disabled"
  32. :checked="item.checked" />
  33. </view>
  34. <view class="listBox-con">
  35. <view style="display: flex;">
  36. <view class="listBox-top" style="justify-content: left;">
  37. <view class="round">{{Number(index)+1}}</view>
  38. <view class="listBox-name">
  39. {{ item.categoryName }}
  40. </view>
  41. </view>
  42. <view class="listBox-top">
  43. <view class="listBox-code">
  44. {{ item.categoryCode }}
  45. </view>
  46. </view>
  47. </view>
  48. <view class="listBox-bottom">
  49. <!-- <view v-for="(itm, index) in tableHeader" :key="index">{{ itm.label }}:{{ item[itm.prop] }}</view> -->
  50. <view>牌号:{{ item.brandNum }}</view>
  51. <view>型号:{{ item.modelType }}</view>
  52. <view>规格:{{ item.specification }}</view>
  53. <view v-if="dimension != 1">批次号:{{ item.batchNo }}</view>
  54. <view class="input_view" v-if="dimension != 3">
  55. 出库数量:
  56. <u--input type="number" placeholder="请输入" border="surround"
  57. v-model="item.outboundNum"
  58. @change="filterOutboundNum($event, item, index)"></u--input>
  59. </view>
  60. <view>计量数量:{{ item.measureQuantity }}({{ item.measureUnit }})</view>
  61. <view class="w100" v-if="dimension == 3">包装编码:{{ item.packageNo }}</view>
  62. <view v-if="dimension == 3">
  63. 包装数量:{{ item.packingQuantity }}({{ item.packingUnit }})</view>
  64. <view>重量:{{ item.weight }}({{ item.weightUnit }})</view>
  65. <view v-if="dimension == 3">发货条码:{{ item.barcodes }}</view>
  66. <view v-if="dimension == 3">物料代号:{{ item.materielDesignation }}</view>
  67. <view v-if="dimension == 3">客户代号:{{ item.clientCode }}</view>
  68. <view v-if="dimension == 3">刻码:{{ item.engrave }}</view>
  69. <view v-if="dimension == 3">仓库:{{ item.warehouseName }}</view>
  70. </view>
  71. </view>
  72. </view>
  73. </label>
  74. </checkbox-group>
  75. <u-empty class="noDate" style="margin-top: 20vh" v-if="!listData.length"></u-empty>
  76. </u-list>
  77. </view>
  78. <view class="footer">
  79. <view class="bottom">
  80. <checkbox v-if="!seletedAll" color="#fff" :checked="seletedAll" @tap="_seletedAll">全选</checkbox>
  81. <checkbox class="select-all" color="#fff" v-else :checked="seletedAll" @tap="_seletedAll">取消全选
  82. </checkbox>
  83. </view>
  84. <u-button type="success" size="small" class="u-reset-button" :disabled="!checkListLen" @click="jumpAdd">
  85. <view class="selBtn">选择( {{ checkListLen }} )</view>
  86. </u-button>
  87. </view>
  88. </view>
  89. <!-- 搜索组件 -->
  90. <u-popup :show="searchVisible" mode="top" @close="searchVisible = false" @open="openSearch">
  91. <!-- <view class="search-container">
  92. <view class="title">筛选</view>
  93. <uni-forms ref="customForm" :modelValue="popupInfo" label-position="top">
  94. <uni-forms-item label="列表维度" name="categoryCode">
  95. <uni-data-select v-model="popupInfo.dimension" :localdata="dimensionOptions"></uni-data-select>
  96. </uni-forms-item>
  97. <uni-forms-item label="仓库" name="sourceBizNo">
  98. <uni-data-select v-model="popupInfo.warehouseId"
  99. :localdata="warehouseListOption"></uni-data-select>
  100. </uni-forms-item>
  101. </uni-forms>
  102. <view class="footer">
  103. <view class="btn reset" @click="handleReset">重置</view>
  104. <view class="btn search" @click="handleSearch">搜索</view>
  105. </view>
  106. </view> -->
  107. <view class="search_list">
  108. <u-form labelPosition="left" :model="popupInfo" labelWidth="180" labelAlign="left" class="baseForm">
  109. <u-form-item label="列表维度:" class="required-form" borderBottom prop="assetType">
  110. <zxz-uni-data-select :localdata="dimensionOptions" v-model="popupInfo.dimension"
  111. dataValue='value' dataKey="text" filterable format='{text}'></zxz-uni-data-select>
  112. </u-form-item>
  113. <u-form-item label="仓库:" class="required-form" borderBottom prop="warehouseId">
  114. <zxz-uni-data-select :localdata="warehouseListOption" v-model="popupInfo.warehouseId"
  115. dataValue='value' dataKey="text" filterable format='{text}'></zxz-uni-data-select>
  116. </u-form-item>
  117. </u-form>
  118. </view>
  119. <view class="operate_box rx-bc">
  120. <u-button size="small" class="u-reset-button" @click="handleReset">
  121. 重置
  122. </u-button>
  123. <u-button type="success" size="small" class="u-reset-button" @click="handleSearch">
  124. 确定
  125. </u-button>
  126. </view>
  127. </u-popup>
  128. <ba-tree-picker ref="treePicker" key="verify" :multiple="false" @select-change="confirm" title="选择分类"
  129. :localdata="classificationList" valueKey="id" textKey="name" childrenKey="child" />
  130. </view>
  131. </template>
  132. <script>
  133. import {
  134. getTreeByIds,
  135. getPackingList,
  136. getWarehouseList,
  137. getProductList,
  138. getBatchList,
  139. getHierarchyList,
  140. getHierarchyFifo
  141. } from '@/api/warehouseManagement'
  142. import {
  143. warehousingType,
  144. tableContentData
  145. } from '@/pages/warehouse/enum.js'
  146. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  147. import {
  148. tableHeader
  149. } from '@/pages/warehouse/common'
  150. import UList from '@/uni_modules/uview-ui/components/u-list/u-list.vue'
  151. export default {
  152. components: {
  153. baTreePicker
  154. },
  155. data() {
  156. return {
  157. popupInfo: {
  158. dimension: 1,
  159. warehouseId: ''
  160. },
  161. dimension: 1,
  162. warehouseId: '',
  163. searchVisible: false,
  164. warehouseListOption: [],
  165. dimensionOptions: [{
  166. value: 1,
  167. text: '物品维度'
  168. },
  169. {
  170. value: 2,
  171. text: '批次维度'
  172. },
  173. {
  174. value: 3,
  175. text: '包装维度'
  176. }
  177. ],
  178. page: 1,
  179. size: 20,
  180. isEnd: true,
  181. searchVal: '',
  182. pickTabIndex: 1,
  183. popupShow: false, //右侧搜索窗
  184. typeIndex: 1,
  185. listData: [], //列表数据
  186. classificationList: [], //分类数据
  187. seletedAll: false, //全选状态
  188. bizScene: '',
  189. warehousingName: '',
  190. warehousingType: ''
  191. }
  192. },
  193. //选择的列表长度
  194. computed: {
  195. tableHeader() {
  196. return tableHeader(+this.warehousingType)
  197. },
  198. checkListLen() {
  199. console.log(
  200. 'this.listData.filter(el => el.checked)---',
  201. this.listData.filter(el => el.checked)
  202. )
  203. return this.listData.filter(el => el.checked).length
  204. },
  205. curTab() {
  206. return warehousingType.find(i => i.id == this.warehousingType) || {}
  207. }
  208. },
  209. onLoad({
  210. assetType
  211. }) {
  212. this.assetType = assetType
  213. this.categoryLevelId = assetType
  214. console.log('assetType---', assetType)
  215. console.log('assetType---', uni.getStorageSync('productList'))
  216. },
  217. //触底刷新
  218. // onReachBottom: function () {
  219. // if (this.isEnd) {
  220. // return
  221. // }
  222. // // 显示加载图标
  223. // uni.showLoading({
  224. // title: '数据加载中'
  225. // })
  226. // //获取更多数据
  227. // this.page++
  228. // this.getList()
  229. // },
  230. onShow() {
  231. this.getClassify()
  232. this.getwarehouseOptions()
  233. },
  234. methods: {
  235. openSearch() {
  236. this.popupInfo = {
  237. dimension: this.dimension,
  238. warehouseId: this.warehouseId
  239. }
  240. },
  241. filterOutboundNum(value, row, index) {
  242. if (value <= 0) {
  243. this.$set(this.listData[index], 'outboundNum', 1)
  244. }
  245. if (value > row.measureQuantity) {
  246. this.$set(this.listData[index], 'outboundNum', row.measureQuantity)
  247. }
  248. },
  249. //获取仓库
  250. getwarehouseOptions() {
  251. getWarehouseList().then(res => {
  252. this.warehouseListOption = res.data.map(item => {
  253. return {
  254. value: item.id,
  255. text: item.name
  256. }
  257. })
  258. })
  259. },
  260. handleReset() {
  261. this.popupInfo = {
  262. dimension: 3,
  263. warehouseId: ''
  264. }
  265. this.dimension = 3
  266. this.warehouseId = ''
  267. this.listData = []
  268. this.getList()
  269. },
  270. handleSearch() {
  271. this.dimension = this.popupInfo.dimension
  272. this.warehouseId = this.popupInfo.warehouseId
  273. this.getList()
  274. },
  275. scrolltolower() {
  276. if (this.isEnd) {
  277. return
  278. }
  279. // 显示加载图标
  280. uni.showLoading({
  281. title: '数据加载中'
  282. })
  283. //获取更多数据
  284. this.page++
  285. this.getList()
  286. },
  287. //列表数据
  288. async getList() {
  289. this.searchVisible = false
  290. this.isEnd = false
  291. this._getClassifyList()
  292. },
  293. async _getClassifyList() {
  294. uni.showLoading({
  295. title: '数据加载中'
  296. })
  297. let res = null
  298. const params = {
  299. pageNum: this.page,
  300. size: this.size,
  301. searchKey: this.searchVal,
  302. warehouseId: this.popupInfo.warehouseId,
  303. categoryLevelId: this.categoryLevelId
  304. }
  305. if (this.popupInfo.dimension == 1) {
  306. // 物品维度
  307. res = await getProductList(params)
  308. } else if (this.popupInfo.dimension == 2) {
  309. // 批次维度
  310. res = await getBatchList(params)
  311. for (let i = 0; i < res.list.length; i++) {
  312. res.list[i].outboundNum = res.list[i].measureQuantity;
  313. }
  314. } else {
  315. // 包装维度
  316. res = await getPackingList(params)
  317. for (let i = 0; i < res.list.length; i++) {
  318. res.list[i].outboundNum = res.list[i].packingQuantity;
  319. }
  320. }
  321. uni.hideLoading()
  322. if (this.page == 1) {
  323. this.listData = []
  324. }
  325. this.listData = this.listData.concat(res.list)
  326. this.isEnd = this.listData.length >= res.count
  327. this.updateProductOutboundNums(this.listData)
  328. },
  329. updateProductOutboundNums(list) {
  330. const productLists = uni.getStorageSync('productList')
  331. console.log(productLists, 'productLists');
  332. if (this.dimension == 1) {
  333. //物品层
  334. for (let i = 0; i < list.length; i++) {
  335. const item = list[i];
  336. const matchedProduct = productLists.find((product) => {
  337. const isMatch = product.categoryId === item.categoryId;
  338. return isMatch;
  339. });
  340. if (matchedProduct) {
  341. this.$set(item, 'outboundNum', matchedProduct.measureQuantity);
  342. this.$set(item, 'disabled', true); // 禁用勾选框
  343. }
  344. // const isSelection = this.selectionList.find(
  345. // (product) => product.categoryId === item.categoryId
  346. // );
  347. // if (isSelection) {
  348. // this.$set(item, 'outboundNum', isSelection.outboundNum);
  349. // }
  350. }
  351. } else {
  352. for (let i = 0; i < list.length; i++) {
  353. const item = list[i];
  354. const matchedProduct = productLists.find((product) => {
  355. const isMatch = product.id === item.id;
  356. return isMatch;
  357. });
  358. if (matchedProduct) {
  359. this.$set(item, 'outboundNum', matchedProduct.measureQuantity);
  360. this.$set(item, 'disabled', true); // 禁用勾选框
  361. }
  362. // const isSelection = this.selectionList.find(
  363. // (product) => product.id === item.id
  364. // );
  365. // if (isSelection) {
  366. // this.$set(item, 'outboundNum', isSelection.outboundNum);
  367. // }
  368. }
  369. }
  370. },
  371. confirm([id]) {
  372. console.log('id----------', id)
  373. this.categoryLevelId = id
  374. this.page = 1
  375. this.getList()
  376. },
  377. async getClassify() {
  378. getTreeByIds({
  379. ids: this.assetType
  380. }).then(res => {
  381. console.log('res--------', res)
  382. this.classificationList = res
  383. this.page = 1
  384. this.getList()
  385. })
  386. },
  387. doSearch() {
  388. this.page = 1
  389. this.getList()
  390. },
  391. //勾选
  392. selectVal(e, val, index) {
  393. this.$set(this.listData[index], 'checked', !this.listData[index].checked)
  394. // this.listData[index].checked = !this.listData[index].checked
  395. this.seletedAll = !this.listData.some(item => !item.checked)
  396. },
  397. //全选按钮
  398. _seletedAll() {
  399. if (!this.seletedAll) {
  400. this.seletedAll = true
  401. this.listData.map(item => {
  402. this.$set(item, 'checked', true)
  403. })
  404. } else {
  405. this.seletedAll = false
  406. //this.checkListLen = 0;
  407. this.listData.map(item => {
  408. this.$set(item, 'checked', false)
  409. })
  410. }
  411. },
  412. //跳转回添加页面
  413. async jumpAdd() {
  414. let selectionList = this.listData.filter(item => item.checked)
  415. if (this.dimension == 1) {
  416. let boolen = selectionList.every(item => item.outboundNum > 0)
  417. if (!boolen) {
  418. uni.showToast({
  419. icon: 'none',
  420. title: '请输入出库数量',
  421. duration: 2000
  422. })
  423. return
  424. }
  425. }
  426. let data = null;
  427. if (this.dimension == 3) {
  428. data = await getHierarchyList({
  429. ids: selectionList.map(item => item.id).join(','),
  430. type: this.dimension
  431. });
  432. } else if (this.dimension == 2) {
  433. data = await getHierarchyFifo({
  434. type: this.dimension,
  435. ids: selectionList.map(item => item.id),
  436. builders: selectionList.map((item) => {
  437. return {
  438. categoryId: item.categoryId,
  439. num: item.outboundNum,
  440. id: item.id
  441. };
  442. })
  443. });
  444. } else if (this.dimension == 1) {
  445. data = await getHierarchyFifo({
  446. type: this.dimension,
  447. builders: selectionList.map((item) => {
  448. return {
  449. categoryId: item.categoryId,
  450. num: item.outboundNum
  451. };
  452. })
  453. });
  454. }
  455. console.log('data-------------------', data)
  456. uni.$emit('setSelectList', data, this.dimension)
  457. uni.navigateBack()
  458. },
  459. //返回添加页
  460. backAdd() {
  461. uni.navigateBack()
  462. }
  463. }
  464. }
  465. </script>
  466. <style lang="scss" scoped>
  467. .mainBox {
  468. height: 100vh;
  469. .main {
  470. height: 100%;
  471. display: flex;
  472. flex-direction: column;
  473. }
  474. .top-wrapper {
  475. display: flex;
  476. height: 88rpx;
  477. align-items: center;
  478. justify-content: space-between;
  479. padding: 20rpx;
  480. /deep/.uni-section {
  481. margin-top: 0px;
  482. }
  483. /deep/.uni-section-header {
  484. padding: 0px;
  485. }
  486. .search_btn {
  487. width: 120rpx;
  488. height: 70rpx;
  489. line-height: 70rpx;
  490. background: $theme-color;
  491. font-size: 28rpx;
  492. color: #fff;
  493. }
  494. .menu_icon {
  495. width: 44rpx;
  496. height: 44rpx;
  497. margin-left: 14rpx;
  498. }
  499. .more_search {
  500. display: flex;
  501. align-items: center;
  502. height: 70rpx;
  503. line-height: 70rpx;
  504. }
  505. /deep/.u-input {
  506. border: 1rpx solid #ccc;
  507. .u-input__content__field-wrapper__field {
  508. height: 40rpx !important;
  509. }
  510. }
  511. image {
  512. width: 52rpx;
  513. height: 52rpx;
  514. margin-left: 10rpx;
  515. }
  516. }
  517. .wrapper {
  518. flex: 1;
  519. overflow: hidden;
  520. }
  521. .listContent {
  522. height: 100% !important;
  523. .listBox {
  524. display: flex;
  525. // height: 180rpx;
  526. padding: 20rpx 0;
  527. border-bottom: 2rpx solid #e5e5e5;
  528. .listBox-sel {
  529. height: 90rpx;
  530. width: 80rpx;
  531. // line-height: 90rpx;
  532. text-align: center;
  533. checkbox {
  534. transform: scale(1.2);
  535. }
  536. }
  537. .listBox-con {
  538. width: 100%;
  539. // display: flex;
  540. // flex-wrap: wrap;
  541. // justify-content: space-between;
  542. align-items: center;
  543. padding: 0 18rpx 0 0;
  544. .round {
  545. width: 40rpx;
  546. height: 40rpx;
  547. line-height: 40rpx;
  548. border-radius: 50%;
  549. background: $theme-color;
  550. color: #fff;
  551. text-align: center;
  552. font-size: 20rpx;
  553. }
  554. .listBox-top {
  555. width: 100%;
  556. display: flex;
  557. justify-content: space-between;
  558. padding-bottom: 10rpx;
  559. .listBox-name,
  560. .listBox-code {
  561. display: inline-block;
  562. font-size: $uni-font-size-sm;
  563. font-weight: bold;
  564. }
  565. }
  566. .listBox-bottom {
  567. width: 100%;
  568. display: flex;
  569. justify-content: space-between;
  570. font-size: $uni-font-size-sm;
  571. flex-wrap: wrap;
  572. >view {
  573. width: 50%;
  574. overflow: hidden;
  575. white-space: nowrap;
  576. text-overflow: ellipsis;
  577. }
  578. .input_view {
  579. display: flex;
  580. align-items: center;
  581. justify-content: center;
  582. .u-input {
  583. height: 36rpx;
  584. padding: 0 !important;
  585. margin-right: 10rpx;
  586. border: 1px solid #ddd;
  587. }
  588. }
  589. .w100 {
  590. width: 100%;
  591. }
  592. }
  593. }
  594. }
  595. .noDate {
  596. height: 100%;
  597. }
  598. }
  599. //底部按钮
  600. .footer {
  601. height: 90rpx;
  602. position: relative;
  603. display: flex;
  604. justify-content: space-between;
  605. align-items: center;
  606. bottom: 0;
  607. width: 100%;
  608. height: 100rpx;
  609. border-top: 1rpx solid #eeecec;
  610. background-color: #ffffff;
  611. z-index: 999;
  612. .bottom {
  613. margin-left: 10rpx;
  614. }
  615. .u-reset-button {
  616. position: absolute;
  617. right: 10rpx;
  618. top: 20rpx;
  619. width: 150rpx;
  620. }
  621. }
  622. .search_list {
  623. min-height: 100rpx;
  624. /deep/ .baseForm {
  625. padding: 0 20rpx;
  626. }
  627. }
  628. .operate_box {
  629. padding: 10rpx 32rpx;
  630. /deep/ .u-button {
  631. width: 40%;
  632. }
  633. }
  634. }
  635. </style>