xiaojiao
2026-01-12 c3b60d865c3457c35054446e81b352e93e00a696
ÏîÄ¿´úÂë/PDA/pages/Inbound/InboundEmpty.vue
@@ -23,14 +23,22 @@
                     :focus="value_rfidfocus" />
               </u-td>
            </u-tr>
         </u-table>
      </view>
      <view style="padding: 0rpx 0rpx;">
         <u-table>
            <u-tr>
               <u-td>
                  <u-button style="width:100px" type="primary" @click="SaveInfomation">确认</u-button>
                  <!-- å…³é”®1:根据提交状态禁用按钮,提示用户正在处理 -->
                  <u-button
                     style="width:100px"
                     type="primary"
                     @click="SaveInfomation"
                     :disabled="isSubmitting"
                     :loading="isSubmitting"
                  >
                     {{ isSubmitting ? '处理中...' : '确认' }}
                  </u-button>
               </u-td>
            </u-tr>
         </u-table>
@@ -39,8 +47,7 @@
</template>
<script>
   var _this;
   var _user;
   // ç§»é™¤å…¨å±€_this,改用箭头函数避免this指向问题
   export default {
      data() {
         return {
@@ -48,7 +55,11 @@
            CurrentUser: '', //当前用户
            value_rfid: '',
            value_qrcode: '',
            value_rfidfocus: false
            value_rfidfocus: false,
            timer: null, // å®šæ—¶å™¨å˜é‡ï¼ˆè¡¥å……定义,避免undefined)
            isSubmitting: false, // å…³é”®2:提交状态锁,标记是否正在处理请求
            lastSubmitTime: 0, // å…³é”®3:记录最后一次提交时间,防防抖
            submitInterval: 3000 // é˜²æŠ–间隔:3秒内不允许重复提交(可调整)
         }
      },
      methods: {
@@ -61,17 +72,38 @@
                  this.date = this.$DateTool.getDate();
               }, 1000)
            }
         },
         SaveInfomation() {
            if (_this.value_rfid.length == 0) {
            // é˜²æŠ–校验:3秒内重复点击直接拦截
            const now = Date.now();
            if (now - this.lastSubmitTime < this.submitInterval) {
               uni.showToast({
                  title: "请勿重复提交!",
                  duration: 2000,
                  icon: 'none'
               });
               return;
            }
            // æäº¤çŠ¶æ€é”ï¼šæ­£åœ¨å¤„ç†ä¸­åˆ™æ‹¦æˆª
            if (this.isSubmitting) {
               uni.showToast({
                  title: "请稍候,正在处理中...",
                  duration: 2000,
                  icon: 'none'
               });
               return;
            }
            // åŽŸæœ‰å­—æ®µæ ¡éªŒ
            if (this.value_rfid.length == 0) {
               uni.showToast({
                  title: "托盘码不能为空",
                  duration: 2000
               });
               return;
            }
            if (_this.value_rfid.length > 6) {
            if (this.value_rfid.length > 6) {
               uni.showToast({
                  title: "托盘长度不能大于6位数。",
                  duration: 2000,
@@ -79,45 +111,62 @@
               });
               return;
            }
            // æ ‡è®°ä¸ºæäº¤ä¸­ï¼Œç¦ç”¨æŒ‰é’®
            this.isSubmitting = true;
            // è®°å½•提交时间,用于防抖
            this.lastSubmitTime = now;
            uni.showModal({
               title: '提示',
               content: '请核对托盘码是否正确?',
               success: function(res) {
               // å…³é”®4:改用箭头函数,避免this指向丢失
               success: (res) => {
                  if (res.confirm) {
                     let data = {
                        MainData: {
                           barcode: _this.value_rfid
                           barcode: this.value_rfid
                        },
                     };
                     _this.$AjaxRequest.Params('post', 'Dt_boxing_head/CreateEmptyPalletTask',
                        data, _user.token);
                     _this.$AjaxRequest.Request().then(function(result) {
                     this.$AjaxRequest.Params('post', 'Dt_boxing_head/CreateEmptyPalletTask',
                        data, this.$UserTool.UserInfo.token);
                     this.$AjaxRequest.Request().then((result) => {
                        // è¯·æ±‚完成,重置提交状态
                        this.isSubmitting = false;
                        if (result.data.status) {
                           uni.showToast({
                              title: "创建空托入库成功!",
                              duration: 2000
                           });
                           _this.value_rfid = "";
                           _this.value_qrcode = "";
                           _this.value_rfidfocus = true;
                           this.value_rfid = "";
                           this.value_qrcode = "";
                           this.value_rfidfocus = true;
                        } else {
                           //console.log(result.data.message);
                           uni.showToast({
                              icon: 'none',
                              title: "请求错误:" + result.data.message,
                              duration: 2000
                           });
                        }
                     }).catch(function(err) {
                     }).catch((err) => {
                        // å¼‚常情况,也要重置提交状态
                        this.isSubmitting = false;
                        uni.showToast({
                           icon: 'none',
                           title: "请求后台异常,错误信息." + err.errMsg,
                           title: "请求后台异常,错误信息:" + err.errMsg,
                           duration: 2000
                        });
                     });
                  } else if (res.cancel) {
                     // å–消确认,重置提交状态
                     this.isSubmitting = false;
                     this.value_rfidfocus = true;
                  }
               },
               // å…³é”®5:弹窗关闭(如点击空白处),必须重置提交状态
               complete: () => {
                  if (!this.isSubmitting) return; // å·²å¤„理完成则跳过
                  this.isSubmitting = false;
               }
            });
         },
@@ -127,8 +176,7 @@
         clearInterval(this.timer)
         this.timer = null;
         this.setTimer();
         _user = this.$UserTool.UserInfo;
         this.CurrentUser = _user.userName;
         this.CurrentUser = this.$UserTool.UserInfo.userName;
         this.UserArray = [this.$UserTool.AllUserInfo];
         this.value_rfidfocus = true;
      },
@@ -138,11 +186,8 @@
         this.timer = null;
      },
      mounted() {
         _this = this;
         //_this.queryOrder();
      },
         // ç§»é™¤å…¨å±€_this赋值,彻底避免this指向问题
      }
   }
</script>
@@ -160,7 +205,6 @@
   .loopItem {
      margin-top: 5px;
      margin-left: 15px;
   }
   .deleteBtn {