1
yangpeixing
2026-04-01 f1bf3ef09713182d434e22dfd8623ea73e02d6d3
¼ª°²PDA/pages/stash/raworderboxing.vue
@@ -26,7 +26,10 @@
                     <view style="display: flex;justify-content: space-around;margin-top: 2%;">
                        <button @click="reset" type="default" size="default"
                           style="width: 160rpx;border: 1rpx solid #007aff;color: #007aff;">重置</button>
                        <button @click="submit" type="primary" size="default" style="width: 160rpx;">组盘</button>
                        <button @click="submit" type="primary" size="default" style="width: 160rpx;"
                           :disabled="isSubmitting" :loading="isSubmitting">
                           {{ isSubmitting ? '提交中...' : '组盘' }}
                        </button>
                     </view>
                  </uni-forms-item>
               </uni-forms>
@@ -41,7 +44,6 @@
                              <view class="uni-title-sub uni-ellipsis-2">采购单号:{{item.purchaseOrderNo}}</view>
                              <view class="uni-note">物料编码:{{item.materielCode}}</view>
                              <view class="uni-note">批次号:{{item.lotNo}}</view>
                              <!-- ç›´æŽ¥ç¼–辑Q值对应的quantity字段 -->
                              <view class="uni-note" style="display: flex; align-items: center; gap: 10rpx;">
                                 æ•°é‡ï¼š
                                 <uni-easyinput 
@@ -74,7 +76,10 @@
                        placeholder="请扫描地址条码" ref='midInput' :focus="addressFocus" />
                  </uni-forms-item>
                  <uni-forms-item>
                     <button @click="inbound" type="primary" size="default" style="margin-top: 2%;">入库确认</button>
                     <button @click="inbound" type="primary" size="default" style="margin-top: 2%;"
                        :disabled="isInbounding" :loading="isInbounding">
                        {{ isInbounding ? '提交中...' : '入库确认' }}
                     </button>
                  </uni-forms-item>
               </uni-forms>
            </view>
@@ -111,7 +116,9 @@
                        <button @click="resetInPk" type="default" size="default"
                           style="width: 160rpx;border: 1rpx solid #007aff;color: #007aff;">重置</button>
                        <button @click="pksubmit" type="primary" size="default"
                           style="margin-top: 2%;">入平库</button>
                           style="margin-top: 2%;" :disabled="isPkSubmitting" :loading="isPkSubmitting">
                           {{ isPkSubmitting ? '提交中...' : '入平库' }}
                        </button>
                     </view>
                  </uni-forms-item>
@@ -127,7 +134,6 @@
                              <view class="uni-title-sub uni-ellipsis-2">采购单号:{{item.purchaseOrderNo}}</view>
                              <view class="uni-note">物料编码:{{item.materielCode}}</view>
                              <view class="uni-note">批次号:{{item.lotNo}}</view>
                              <!-- ç›´æŽ¥ç¼–辑Q值对应的quantity字段 -->
                              <view class="uni-note" style="display: flex; align-items: center; gap: 10rpx;">
                                 æ•°é‡ï¼š
                                 <uni-easyinput 
@@ -187,7 +193,13 @@
            Testcheck: false,
            pkmaterSn: "",
            pkmatInfos: [],
            addressdisabled: false
            addressdisabled: false,
            // æ ¸å¿ƒé”ï¼šé˜²æ­¢é‡å¤æäº¤
            isSubmitting: false,
            isInbounding: false,
            isPkSubmitting: false,
            // è¯·æ±‚唯一标识:用于取消重复请求
            submitRequest: null
         }
      },
      onShow() {},
