1
yangpeixing
5 天以前 48e2278d7ac330c7f05deda6f884acb6f01206b4
¼ª°²PDA/pages/stash/raworderboxing.vue
@@ -22,28 +22,18 @@
                        v-model="Initiallife" />
                  </uni-forms-item>
                  <!-- <uni-forms-item>
                     <checkbox checked="check">是否满盘</checkbox>
                  </uni-forms-item> -->
                  <uni-forms-item>
                     <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>
               <uni-list>
                  <!-- <uni-list-item direction="column" v-for="item in matTotal" :key="item.matCode">
                     <template v-slot:body>
                        <view class="uni-list-box">
                           <view class="uni-content">
                              <view class="uni-title-sub uni-ellipsis-2">物料编码:{{item.matCode}}</view>
                              <view class="uni-title-sub uni-ellipsis-2">数量:{{item.matQuantity}}</view>
                           </view>
                        </view>
                     </template>
                  </uni-list-item> -->
                  <uni-list-item direction="column" v-for="(item,index) in matInfos" :key="index">
                     <template v-slot:body>
                        <view class="uni-list-box">
@@ -54,7 +44,16 @@
                              <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>
                              <view class="uni-note">数量:{{item.quantity}}</view>
                              <view class="uni-note" style="display: flex; align-items: center; gap: 10rpx;">
                                 æ•°é‡ï¼š
                                 <uni-easyinput
                                    type="number"
                                    min="1"
                                    style="width: 150rpx; display: inline-block;"
                                    v-model="item.quantity"
                                    @input="handleQuantityChange(item)"
                                 />
                              </view>
                              <view class="uni-note">生产日期:{{item.productionDate}}</view>
                              <view class="uni-note">有效期:{{item.effectiveDate}}</view>
                              <view class="uni-note">交货单号:{{item.deliveryNote}}</view>
@@ -77,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>
@@ -92,8 +94,6 @@
                              <view style="font-size: 18px;">单据号:{{orderNo}}</view>
                              <view style="font-size: 18px;">物料编码:{{item.materielCode}}</view>
                              <view>物料名称:{{item.materielName}}</view>
                              <!-- <view>物料规格:{{item.materielSpec}}</view> -->
                              <!-- <view style="font-size: 18px;">物料名称:{{item.matName}}</view> -->
                              <view style="font-size: 18px;">数量:{{item.orderQuantity}}</view>
                              <view style="font-size: 18px;">组盘数量:{{item.receiptQuantity}}</view>
                           </view>
@@ -116,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>
@@ -132,7 +134,16 @@
                              <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>
                              <view class="uni-note">数量:{{item.quantity}}</view>
                              <view class="uni-note" style="display: flex; align-items: center; gap: 10rpx;">
                                 æ•°é‡ï¼š
                                 <uni-easyinput
                                    type="number"
                                    min="1"
                                    style="width: 150rpx; display: inline-block;"
                                    v-model="item.quantity"
                                    @input="handlePkQuantityChange(item)"
                                 />
                              </view>
                              <view class="uni-note">生产日期:{{item.productionDate}}</view>
                              <view class="uni-note">有效期:{{item.effectiveDate}}</view>
                              <view class="uni-note">交货单号:{{item.deliveryNote}}</view>
