selectOutType copy.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  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-else>
  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 '../enum.js'
  146. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  147. import {
  148. tableHeader
  149. } from '../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: 3,
  159. warehouseId: ''
  160. },
  161. dimension: 3,
  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. },
  214. //触底刷新
  215. // onReachBottom: function () {
  216. // if (this.isEnd) {
  217. // return
  218. // }
  219. // // 显示加载图标
  220. // uni.showLoading({
  221. // title: '数据加载中'
  222. // })
  223. // //获取更多数据
  224. // this.page++
  225. // this.getList()
  226. // },
  227. onShow() {
  228. this.getClassify()
  229. this.getwarehouseOptions()
  230. },
  231. methods: {
  232. openSearch() {
  233. this.popupInfo = {
  234. dimension: this.dimension,
  235. warehouseId: this.warehouseId
  236. }
  237. },
  238. filterOutboundNum(value, row, index) {
  239. if (value <= 0) {
  240. this.$set(this.listData[index], 'outboundNum', 1)
  241. }
  242. if (value > row.measureQuantity) {
  243. this.$set(this.listData[index], 'outboundNum', row.measureQuantity)
  244. }
  245. },
  246. //获取仓库
  247. getwarehouseOptions() {
  248. getWarehouseList().then(res => {
  249. this.warehouseListOption = res.data.map(item => {
  250. return {
  251. value: item.id,
  252. text: item.name
  253. }
  254. })
  255. })
  256. },
  257. handleReset() {
  258. this.popupInfo = {
  259. dimension: 3,
  260. warehouseId: ''
  261. }
  262. this.dimension = 3
  263. this.warehouseId = ''
  264. this.listData = []
  265. this.getList()
  266. },
  267. handleSearch() {
  268. this.dimension = this.popupInfo.dimension
  269. this.warehouseId = this.popupInfo.warehouseId
  270. this.getList()
  271. },
  272. scrolltolower() {
  273. if (this.isEnd) {
  274. return
  275. }
  276. // 显示加载图标
  277. uni.showLoading({
  278. title: '数据加载中'
  279. })
  280. //获取更多数据
  281. this.page++
  282. this.getList()
  283. },
  284. //列表数据
  285. async getList() {
  286. this.searchVisible = false
  287. this.isEnd = false
  288. this._getClassifyList()
  289. },
  290. async _getClassifyList() {
  291. uni.showLoading({
  292. title: '数据加载中'
  293. })
  294. let res = null
  295. const params = {
  296. pageNum: this.page,
  297. size: this.size,
  298. searchKey: this.searchVal,
  299. warehouseId: this.popupInfo.warehouseId,
  300. categoryLevelId: this.categoryLevelId
  301. }
  302. if (this.popupInfo.dimension == 1) {
  303. // 物品维度
  304. res = await getProductList(params)
  305. } else if (this.popupInfo.dimension == 2) {
  306. // 批次维度
  307. res = await getBatchList(params)
  308. } else {
  309. // 包装维度
  310. res = await getPackingList(params)
  311. }
  312. uni.hideLoading()
  313. if (this.page == 1) {
  314. this.listData = []
  315. }
  316. this.listData = this.listData.concat(res.list)
  317. this.isEnd = this.listData.length >= res.count
  318. },
  319. confirm([id]) {
  320. console.log('id----------', id)
  321. this.categoryLevelId = id
  322. this.page = 1
  323. this.getList()
  324. },
  325. async getClassify() {
  326. getTreeByIds({
  327. ids: this.assetType
  328. }).then(res => {
  329. console.log('res--------', res)
  330. this.classificationList = res
  331. this.page = 1
  332. this.getList()
  333. })
  334. },
  335. doSearch() {
  336. this.page = 1
  337. this.getList()
  338. },
  339. //勾选
  340. selectVal(e, val, index) {
  341. this.$set(this.listData[index], 'checked', !this.listData[index].checked)
  342. // this.listData[index].checked = !this.listData[index].checked
  343. this.seletedAll = !this.listData.some(item => !item.checked)
  344. },
  345. //全选按钮
  346. _seletedAll() {
  347. if (!this.seletedAll) {
  348. this.seletedAll = true
  349. this.listData.map(item => {
  350. this.$set(item, 'checked', true)
  351. })
  352. } else {
  353. this.seletedAll = false
  354. //this.checkListLen = 0;
  355. this.listData.map(item => {
  356. this.$set(item, 'checked', false)
  357. })
  358. }
  359. },
  360. //跳转回添加页面
  361. async jumpAdd() {
  362. let selectionList = this.listData.filter(item => item.checked)
  363. if (this.dimension == 1) {
  364. let boolen = selectionList.every(item => item.outboundNum > 0)
  365. if (!boolen) {
  366. uni.showToast({
  367. icon: 'none',
  368. title: '请输入出库数量',
  369. duration: 2000
  370. })
  371. return
  372. }
  373. }
  374. let data = null
  375. if (this.dimension != 1) {
  376. data = await getHierarchyList({
  377. ids: selectionList.map(item => item.id).join(','),
  378. type: this.dimension
  379. })
  380. } else {
  381. data = await getHierarchyFifo({
  382. type: this.dimension,
  383. builders: selectionList.map(item => {
  384. return {
  385. categoryId: item.categoryId,
  386. num: item.outboundNum
  387. }
  388. })
  389. })
  390. }
  391. console.log('data-------------------', data)
  392. uni.$emit('setSelectList', data)
  393. uni.navigateBack()
  394. },
  395. //返回添加页
  396. backAdd() {
  397. uni.navigateBack()
  398. }
  399. }
  400. }
  401. </script>
  402. <style lang="scss" scoped>
  403. .mainBox {
  404. height: 100vh;
  405. .main {
  406. height: 100%;
  407. display: flex;
  408. flex-direction: column;
  409. }
  410. .top-wrapper {
  411. display: flex;
  412. height: 88rpx;
  413. align-items: center;
  414. justify-content: space-between;
  415. padding: 20rpx;
  416. /deep/.uni-section {
  417. margin-top: 0px;
  418. }
  419. /deep/.uni-section-header {
  420. padding: 0px;
  421. }
  422. .search_btn {
  423. width: 120rpx;
  424. height: 70rpx;
  425. line-height: 70rpx;
  426. background: $theme-color;
  427. font-size: 28rpx;
  428. color: #fff;
  429. }
  430. .menu_icon {
  431. width: 44rpx;
  432. height: 44rpx;
  433. margin-left: 14rpx;
  434. }
  435. .more_search {
  436. display: flex;
  437. align-items: center;
  438. height: 70rpx;
  439. line-height: 70rpx;
  440. }
  441. /deep/.u-input {
  442. border: 1rpx solid #ccc;
  443. .u-input__content__field-wrapper__field {
  444. height: 40rpx !important;
  445. }
  446. }
  447. image {
  448. width: 52rpx;
  449. height: 52rpx;
  450. margin-left: 10rpx;
  451. }
  452. }
  453. .wrapper {
  454. flex: 1;
  455. overflow: hidden;
  456. }
  457. .listContent {
  458. height: 100% !important;
  459. .listBox {
  460. display: flex;
  461. // height: 180rpx;
  462. padding: 20rpx 0;
  463. border-bottom: 2rpx solid #e5e5e5;
  464. .listBox-sel {
  465. height: 90rpx;
  466. width: 80rpx;
  467. // line-height: 90rpx;
  468. text-align: center;
  469. checkbox {
  470. transform: scale(1.2);
  471. }
  472. }
  473. .listBox-con {
  474. width: 100%;
  475. // display: flex;
  476. // flex-wrap: wrap;
  477. // justify-content: space-between;
  478. align-items: center;
  479. padding: 0 18rpx 0 0;
  480. .round {
  481. width: 40rpx;
  482. height: 40rpx;
  483. line-height: 40rpx;
  484. border-radius: 50%;
  485. background: $theme-color;
  486. color: #fff;
  487. text-align: center;
  488. font-size: 20rpx;
  489. }
  490. .listBox-top {
  491. width: 100%;
  492. display: flex;
  493. justify-content: space-between;
  494. padding-bottom: 10rpx;
  495. .listBox-name,
  496. .listBox-code {
  497. display: inline-block;
  498. font-size: $uni-font-size-sm;
  499. font-weight: bold;
  500. }
  501. }
  502. .listBox-bottom {
  503. width: 100%;
  504. display: flex;
  505. justify-content: space-between;
  506. font-size: $uni-font-size-sm;
  507. flex-wrap: wrap;
  508. >view {
  509. width: 50%;
  510. overflow: hidden;
  511. white-space: nowrap;
  512. text-overflow: ellipsis;
  513. }
  514. .input_view {
  515. display: flex;
  516. align-items: center;
  517. justify-content: center;
  518. .u-input {
  519. height: 36rpx;
  520. padding: 0 !important;
  521. margin-right: 10rpx;
  522. border: 1px solid #ddd;
  523. }
  524. }
  525. .w100 {
  526. width: 100%;
  527. }
  528. }
  529. }
  530. }
  531. .noDate {
  532. height: 100%;
  533. }
  534. }
  535. //底部按钮
  536. .footer {
  537. height: 90rpx;
  538. position: relative;
  539. display: flex;
  540. justify-content: space-between;
  541. align-items: center;
  542. bottom: 0;
  543. width: 100%;
  544. height: 100rpx;
  545. border-top: 1rpx solid #eeecec;
  546. background-color: #ffffff;
  547. z-index: 999;
  548. .bottom {
  549. margin-left: 10rpx;
  550. }
  551. .u-reset-button {
  552. position: absolute;
  553. right: 10rpx;
  554. top: 20rpx;
  555. width: 150rpx;
  556. }
  557. }
  558. .search_list {
  559. min-height: 100rpx;
  560. /deep/ .baseForm {
  561. padding: 0 20rpx;
  562. }
  563. }
  564. .operate_box {
  565. padding: 10rpx 32rpx;
  566. /deep/ .u-button {
  567. width: 40%;
  568. }
  569. }
  570. }
  571. </style>