whycq
2022-08-24 36fc4fa64ba5a7fd9f23b33c94c918d4b3ca70e3
pages/basics/checkout.vue
@@ -9,7 +9,7 @@
            <view class="square-content">
               <view class="content-input">
                  <input v-model="barcode" type="text" placeholder="扫码 / 输入" maxlength="8" 
                  @input="findBarcode()" :focus="barcodeFocus" @focus="focuss" >
                  @input="findBarcode()" :focus="barcodeFocus" >
                  <uni-icons type="closeempty" size="20" color="#dadada" @click="removeBarcode()"></uni-icons>
               </view>
            </view>
@@ -22,7 +22,7 @@
            <view class="square-content">
               <view class="content-input-combox" style="width: 94%;">
                  <input style="width: 90%;" type="text" v-model="matnr" placeholder="扫码 / 输入" @input="findMat()":focus="focus"
                   @focus="focuss">
                  >
                  <!-- @focus="focuss" -->
                  <uni-icons type="closeempty" size="20" color="#dadada" @click="removeMatnr()"></uni-icons>
               </view>
@@ -73,6 +73,7 @@
   export default {
      data() {
         return {
            commonUrl:null,
            barcode: '',
            barcodeFocus:true,
            focus:false,
@@ -100,21 +101,28 @@
            // this.getMatListLen()
         },1000)
      },
      onLoad() {
         // #ifdef APP
         setInterval(()=>{
            uni.hideKeyboard()
         },20)
         // #endif
      },
      mounted(){
         const UIP = uni.getStorageSync('UIP');
         this.baseIP = UIP;
         const UPORT = uni.getStorageSync('UPORT');
         this.basePORT = UPORT
         const PROJ = uni.getStorageSync('UPROJ');
         this.baseUrl = PROJ
         this.getUrl()
      },
      methods: {
         huanghang() {
               this.focus = false;
               this.$nextTick(function() {
                  this.focus = true;
               });
               this.matnr = ''
         // 获取url
         getUrl() {
            this.commonUrl = this.baseHttp + this.baseIP + ':' +this.basePORT + "/" +this.baseUrl
         },
         // 出库分为两种 一:全板出库 扫描托盘码显示全板商品 可以直接确认 二是减料出库 扫描托盘码提示需要出库数量  扫描货品条码达到最大出库数量即可
         messageToggle(type) {
            this.msgType = type
            this.messageText = `这是一条${type}消息提示`
@@ -124,14 +132,21 @@
            // this.listLen = this.matList.length;
         },
         focuss() {
            // uni.hideKeyboard()
            let that = this;
            that.barcodeFocus = false;
            setTimeout(()=>{
               that.barcode = ''
               that.barcodeFocus = true;
            }, 100);
         },
         resst() {
            this.matList = []
            this.barcode = ''
            this.matnr = ''
            this.matCount = ''
            this.removeBarcode();
            uni.vibrateShort();
         },
         removeBarcode() {
            this.barcode = ''
@@ -140,6 +155,16 @@
            this.$nextTick(function() {
               this.barcodeFocus = true;
            });
         },
         foucss() {
            // #ifdef APP
            let that = this;
            that.focus = false;
            setTimeout(()=>{
               that.matnr = '';
               that.focus = true;
            }, 100);
            // #endif
         },
         removeMatnr() {
            this.matnr = ''
@@ -180,7 +205,7 @@
         findBarcode() {
            let that = this
            uni.request({
                url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mobile/pakout/confirm/barcode/auth',
                url: that.commonUrl + '/mobile/pakout/confirm/barcode/auth',
                data: {
                  barcode:that.barcode
                },
@@ -188,22 +213,20 @@
                  '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;
                        that.foucss();
                        return;
                     }
                     if (res.data.ioType === 103) {
                     if (res.data.ioType === 103 || res.data.ioType === 104 || res.data.ioType === 107) {
                        that.matCount = res.data.list.length
                        that.wrkNo = res.data.list[0].wrkNo
                        that.foucss();
                        return;
                     }
                     // if (res.data) {
                     //    that.matCount = res.data.length
                     // }
                  } else if (res.code === 403) {
                     uni.showToast({title: res.msg, icon: "none", position: 'top'})
                        setTimeout(() => {
@@ -213,6 +236,7 @@
                     }, 1000);
                  } else {
                     uni.showToast({title: res.msg, icon: "none",position: 'top'})
                     that.focuss()
                  }
                  
               }
@@ -221,8 +245,16 @@
         },
         findMat() {
            let that = this
            if(that.barcode == '') {
               uni.showToast({title: '请先扫描托盘码!', icon: "none",position: 'top'})
               that.focuss()
               setTimeout(function() {
                  that.matnr = ''
               }, 100);
               return;
            }
            uni.request({
                url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mobile/pakout/confirm/pick/auth',
                url: that.commonUrl + '/mobile/pakout/confirm/pick/auth',
                data: {
                  wrkNo:that.wrkNo,
                  matnr:that.matnr
@@ -231,35 +263,25 @@
                  '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++) {
                           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 {
                     var add = true
                     if(res.data) {
                        console.log(that.matnr);
                        for(let i = 0;i < that.matList.length; i++) {
                           var matnr = that.matList[i].matnr + '-' +  that.matList[i].batch
                           console.log(matnr);
                           if (matnr === that.matnr) {
                              that.messageToggle('warn');
                              that.messageText = '已出全部商品,请确认出库';
                              that.huanghang();
                              return;
                              that.messageText = '该商品已添加';
                              that.foucss();
                              add = false
                           }
                        }
                        if (add) {
                           that.matList.unshift(res.data);
                           that.listLen = that.matList.length;
                           that.foucss();
                        }
                     }
                  } else if (res.code == 403) {
@@ -271,6 +293,7 @@
                     }, 1000);
                  } else {
                     uni.showToast({title: res.msg, icon: "none",position: 'top'})
                     that.foucss();
                  }
                  
               }
@@ -302,7 +325,7 @@
            }
            uni.showLoading();
            uni.request({
                url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mobile/pakout/confirm/auth',
                url: that.commonUrl + '/mobile/pakout/confirm/auth',
                data: that.matList,
               method: 'POST',
                header: {