chooseProduct.vue 14 KB

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