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-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" closeable 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. 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*40)
  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. overflow: auto;
  464. }
  465. .footer-bar{
  466. background-color: #f8f8f8;
  467. padding: 20upx;
  468. .f-left{
  469. color: #fff;
  470. }
  471. .active{
  472. background-color: #0485F6;
  473. }
  474. .f-mid{
  475. flex-grow: 1;
  476. color: #666;
  477. > view{
  478. padding: 0 5upx;
  479. &:first-child{
  480. text{
  481. color: red;
  482. margin: 0 5upx;
  483. }
  484. }
  485. &:last-child{
  486. font-size: 0.8rem;
  487. color: #0485F6;
  488. }
  489. }
  490. }
  491. .f-btns{
  492. button{
  493. width: 200upx;
  494. }
  495. }
  496. }
  497. // 筛选
  498. .tabBox{
  499. height: 100vh;
  500. .tabs{
  501. margin-top: 100rpx;
  502. overflow: auto;
  503. padding: 20rpx;
  504. > view{
  505. flex-wrap: wrap;
  506. justify-content: space-between;
  507. > view{
  508. width: 98%;
  509. border: 1rpx solid #eee;
  510. padding: 15rpx;
  511. border-radius: 50rpx;
  512. text-align: center;
  513. margin-bottom: 15rpx;
  514. /deep/ .u-checkbox__label{
  515. flex-grow: 1;
  516. }
  517. }
  518. &:first-child{
  519. > view{
  520. width: 100%;
  521. }
  522. }
  523. }
  524. }
  525. .btns{
  526. display: flex;
  527. padding: 40upx 20upx 20upx;
  528. justify-content: space-between;
  529. .handle-btn {
  530. font-size: 28upx;
  531. }
  532. }
  533. }
  534. // 购物车
  535. .cpb_cart-mask{
  536. position: fixed;
  537. width: 100%;
  538. background: rgba(0,0,0,0.5);
  539. z-index: 900;
  540. bottom: 100rpx;
  541. top: 0;
  542. }
  543. .cpb_cart-box{
  544. background-color: #fff;
  545. position: absolute;
  546. width: 100%;
  547. z-index: 1000;
  548. bottom: 0;
  549. border-radius: 30rpx 30rpx 0 0;
  550. max-height: 70vh;
  551. display: flex;
  552. flex-direction: column;
  553. .cpb_close{
  554. position: absolute;
  555. top: 10rpx;
  556. right: 20rpx;
  557. width: 70rpx;
  558. height: 70rpx;
  559. font-size: 32rpx;
  560. color: #999;
  561. }
  562. .cpb_cart-tit{
  563. text-align: center;
  564. padding: 20rpx;
  565. font-size: 32rpx;
  566. border-bottom: 2rpx solid #eee;
  567. .cpb_heji{
  568. padding-top: 20rpx;
  569. font-size: 26upx;
  570. > text{
  571. color: #ff5500;
  572. }
  573. > view{
  574. color: #999;
  575. > text{
  576. color: #333;
  577. &:first-child{
  578. margin-right: 20upx;
  579. }
  580. }
  581. }
  582. }
  583. }
  584. .cpb_cart-list{
  585. padding: 20rpx 0;
  586. overflow: auto;
  587. flex-grow: 1;
  588. > view{
  589. margin-bottom: 20rpx;
  590. }
  591. .nav-right-item{
  592. padding: 0 30upx;
  593. &:last-child{
  594. border-bottom:2rpx solid #eee;
  595. }
  596. }
  597. .item-name{
  598. font-size: 26rpx;
  599. text{
  600. background: rgba(3, 54, 146, 0.15);
  601. color: #1c588a;
  602. border-radius: 1em;
  603. font-size: 0.8em;
  604. padding: 0 0.5em;
  605. margin-right: 10upx;
  606. }
  607. margin-top: 10upx;
  608. }
  609. .item-info{
  610. flex-grow: 1;
  611. padding-left: 0.8em;
  612. }
  613. .item-detail{
  614. .item-detail-info{
  615. padding: 10upx 0 4upx;
  616. font-size: 24upx;
  617. .pnums{
  618. margin-right: 10rpx;
  619. color: #333;
  620. }
  621. .pnums1{
  622. margin-right: 10rpx;
  623. color: red;
  624. }
  625. > view{
  626. padding-bottom: 10rpx;
  627. align-items: center;
  628. .item-detail-text{
  629. color: #999;
  630. margin-left: 20upx;
  631. }
  632. }
  633. }
  634. }
  635. }
  636. }
  637. }
  638. </style>