creatOrder.vue 15 KB

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