#
whycq
2022-05-12 17d991dc11f5d00a07e5f14515cc6b950c6c2df0
pages/basics/checkout.vue
@@ -8,55 +8,27 @@
            </view>
            <view class="square-content">
               <view class="content-input">
                  <input v-model="barcode" type="text" placeholder="扫码 / 输入" maxlength="8" @input="findBarcode()">
                  <input v-model="barcode" type="text" placeholder="扫码 / 输入" maxlength="8"
                  @input="findBarcode()" :focus="barcodeFocus" @focus="focuss" >
                  <uni-icons type="closeempty" size="20" color="#dadada" @click="removeBarcode()"></uni-icons>
               </view>
            </view>
         </view>
         <!-- <view class="pak-seach-box">
            <view class="box-top">
               <view class="color-block-blue"></view>
               <text class="title">托盘条码</text>
            </view>
            <view class="box-buttom">
               <input v-model="barcode" type="text" placeholder="扫码 / 输入" maxlength="8" @input="findBarcode()">
               <view class="search-icon">
                  <uni-icons type="closeempty" size="20" color="#a5a5a5" @click="removeBarcode()"></uni-icons>
               </view>
            </view>
         </view> -->
         <view class="square-2">
            <view class="square-title">
               <view class="title-sign"><view class="sign"></view></view>
               <view class="title-text"><text>货品条码</text></view>
            </view>
            <view class="square-content">
               <view class="content-combox">
                  <uni-combox  emptyTips="暂无数据" :candidates="staNoList" v-model="staNo" placeholder="站台号"></uni-combox>
               </view>
               <view class="content-input-combox">
                  <input type="text" v-model="matnr" placeholder="扫码 / 输入" @input="findMat()">
               <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>
            </view>
         </view>
         
         <!-- <view class="pak-seach-box">
            <view class="box-top">
               <view class="color-block-blue"></view>
               <text class="title">货品条码</text>
            </view>
            <view class="box-buttom">
               <input v-model="matnr" type="text" placeholder="扫码 / 输入" @input="findMat()">
               <view class="search-icon">
                  <uni-icons type="closeempty" size="20" color="#a5a5a5" @click="removeMatnr()"></uni-icons>
               </view>
            </view>
            <view class="combox">
               <uni-combox  emptyTips="暂无数据" :candidates="staNoList" v-model="staNo" placeholder="站台号"></uni-combox>
            </view>
         </view> -->
         <view class="square-1">
            <view class="square-title">
               <view class="title-sign"><view class="sign"></view></view>
@@ -66,16 +38,14 @@
         <view class="square-none" v-show="matList.length === 0">
            <view class="v-show">暂无更多数据...</view>
         </view>
         <!-- <view class="pak-data-box"  v-show="matList.length === 0">
            <view style="text-align: center;">暂无更多数据</view>
         </view> -->
         <checkbox-group @change="checkbox">
            <view v-for="(item,index) in matList" :key="index" class="data-list bg-false" :class="'bg-'+item.checked" >
               <view class="data-list-left">
                  <view class="matnr">{{item.barcode}}</view>
                  <view class="matnr" :style="item.color">No:{{listLen-index}}</view>
                  <view class="matnr" :style="item.color">{{item.matnr}}-{{item.batch}}</view>
               </view>
               <view class="data-list-right">
                  <uni-icons type="trash" size="25" color="#a5a5a5" @click="remove(item,index)"></uni-icons>
                  <uni-icons type="trash" size="20" color="#a5a5a5" @click="remove(item,index)"></uni-icons>
               </view>
            </view>
         </checkbox-group>
@@ -88,6 +58,12 @@
            <button class="cu-btn lg pakin-btn bg-blue" @click="comb()">确认</button>
         </view>
      </view>
      <view>
         <!-- 提示信息弹窗 -->
         <uni-popup ref="message" type="message">
            <uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
         </uni-popup>
      </view>
   </view>
