647556386
2026-01-19 c36c6a8236689fb3704a2d7722c39bb2c4bf7aa0
ÏîÄ¿´úÂë/WIDESEA_WMSClient/src/extension/inbound/extend/Pallet.vue
@@ -203,6 +203,8 @@
      scanTimer: null,
      manualInputTimer: null,
      scanTarget: 'tray', // å½“前扫码目标: tray æˆ– material
      isSubmitting: false, // æ–°å¢žï¼šæäº¤é”å®šï¼Œé˜²æ­¢é‡å¤è¯·æ±‚
      groupedBarcodes: [],
      // åº“存统计相关变量
      totalStockSum: 0,
@@ -266,7 +268,6 @@
        this.resetData();
        this.$nextTick(() => {
          setTimeout(() => {
            this.fetchStockStatistics(); // åŠ è½½ç»Ÿè®¡æ•°æ®
            this.fetchUnpalletMaterialDetails();
          }, 300);
        });
@@ -286,18 +287,12 @@
        this.palletForm = { palletCode: '', barcode: '' };
        this.backData = [];
        this.$refs.palletForm?.reset();
        this.fetchStockStatistics(); // å•据号变了,刷新统计
        this.fetchUnpalletMaterialDetails();
      }
    }
  },
  mounted() {
    document.addEventListener('keypress', this.handleKeyPress);
    setTimeout(() => {
      this.focusLocationSelect();
    }, 300);
  },
  beforeDestroy() {
    document.removeEventListener('keypress', this.handleKeyPress);
@@ -306,9 +301,10 @@
  methods: {
    open() {
      this.show = true;
      this.orderNo = "";
      this.resetData();
      this.initLocationTypes();
      this.initwarehouseTypes();
      this.fetchStockStatistics();
      this.fetchUnpalletMaterialDetails();
    },
    validateLocationType(rule, value, callback) {
@@ -324,7 +320,7 @@
    // æ ¹æ®æ¡ç åˆ—表获取详细数据
    async fetchUnpalletMaterialDetails() {
      try {
        const response = await http.post('/api/InboundOrder/UnPalletGroupBarcode?orderNo=' + this.docNo, {});
        const response = await http.post('/api/InboundOrder/UnPalletGroupBarcode?orderNo=' + this.orderNo, {});
        if (response.status && Array.isArray(response.data)) {
          this.unpalletMaterials = response.data;
          this.unpalletBarcodes = response.data.map(item => item.barcode || '');
@@ -361,9 +357,9 @@
      }
    },
    async fetchStockStatistics() {
    async fetchStockStatistics(orderNo) {
      // å•据号为空时不查询
      if (!this.docNo) {
      if (!orderNo) {
        this.sumError = '单据号为空,无法统计';
        return;
      }
@@ -371,7 +367,7 @@
      this.sumLoading = true;
      this.sumError = '';
      try {
        const response = await http.post('/api/InboundOrder/UnPalletQuantity?orderNo=' + this.orderNo, {});
        const response = await http.post('/api/InboundOrder/UnPalletQuantity?orderNo=' + orderNo, {});
        if (response.data) {
          this.totalStockSum = response.data.stockSumQuantity || 0;
          this.totalStockCount = response.data.stockCount || 0;
@@ -440,7 +436,8 @@
    },
    // é‡ç½®æ‰€æœ‰æ•°æ®
    resetData() {
      console.log('重置弹框数据');
      this.groupedBarcodes = []; // æ¸…空已组盘条码
      this.isSubmitting = false; // é‡ç½®æäº¤é”
      this.trayBarcode = '';
      this.barcode = '';
      this.materials = [];
@@ -626,6 +623,10 @@
    // å¤„理物料条码提交
    async handleBarcodeSubmit() {
      if (this.isSubmitting) {
    this.$message.warning('正在处理中,请稍候');
    return;
  }
      if (!await this.validateForm()) return;
      const currentBarcode = this.barcode.trim();
@@ -643,8 +644,8 @@
      this.focusBarcodeInput();
      this.error = '';
      this.loading = true;
      this.isSubmitting = true; // å¼€å¯æäº¤é”
      console.log(currentBarcode);
      try {
        // è°ƒç”¨API查询物料信息
        const materialData = await this.fetchMaterialData(currentBarcode);
@@ -653,6 +654,7 @@
        }
        this.materials = [];
        const newBarcodes = []; // ä¸´æ—¶å­˜å‚¨æœ¬æ¬¡æ–°å¢žçš„æ¡ç 
        materialData.forEach(item => {
          this.materials.push({
            ...item,
@@ -661,10 +663,14 @@
            locationDesc: this.currentLocationDesc,
            scanTime: this.formatTime(new Date())
          });
          newBarcodes.push(item.barcode); // æ”¶é›†æœ¬æ¬¡ç»„盘的条码
        });
        this.orderNo = materialData[0].orderNo;
         // å°†æœ¬æ¬¡ç»„盘的条码加入已组盘列表
        this.groupedBarcodes = [...new Set([...this.groupedBarcodes, ...newBarcodes])];
        this.fetchStockStatistics();
        this.orderNo = materialData[0].orderNo;
        await this.fetchStockStatistics(materialData[0].orderNo);
        await this.fetchUnpalletMaterialDetails();
        // æ¸…空物料输入框并保持聚焦
        this.barcode = '';
        this.scanCode = ''; // æ¸…空扫码缓存
@@ -683,6 +689,7 @@
        }, 100);
      } finally {
        this.loading = false;
        this.isSubmitting = false; // å…³é—­æäº¤é”
      }
    },
@@ -724,7 +731,7 @@
    // å¤„理扫码枪输入
    handleKeyPress(event) {
      // å¦‚果是手动输入模式,不处理扫码枪逻辑
      if (this.isManualInput) {
      if (this.isManualInput || this.isSubmitting) {
        return;
      }
@@ -733,6 +740,7 @@
      // å¿½ç•¥ç›´æŽ¥æŒ‰ä¸‹çš„回车键(由handleBarcodeSubmit处理)
      if (key === 'Enter') {
        event.preventDefault(); // å¼ºåˆ¶é˜»æ­¢é»˜è®¤è¡Œä¸ºï¼Œé¿å…é‡å¤è§¦å‘
        if (this.scanCode.length > 0) {
          // é˜»æ­¢é»˜è®¤å›žè½¦è¡Œä¸ºï¼Œé¿å…è¡¨å•提交
          event.preventDefault();
@@ -772,44 +780,6 @@
      }, 100);
      this.lastKeyTime = currentTime;
    },
    // åˆ é™¤ç‰©æ–™
    removeMaterial(index) {
      this.$confirm('确定要删除这条物料记录吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.materials.splice(index, 1);
        this.$message({
          type: 'success',
          message: '删除成功!'
        });
        this.fetchStockStatistics();
      }).catch(() => {
        // å–消删除
      });
    },
    // æ¸…空所有物料
    clearAllMaterials() {
      if (this.materials.length === 0) return;
      this.$confirm('确定要清空所有物料记录吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.materials = [];
        this.$message({
          type: 'success',
          message: '已清空所有记录!'
        });
      }).catch(() => {
        // å–消清空
      });
    },
    // æ ¼å¼åŒ–æ—¶é—´