@@ -153,7 +164,7 @@
   export default {
      data() {
         return {
            items: ['组盘', '入库', '单据信息'], //, '解盘'
            items: ['组盘', '入库', '单据信息'],
            current: 0,
            matTotal: [],
            matInfos: [],
@@ -182,7 +193,13 @@
            Testcheck: false,
            pkmaterSn: "",
            pkmatInfos: [],
            addressdisabled: false
            addressdisabled: false,
            // æ ¸å¿ƒé”ï¼šé˜²æ­¢é‡å¤æäº¤
            isSubmitting: false,
            isInbounding: false,
            isPkSubmitting: false,
            // è¯·æ±‚唯一标识:用于取消重复请求
            submitRequest: null
         }
      },
      onShow() {},
@@ -212,12 +229,15 @@
         this.getData();
      },
      methods: {
         // voiceSpeech(src) {
         //    innerAudioContext.src = src; // '../../static/success.mp3';
         //    innerAudioContext.play();
         // },
         // æ•°é‡ç¼–辑校验
         handleQuantityChange(item) {
            item.quantity = item.quantity ? Math.max(1, parseInt(item.quantity)) : 1;
         },
         handlePkQuantityChange(item) {
            item.quantity = item.quantity ? Math.max(1, parseInt(item.quantity)) : 1;
         },
         updateFocus() {
            debugger
            this.$nextTick(() => {
               this.materSn = '';
               if (!this.focus) {
@@ -226,7 +246,6 @@
            });
         },
         barcodeFocus() {
            debugger
            this.barcode = '';
            if (this.focus) {
               this.focus = false;
@@ -260,120 +279,114 @@
         barcodeInput() {
            this.$nextTick(function(x) {
               if (this.barcode.length > 0) {
                  // if (this.barcode.substring(0, 1) == 'A' || this.barcode.substring(0, 2) == 'TP') {
                  this.focus = true;
                  // } else {
                  //    this.$refs.uToast.show({
                  //       title: "扫码错误,请扫描托盘码",
                  //       type: "error"
                  //    })
                  // }
               }
            })
         },
         // ç»„盘页内箱码解析
         snInput() {
            this.$nextTick(() => {
               if (this.materSn != "") {
               if (!this.materSn) return;
               setTimeout(() => {
                  this.focus = false;
                  var matSn = this.materSn;
                  let matSn = this.materSn.trim();
                  if (this.warehouseId == 11) {
                     matSn = matSn.replace(/,SC.*/, '');
                  }
                  //查询matSn是否存在字符
                  if(matSn.indexOf("PO")>0){
                     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,
                                 type: "error"
                              })
                              // setTimeout(() => {
                              //    this.voiceSpeech('../../static/fail.mp3');
                              // }, 100);
                              return;
                           }
                           // setTimeout(() => {
                           //    this.voiceSpeech('../../static/success.mp3');
                           // }, 100);
                        } else {
                  const requiredFields = ['M:', 'BS:', 'DM:', 'DE:', 'Q:', 'PO:', 'DN:'];
                  const hasAllFields = requiredFields.every(field => matSn.includes(field));
                  if (!hasAllFields) {
                     this.$refs.uToast.show({
                        title: "内箱码不完整,请重新扫描",
                        type: "error"
                     });
                     this.materSn = "";
                     return;
                  }
                  if (matSn.indexOf("PO") <= 0) {
                     this.$refs.uToast.show({
                        title: "内箱码格式错误(无PO标识)",
                        type: "error"
                     });
                     this.materSn = "";
                     return;
                  }
                  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,
                              type: "error"
                           })
                           // setTimeout(() => {
                           //    this.voiceSpeech('../../static/fail.mp3');
                           // }, 100);
                              type: "warning"
                           });
                        }
                     })
                  }
                  setTimeout(() => {
                     this.materSn = "";
                  }, 100);
               }
                     } else {
                        this.$refs.uToast.show({
                           title: res.message,
                           type: "error"
                        });
                     }
                  });
                  this.materSn = "";
               }, 1000);
            })
         },
         // å…¥å¹³åº“页内箱码解析
         pksnInput() {
            this.$nextTick(() => {
               if (this.pkmaterSn != "") {
                  var matSn = this.pkmaterSn;
                  if(matSn.indexOf("PO")>0){
                     this.$u.post('/api/MaterielInfo/CodeAnalysis?serNum=' + matSn, {}).then((res) => {
                        if (res.status) {
                           this.pksns.push(res.data.serialNumber);
                           this.pkmatInfos.push(res.data);
                           if (!res.status) {
                              this.$refs.uToast.show({
                                 title: res.message,
                                 type: "error"
                              })
                              // setTimeout(() => {
                              //    this.voiceSpeech('../../static/fail.mp3');
                              // }, 100);
                              return;
                           }
                           // setTimeout(() => {
                           //    this.voiceSpeech('../../static/success.mp3');
                           // }, 100);
                           return;
                        } else {
                           this.$refs.uToast.show({
                              title: res.message,
                              type: "error"
                           })
                           // setTimeout(() => {
                           //    this.voiceSpeech('../../static/fail.mp3');
                           // }, 100);
                        }
                     })
                  }
                  setTimeout(() => {
               if (!this.pkmaterSn) return;
               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) {
                     this.$refs.uToast.show({
                        title: "内箱码不完整,请重新扫描",
                        type: "error"
                     });
                     this.pkmaterSn = "";
                  }, 100);
               }
                     return;
                  }
                  if (matSn.indexOf("PO") <= 0) {
                     this.$refs.uToast.show({
                        title: "内箱码格式错误(无PO标识)",
                        type: "error"
                     });
                     this.pkmaterSn = "";
                     return;
                  }
                  this.$u.post('/api/MaterielInfo/CodeAnalysis?serNum=' + matSn, {}).then((res) => {
                     if (res.status) {
                        this.pksns.push(res.data.serialNumber);
                        this.pkmatInfos.push(res.data);
                     } else {
                        this.$refs.uToast.show({
                           title: res.message,
                           type: "error"
                        });
                     }
                  });
                  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,
@@ -387,22 +400,15 @@
                  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() {
@@ -426,7 +432,7 @@
            this.matInfos = [];
            this.sns = [];
            this.materSn = "";
            if (this.warehouseId = !6) {
            if (this.warehouseId != 6) {
               this.Initiallife = 0;
            }
         },
@@ -436,101 +442,130 @@
            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;
            }
            this.$u.post('/api/InboundOrder/InPinKu?warehouseId=' + this.warehouseId + "&orderNo=" + this.orderNo, this
               .pksns).then(res => {
               if (res.status) {
                  this.$refs.uToast.show({
                     title: "入库成功",
                     type: "success"
                  })
                  this.pkfocus = false;
                  this.pkmatInfos = [];
                  this.pksns = [];
               } else {
                  this.$refs.uToast.show({
                     title: res.message,
                     type: "error"
                  })
               }
            })
         },
         submit() {
            if (this.barcode == "") {
               this.$refs.uToast.show({
                  title: "请扫描托盘条码",
                  type: 'error'
            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.pkfocus = false;
                     this.pkmatInfos = [];
                     this.pksns = [];
                  } else {
                     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'});
               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;
            }
            if (this.warehouseId == 2) { //油墨仓库区ID
               this.sn = this.sns[0];
            // 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++) {
                  this.sns.push(this.sn);
                  submitSns.push({...firstItem});
               }
            }
            this.$u.post('/api/InboundOrder/MaterielGroup', {
               MainData: {
                  "palletCode": this.barcode,
                  "orderNo": this.orderNo,
                  "initiallife": this.Initiallife,
                  // "isFull": this.check
                  "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: this.sns
            }).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) { //测试架仓库区ID
                     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);
         }
      }
   }
@@ -538,23 +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%;
   }
   .content {display: flex; height: 150px;}
   .content-text {font-size: 14px; color: #666;}
   .itemstyle {margin-top: 30px; margin-left: 5%;}
   .headerstyle {width: 90%;}
</style>