whycq
2022-08-24 36fc4fa64ba5a7fd9f23b33c94c918d4b3ca70e3
pages/basics/outPakin.vue
@@ -8,8 +8,8 @@
            </view>
            <view class="square-content">
               <view class="content-input">
                  <input v-model="barcode" type="text" placeholder="扫码 / 输入" maxlength="8"
                  :focus="barcodeFocus" @focus="focuss">
                  <input readonly="value" v-model="barcode" type="text" placeholder="扫码 / 输入" maxlength="8"
                  :focus="barcodeFocus" @input="nextInput">
                  <uni-icons type="closeempty" size="20" color="#dadada" @click="removeBarcode()"></uni-icons>
               </view>
            </view>
@@ -21,10 +21,11 @@
            </view>
            <view class="square-content">
               <view class="content-input">
                  <input v-model="matnr" type="text" placeholder="扫码 / 输入" @input="findMat()"
                  :focus="focus" @focus="focuss" >
                  <input v-model="matnrId" type="text" placeholder="扫码 / 输入" @input="findMat()"
                  :focus="focus"@focus="empty()">
                   <!-- :focus="focus" @blur="clear "> -->
                  <!-- @focus="focuss" -->
                  <uni-icons type="closeempty" size="20" color="#dadada" @click="removeMatnr()"></uni-icons>
                  <uni-icons type="closeempty" size="20" color="#dadada" @click="foucss()"></uni-icons>
               </view>
            </view>
         </view>
@@ -63,6 +64,29 @@
            <uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
         </uni-popup>
      </view>
      <!-- 确认仓库弹窗 -->
      <view>
         <uni-popup ref="checkOrigin" type="center" backgroundColor="#fff">
            <view class="origin-box">
               <view class="square-title">
                  <view class="title-sign"><view class="sign"></view></view>
                  <view class="title-text"><text>确认仓库</text></view>
               </view>
               <view style="width: 100%;">
                  <radio-group @change="radioChange" style="display: block;">
                     <label class="radio" v-for="(origin, index) in origins" :key="origins.value">
                        <radio style="transform:scale(0.7)" :value="origin.value" :checked="index === current" />{{origin.value}}
                     </label>
                  </radio-group>
               </view>
               <view class="pop-btn flex  justify-around">
                  <button class="cu-btn bg-blue lg" @click="check()">确认</button>
               </view>
            </view>
         </uni-popup>
      </view>
   </view>
