chooseProduct.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  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. }
  317. uni.showLoading({
  318. mask:true,
  319. title:"正在加载..."
  320. })
  321. queryProductListForReplenish(params).then(res => {
  322. if(res.status == 200){
  323. let list = res.data
  324. if (list && list.length){
  325. _this.partList = list
  326. } else {
  327. _this.partList = list || []
  328. }
  329. }else{
  330. _this.partList = []
  331. }
  332. this.showTab = false
  333. // 赋值
  334. if(_this.nowData.chooseKey.length){
  335. _this.partList = _this.partList.filter(item => {
  336. const row = _this.nowData.chooseKey.findIndex(k => k == item.id)
  337. return !(row>=0)
  338. })
  339. }
  340. // 已选
  341. _this.partList.map(item => {
  342. const row = _this.chooseList.find(k => k.id == item.id)
  343. item.checked = !!row
  344. })
  345. this.$refs.productList.setData(_this.partList)
  346. setTimeout(()=>{
  347. uni.hideLoading()
  348. },_this.partList.length*30)
  349. })
  350. },
  351. // 提交
  352. submitOrder(){
  353. if(this.totalCategory){
  354. if(this.nowData.chooseKey.length){
  355. uni.$emit("chooseDbhProduct",this.chooseList)
  356. uni.navigateBack()
  357. }else{
  358. this.$store.state.vuex_tempData = this.chooseList
  359. uni.redirectTo({
  360. url: "/pages/soldOut/creatOrder?data="+encodeURIComponent(JSON.stringify(this.nowData))
  361. })
  362. }
  363. }else{
  364. uni.showToast({
  365. icon: 'none',
  366. title: '请选择产品'
  367. })
  368. }
  369. },
  370. // 扫描
  371. toScan(){
  372. this.mpaasScanModule = uni.requireNativePlugin("wss-scan")
  373. this.mpaasScanModule.scan(
  374. {
  375. "scanMode":"Customized",
  376. "scanStyle":{
  377. "scanFrameSizePlus":{"width":250,"height":250},
  378. "scanFrameSize":200,
  379. "scanLight":"visible",
  380. "scanText":"对准条形码/二维码进行识别",
  381. "scanTitle":"扫码搜索货位产品",
  382. }
  383. },
  384. (result) => {
  385. if(result.scanStatus == 1){
  386. this.scanResult(result)
  387. }
  388. })
  389. },
  390. // 扫描结果
  391. scanResult(data){
  392. // 二维码
  393. if(data.scanType == 'QRCODE'){
  394. const ret = data.scanValue.split("&")
  395. this.queryWord = ret[1] // 产品编码
  396. }else{
  397. this.queryWord = data.scanValue
  398. }
  399. this.stockStateList = []
  400. this.getpartList()
  401. }
  402. }
  403. }
  404. </script>
  405. <style lang="less">
  406. .content{
  407. height: 100vh;
  408. width: 100%;
  409. background: #fff;
  410. .searchBar{
  411. padding: 0.3rem 0.8rem;
  412. .p-title{
  413. padding: 0 15rpx;
  414. display: flex;
  415. align-items: center;
  416. color: #222;
  417. font-size: 30rpx;
  418. > text{
  419. display: block;
  420. height: 30rpx;
  421. width: 6rpx;
  422. background: #0485F6;
  423. margin-right: 10rpx;
  424. border-radius: 10rpx;
  425. }
  426. .shelfName{
  427. flex-grow: 1;
  428. font-weight: bold;
  429. width: 80%;
  430. > view{
  431. overflow: hidden;
  432. white-space: nowrap;
  433. text-overflow: ellipsis;
  434. }
  435. }
  436. .btns{
  437. width:100rpx;
  438. text-align: right;
  439. font-size: 28rpx;
  440. color: #0485F6;
  441. }
  442. }
  443. .search{
  444. margin-top: 15upx;
  445. padding: 0.1rem;
  446. border-radius: 50rpx;
  447. border:1rpx solid #eee;
  448. .input{
  449. flex-grow: 1;
  450. padding: 4rpx;
  451. }
  452. .icon{
  453. width: 13%;
  454. text-align: center;
  455. font-size: 46rpx;
  456. color: #999;
  457. }
  458. }
  459. }
  460. .check-list{
  461. padding: 0 0.8rem;
  462. flex-grow: 1;
  463. flex-basis: 0;
  464. overflow: auto;
  465. }
  466. .footer-bar{
  467. background-color: #f8f8f8;
  468. padding: 20upx;
  469. .f-left{
  470. color: #fff;
  471. }
  472. .active{
  473. background-color: #0485F6;
  474. }
  475. .f-mid{
  476. flex-grow: 1;
  477. color: #666;
  478. > view{
  479. padding: 0 5upx;
  480. &:first-child{
  481. text{
  482. color: red;
  483. margin: 0 5upx;
  484. }
  485. }
  486. &:last-child{
  487. font-size: 0.8rem;
  488. color: #0485F6;
  489. }
  490. }
  491. }
  492. .f-btns{
  493. button{
  494. width: 200upx;
  495. }
  496. }
  497. }
  498. // 筛选
  499. .tabBox{
  500. height: 100vh;
  501. .tabs{
  502. margin-top: 100rpx;
  503. overflow: auto;
  504. padding: 20rpx;
  505. > view{
  506. flex-wrap: wrap;
  507. justify-content: space-between;
  508. > view{
  509. width: 98%;
  510. border: 1rpx solid #eee;
  511. padding: 15rpx;
  512. border-radius: 50rpx;
  513. text-align: center;
  514. margin-bottom: 15rpx;
  515. /deep/ .u-checkbox__label{
  516. flex-grow: 1;
  517. }
  518. }
  519. &:first-child{
  520. > view{
  521. width: 100%;
  522. }
  523. }
  524. }
  525. }
  526. .btns{
  527. display: flex;
  528. padding: 40upx 20upx 20upx;
  529. justify-content: space-between;
  530. .handle-btn {
  531. font-size: 28upx;
  532. }
  533. }
  534. }
  535. // 购物车
  536. .cpb_cart-mask{
  537. position: fixed;
  538. width: 100%;
  539. background: rgba(0,0,0,0.5);
  540. z-index: 900;
  541. bottom: 100rpx;
  542. top: 0;
  543. }
  544. .cpb_cart-box{
  545. background-color: #fff;
  546. position: absolute;
  547. width: 100%;
  548. z-index: 1000;
  549. bottom: 0;
  550. border-radius: 30rpx 30rpx 0 0;
  551. max-height: 70vh;
  552. display: flex;
  553. flex-direction: column;
  554. .cpb_close{
  555. position: absolute;
  556. top: 10rpx;
  557. right: 20rpx;
  558. width: 70rpx;
  559. height: 70rpx;
  560. font-size: 32rpx;
  561. color: #999;
  562. }
  563. .cpb_cart-tit{
  564. text-align: center;
  565. padding: 20rpx;
  566. font-size: 32rpx;
  567. border-bottom: 2rpx solid #eee;
  568. .cpb_heji{
  569. padding-top: 20rpx;
  570. font-size: 26upx;
  571. > text{
  572. color: #ff5500;
  573. }
  574. > view{
  575. color: #999;
  576. > text{
  577. color: #333;
  578. &:first-child{
  579. margin-right: 20upx;
  580. }
  581. }
  582. }
  583. }
  584. }
  585. .cpb_cart-list{
  586. padding: 20rpx 0;
  587. overflow: auto;
  588. flex-grow: 1;
  589. > view{
  590. margin-bottom: 20rpx;
  591. }
  592. .nav-right-item{
  593. padding: 0 30upx;
  594. &:last-child{
  595. border-bottom:2rpx solid #eee;
  596. }
  597. }
  598. .item-name{
  599. font-size: 26rpx;
  600. text{
  601. background: rgba(3, 54, 146, 0.15);
  602. color: #1c588a;
  603. border-radius: 1em;
  604. font-size: 0.8em;
  605. padding: 0 0.5em;
  606. margin-right: 10upx;
  607. }
  608. margin-top: 10upx;
  609. }
  610. .item-info{
  611. flex-grow: 1;
  612. padding-left: 0.8em;
  613. }
  614. .item-detail{
  615. .item-detail-info{
  616. padding: 5upx 0;
  617. font-size: 24upx;
  618. .pnums{
  619. margin-right: 10rpx;
  620. color: #333;
  621. }
  622. .pnums1{
  623. margin-right: 10rpx;
  624. color: red;
  625. }
  626. > view{
  627. padding-bottom: 10rpx;
  628. align-items: center;
  629. .item-detail-text{
  630. color: #999;
  631. }
  632. }
  633. }
  634. }
  635. }
  636. }
  637. }
  638. </style>