selectOutType.vue 16 KB

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