@@ -217,12 +229,10 @@
         this.getData();
      },
      methods: {
         // ç»„盘页数量编辑校验(直接修改原生quantity字段)
         // æ•°é‡ç¼–辑校验
         handleQuantityChange(item) {
            item.quantity = item.quantity ? Math.max(1, parseInt(item.quantity)) : 1;
         },
         // å…¥å¹³åº“页数量编辑校验(直接修改原生quantity字段)
         handlePkQuantityChange(item) {
            item.quantity = item.quantity ? Math.max(1, parseInt(item.quantity)) : 1;
         },
@@ -235,14 +245,12 @@
               }
            });
         },
         barcodeFocus() {
            this.barcode = '';
            if (this.focus) {
               this.focus = false;
            }
         },
         getData() {
            var postData = {
               MainData: {
@@ -258,7 +266,6 @@
               }
            })
         },
         onClickItem(e) {
            this.focus = false;
            this.addressFocus = false;
@@ -269,7 +276,6 @@
               }
            }
         },
         barcodeInput() {
            this.$nextTick(function(x) {
               if (this.barcode.length > 0) {
@@ -277,23 +283,16 @@
               }
            })
         },
         // ç»„盘页内箱码解析(直接操作原生quantity字段)
         // ç»„盘页内箱码解析
         snInput() {
            this.$nextTick(() => {
               if (!this.materSn) return;
               // å»¶è¿Ÿ100ms确保扫码完成
               setTimeout(() => {
                  this.focus = false;
                  let matSn = this.materSn.trim();
                  // ä»“库11的特殊处理
                  if (this.warehouseId == 11) {
                     matSn = matSn.replace(/,SC.*/, '');
                  }
                  // æ ¡éªŒå†…箱码完整性
                  const requiredFields = ['M:', 'BS:', 'DM:', 'DE:', 'Q:', 'PO:', 'DN:'];
                  const hasAllFields = requiredFields.every(field => matSn.includes(field));
                  if (!hasAllFields) {
@@ -304,8 +303,6 @@
                     this.materSn = "";
                     return;
                  }
                  // æ ¡éªŒPO字段存在性
                  if (matSn.indexOf("PO") <= 0) {
                     this.$refs.uToast.show({
                        title: "内箱码格式错误(无PO标识)",
@@ -314,14 +311,11 @@
                     this.materSn = "";
                     return;
                  }
                  // è§£æžå†…箱码(直接使用返回的quantity作为Q值)
                  this.$u.post('/api/MaterielInfo/CodeAnalysis?serNum=' + matSn, {}).then((res) => {
                     this.Testcheck = false;
                     if (res.status) {
                        this.sns.push(res.data.serialNumber);
                        this.matInfos.push(res.data);
                        if (res.message) {
                           this.$refs.uToast.show({
                              title: res.message,
@@ -335,22 +329,16 @@
                        });
                     }
                  });
                  this.materSn = "";
               }, 1000);
            })
         },
         // å…¥å¹³åº“页内箱码解析(直接操作原生quantity字段)
         // å…¥å¹³åº“页内箱码解析
         pksnInput() {
            this.$nextTick(() => {
               if (!this.pkmaterSn) return;
               // å»¶è¿Ÿ100ms确保扫码完成
               setTimeout(() => {
                  let matSn = this.pkmaterSn.trim();
                  // æ ¡éªŒå†…箱码完整性
                  const requiredFields = ['M:', 'BS:', 'DM:', 'DE:', 'Q:', 'PO:', 'DN:'];
                  const hasAllFields = requiredFields.every(field => matSn.includes(field));
                  if (!hasAllFields) {
@@ -361,8 +349,6 @@
                     this.pkmaterSn = "";
                     return;
                  }
                  // æ ¡éªŒPO字段存在性
                  if (matSn.indexOf("PO") <= 0) {
                     this.$refs.uToast.show({
                        title: "内箱码格式错误(无PO标识)",
@@ -371,8 +357,6 @@
                     this.pkmaterSn = "";
                     return;
                  }
                  // è§£æžå†…箱码(直接使用返回的quantity作为Q值)
                  this.$u.post('/api/MaterielInfo/CodeAnalysis?serNum=' + matSn, {}).then((res) => {
                     if (res.status) {
                        this.pksns.push(res.data.serialNumber);
@@ -384,27 +368,25 @@
                        });
                     }
                  });
                  this.pkmaterSn = "";
               }, 100);
            })
         },
         // å…¥åº“确认(加锁)
         inbound() {
            if (this.isInbounding) {
               this.$refs.uToast.show({title: "正在提交中,请勿重复操作", type: "warning"});
               return;
            }
            if (this.inboundBarcode == "") {
               this.$refs.uToast.show({
                  title: "请扫描托盘条码",
                  type: "error"
               })
               this.$refs.uToast.show({title: "请扫描托盘条码", type: "error"});
               return;
            }
            if (this.address == "") {
               this.$refs.uToast.show({
                  title: "请扫描地址条码",
                  type: "error"
               })
               this.$refs.uToast.show({title: "请扫描地址条码", type: "error"});
               return;
            }
            this.isInbounding = true;
            var postData = {
               MainData: {
                  "barcode": this.inboundBarcode,
@@ -418,25 +400,17 @@
                  if (this.warehouseId != 5) this.address = "";
                  setTimeout(() => {
                     this.addressFocus = false;
                     this.$refs.uToast.show({
                        title: "成功",
                        type: "success"
                     })
                     this.$refs.uToast.show({title: "成功", type: "success"});
                  }, 200);
               } else {
                  this.$refs.uToast.show({
                     title: res.message,
                     type: "error"
                  })
                  this.$refs.uToast.show({title: res.message, type: "error"});
               }
            }).catch(err => {
               this.$refs.uToast.show({
                  title: err.message,
                  type: "error"
               })
               this.$refs.uToast.show({title: err.message, type: "error"});
            }).finally(() => {
               this.isInbounding = false;
            })
         },
         inputChangebarcode() {
            this.addressFocus = false;
            this.$nextTick(function(x) {
@@ -445,17 +419,14 @@
               }
            })
         },
         deleteList(res) {
            this.matInfos.splice(res, 1);
            this.sns.splice(res, 1);
         },
         pkdeleteList(res) {
            this.pkmatInfos.splice(res, 1);
            this.pksns.splice(res, 1);
         },
         reset() {
            this.barcode = "";
            this.matInfos = [];
@@ -465,125 +436,136 @@
               this.Initiallife = 0;
            }
         },
         resetInPk() {
            this.pkmaterSn = "";
            this.pkfocus = false;
            this.pkmatInfos = [];
            this.pksns = [];
         },
         // å…¥å¹³åº“(加锁)
         pksubmit() {
            if (this.pkmatInfos.length == 0) {
               this.$refs.uToast.show({
                  title: "请扫描内箱标签",
                  type: 'error'
               })
            if (this.isPkSubmitting) {
               this.$refs.uToast.show({title: "正在提交中,请勿重复操作", type: "warning"});
               return;
            }
            // ç›´æŽ¥ä½¿ç”¨ä¿®æ”¹åŽçš„quantity(对应Q值)提交
            if (this.pkmatInfos.length == 0) {
               this.$refs.uToast.show({title: "请扫描内箱标签", type: 'error'});
               return;
            }
            this.isPkSubmitting = true;
            const submitData = this.pkmatInfos.map(item => ({
               serialNumber: item.serialNumber,
               quantity: item.quantity
            }));
            this.$u.post('/api/InboundOrder/InPinKu?warehouseId=' + this.warehouseId + "&orderNo=" + this.orderNo, submitData)
               .then(res => {
                  if (res.status) {
                     this.$refs.uToast.show({
                        title: "入库成功",
                        type: "success"
                     })
                     this.$refs.uToast.show({title: "入库成功", type: "success"});
                     this.pkfocus = false;
                     this.pkmatInfos = [];
                     this.pksns = [];
                  } else {
                     this.$refs.uToast.show({
                        title: res.message,
                        type: "error"
                     })
                     this.$refs.uToast.show({title: res.message, type: "error"});
                  }
               }).finally(() => {
                  this.isPkSubmitting = false;
               })
         },
         
         // æ ¸å¿ƒä¿®å¤ï¼šç»„盘提交(彻底杜绝重复调用)
         submit() {
            // 1. ç¬¬ä¸€å±‚锁:状态锁拦截
            if (this.isSubmitting) {
               this.$refs.uToast.show({title: "正在提交中,请勿重复操作", type: "warning"});
               return;
            }
            // 2. è¡¨å•校验
            if (this.barcode == "") {
               this.$refs.uToast.show({
                  title: "请扫描托盘条码",
                  type: 'error'
               })
               this.$refs.uToast.show({title: "请扫描托盘条码", type: 'error'});
               return;
            }
            if (this.matInfos.length == 0) {
               this.$refs.uToast.show({
                  title: "请扫描内箱标签",
                  type: 'error'
               })
               this.$refs.uToast.show({title: "请扫描内箱标签", type: 'error'});
               return;
            }
            if (this.Test) {
               if (!this.Testcheck) {
                  this.Testcheck = true;
                  if (this.warehouseId == 2) {
                     this.$refs.uToast.show({
                        title: "请确认数量",
                        type: 'error'
                     })
                  } else if (this.warehouseId == 6) {
                     this.$refs.uToast.show({
                        title: "请确认初始寿命",
                        type: 'error'
                     })
                  }
                  return;
               }
            if (this.Test && !this.Testcheck) {
               this.Testcheck = true;
               this.$refs.uToast.show({
                  title: this.warehouseId == 2 ? "请确认数量" : "请确认初始寿命",
                  type: 'error'
               });
               return;
            }
            // ç›´æŽ¥ä½¿ç”¨ä¿®æ”¹åŽçš„quantity(对应Q值)提交
            // 3. å¼ºåˆ¶å–消未完成的请求(关键!)
            if (this.submitRequest) {
               this.submitRequest.abort(); // å–消上一次未完成的请求
            }
            // 4. ç«‹å³ä¸Šé”
            this.isSubmitting = true;
            uni.showLoading({title: '提交中...', mask: true});
            // 5. æž„造请求数据
            let submitSns = this.matInfos.map(item => ({
               serialNumber: item.serialNumber,
               quantity: item.quantity
            }));
            // æ²¹å¢¨ä»“库特殊处理
            if (this.warehouseId == 2) {
               const firstItem = submitSns[0];
               for (var i = 0; i < this.Initiallife - 1; i++) {
                  submitSns.push({...firstItem});
               }
            }
            this.$u.post('/api/InboundOrder/MaterielGroup', {
               MainData: {
                  "palletCode": this.barcode,
                  "orderNo": this.orderNo,
                  "initiallife": this.Initiallife,
                  "warehouseId": this.warehouseId
            // 6. ä½¿ç”¨åŽŸç”Ÿuni.request(支持取消),替代$u.post
            const requestData = {
               url: '/api/InboundOrder/MaterielGroup',
               method: 'POST',
               data: {
                  MainData: {
                     "palletCode": this.barcode,
                     "orderNo": this.orderNo,
                     "initiallife": this.Initiallife,
                     "warehouseId": this.warehouseId
                  },
                  DelKeys: submitSns
               },
               DelKeys: submitSns
            }).then(res => {
               this.Testcheck = false;
               if (res.status) {
                  this.$refs.uToast.show({
                     title: "组盘成功",
                     type: "success"
                  })
                  this.focus = false;
                  this.barcode = "";
                  this.matInfos = [];
                  this.sns = [];
                  this.matTotal = [];
                  if (this.warehouseId != 6) {
                     this.Initiallife = "";
               success: (res) => {
                  // é€‚配接口返回格式(根据你的实际返回调整)
                  const result = res.data;
                  this.Testcheck = false;
                  if (result.status) {
                     this.$refs.uToast.show({title: "组盘成功", type: "success"});
                     this.focus = false;
                     this.barcode = "";
                     this.matInfos = [];
                     this.sns = [];
                     this.matTotal = [];
                     if (this.warehouseId != 6) {
                        this.Initiallife = "";
                     }
                  } else {
                     this.$refs.uToast.show({title: result.message, type: "error"});
                  }
               } else {
                  this.$refs.uToast.show({
                     title: res.message,
                     type: "error"
                  })
               },
               fail: (err) => {
                  // æŽ’除主动取消的请求(避免误提示)
                  if (err.errMsg !== 'request:fail abort') {
                     this.$refs.uToast.show({title: err.message || "提交失败", type: "error"});
                  }
               },
               complete: () => {
                  // 7. è§£é” + æ¸…空请求标识
                  this.isSubmitting = false;
                  this.submitRequest = null;
                  uni.hideLoading();
               }
            })
            };
            // 8. ä¿å­˜è¯·æ±‚标识,用于取消重复请求
            this.submitRequest = uni.request(requestData);
         }
      }
   }
@@ -591,24 +573,8 @@
<style lang="scss">
   @import '@/common/uni-ui.scss';
   .content {
      display: flex;
      height: 150px;
   }
   .content-text {
      font-size: 14px;
      color: #666;
   }
   .itemstyle {
      margin-top: 30px;
      margin-left: 5%;
   }
   .headerstyle {
      width: 90%;
   }
</style>
   .content {display: flex; height: 150px;}
   .content-text {font-size: 14px; color: #666;}
   .itemstyle {margin-top: 30px; margin-left: 5%;}
   .headerstyle {width: 90%;}
</style>