</template>
@@ -97,15 +73,30 @@
      data() {
         return {
            barcode: '',
            barcodeFocus:true,
            focus:false,
            type: 'center',
            searchBox: 'hide',
            pick:'hide',
            matnr:'',
            matList:[{barcode:'92992929292'}],
            matList:[{matnr:'1101842-10000',batch:'22047515999',color:{color:'red'}}],
            // matList:[],
            result: '',
            siteList:[],
            desc:'',
            staNoList:[],
            staNo:'',
            satNo:'',
            listLen:0,
            msgType: 'success',
            messageText: '这是一条成功提示',
            fontColor:{color:'red'}
         }
      },
      onReady() {
         setInterval(function(){
            // console.log(this.matList)
            // this.getMatListLen()
         },1000)
      },
      mounted(){
         const UIP = uni.getStorageSync('UIP');
@@ -113,44 +104,64 @@
         const UPORT = uni.getStorageSync('UPORT');
         this.basePORT = UPORT
         this.getOutBound();
      },
      methods: {
         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;
         },
         focuss() {
            // uni.hideKeyboard()
         },
         resst() {
            this.matList = []
            this.barcode = ''
            this.matnr = ''
            this.desc = ''
            uni.vibrateShort();
         },
         removeBarcode() {
            this.barcode = ''
            uni.vibrateShort();
            uni.vibrateShort();
            this.barcodeFocus = false;
            this.$nextTick(function() {
               this.barcodeFocus = true;
            });
         },
         removeMatnr() {
            this.matnr = ''
            uni.vibrateShort();
            this.focus = false;
            this.$nextTick(function() {
               this.focus = true;
            });
         },
         remove(item,index) {
            this.matList.splice(index,1)
            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;
            }
            if (that.matList.length === 0) {
               uni.showToast({title: '请添加商品列表', icon: "none", position: 'top'});
               return;
            }
            uni.showLoading();
            uni.request({
                url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mobile/comb/auth',
                data: JSON.stringify({
                  barcode: that.barcode,
                  combMats: that.matList
               }),
                url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mobile/pakout/confirm/auth',
                data: that.matList,
               method: 'POST',
                header: {
                  'token':uni.getStorageSync('token')
@@ -164,6 +175,10 @@
                        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(() => {
@@ -209,10 +224,61 @@
                  'token':uni.getStorageSync('token')
                },
               success(result) {
                  console.log(result)
                  var res = result.data;
                  if(res.code === 200 ) {
                     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;
                        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'})
                     setTimeout(() => {
                        uni.reLaunch({
                           url: '../login/login'
                        });
                     }, 1000);
                  } else {
                     uni.showToast({title: res.msg, icon: "none",position: 'top'})
                  }
                  
               }
            });
         },
         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])
               }
            }
            console.log(this.matList)
         },
         findBarcode() {
            let that = this
@@ -222,11 +288,22 @@
                  barcode:that.barcode
                },
                header: {
                  'token':uni.getStorageSync('token')
                  'token':uni.getStorageSync('token'),
                },
               success(result) {
                  console.log(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;
               }
            });
            
@@ -234,7 +311,7 @@
         getOutBound() {         // 获取出库口
            let that = this
            uni.request({
               url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/available/take/check/site',
               url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/available/take/site',
               method: 'POST',
               header: {
                  'token':uni.getStorageSync('token')
@@ -242,6 +319,9 @@
               success(result) {
                  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
                  } else if (res.code == 403) {
                     uni.showToast({title: res.msg, icon: "none", position: 'top'})
@@ -261,7 +341,6 @@
            
         }, // getCheckDetl
         change(e) {
            console.log('当前模式:' + e.type + ',状态:' + e.show);
         },
         toggle(type) {
            this.type = type
@@ -348,12 +427,7 @@
      margin-top: 5rpx;
      margin-right: 10rpx;
   }
   .combox {
      position: fixed;
      display: inline-block;
      width: 28%;
      float: right;
   }
   /* .pak-seach-box input {
      background-color: #ededed;
      border: 1rpx solid #d8d8d8;
@@ -407,7 +481,7 @@
      margin-top: 20rpx;
   }
   .data-list:last-child {
      margin-bottom: 120rpx;
      margin-bottom: 200rpx;
   }
   /* .data-list-left {
      display: inline-block;
@@ -429,10 +503,11 @@
   .matnr {
      display: inline-block;
      width: 100%;
      font-size: 16px;
      font-size: 14px;
      font-weight: 700;
      height: 130rpx;
      line-height: 130rpx;
      padding-top: 15rpx;
      /* height: 130rpx;
      line-height: 130rpx; */
   }
   .data-list-right {
      /* background-color: #6739B6; */