creatOrder.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  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="暂无产品" @updateNums="updateNums" @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" @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="changeSearch">查询</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. if(!e.value){
  234. this.showCart = false
  235. }
  236. },
  237. allCheckedCallback(val){
  238. this.allChecked = val
  239. this.chooseList = this.$refs.productList.getAllChecked()
  240. },
  241. // 创建补货单
  242. creatOrder(data){
  243. uni.showLoading({
  244. title:"正在保存.."
  245. })
  246. stockCheckSave({
  247. shelfSn: this.nowData.shelfSn,
  248. totalCategory: this.nowData.totalCategory,
  249. totalStockQty: this.nowData.totalStockQty,
  250. totalFreezeQty: this.nowData.totalFreezeQty
  251. }).then(res => {
  252. if(res.status == 200){
  253. this.detail = res.data || null
  254. this.stockCheckSn = res.data.stockCheckSn
  255. }else{
  256. uni.hideLoading()
  257. }
  258. })
  259. },
  260. // 打开购物车
  261. openCart(){
  262. if(this.totalCategory){
  263. this.chooseList = this.$refs.productList.getAllChecked()
  264. this.showCart = !this.showCart
  265. }else{
  266. uni.showToast({
  267. icon: 'none',
  268. title: '请先添加产品'
  269. })
  270. }
  271. },
  272. // 删除购物车产品
  273. delDetail(item,i){
  274. console.log(item.id,i)
  275. this.$refs.productList.setChecked(item.id,false)
  276. const index = this.chooseList.findIndex(k => k.id == item.id)
  277. this.chooseList.splice(index,1)
  278. // 全部清空
  279. if(this.chooseList.length==0){
  280. this.clearChoose()
  281. }
  282. },
  283. // 空列表
  284. clearDetail(){
  285. const _this = this
  286. clzConfirm({
  287. title: '提示',
  288. content: '确认要清空列表吗?',
  289. success (ret) {
  290. if (ret.confirm || ret.index == 0) {
  291. _this.clearChoose()
  292. }
  293. }
  294. })
  295. },
  296. // 清空已选数据
  297. clearChoose(){
  298. this.chooseList = []
  299. this.showCart = false
  300. this.allChecked = false
  301. if(this.$refs.productList){
  302. this.$refs.productList.allSelect(false)
  303. }
  304. },
  305. updateNums(){
  306. this.chooseList = this.$refs.productList.getAllChecked()
  307. },
  308. // 修改数量
  309. cartChangeNums(v){
  310. this.$refs.productList.changeNums(v.index.split('_')[1],v.value)
  311. this.chooseList.splice()
  312. },
  313. clearSearch(){
  314. this.queryWord = ''
  315. this.changeSearch()
  316. },
  317. handleClear(){
  318. this.stockStateList = []
  319. this.queryKeys.map(item => item.checked = false)
  320. this.changeSearch()
  321. },
  322. changeSearch(){
  323. this.pageNo = 1
  324. this.partList = []
  325. this.getpartList()
  326. },
  327. // 获取数字货架列表
  328. getpartList(){
  329. const _this = this
  330. let params = {
  331. shelfSn: this.nowData.shelfSn,
  332. queryWord: this.queryWord,
  333. stockStateList: this.stockStateList
  334. }
  335. _this.clearChoose()
  336. _this.partList = []
  337. _this.$refs.productList && _this.$refs.productList.setData(_this.partList)
  338. _this.status = 'loading'
  339. uni.showLoading({
  340. mask:true,
  341. title:"正在加载..."
  342. })
  343. queryProductListForReplenish(params).then(res => {
  344. if(res.status == 200){
  345. let list = res.data
  346. if (list && list.length){
  347. _this.partList = list
  348. } else {
  349. _this.partList = list || []
  350. }
  351. }else{
  352. _this.partList = []
  353. }
  354. this.showTab = false
  355. this.$refs.productList.setData(_this.partList)
  356. setTimeout(()=>{
  357. uni.hideLoading()
  358. },this.partList.length*40)
  359. })
  360. },
  361. // 提交
  362. submitOrder(){
  363. if(this.totalCategory){
  364. this.handleSave()
  365. }else{
  366. uni.showToast({
  367. icon: 'none',
  368. title: '请先添加产品'
  369. })
  370. }
  371. },
  372. handleSave () {
  373. const data = this.chooseList
  374. const dataList = []
  375. data.map(item => {
  376. dataList.push({
  377. shelfPlaceSn: item.shelfPlaceSn,
  378. shelfPlaceCode: item.shelfPlaceCode,
  379. productSn: item.productSn,
  380. productCode: item.productCode,
  381. qty: item.replenishQty
  382. })
  383. })
  384. this.showLoading("正在提交...")
  385. // 开始提交
  386. saveMainAndDetail({
  387. shelfSn: this.nowData.shelfSn,
  388. dealerSn: this.nowData.dealerSn,
  389. detailList: dataList
  390. }).then(res => {
  391. if (res.status == 200) {
  392. this.toashMsg(res.message)
  393. uni.redirectTo({ url: "/pages/replenishmentManage/outWarehousing?sn="+res.data.replenishBillSn })
  394. }
  395. uni.hideLoading()
  396. })
  397. },
  398. // 扫描
  399. toScan(){
  400. this.mpaasScanModule = uni.requireNativePlugin("wss-scan")
  401. this.mpaasScanModule.scan(
  402. {
  403. "scanMode":"Customized",
  404. "scanStyle":{
  405. "scanFrameSizePlus":{"width":250,"height":250},
  406. "scanFrameSize":200,
  407. "scanLight":"visible",
  408. "scanText":"对准条形码/二维码进行识别",
  409. "scanTitle":"扫码搜索货位产品",
  410. }
  411. },
  412. (result) => {
  413. if(result.scanStatus == 1){
  414. this.scanResult(result)
  415. }
  416. })
  417. },
  418. // 扫描结果
  419. scanResult(data){
  420. // 二维码
  421. if(data.scanType == 'QRCODE'){
  422. const ret = data.scanValue.split("&")
  423. this.queryWord = ret[1] // 产品编码
  424. }else{
  425. this.queryWord = data.scanValue
  426. }
  427. this.stockStateList = []
  428. this.getpartList()
  429. }
  430. }
  431. }
  432. </script>
  433. <style lang="less">
  434. .content{
  435. height: 100vh;
  436. width: 100%;
  437. background: #fff;
  438. .searchBar{
  439. padding: 0 0.8rem 0.3rem;
  440. .p-title{
  441. padding: 0 15rpx;
  442. display: flex;
  443. align-items: center;
  444. color: #222;
  445. font-size: 30rpx;
  446. > text{
  447. display: block;
  448. height: 30rpx;
  449. width: 6rpx;
  450. background: #0485F6;
  451. margin-right: 10rpx;
  452. border-radius: 10rpx;
  453. }
  454. .shelfName{
  455. flex-grow: 1;
  456. font-weight: bold;
  457. width: 80%;
  458. > view{
  459. overflow: hidden;
  460. white-space: nowrap;
  461. text-overflow: ellipsis;
  462. }
  463. }
  464. .btns{
  465. width:100rpx;
  466. text-align: right;
  467. font-size: 28rpx;
  468. color: #0485F6;
  469. }
  470. }
  471. .search{
  472. margin-top: 15upx;
  473. padding: 0.1rem;
  474. border-radius: 50rpx;
  475. border:1rpx solid #eee;
  476. .input{
  477. flex-grow: 1;
  478. padding: 4rpx;
  479. }
  480. .icon{
  481. width: 13%;
  482. text-align: center;
  483. font-size: 46rpx;
  484. color: #999;
  485. }
  486. }
  487. }
  488. .check-list{
  489. padding: 0 0.8rem;
  490. flex-grow: 1;
  491. overflow: auto;
  492. }
  493. .footer-bar{
  494. background-color: #f8f8f8;
  495. padding: 20upx;
  496. .f-left{
  497. color: #fff;
  498. }
  499. .active{
  500. background-color: #0485F6;
  501. }
  502. .f-mid{
  503. flex-grow: 1;
  504. color: #666;
  505. > view{
  506. padding: 0 5upx;
  507. &:first-child{
  508. text{
  509. color: red;
  510. }
  511. }
  512. &:last-child{
  513. font-size: 0.8rem;
  514. }
  515. }
  516. }
  517. .f-btns{
  518. button{
  519. width: 200upx;
  520. }
  521. }
  522. }
  523. // 筛选
  524. .tabBox{
  525. height: 100vh;
  526. .tabs{
  527. overflow: auto;
  528. padding: 20rpx;
  529. > view{
  530. flex-wrap: wrap;
  531. justify-content: space-between;
  532. > view{
  533. width: 98%;
  534. border: 1rpx solid #eee;
  535. padding: 15rpx;
  536. border-radius: 50rpx;
  537. text-align: center;
  538. margin-bottom: 15rpx;
  539. /deep/ .u-checkbox__label{
  540. flex-grow: 1;
  541. }
  542. }
  543. &:first-child{
  544. > view{
  545. width: 100%;
  546. }
  547. }
  548. }
  549. }
  550. .btns{
  551. display: flex;
  552. padding: 40upx 20upx 20upx;
  553. justify-content: space-between;
  554. .handle-btn {
  555. font-size: 28upx;
  556. }
  557. }
  558. }
  559. // 购物车
  560. .cpb_cart-mask{
  561. position: fixed;
  562. width: 100%;
  563. background: rgba(0,0,0,0.5);
  564. z-index: 900;
  565. bottom: 100rpx;
  566. top: 0;
  567. }
  568. .cpb_cart-box{
  569. background-color: #fff;
  570. position: absolute;
  571. width: 100%;
  572. z-index: 1000;
  573. bottom: 0;
  574. border-radius: 30rpx 30rpx 0 0;
  575. max-height: 70vh;
  576. display: flex;
  577. flex-direction: column;
  578. .cpb_close{
  579. position: absolute;
  580. top: 10rpx;
  581. right: 20rpx;
  582. width: 70rpx;
  583. height: 70rpx;
  584. font-size: 32rpx;
  585. color: #999;
  586. }
  587. .cpb_cart-tit{
  588. text-align: center;
  589. padding: 20rpx;
  590. font-size: 32rpx;
  591. border-bottom: 2rpx solid #eee;
  592. .cpb_heji{
  593. padding-top: 20rpx;
  594. font-size: 26upx;
  595. > text{
  596. color: #00aaff;
  597. }
  598. > view{
  599. color: #999;
  600. > text{
  601. color: #333;
  602. &:first-child{
  603. margin-right: 20upx;
  604. }
  605. }
  606. }
  607. }
  608. }
  609. .cpb_cart-list{
  610. padding: 20rpx 0;
  611. overflow: auto;
  612. flex-grow: 1;
  613. > view{
  614. margin-bottom: 20rpx;
  615. }
  616. .nav-right-item{
  617. padding: 0 30upx;
  618. &:last-child{
  619. border-bottom:2rpx solid #eee;
  620. }
  621. }
  622. .item-name{
  623. font-size: 26rpx;
  624. text{
  625. background: rgba(3, 54, 146, 0.15);
  626. color: #1c588a;
  627. border-radius: 1em;
  628. font-size: 0.8em;
  629. padding: 0 0.5em;
  630. margin-right: 10upx;
  631. }
  632. margin-top: 10upx;
  633. }
  634. .item-info{
  635. flex-grow: 1;
  636. padding-left: 0.8em;
  637. }
  638. .item-detail{
  639. .item-detail-info{
  640. padding: 10upx 0 4upx;
  641. font-size: 24upx;
  642. .pnums{
  643. margin-right: 10rpx;
  644. color: #333;
  645. }
  646. .pnums1{
  647. margin-right: 10rpx;
  648. color: red;
  649. }
  650. > view{
  651. padding-bottom: 10rpx;
  652. align-items: center;
  653. .item-detail-text{
  654. color: #999;
  655. margin-left: 20upx;
  656. }
  657. }
  658. }
  659. }
  660. }
  661. }
  662. }
  663. </style>