chooseProduct.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <template>
  2. <view class="content flex flex_column">
  3. <view class="searchBar">
  4. <view class="p-title flex align_center">
  5. <text></text>
  6. <view class="shelfName">
  7. <view>{{nowData.shelfName}}</view>
  8. </view>
  9. <view class="btns" @click="showTab = true">筛选<u-icon size="20" name="arrow-down"></u-icon></view>
  10. </view>
  11. <view class="search flex align_center">
  12. <view class="input">
  13. <u-search
  14. v-model="queryWord"
  15. @custom="getpartList"
  16. @search="getpartList"
  17. @clear="clearSearch"
  18. @input="$u.debounce(changeSearch, 800)"
  19. bg-color="#fff"
  20. :show-action="false"
  21. placeholder="请输入产品编码或名称搜索"></u-search>
  22. </view>
  23. <view class="icon" @click="toScan">
  24. <u-icon name="scan"></u-icon>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="check-list">
  29. <productList ref="productList" noDataText="暂无待补货产品" @allChecked="allCheckedCallback"></productList>
  30. </view>
  31. <!-- 底部栏 -->
  32. <view class="footer-bar flex align_center" v-if="partList.length">
  33. <view class="f-left">
  34. <u-checkbox size="40" @change="allCheckeChange" v-model="allChecked" shape="circle">{{allChecked?'取消全选':'全选'}}</u-checkbox>
  35. </view>
  36. <view class="f-mid" @click="openCart">
  37. <view>
  38. 已选<text>{{totalCategory}}</text>款产品
  39. </view>
  40. <view v-if="!showCart">
  41. 查看明细 <u-icon name="arrow-up"></u-icon>
  42. </view>
  43. <view v-else>
  44. 关闭明细 <u-icon name="arrow-down"></u-icon>
  45. </view>
  46. </view>
  47. <view class="f-btns">
  48. <u-button size="medium" @click="submitOrder" :custom-style="customBtnStyle" shape="circle" type="primary" hover-class="none" >确定选择</u-button>
  49. </view>
  50. </view>
  51. <!-- 已选配件 购物车 -->
  52. <div class="cpb_cart-mask" v-if="showCart">
  53. <div class="cpb_cart-box">
  54. <div class="cpb_close flex align-center justify_center" @click="showCart=false">
  55. <u-icon name="close"></u-icon>
  56. </div>
  57. <div class="cpb_cart-tit">
  58. <view>已选配件</view>
  59. <view class="cpb_heji flex align_center justify_between">
  60. <text @click="clearDetail">清空列表</text>
  61. </view>
  62. </div>
  63. <div class="cpb_cart-list">
  64. <view
  65. v-for="(item, index) in chooseList"
  66. :key="'cpb_'+item.id"
  67. >
  68. <view class="nav-right-item flex align_center">
  69. <view class="uni-col-1" @click="delDetail(item,index)">
  70. <u-icon name="close-circle" color="#ff5500" size="35"></u-icon>
  71. </view>
  72. <view class="uni-col-9 flex">
  73. <view class="uni-col-2">
  74. <u-image :src="item.productImageUrl?item.productImageUrl:`../../static/${$config('themePath')}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
  75. </view>
  76. <view class="item-info uni-col-8">
  77. <view class="item-name">
  78. <text>{{item.shelfPlaceCode}}</text>
  79. {{item.productCode}}
  80. </view>
  81. <view class="item-name ellipsis-two">
  82. {{item.productName}}
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. <view class="nav-right-item">
  88. <view class="item-detail">
  89. <view class="item-detail-info align_center flex justify_between">
  90. <view></view>
  91. <view class="flex justify_end">
  92. <view class="item-detail-text">
  93. 最大库容:<text class="pnums">{{item.maxQty||0}}</text>
  94. 货架库存:<text class="pnums">{{item.qty||0}}</text>
  95. 门店库存:<text class="pnums">{{item.qplsStockQty||0}}</text>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. <view class="item-detail">
  101. <view class="item-detail-info">
  102. <view class="flex justify_end">
  103. <view class="item-detail-text flex">
  104. <view v-if="item.replenishBillQty">补货在途:<text class="pnums1">{{item.replenishBillQty||0}}</text></view>
  105. <view v-if="item.recallBillQty">调回在途:<text class="pnums1">{{item.recallBillQty||0}}</text></view>
  106. </view>
  107. </view>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. </div>
  113. </div>
  114. </div>
  115. <!-- 筛选项 -->
  116. <u-popup v-model="showTab" mode="right" closeable width="70%">
  117. <view class="tabBox flex flex_column">
  118. <view class="tabs">
  119. <u-checkbox-group wrap @change="checkboxGroupChange">
  120. <u-checkbox
  121. v-model="item.checked"
  122. v-for="(item, index) in queryKeys" :key="index"
  123. :name="item.code"
  124. >{{item.name}}</u-checkbox>
  125. </u-checkbox-group>
  126. </view>
  127. <view class="btns">
  128. <u-button class="handle-btn" shape="circle" size="medium" hover-class="none" @click="handleClear">重置</u-button>
  129. <u-button class="handle-btn" shape="circle" size="medium" hover-class="none" :custom-style="customBtnStyle" @click="changeSearch">查询</u-button>
  130. </view>
  131. </view>
  132. </u-popup>
  133. </view>
  134. </template>
  135. <script>
  136. import { queryProductListForReplenish } from '@/api/shelf'
  137. import { saveMainAndDetail } from '@/api/shelfReplenish'
  138. import productList from './productList.vue'
  139. import { clzConfirm } from '@/libs/tools'
  140. export default {
  141. components: {
  142. productList
  143. },
  144. data() {
  145. return {
  146. queryWord: '',
  147. nowData:null,
  148. detail:null,
  149. pageNo:1,
  150. pageSize: 20,
  151. total: 0, // 列表总数
  152. noDataText: '暂无产品',
  153. status: 'loading',
  154. partList: [],
  155. allChecked: false,
  156. showCart: false,
  157. showTab: false,
  158. customBtnStyle: { // 自定义按钮样式
  159. borderColor: this.$config('primaryColor'),
  160. backgroundColor: this.$config('primaryColor'),
  161. color: '#fff'
  162. },
  163. orderTotal: 0,
  164. chooseList: [],
  165. tempData: null,
  166. queryKeys: [
  167. {
  168. name: '库存充足',
  169. code: 'stockEnough',
  170. checked: false
  171. },
  172. {
  173. name: '部分缺货',
  174. code: 'portionStockout',
  175. checked: false
  176. },
  177. {
  178. name: '全部缺货',
  179. code: 'allStockout',
  180. checked: false
  181. }
  182. ],
  183. stockStateList:[]
  184. }
  185. },
  186. onNavigationBarButtonTap(e) {
  187. if(e.index == 0){
  188. uni.navigateTo({
  189. url: '/pages/stockCheck/checkRecord?shelfSn='+this.nowData.shelfSn
  190. })
  191. }
  192. },
  193. onBackPress(e) {
  194. console.log(e)
  195. if((this.showTab || this.showCart)&&e.from != 'navigateBack') {
  196. this.showTab = false;
  197. this.showCart = false;
  198. return true;
  199. }
  200. },
  201. onLoad(opts) {
  202. this.nowData = JSON.parse(decodeURIComponent(opts.data));
  203. this.getpartList()
  204. },
  205. onReady() {
  206. uni.setNavigationBarColor({
  207. frontColor: '#ffffff',
  208. backgroundColor: this.$config('primaryColor')
  209. })
  210. },
  211. computed: {
  212. totalCategory () {
  213. return this.chooseList.length
  214. },
  215. },
  216. methods: {
  217. checkboxGroupChange(e) {
  218. this.stockStateList = e
  219. },
  220. // 单击全选
  221. allCheckeChange(e){
  222. this.$refs.productList.allSelect(e.value)
  223. const list = this.$refs.productList.getAllData()
  224. list.map(item => {
  225. this.allCheckedCallback(true,item)
  226. })
  227. if(!e.value && this.showCart){
  228. this.showCart = false
  229. }
  230. },
  231. // 选中事件
  232. allCheckedCallback(isAllChecked,row){
  233. console.log(isAllChecked,row)
  234. const has = this.chooseList.findIndex(k => k.id == row.id)
  235. // 在已选列表中
  236. if(has>=0){
  237. // 取消选中
  238. if(!row.checked){
  239. this.chooseList.splice(has,1)
  240. }
  241. }else{
  242. // 不在已选列表中,添加
  243. if(row.checked){
  244. this.chooseList.push(row)
  245. }
  246. }
  247. // 是否全选
  248. this.allChecked = isAllChecked
  249. },
  250. // 打开购物车
  251. openCart(){
  252. if(this.totalCategory){
  253. this.showCart = !this.showCart
  254. }else{
  255. uni.showToast({
  256. icon: 'none',
  257. title: '请先添加产品'
  258. })
  259. }
  260. },
  261. // 删除购物车产品
  262. delDetail(item,i){
  263. console.log(item.id,i)
  264. this.$refs.productList.setChecked(item.id,false)
  265. const index = this.chooseList.findIndex(k => k.id == item.id)
  266. this.chooseList.splice(index,1)
  267. this.allChecked = false
  268. // 全部清空
  269. if(this.chooseList.length==0){
  270. this.clearChoose()
  271. }
  272. },
  273. // 空列表
  274. clearDetail(){
  275. const _this = this
  276. clzConfirm({
  277. title: '提示',
  278. content: '确认要清空列表吗?',
  279. success (ret) {
  280. if (ret.confirm || ret.index == 0) {
  281. _this.clearChoose()
  282. }
  283. }
  284. })
  285. },
  286. // 清空已选数据
  287. clearChoose(){
  288. this.chooseList = []
  289. this.showCart = false
  290. this.allChecked = false
  291. if(this.$refs.productList){
  292. this.$refs.productList.allSelect(false)
  293. }
  294. },
  295. clearSearch(){
  296. this.queryWord = ''
  297. this.changeSearch()
  298. },
  299. handleClear(){
  300. this.stockStateList = []
  301. this.queryKeys.map(item => item.checked = false)
  302. this.changeSearch()
  303. },
  304. changeSearch(){
  305. this.pageNo = 1
  306. this.partList = []
  307. this.getpartList()
  308. },
  309. // 获取数字货架列表
  310. getpartList(){
  311. const _this = this
  312. let params = {
  313. shelfSn: this.nowData.shelfSn,
  314. queryWord: this.queryWord,
  315. stockStateList: this.stockStateList,
  316. enableFlag: 1
  317. }
  318. uni.showLoading({
  319. mask:true,
  320. title:"正在加载..."
  321. })
  322. queryProductListForReplenish(params).then(res => {
  323. if(res.status == 200){
  324. let list = res.data
  325. if (list && list.length){
  326. _this.partList = list
  327. } else {
  328. _this.partList = list || []
  329. }
  330. }else{
  331. _this.partList = []
  332. }
  333. this.showTab = false
  334. // 赋值
  335. if(_this.nowData.chooseKey.length){
  336. _this.partList = _this.partList.filter(item => {
  337. const row = _this.nowData.chooseKey.findIndex(k => k == item.id)
  338. return !(row>=0)
  339. })
  340. }
  341. // 已选
  342. _this.partList.map(item => {
  343. const row = _this.chooseList.find(k => k.id == item.id)
  344. item.checked = !!row
  345. })
  346. this.$refs.productList.setData(_this.partList)
  347. setTimeout(()=>{
  348. uni.hideLoading()
  349. },_this.partList.length*30)
  350. })
  351. },
  352. // 提交
  353. submitOrder(){
  354. if(this.totalCategory){
  355. if(this.nowData.chooseKey.length){
  356. uni.$emit("chooseDbhProduct",this.chooseList)
  357. uni.navigateBack()
  358. }else{
  359. this.$store.state.vuex_tempData = this.chooseList
  360. uni.redirectTo({
  361. url: "/pages/soldOut/creatOrder?data="+encodeURIComponent(JSON.stringify(this.nowData))
  362. })
  363. }
  364. }else{
  365. uni.showToast({
  366. icon: 'none',
  367. title: '请选择产品'
  368. })
  369. }
  370. },
  371. // 扫描
  372. toScan(){
  373. this.mpaasScanModule = uni.requireNativePlugin("wss-scan")
  374. this.mpaasScanModule.scan(
  375. {
  376. "scanMode":"Customized",
  377. "scanStyle":{
  378. "scanFrameSizePlus":{"width":250,"height":250},
  379. "scanFrameSize":200,
  380. "scanLight":"visible",
  381. "scanText":"对准条形码/二维码进行识别",
  382. "scanTitle":"扫码搜索货位产品",
  383. }
  384. },
  385. (result) => {
  386. if(result.scanStatus == 1){
  387. this.scanResult(result)
  388. }
  389. })
  390. },
  391. // 扫描结果
  392. scanResult(data){
  393. // 二维码
  394. if(data.scanType == 'QRCODE'){
  395. const ret = data.scanValue.split("&")
  396. this.queryWord = ret[1] // 产品编码
  397. }else{
  398. this.queryWord = data.scanValue
  399. }
  400. this.stockStateList = []
  401. this.getpartList()
  402. }
  403. }
  404. }
  405. </script>
  406. <style lang="less">
  407. .content{
  408. height: 100vh;
  409. width: 100%;
  410. background: #fff;
  411. .searchBar{
  412. padding: 0.3rem 0.8rem;
  413. .p-title{
  414. padding: 0 15rpx;
  415. display: flex;
  416. align-items: center;
  417. color: #222;
  418. font-size: 30rpx;
  419. > text{
  420. display: block;
  421. height: 30rpx;
  422. width: 6rpx;
  423. background: #0485F6;
  424. margin-right: 10rpx;
  425. border-radius: 10rpx;
  426. }
  427. .shelfName{
  428. flex-grow: 1;
  429. font-weight: bold;
  430. width: 80%;
  431. > view{
  432. overflow: hidden;
  433. white-space: nowrap;
  434. text-overflow: ellipsis;
  435. }
  436. }
  437. .btns{
  438. width:100rpx;
  439. text-align: right;
  440. font-size: 28rpx;
  441. color: #0485F6;
  442. }
  443. }
  444. .search{
  445. margin-top: 15upx;
  446. padding: 0.1rem;
  447. border-radius: 50rpx;
  448. border:1rpx solid #eee;
  449. .input{
  450. flex-grow: 1;
  451. padding: 4rpx;
  452. }
  453. .icon{
  454. width: 13%;
  455. text-align: center;
  456. font-size: 46rpx;
  457. color: #999;
  458. }
  459. }
  460. }
  461. .check-list{
  462. padding: 0 0.8rem;
  463. flex-grow: 1;
  464. flex-basis: 0;
  465. overflow: auto;
  466. }
  467. .footer-bar{
  468. background-color: #f8f8f8;
  469. padding: 20upx;
  470. .f-left{
  471. color: #fff;
  472. }
  473. .active{
  474. background-color: #0485F6;
  475. }
  476. .f-mid{
  477. flex-grow: 1;
  478. color: #666;
  479. > view{
  480. padding: 0 5upx;
  481. &:first-child{
  482. text{
  483. color: red;
  484. margin: 0 5upx;
  485. }
  486. }
  487. &:last-child{
  488. font-size: 0.8rem;
  489. color: #0485F6;
  490. }
  491. }
  492. }
  493. .f-btns{
  494. button{
  495. width: 200upx;
  496. }
  497. }
  498. }
  499. // 筛选
  500. .tabBox{
  501. height: 100vh;
  502. .tabs{
  503. margin-top: 100rpx;
  504. overflow: auto;
  505. padding: 20rpx;
  506. > view{
  507. flex-wrap: wrap;
  508. justify-content: space-between;
  509. > view{
  510. width: 98%;
  511. border: 1rpx solid #eee;
  512. padding: 15rpx;
  513. border-radius: 50rpx;
  514. text-align: center;
  515. margin-bottom: 15rpx;
  516. /deep/ .u-checkbox__label{
  517. flex-grow: 1;
  518. }
  519. }
  520. &:first-child{
  521. > view{
  522. width: 100%;
  523. }
  524. }
  525. }
  526. }
  527. .btns{
  528. display: flex;
  529. padding: 40upx 20upx 20upx;
  530. justify-content: space-between;
  531. .handle-btn {
  532. font-size: 28upx;
  533. }
  534. }
  535. }
  536. // 购物车
  537. .cpb_cart-mask{
  538. position: fixed;
  539. width: 100%;
  540. background: rgba(0,0,0,0.5);
  541. z-index: 900;
  542. bottom: 100rpx;
  543. top: 0;
  544. }
  545. .cpb_cart-box{
  546. background-color: #fff;
  547. position: absolute;
  548. width: 100%;
  549. z-index: 1000;
  550. bottom: 0;
  551. border-radius: 30rpx 30rpx 0 0;
  552. max-height: 70vh;
  553. display: flex;
  554. flex-direction: column;
  555. .cpb_close{
  556. position: absolute;
  557. top: 10rpx;
  558. right: 20rpx;
  559. width: 70rpx;
  560. height: 70rpx;
  561. font-size: 32rpx;
  562. color: #999;
  563. }
  564. .cpb_cart-tit{
  565. text-align: center;
  566. padding: 20rpx;
  567. font-size: 32rpx;
  568. border-bottom: 2rpx solid #eee;
  569. .cpb_heji{
  570. padding-top: 20rpx;
  571. font-size: 26upx;
  572. > text{
  573. color: #ff5500;
  574. }
  575. > view{
  576. color: #999;
  577. > text{
  578. color: #333;
  579. &:first-child{
  580. margin-right: 20upx;
  581. }
  582. }
  583. }
  584. }
  585. }
  586. .cpb_cart-list{
  587. padding: 20rpx 0;
  588. overflow: auto;
  589. flex-grow: 1;
  590. > view{
  591. margin-bottom: 20rpx;
  592. }
  593. .nav-right-item{
  594. padding: 0 30upx;
  595. &:last-child{
  596. border-bottom:2rpx solid #eee;
  597. }
  598. }
  599. .item-name{
  600. font-size: 26rpx;
  601. text{
  602. background: rgba(3, 54, 146, 0.15);
  603. color: #1c588a;
  604. border-radius: 1em;
  605. font-size: 0.8em;
  606. padding: 0 0.5em;
  607. margin-right: 10upx;
  608. }
  609. margin-top: 10upx;
  610. }
  611. .item-info{
  612. flex-grow: 1;
  613. padding-left: 0.8em;
  614. }
  615. .item-detail{
  616. .item-detail-info{
  617. padding: 5upx 0;
  618. font-size: 24upx;
  619. .pnums{
  620. margin-right: 10rpx;
  621. color: #333;
  622. }
  623. .pnums1{
  624. margin-right: 10rpx;
  625. color: red;
  626. }
  627. > view{
  628. padding-bottom: 10rpx;
  629. align-items: center;
  630. .item-detail-text{
  631. color: #999;
  632. }
  633. }
  634. }
  635. }
  636. }
  637. }
  638. }
  639. </style>