123
zhang
2025-05-26 112c71dbe86fdffffe3dceb13fc7881e7fbe7881
pages/basics/order.vue
@@ -9,7 +9,7 @@
            <view class="square-content">
               <view class="content-input">
                  <input  v-model="barcode" type="text" placeholder="扫码 / 输入" maxlength="10"
                  :focus="barcodeFocus" @input="barcodeInput">
                  :focus="barcodeFocus" @input="barcodeInput" placeholder-style="line-height:  85rpx;">
                  <uni-icons type="closeempty" size="20" color="#dadada" @click="removeBarcode()"></uni-icons>
               </view>
            </view>
@@ -23,8 +23,22 @@
            <view class="square-content">
               <view class="content-input">
                  <input v-model="order" type="text" placeholder="扫码 / 输入" @input="findOrder()"
                  :focus="focus">
                  :focus="focus" placeholder-style="line-height:  85rpx;">
                  <uni-icons type="closeempty" size="20" color="#dadada" @click="removeOrder()"></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-input">
                  <input v-model="tiaoma" type="text" placeholder="扫码 / 输入" @input="findTiaoMa()"
                  :focus="tmfocus" placeholder-style="line-height:  85rpx;">
                  <uni-icons type="closeempty" size="20" color="#dadada" @click="removeTm()"></uni-icons>
               </view>
            </view>
         </view>
@@ -34,15 +48,15 @@
               <view class="title-sign"><view class="sign"></view></view>
               <view class="title-text"><text>商品列表</text></view>
               <view v-show="matList.length != 0" class="lable">
                  <label class="label-btn" style="width: 170rpx;line-height: 95rpx;"  >
                  <!-- <label class="label-btn" style="width: 170rpx;line-height: 95rpx;"  >
                     <checkbox :checked="check" @click="allChecked()">{{checkText}}</checkbox>
                  </label>
                  <label class="label-btn"  >
                  </label> -->
                  <!-- <label class="label-btn"  >
                     <text  @click="reChecked()">反选</text>
                  </label>
                  <label >
                     <uni-icons type="trash" size="25" color="#a5a5a5" @click="remove()"></uni-icons>
                  </label>
                  </label> -->
               </view>
            </view>
            
@@ -52,16 +66,19 @@
         </view>
         
         <checkbox-group @change="checkbox">
            <view v-for="(item,index) in matList" :key="index" class="data-list bg-false" :class="'bg-'+item.checked" >
               <label class="left-check-box">
                  <checkbox :value="item.id+''" :checked="item.checked" style="display: block;" />
            <view v-for="(item,index) in matList" :key="index" v-if="item.anfme>0"  class="data-list bg-false" :class="'bg-'+item.checked" >
               <label class="left-check-box" >
                  <checkbox :value="item.id+''" :checked="true" style="display: block;" />
               </label>
               <view class="data-list-left">
                  <view class="matnr"><text style="width: 700rpx;">编码:{{item.matnr}}</text></view>
               <view class="data-list-left" >
                  <view class="matnr"><text style="width: 700rpx;">品号:{{item.matnr}}</text></view>
                  <view><text style="width: 700rpx;">品名:{{item.maktx}}</text></view>
                  <view><text style="width: 700rpx;">批号:{{item.batch}}</text></view>
                  <view>
                     <text style="width: 700rpx;">数量:{{item.anfme}}</text>
                     <text style="width: 700rpx;">总数量:{{item.count}}</text>
                  </view>
                  <view>
                     <text style="width: 700rpx;">可组托最大数量:{{item.anfme}}</text>
                  </view>
               </view>
               <view class="data-list-right">