</template>
@@ -71,86 +95,69 @@
   export default {
      data() {
         return {
            commonUrl:null,
            barcode: '',
            barcodeFocus:true,
            focus:false,
            type: 'center',
            searchBox: 'hide',
            pick:'hide',
            matnr:'',
            matnrId:'',
            // matList:[{matnr:'1101842-10000',batch:'22047515999'}],
            matList:[],
            result: '',
            listLen:0,
            msgType: 'success',
            messageText: '这是一条成功提示',
            origins: [{value:'1288'},{value:'5055'}],
            origin: null, // 仓库
            current: 0,
            isNum:false
         }
      },
      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()
      },
      onLoad() {
         // #ifdef APP
         setInterval(()=>{
            uni.hideKeyboard()
         },20)
         // #endif
      },
      methods: {
         messageToggle(type) {
            this.msgType = type
            this.messageText = `这是一条${type}消息提示`
            this.$refs.message.open()
         // 获取url
         getUrl() {
            this.commonUrl = this.baseHttp + this.baseIP + ':' +this.basePORT + "/" +this.baseUrl
         },
         focuss() {
            // setInterval(function(){
            //    uni.hideKeyboard()
            // },20)
            // uni.hideKeyboard()
         },
         resst() {
            this.matList = []
            this.barcode = ''
            this.matnr = ''
            uni.vibrateShort();
         },
         removeBarcode() {
            this.barcode = ''
            uni.vibrateShort();
            this.barcodeFocus = false;
            this.$nextTick(function() {
               this.barcodeFocus = true;
            });
         },
         removeMatnr() {
            this.focus = false;
            this.$nextTick(function() {
               this.focus = true;
            });
            this.matnr = ''
            uni.vibrateShort();
         },
         remove(item,index) {
            this.matList.splice(index,1)
            this.listLen = this.matList.length
            this.messageToggle('success')
            this.messageText = '删除成功'
            uni.vibrateShort();
         },
         comb() {
            uni.vibrateShort();
            let that = this;
            if (that.barcode === '') {
               uni.showToast({title: '请扫描托盘条码', icon: "none", position: 'top'});
               return;
         radioChange(evt) {
            for (let i = 0; i < this.origins.length; i++) {
               if (this.origins[i].value === evt.detail.value) {
                  this.current = i;
                  break;
               }
            }
            if (that.matList.length === 0) {
               uni.showToast({title: '请添加商品列表', icon: "none", position: 'top'});
               return;
         },
         // 确认出库口
         check() {
            let that = this
            if (this.current == 0) {
               this.origin = 1288
            } else {
               this.origin = 5055
            }
            uni.showLoading();
            this.$refs.checkOrigin.close()
            uni.request({
                url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mobile/comb/auth',
                url: that.commonUrl + '/mobile/comb/auth',
                data: JSON.stringify({
                  barcode: that.barcode,
                  origin: that.origin,
                  combMats: that.matList
               }),
               method: 'POST',
@@ -169,6 +176,7 @@
                     that.barcode = '';
                     that.matList = '';
                     that.matList = [];
                     that.barcodeFocuss();
                  } else if (res.code == 403) {
                     uni.showToast({title: res.msg, icon: "none", position: 'top'})
                     setTimeout(() => {
@@ -182,55 +190,217 @@
               }
            });
         },
         nextInput() {
            if (this.barcode.length == 8) {
               this.foucss()
            }
         },
         empty() {
            return this.inputValue='';
         },
         barcodeFocuss() {
            // #ifdef APP
            let that = this;
            that.barcodeFocus = false;
            setTimeout(()=>{
               that.matnrId = '';
               that.barcodeFocus = true;
            }, 100);
            // #endif
         },
         foucss() {
            // #ifdef APP
            let that = this;
            that.focus = false;
            setTimeout(()=>{
               that.matnrId = '';
               that.focus = true;
            }, 100);
            // #endif
         },
         clear() {
            this.matnrId = ''
         },
         messageToggle(type) {
            this.msgType = type
            this.messageText = `这是一条${type}消息提示`
            this.$refs.message.open()
         },
         resst() {
            this.matnrId = '';
            this.matList = [];
            this.barcode = '';
            this.barcodeFocuss();
         },
         removeBarcode() {
            this.barcode = ''
            this.barcodeFocus = false;
            this.$nextTick(function() {
               this.barcodeFocus = true;
            });
         },
         remove(item,index) {
            this.matnrId = ''
            this.matList.splice(index,1)
            this.listLen = this.matList.length
            this.messageToggle('success')
            this.messageText = '删除成功'
         },
         comb() {
            let that = this;
            if (that.barcode === '') {
               uni.showToast({title: '请扫描托盘条码', icon: "none", position: 'top'});
               return;
            }
            if (that.matList.length === 0) {
               uni.showToast({title: '请添加商品列表', icon: "none", position: 'top'});
               return;
            }
            // uni.showLoading();
            that.$refs.checkOrigin.open()
         },
         // 输入的不是数字的排除
         checkNum(theObj) {
            var reg = /^[0-9]*$/;
            if (!reg.test(theObj)) {
               this.isNum = false;
               return ;
            }
            var year = theObj.substring(0,2)
            //获取当前年份
            var dt = new Date();
            var thisYear = new Date().getFullYear() + ''
            thisYear = thisYear.substring(2,4)
            if(year > thisYear) {
               this.isNum = false;
               return ;
            }
            this.isNum = true;
         },
         // 添加扫描日志
         addLog(matCode,userName) {
            let that = this;
            uni.request({
               url: that.commonUrl + "/mobile/addLog/auth",
               data: {
                  matcode:matCode,
                  username:userName
               },
               header: {
                  'token':uni.getStorageSync('token')
               },
               // method:"POST",
               success(result) {
                  var res = result.data
                  if(res.code === 200) {
                     // uni.showToast({title: "添加成功", icon: "none",position: 'center'})
                  }
               }
            })
         },
         // 检索商品
         findMat() {
            let that = this
            let str = that.matnr.split('-')
            that.matnr = str[0]+'-'+str[1]
            uni.showLoading();
            let userName = uni.getStorageSync('HCuname')
            let matCode = that.matnrId
            // 开启扫描日志
            that.addLog(matCode,userName)
            // that.foucss();
            // return;
            if(that.matList.length > 15) {
               that.messageToggle('warn');
               that.messageText = '组托商品数量已超过16件,请完成当前组托';
               that.foucss();
               return;
            }
            if (that.matnrId.length > 25){
               that.messageToggle('warn');
               that.messageText = '商品编码超长,请重试';
               that.foucss();
               return;
            }
            let str = that.matnrId.split('-')
            let matnr = str[0] + '-' + str[1]
            // 检查条码中非数字
            that.checkNum(str[2])
            // 检查序列码长度
            if (str[2].length != 11) {
               that.messageToggle('warn');
               that.messageText = '商品序列码长度有误,请重试!';
               that.foucss();
               return;
            }
            // 检查年份
            var dt = new Date();
            var year = (dt.getFullYear() + '').substring(2,4)
            var month = (dt.getMonth()+1) < 10 ? '0'+ (dt.getMonth()+1) : (dt.getMonth()+1);
            if (str[2].substring(0,2) > year) {
               that.messageToggle('warn');
               that.messageText = '商品序列码年份有误,请重试!';
               that.foucss();
               return;
            }
            // 检查月份
            if (str[2].substring(2,4) > 12) {
               that.messageToggle('warn');
               that.messageText = '商品序列码月份有误,请重试!';
               that.foucss();
               return;
            }
            if (str)
            if (that.isNum == false) {
               that.messageToggle('warn');
               that.messageText = '商品编码有误,请重试!';
               that.foucss();
               return;
            }
            for (let k = 0; k < that.matList.length;k++) {
               if (that.matList[k].matnr != matnr) {
                  that.messageToggle('warn');
                  that.messageText = '商品种类不一致,请重试!';
                  that.foucss();
                  return;
               }
            }
            // return;
            // uni.showLoading();
            uni.request({
                url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mat/auth',
                url: that.commonUrl + '/barcode/check/auth',
                data: {
                  matnr:that.matnr
                  barcode:that.matnrId
                },
                header: {
                  'token':uni.getStorageSync('token')
                },
               success(result) {
                  uni.vibrateShort();
                  uni.hideLoading();
                  // uni.vibrateShort();
                  let res = result.data
                  if (res.code === 200 && res.data) {
                     let add = true;
                     if(res.data) {
                        let mat = res.data;
                        mat['batch'] = str[2];
                        mat['anfme'] = 1
                        for(let i = 0;i < that.matList.length;i++) {
                           if(that.matList[i].batch == str[2]) {
                              that.messageToggle('warn');
                              that.messageText = '重复扫描';
                              that.focus = false;
                              that.$nextTick(function() {
                                 that.focus = true;
                              });
                              add = false;
                              break;
                           }
                     let mat = res.data;
                     mat['batch'] = str[2];
                     mat['anfme'] = 1
                     for(let i = 0;i < that.matList.length;i++) {
                        if(that.matList[i].batch == str[2]) {
                           that.messageToggle('warn');
                           that.messageText = '重复扫描';
                           that.foucss();
                           add = false;
                        }
                     }
                     if(add) {
                        that.messageToggle('success');
                        that.messageText = '检索成功';
                        that.focus = false;
                        that.$nextTick(function() {
                           that.focus = true;
                        });
                        // uni.hideKeyboard();
                        that.matList.unshift(res.data)
                     }
                     that.matnr = ''
                        that.foucss();
                     }
                     that.listLen = that.matList.length;
                     uni.hideLoading();
                  } else if (res.code == 403) {
                     that.messageToggle('error')
                     that.messageText = res.msg
@@ -265,24 +435,13 @@
   /* @import "../../colorui/main.css";
   @import "../../colorui/icon.css"; */
   /* 
   1101842-10000-22047515999
   1101842-10000-22047518494
   1101842-10000-22047518532
   1101842-10000-22047515990
   1101842-10000-22047515997
   1101842-10000-22047518515
   1101842-10000-22047515778
   1101842-10000-22047515938
   1101842-10000-22047518518
   1101842-10000-22047518517
   1101842-10000-22047515967
   1101842-10000-22047518472
   1101842-10000-22047518516
   1101842-10000-22047518511
   1101842-10000-22047515864
   1101842-10000-22047515889
    */
   
    */
   .pop-btn {
      position: absolute;
      width: 100%;
      bottom: 20rpx;
   }
   .pak-seach-box {
      background-color: #FFFFFF;
      margin: 15rpx 15rpx 0rpx 15rpx;