creatOrder.vue 15 KB

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