chooseProduct.vue 15 KB

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