@@ -125,14 +142,18 @@
   export default {
      data() {
         return {
            commonUrl:null,
            barcode: '',
            barcodeFocus:true,
            tmfocus:false,
            focus:false,
            type: 'center',
            searchBox: 'hide',
            pick:'hide',
            order:null,
            orderNo:null,
            tiaoma:null,
            tiaomas:[],
            matList:[],
            result: '',
            count:'',
@@ -150,8 +171,15 @@
         this.baseIP = UIP;
         const UPORT = uni.getStorageSync('UPORT');
         this.basePORT = UPORT
         const PROJ = uni.getStorageSync('UPROJ');
         this.baseUrl = PROJ
         this.getUrl()
      },
      methods: {
         // 获取url
         getUrl() {
            this.commonUrl = this.baseHttp + this.baseIP + ':' +this.basePORT + "/" +this.baseUrl
         },
         // barcode input 事件
         barcodeInput() {
            var len = this.barcode.length
@@ -208,13 +236,20 @@
               this.focus = true;
            });
         },
         removeTm() {
            this.tiaoma = ''
            uni.vibrateShort();
            this.tmfocus = false;
            this.$nextTick(function() {
               this.focus = true;
            });
         },
         eject(type) {
            this.type = type
            // open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
            this.$refs.revise.open(type)
         },
         initAnfme() {
            for (var i = 0; i < this.matList.length; i++) {
               this.matList[i].anfme = 0
            }
@@ -263,7 +298,11 @@
         comb() {
            uni.vibrateShort();
            let that = this;
            if (that.barcode === '') {
            if (!that.orderNo) {
               uni.showToast({title: '请扫描单据号', icon: "none", position: 'top'});
               return;
            }
            if (!that.barcode) {
               uni.showToast({title: '请扫描托盘条码', icon: "none", position: 'top'});
               return;
            }
@@ -271,23 +310,24 @@
               uni.showToast({title: '托盘码必须为8位', icon: "none", position: 'top'});
               return;
            }
            if (that.matList.length === 0) {
            let mats =that.matList.filter(mat =>mat.anfme>0);
            if (mats.length === 0) {
               uni.showToast({title: '请添加商品列表', icon: "none", position: 'top'});
               return;
            }
            for (var i = 0; i < that.matList.length; i++) {
               if (that.matList[i].anfme === 0) {
                  uni.showToast({title: '商品组托数量为0不能组托', icon: "none", position: 'top'});
                  return;
               }
            }
            // for (var i = 0; i < mats.length; i++) {
            //    if (that.matList[i].anfme === 0) {
            //       uni.showToast({title: '商品组托数量为0不能组托', icon: "none", position: 'top'});
            //       return;
            //    }
            // }
            uni.showLoading();
            uni.request({
                url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mobile/comb/auth',
                url: that.commonUrl + '/mobile/comb/auth',
                data: JSON.stringify({
                  orderNo: that.orderNo,
                  barcode: that.barcode,
                  combMats: that.matList
                  combMats: mats
               }),
               method: 'POST',
                header: {
@@ -319,7 +359,7 @@
         findOrder() {
            let that = this
            uni.request({
                url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mobile/order/search/orderNo/auth',
                url: that.commonUrl + '/mobile/order/search/orderNo/auth',
                data: {
                  orderNo: that.order
                },
@@ -327,16 +367,23 @@
                  'token':uni.getStorageSync('token')
                },
               success(result) {
                  console.log("result:");
                  console.log(result)
                  let res = result.data
                  if (res.code === 200) {
                     if(res.data) {
                           uni.showLoading();
                        that.matList = res.data;
                        that.orderNo = that.order
                        that.initAnfme()
                        console.log(that.matList)
                     }
                  if (res.code === 200 && res.data) {
                     uni.showLoading();
                     that.orderNo = that.order
                     // that.matList = res.data.map(item => ({
                     //    ...item,
                     //    combMats: typeof item.combMats === 'string' ?
                     //           JSON.parse(item.combMats) : item.combMats // 确保对象结构[1,2](@ref)
                     // }));
                     that.matList = res.data.combMats
                     that.initAnfme();
                     console.log("that.matList:");
                     console.log(that.matList)
                  } else if (res.code == 403) {
                     uni.showToast({title: res.msg, icon: "none", position: 'top'})
                     setTimeout(() => {
@@ -348,6 +395,66 @@
                     uni.showToast({title: res.msg, icon: "none",position: 'top'})
                  }
               }
            });
         },
         findTiaoMa() {
            let that = this
            if (!that.orderNo) {
               uni.showToast({title: '请扫描单据号', icon: "none", position: 'top'});
               return;
            }
            uni.request({
                url: that.commonUrl + '/mobile/mat/search/auth',
                data: {
                  matnr: that.tiaoma
                },
                header: {
                  'token':uni.getStorageSync('token')
                },
               success(result) {
                  console.log("result:");
                  console.log(result)
                  let res = result.data
                  if (res.code === 200 && res.data) {
                     that.checkMat(res.data)
                     //this.tiaomas.unshift(that.tiaoma)
                  } 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'})
                  }
               }
            });
         },
         checkMat(mat) {
            var len = this.matList.length
            var add = true
            for (var i = 0; i < len; i++) {
               if (mat.matnr == this.matList[i].matnr) {
                  if ( mat.batch){
                     if( mat.batch == this.matList[i].batch){
                        this.matList[i].anfme += mat.anfme
                        this.$forceUpdate() // 强制刷新
                        add = false
                     }
                  }else{
                     this.matList[i].anfme += mat.anfme
                     this.$forceUpdate() // 强制刷新
                     add = false
                  }
               }
            }
            this.tiaoma = ''
            uni.vibrateShort();
            this.focus = false;
            this.$nextTick(function() {
               this.focus = true;
            });
         },
         change(e) {
@@ -534,8 +641,8 @@
   }
   .data-list {
      border-bottom: 1px solid #d8d8d8;
      height: 180rpx;
      margin: 15rpx;
      height: 210rpx;
      margin: 15rpx auto auto auto;
      border-radius: 20rpx;
   }
   .data-list:first-child {