#
whycq
2022-06-29 0dfcb8bfb508cbe160071509a0ee71a327e5207f
pages/basics/checkout.vue
@@ -1,6 +1,6 @@
<template>
   <view >
      <scroll-view scroll-y catch:touchmove="touchmove">
      <scroll-view scroll-y class="scroll-Y">
         <view class="square-2">
            <view class="square-title">
               <view class="title-sign"><view class="sign"></view></view>
@@ -33,10 +33,11 @@
            <view class="square-title">
               <view class="title-sign"><view class="sign"></view></view>
               <view class="title-text"><text>商品列表</text></view>
               <view v-show="matCount > 0" style="display: inline-block;float: right;height: 100rpx;line-height: 100rpx;margin-right: 50rpx;">请扫码选取 {{matCount}} 件商品</view>
            </view>
         </view>
         <view class="square-none" v-show="matList.length === 0">
            <view class="v-show">暂无更多数据...</view>
            <view class="v-show">暂无更多数据. . . </view>
         </view>
         <checkbox-group @change="checkbox">
            <view v-for="(item,index) in matList" :key="index" class="data-list bg-false" :class="'bg-'+item.checked" >
@@ -79,17 +80,18 @@
            searchBox: 'hide',
            pick:'hide',
            matnr:'',
            matList:[{matnr:'1101842-10000',batch:'22047515999',color:{color:'red'}}],
            // matList:[],
            // matList:[{matnr:'1101842-10000',batch:'22047515999',color:{color:'red'}}],
            matList:[],
            result: '',
            siteList:[],
            desc:'',
            staNoList:[],
            satNo:'',
            listLen:0,
            msgType: 'success',
            messageText: '这是一条成功提示',
            fontColor:{color:'red'}
            fontColor:{color:'red'},
            matCount:'',
            wrkNo:'',
         }
      },
      onReady() {
@@ -103,21 +105,21 @@
         this.baseIP = UIP;
         const UPORT = uni.getStorageSync('UPORT');
         this.basePORT = UPORT
         this.getOutBound();
         
      },
      methods: {
         huanghang() {
            this.matnr = ''
            this.focus = false;
            this.$nextTick(function() {
               this.focus = true;
            });
         },
         messageToggle(type) {
            this.msgType = type
            this.messageText = `这是一条${type}消息提示`
            this.$refs.message.open()
         },
         choseStaNo() {
            for (var i = 0;i < this.staNoList.length; i++) {
               if (this.desc == this.staNoList[i].desc) {
                  this.staNo = this.staNoList[i].siteId
               }
            }
         },
         getMatListLen() {
            // this.listLen = this.matList.length;
@@ -129,7 +131,7 @@
            this.matList = []
            this.barcode = ''
            this.matnr = ''
            this.desc = ''
            this.matCount = ''
            uni.vibrateShort();
         },
         removeBarcode() {
@@ -155,43 +157,7 @@
            this.messageText = '删除成功'
            uni.vibrateShort();
         },
         comb() {
            uni.vibrateShort();
            let that = this;
            uni.showLoading();
            uni.request({
                url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mobile/pakout/confirm/auth',
                data: that.matList,
               method: 'POST',
                header: {
                  'token':uni.getStorageSync('token')
                },
               success(result) {
                  uni.showLoading();
                  var res = result.data
                  if (res.code === 200) {
                     uni.showToast({
                        title: res.msg,
                        position: 'bottom',
                        duration: 1000
                     });
                     that.matList = []
                     that.barcode = ''
                     that.matnr = ''
                     that.desc = ''
                  } else if (res.code == 403) {
                     uni.showToast({title: res.msg, icon: "none", position: 'top'})
                     setTimeout(() => {
                        uni.reLaunch({
                           url: '../login/login'
                        });
                     }, 1000);
                  } else {
                     uni.showToast({title: res.msg, icon: "none",position: 'top'})
                  }
               }
            });
         },
         selectMat() {
            let that = this
            uni.vibrateShort();
@@ -212,35 +178,90 @@
            });
            that.matnr = ''
         },
         findBarcode() {
            let that = this
            uni.request({
                url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mobile/pakout/confirm/barcode/auth',
                data: {
                  barcode:that.barcode
                },
                header: {
                  'token':uni.getStorageSync('token'),
                },
               success(result) {
                  console.log(result)
                  let res = result.data;
                  if (res.code === 200) {
                     if (res.data.ioType === 101) {
                        that.matList = res.data.list.concat(that.matList)
                        that.listLen = that.matList.length;
                        return;
                     }
                     if (res.data.ioType === 103) {
                        that.matCount = res.data.list.length
                        that.wrkNo = res.data.list[0].wrkNo
                        return;
                     }
                     // if (res.data) {
                     //    that.matCount = res.data.length
                     // }
                  } else if (res.code === 403) {
                     uni.showToast({title: res.msg, icon: "none", position: 'top'})
                        setTimeout(() => {
                           uni.reLaunch({
                              url: '../login/login'
                           });
                     }, 1000);
                  } else {
                     uni.showToast({title: res.msg, icon: "none",position: 'top'})
                  }
               }
            });
         },
         findMat() {
            let that = this
            uni.request({
                url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mobile/pakout/query/auth',
                url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mobile/pakout/confirm/pick/auth',
                data: {
                  staNo:that.staNo,
                  wrkNo:that.wrkNo,
                  matnr:that.matnr
                },
                header: {
                  'token':uni.getStorageSync('token')
                },
               success(result) {
                  console.log(result)
                  var res = result.data;
                  if(res.code === 200 ) {
                     if(res.data) {
                        if (that.matList.length == 0) {
                           that.matList.push(res.data)
                           that.listLen = that.matList.length;
                           that.huanghang();
                           return;
                        }
                        for(let i = 0;i<that.matList.length;i++) {
                           for (let j = 0;j < res.data.length; j++) {
                              if(JSON.stringify(that.matList[i]) === JSON.stringify(res.data[j])) {
                                 res.data.splice(j,1)
                           if (that.matList.length < that.matCount){
                              if(JSON.stringify(that.matList[i]) === JSON.stringify(res.data)) {
                                 that.messageToggle('warn');
                                 that.messageText = '该商品已添加';
                                 that.huanghang();
                                 return;
                              } else {
                                 that.matList.unshift(res.data);
                                 that.listLen = that.matList.length;
                                 that.huanghang();
                                 return;
                              }
                           } else {
                              that.messageToggle('warn');
                              that.messageText = '已出全部商品,请确认出库';
                              that.huanghang();
                              return;
                           }
                        }
                        that.matList = res.data.concat(that.matList)
                        that.listLen = that.matList.length;
                        that.focus = false;
                        that.$nextTick(function() {
                           that.focus = true;
                        });
                        that.matnr = ''
                     }
                  } else if (res.code == 403) {
                     uni.showToast({title: res.msg, icon: "none", position: 'top'})
@@ -256,73 +277,44 @@
               }
            });
         },
         addMatList(mat) {
            console.log(mat)
            if (this.matList.length == 0){
               // this.matList.push(mat[0])
               // this.matList.prototype.push.apply(mat)
            } else {
               let toUnshift = true
               for (var i = 0; i < this.matList.length; i++) {
                  let matnr = this.matList[i].matnr
                  if (matnr == this.matList[i].matnr) {
                     // this.messageToggle('warn')
                     // this.messageText = matnr + '已经扫描,请勿重复扫描'
                     toUnshift = false
                  }
               }
               if (toUnshift) {
                  this.matList.unshift(mat[0])
               }
         comb() {
            let that = this;
            if (that.barcode === '') {
               this.messageToggle('error')
               this.messageText = '请扫描托盘码'
               return;
            }
            console.log(this.matList)
         },
         findBarcode() {
            let that = this
            uni.request({
                url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mobile/pakout/query/auth',
                data: {
                  barcode:that.barcode
                },
                header: {
                  'token':uni.getStorageSync('token'),
                },
               success(result) {
                  var res = result.data;
                  if(res.data) {
                     for(let i = 0;i<that.matList.length;i++) {
                        for (let j = 0;j < res.data.length; j++) {
                           if(JSON.stringify(that.matList[i]) === JSON.stringify(res.data[j])) {
                              res.data.splice(j,1)
                           }
                        }
                     }
                     that.matList = res.data.concat(that.matList)
                  }
                  that.listLen = that.matList.length;
               }
            });
            if (that.barcode.length !== 8) {
               this.messageToggle('error')
               this.messageText = '托盘码必须为8位'
               return;
            }
            if (that.matList.length === 0) {
               this.messageToggle('error')
               this.messageText = '请添加商品列表'
               return;
            }
            
         },
         getOutBound() {         // 获取出库口
            let that = this
            if (that.matList.length < that.matCount) {
               var len = that.matCount - that.matList.length
               that.messageToggle('error')
               that.messageText = '还剩' + len + '件未扫描'
               return;
            }
            uni.showLoading();
            uni.request({
               url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/available/take/site',
                url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mobile/pakout/confirm/auth',
                data: that.matList,
               method: 'POST',
               header: {
                header: {
                  'token':uni.getStorageSync('token')
               },
                },
               success(result) {
                  uni.showLoading();
                  var res = result.data
                  if (res.code === 200) {
                     for (var i = 0; i < res.data.length; i++){
                        that.siteList.push(res.data[i].desc)
                     }
                     that.staNoList = res.data
                     uni.showToast({ title: res.msg,position: 'bottom',duration: 1000});
                     that.resst();
                  } else if (res.code == 403) {
                     uni.showToast({title: res.msg, icon: "none", position: 'top'})
                     setTimeout(() => {
@@ -333,9 +325,9 @@
                  } else {
                     uni.showToast({title: res.msg, icon: "none",position: 'top'})
                  }
               },
               }
            });
         }, // getOutBound
         },
         getCheckDetl() {   // 获取出库口货物信息
            let that = this
            
@@ -375,7 +367,7 @@
<style>
   /* @import "../../colorui/main.css";
   @import "../../colorui/icon.css"; */
   .pak-seach-box {
      background-color: #FFFFFF;
      margin: 15rpx 15rpx 0rpx 15rpx;