647556386
2026-01-22 68e75f8e483accd14d34ea64e228678c58b498bc
ÏîÄ¿´úÂë/WIDESEA_WMSClient/src/extension/inbound/extend/AllcatedPallet.vue
@@ -70,11 +70,11 @@
            <div class="input-label">物料条码</div>
            <el-input ref="barcodeInput" v-model="barcode" placeholder="请扫描或输入物料条码后按回车键" clearable
              :disabled="!form.locationType || !trayBarcode || !form.warehouseType"
              @keyup.enter.native="handleBarcodeSubmit" @clear="handleClear" @input="handleBarcodeInput"
              @keyup.enter.native="debounceHandleBarcodeSubmit" @clear="handleClear" @input="handleBarcodeInput"
              class="custom-input" size="medium">
              <template slot="append">
                <el-button :loading="loading" @click="handleBarcodeSubmit" type="primary" icon="el-icon-search"
                  :disabled="!form.locationType || !trayBarcode || !barcode || !from.warehouseType" size="medium">
                <el-button :loading="loading" @click="debounceHandleBarcodeSubmit" type="primary" icon="el-icon-search"
                  :disabled="!form.locationType || !trayBarcode || !barcode || !form.warehouseType" size="medium">
                  {{ loading ? '查询中...' : '查询' }}
                </el-button>
              </template>
@@ -84,7 +84,7 @@
          <div class="input-tips compact-tips">
            <p>提示:请先选择仓库 â†’ é€‰æ‹©ä»“库区域 â†’ è¾“入料箱码 â†’ è¾“入物料条码</p>
            <p v-if="!form.warehouseType" class="warning-text">⚠️ è¯·å…ˆé€‰æ‹©ä»“库</p>
            <p v-if="!form.locationType && !form.warehouseType" class="warning-text">⚠️ è¯·å…ˆé€‰æ‹©ä»“库区域</p>
            <p v-if="form.warehouseType && !form.locationType" class="warning-text">⚠️ è¯·å…ˆé€‰æ‹©ä»“库区域</p>
            <p v-if="form.warehouseType && form.locationType && !trayBarcode" class="warning-text">⚠️ è¯·å…ˆè¾“入料箱码</p>
          </div>
@@ -111,7 +111,6 @@
              <el-tag type="primary" size="small">未组盘 {{ totalStockCount }}</el-tag>
            </span>
          </div>
          <div class="table-container">
            <el-table :data="unpalletMaterials" stripe style="width: 100%" height="100%" size="small"
@@ -146,7 +145,7 @@
          <div v-if="materials.length === 0" class="empty-state compact">
            <i class="el-icon-document"></i>
            <p v-if="!form.warehouseType">请先选择仓库</p>
            <p v-if="!form.locationType">请先选择仓库区域</p>
            <p v-if="form.warehouseType && !form.locationType">请先选择仓库区域</p>
            <p v-else-if="!trayBarcode">请先输入料箱条码</p>
            <p v-else>暂无物料数据,请扫描或输入物料条码</p>
          </div>
@@ -171,9 +170,23 @@
    </template>
  </vol-box>
</template>
<script>
import http from '@/api/http.js';
import VolBox from '@/components/basic/VolBox.vue';
// é˜²æŠ–函数保持不变
function debounce(func, wait) {
  let timeout;
  return function () {
    const context = this;
    const args = arguments;
    clearTimeout(timeout);
    timeout = setTimeout(() => {
      func.apply(context, args);
    }, wait);
  };
}
export default {
  components: { VolBox },
@@ -193,27 +206,25 @@
      unpalletBarcodes: [],
      unpalletBarcodesLoading: false,
      unpalletMaterials: [], // æœªç»„盘详细数据列表
      unpalletMaterials: [],
      // æ‰«ç æžªç›¸å…³å˜é‡
      scanCode: '',
      lastKeyTime: null,
      isManualInput: false,
      isScanning: false,
      scanTimer: null,
      manualInputTimer: null,
      scanTarget: 'tray', // å½“前扫码目标: tray æˆ– material
      scanTarget: 'tray',
      isSubmitting: false,
      palletGroupedBarcodes: {},
      // åº“存统计相关变量
      totalStockSum: 0,
      totalStockCount: 0,
      uniqueUnit: '',
      sumLoading: false,
      sumError: '',
      // ä»“库相关变量
      warehouseTypes: [],
      warehouseLoading: false,
      // ä»“库区域相关变量
      locationTypes: [],
      locationLoading: false,
      form: {
@@ -245,22 +256,25 @@
  },
  computed: {
    // å½“前选择的仓库名称
    currentWarehouseName() {
      const warehouse = this.warehouseTypes.find(item => item.warehouseType === this.form.warehouseType);
      return warehouse ? warehouse.warehouseTypeDesc : '';
    },
    // å½“前选择的仓库区域描述
    currentLocationDesc() {
      const location = this.locationTypes.find(item => item.locationType === this.form.locationType)
      return location ? location.locationTypeDesc : ''
    },
    debounceHandleBarcodeSubmit() {
      return debounce(this.handleBarcodeSubmit, 500);
    }
  },
  watch: {
    visible(newVal, oldVal) {
      this.palletVisible = newVal;
      // å½“从 false å˜ä¸º true æ—¶ï¼Œè¡¨ç¤ºå¼¹æ¡†æ‰“å¼€
      if (newVal === true && oldVal === false) {
        console.log('弹框打开,重置数据');
        this.resetData();
@@ -271,15 +285,16 @@
        });
      }
      // å½“从 true å˜ä¸º false æ—¶ï¼Œè¡¨ç¤ºå¼¹æ¡†å…³é—­
      if (newVal === false && oldVal === true) {
        console.log('弹框关闭,重置数据');
        this.resetData();
      }
    },
    palletVisible(newVal) {
      this.$emit('update:visible', newVal);
    },
    docNo(newVal) {
      if (newVal) {
        this.palletForm = { palletCode: '', barcode: '' };
@@ -289,13 +304,16 @@
      }
    }
  },
  mounted() {
    document.addEventListener('keypress', this.handleKeyPress);
  },
  beforeDestroy() {
    document.removeEventListener('keypress', this.handleKeyPress);
    this.clearAllTimers();
  },
  methods: {
    open() {
      this.show = true;
@@ -305,6 +323,7 @@
      this.initwarehouseTypes();
      this.fetchUnpalletMaterialDetails();
    },
    validateLocationType(rule, value, callback) {
      if (!this.form.warehouseType) {
        callback(new Error('请先选择仓库'));
@@ -315,72 +334,104 @@
      }
    },
    // æ ¹æ®æ¡ç åˆ—表获取详细数据
    async fetchUnpalletMaterialDetails() {
      try {
        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 || '');
          this.totalStockCount = response.data.length;
        } else {
          this.unpalletMaterials = [];
        }
      } catch (err) {
        this.unpalletMaterials = this.unpalletBarcodes.map(barcode => ({
          barcode: barcode,
          materielCode: '-',
          batchNo: '-',
          stockQuantity: '-',
          unit: '-',
          supplyCode: '-',
          warehouseType: '-'
        }));
      }
    // èŽ·å–æœªç»„ç›˜ç‰©æ–™è¯¦æƒ…
    fetchUnpalletMaterialDetails() {
      this.unpalletBarcodesLoading = true;
      http.post('/api/InboundOrder/UnPalletGroupBarcode?orderNo=' + this.orderNo, {})
        .then(response => {
          if (response.status && Array.isArray(response.data)) {
            this.unpalletMaterials = response.data;
            this.unpalletBarcodes = response.data.map(item => item.barcode || '');
            this.totalStockCount = response.data.length;
          } else {
            this.unpalletMaterials = [];
          }
        })
        .catch(err => {
          console.error('获取未组盘物料失败:', err);
          this.unpalletMaterials = this.unpalletBarcodes.map(barcode => ({
            barcode: barcode,
            materielCode: '-',
            batchNo: '-',
            stockQuantity: '-',
            unit: '-',
            supplyCode: '-',
            warehouseType: '-'
          }));
        })
        .finally(() => {
          this.unpalletBarcodesLoading = false;
        });
    },
    async initLocationTypes() {
      try {
        const { data } = await this.http.post("api/LocationInfo/GetLocationTypes")
        this.locationTypes = data
      } catch (e) {
        this.$message.error('获取区域类型失败')
      }
    // åˆå§‹åŒ–仓库区域类型
    initLocationTypes() {
      this.locationLoading = true;
      this.http.post("api/LocationInfo/GetLocationTypes")
        .then(({ data }) => {
          this.locationTypes = data;
        })
        .catch(e => {
          console.error('获取区域类型失败:', e);
          this.$message.error('获取区域类型失败');
        })
        .finally(() => {
          this.locationLoading = false;
        });
    },
    async initwarehouseTypes() {
      try {
        const { data } = await this.http.post("api/Warehouse/GetwarehouseTypes")
        this.warehouseTypes = data
      } catch (e) {
        this.$message.error('获取区域类型失败')
      }
    // åˆå§‹åŒ–仓库类型
    initwarehouseTypes() {
      this.warehouseLoading = true;
      this.http.post("api/Warehouse/GetwarehouseTypes")
        .then(({ data }) => {
          this.warehouseTypes = data;
        })
        .catch(e => {
          console.error('获取仓库类型失败:', e);
          this.$message.error('获取仓库类型失败');
        })
        .finally(() => {
          this.warehouseLoading = false;
        });
    },
    async fetchStockStatistics(orderNo) {
      // å•据号为空时不查询
    // èŽ·å–åº“å­˜ç»Ÿè®¡
    fetchStockStatistics(orderNo) {
      if (!orderNo) {
        this.sumError = '单据号为空,无法统计';
        return;
        return Promise.resolve(null);
      }
      this.sumLoading = true;
      this.sumError = '';
      try {
        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;
          this.uniqueUnit = response.data.uniqueUnit || '';
        }
      } catch (err) {
        this.sumError = '统计加载失败';
        this.totalStockSum = 0;
        this.totalStockCount = 0;
      } finally {
        this.sumLoading = false;
      }
      return http.post('/api/InboundOrder/UnPalletQuantity?orderNo=' + orderNo, {})
        .then(response => {
          if (response.data) {
            this.totalStockSum = response.data.stockSumQuantity || 0;
            this.totalStockCount = response.data.stockCount || 0;
            this.uniqueUnit = response.data.uniqueUnit || '';
          }
          return response.data;
        })
        .catch(err => {
          console.error('统计加载失败:', err);
          this.sumError = '统计加载失败';
          this.totalStockSum = 0;
          this.totalStockCount = 0;
          throw err;
        })
        .finally(() => {
          this.sumLoading = false;
        });
    },
    async validateForm() {
    // è¡¨å•验证
    validateForm() {
      return new Promise((resolve) => {
        if (!this.$refs.locationForm) {
          this.error = '表单未初始化';
@@ -394,10 +445,9 @@
            this.error = '';
            resolve(true);
          } else {
            if (!this.from.warehouseType) {
            if (!this.form.warehouseType) {
              this.error = '请先选择仓库';
            }
            else if (this.form.locationType === null || this.form.locationType === undefined || this.form.locationType === '') {
            } else if (!this.form.locationType) {
              this.error = '请先选择仓库区域';
            } else {
              this.error = '请检查表单填写是否正确';
@@ -407,7 +457,7 @@
        });
      });
    },
    // èšç„¦åˆ°æ‰˜ç›˜è¾“入框
    focusTrayInput() {
      if (this.$refs.trayInput && this.$refs.trayInput.$el) {
        const inputEl = this.$refs.trayInput.$el.querySelector('input');
@@ -420,7 +470,6 @@
      }
    },
    // èšç„¦åˆ°ç‰©æ–™è¾“入框
    focusBarcodeInput() {
      if (this.$refs.barcodeInput && this.$refs.barcodeInput.$el) {
        const inputEl = this.$refs.barcodeInput.$el.querySelector('input');
@@ -432,8 +481,10 @@
        }
      }
    },
    // é‡ç½®æ‰€æœ‰æ•°æ®
    resetData() {
      this.palletGroupedBarcodes = {};
      this.isSubmitting = false;
      this.trayBarcode = '';
      this.barcode = '';
      this.materials = [];
@@ -455,10 +506,10 @@
      this.form = {
        warehouseType: null,
        locationType: null
      }
      };
      this.warehouseTypes = [];
      this.locationTypes = [];
      // æ¸…除表单验证状态
      this.$nextTick(() => {
        if (this.$refs.locationForm) {
          this.$refs.locationForm.clearValidate();
@@ -466,7 +517,6 @@
      });
    },
    // æ¸…除所有计时器
    clearAllTimers() {
      if (this.manualInputTimer) {
        clearTimeout(this.manualInputTimer);
@@ -477,121 +527,108 @@
        this.scanTimer = null;
      }
    },
    handleDialogClose() {
      this.show = false;
      this.resetData();
    },
    // ç¡®è®¤æŒ‰é’®
    async handleConfirm() {
      if (!await this.validateForm()) return;
    handleConfirm() {
      this.validateForm()
        .then(valid => {
          if (!valid) return;
          if (this.materials.length === 0) {
            this.$message.warning('请至少添加一个物料');
            return;
          }
      if (this.materials.length === 0) {
        this.$message.warning('请至少添加一个物料');
        return;
      }
          if (!this.trayBarcode) {
            this.$message.warning('请输入托盘条码');
            return;
          }
      if (!this.trayBarcode) {
        this.$message.warning('请输入托盘条码');
        return;
      }
          const result = {
            warehouseType: this.form.warehouseType,
            warehouseName: this.currentWarehouseName,
            locationType: this.form.locationType,
            locationDesc: this.currentLocationDesc,
            trayBarcode: this.trayBarcode,
            materials: this.materials,
            docNo: this.docNo
          };
      const result = {
        warehouseType: this.form.warehouseType,
        warehouseName: this.currentWarehouseName,
        locationType: this.form.locationType,
        locationDesc: this.currentLocationDesc,
        trayBarcode: this.trayBarcode,
        materials: this.materials,
        docNo: this.docNo
      };
      // è§¦å‘父组件的 back-success äº‹ä»¶
      this.$emit('back-success', result);
      this.palletVisible = false;
          this.$emit('back-success', result);
          this.palletVisible = false;
        });
    },
    // å¤„理托盘输入
    handleTrayInput() {
      // æ ‡è®°ä¸ºæ‰‹åŠ¨è¾“å…¥æ¨¡å¼
      this.isManualInput = true;
      this.isScanning = false;
      // æ¸…除之前的计时器
      if (this.manualInputTimer) {
        clearTimeout(this.manualInputTimer);
      }
      // è®¾ç½®è®¡æ—¶å™¨ï¼Œå¦‚果一段时间内没有输入,则重置为扫码模式
      this.manualInputTimer = setTimeout(() => {
        this.isManualInput = false;
      }, 1000);
    },
    // å¤„理物料输入
    handleBarcodeInput() {
      // æ ‡è®°ä¸ºæ‰‹åŠ¨è¾“å…¥æ¨¡å¼
      this.isManualInput = true;
      this.isScanning = false;
      // æ¸…除之前的计时器
      if (this.manualInputTimer) {
        clearTimeout(this.manualInputTimer);
      }
      // è®¾ç½®è®¡æ—¶å™¨ï¼Œå¦‚果一段时间内没有输入,则重置为扫码模式
      this.manualInputTimer = setTimeout(() => {
        this.isManualInput = false;
      }, 1000);
    },
    // å¤„理托盘条码提交
    async handleTraySubmit() {
      // å…ˆç›´æŽ¥æ£€æŸ¥locationType,避免表单验证的异步问题
    handleTraySubmit() {
      this.barcode = '';
      this.materials = [];
      this.error = '';
      if (!this.form.warehouseType) {
        this.error = '请先选择仓库';
        return;
      }
      if (!this.form.locationType) {
        this.error = '请先选择仓库区域';
        //this.$message.warning('请先选择仓库区域');
        return;
      }
      // ç„¶åŽå†è¿›è¡Œå®Œæ•´çš„表单验证
      if (!await this.validateForm()) return;
      this.validateForm()
        .then(valid => {
          if (!valid) return;
          const currentTrayBarcode = this.trayBarcode.trim();
      const currentTrayBarcode = this.trayBarcode.trim();
          if (!currentTrayBarcode) {
            this.error = '请输入或扫描托盘条码';
            return;
          }
      if (!currentTrayBarcode) {
        this.error = '请输入或扫描托盘条码';
        return;
      }
          this.error = '';
      this.error = '';
          if (!this.trayBarcodeReg.test(currentTrayBarcode)) {
            this.$message("托盘号格式错误");
            this.focusTrayInput();
            return;
          }
      if (!this.trayBarcodeReg.test(currentTrayBarcode)) {
        // ElMessage.warning({
        //   message: '托盘号格式错误',
        //   type: 'warning',
        //   duration: 3000
        // })
        this.$message("托盘号格式错误");
        this.focusTrayInput();
        return;
      }
      // è®¾ç½®æ‰˜ç›˜æ¡ç åŽï¼Œè‡ªåŠ¨èšç„¦åˆ°ç‰©æ–™è¾“å…¥æ¡†
      this.focusBarcodeInput();
      // this.$message({
      //   message: `托盘条码已设置: ${currentTrayBarcode}`,
      //   type: 'success',
      //   duration: 2000
      // });
      this.$message.success(`托盘条码已设置: ${currentTrayBarcode}`);
          this.focusBarcodeInput();
          this.$message.success(`托盘条码已设置: ${currentTrayBarcode}`);
        });
    },
    // æ¸…除托盘
    clearTray() {
      this.trayBarcode = '';
      this.materials = [];
@@ -603,12 +640,10 @@
      });
    },
    // æ¸…空托盘输入
    handleTrayClear() {
      this.error = '';
    },
    // æ¸…空输入
    handleClear() {
      this.error = '';
      this.scanCode = '';
@@ -616,123 +651,171 @@
      this.isScanning = false;
    },
    // å¤„理物料条码提交
    async handleBarcodeSubmit() {
      if (!await this.validateForm()) return;
    handleBarcodeSubmit() {
      if (this.isSubmitting) {
        this.$message.warning('正在处理中,请稍候');
        return;
      }
      const currentBarcode = this.barcode.trim();
      if (!this.trayBarcode) {
        this.error = '请先输入托盘条码';
        this.focusTrayInput();
        return;
      }
      if (!currentBarcode) {
        this.error = '请输入或扫描物料条码';
        return;
      }
      this.focusBarcodeInput();
      this.error = '';
      this.loading = true;
      try {
        // è°ƒç”¨API查询物料信息
        const materialData = await this.fetchMaterialData(currentBarcode);
        if (!materialData || materialData.length === 0) {
          return;
        }
        this.materials = [];
        materialData.forEach(item => {
          this.materials.push({
            ...item,
            trayCode: this.trayBarcode,
            locationType: this.form.locationType,
            locationDesc: this.currentLocationDesc,
            scanTime: this.formatTime(new Date())
          });
        });
        this.orderNo = materialData[0].orderNo;
        await this.fetchStockStatistics(materialData[0].orderNo);
        await this.fetchUnpalletMaterialDetails();
        // æ¸…空物料输入框并保持聚焦
      const currentTrayGrouped = this.palletGroupedBarcodes[this.trayBarcode] || [];
      if (currentTrayGrouped.includes(currentBarcode)) {
        this.error = `条码 ${currentBarcode} å·²è¢«å½“前托盘组盘,请勿重复操作`;
        this.barcode = '';
        this.scanCode = ''; // æ¸…空扫码缓存
        this.isScanning = false;
        setTimeout(() => {
          this.focusBarcodeInput();
        }, 100);
      } catch (err) {
        this.error = err.message || '查询条码信息失败,请重试';
        this.focusBarcodeInput();
        setTimeout(() => {
          // é€‰ä¸­è¾“入框内的错误内容(确保focus完成后执行)
          const inputEl = this.$refs.barcodeInput?.$el?.querySelector('input');
          if (inputEl) inputEl.select();
        }, 100);
      } finally {
        this.loading = false;
        return;
      }
      this.isSubmitting = true;
      this.validateForm()
        .then(valid => {
          if (!valid) {
            this.isSubmitting = false;
            return;
          }
          if (!this.trayBarcode) {
            this.error = '请先输入托盘条码';
            this.focusTrayInput();
            this.isSubmitting = false;
            return;
          }
          if (!currentBarcode) {
            this.error = '请输入或扫描物料条码';
            this.isSubmitting = false;
            return;
          }
          this.focusBarcodeInput();
          this.error = '';
          this.loading = true;
          console.log('组盘请求参数:', {
            palletCode: this.trayBarcode,
            barcode: currentBarcode,
            locationTypeDesc: this.currentLocationDesc,
            locationType: this.form.locationType,
            warehouseType: this.form.warehouseType
          });
          return this.fetchMaterialData(currentBarcode);
        })
        .then(materialData => {
          if (!materialData || materialData.length === 0) {
            return;
          }
          this.materials = [];
          const newBarcodes = [];
          materialData.forEach(item => {
            this.materials.push({
              ...item,
              trayCode: this.trayBarcode,
              locationType: this.form.locationType,
              locationDesc: this.currentLocationDesc,
              scanTime: this.formatTime(new Date())
            });
            newBarcodes.push(item.barcode);
          });
          if (!this.palletGroupedBarcodes[this.trayBarcode]) {
            this.palletGroupedBarcodes[this.trayBarcode] = [];
          }
          this.palletGroupedBarcodes[this.trayBarcode] = [...new Set([...this.palletGroupedBarcodes[this.trayBarcode], ...newBarcodes])];
          this.orderNo = materialData[0].orderNo;
          return Promise.all([
            this.fetchStockStatistics(materialData[0].orderNo),
            this.fetchUnpalletMaterialDetails()
          ]);
        })
        .then(() => {
          this.barcode = '';
          this.scanCode = '';
          this.isScanning = false;
          setTimeout(() => {
            this.focusBarcodeInput();
          }, 100);
        })
        .catch(err => {
          console.error('处理物料条码失败:', err);
          this.error = err.message || '查询条码信息失败,请重试';
          this.focusBarcodeInput();
          setTimeout(() => {
            const inputEl = this.$refs.barcodeInput?.$el?.querySelector('input');
            if (inputEl) inputEl.select();
          }, 100);
        })
        .finally(() => {
          this.loading = false;
          this.isSubmitting = false;
        });
    },
    // API请求 - æ›¿æ¢ä¸ºå®žé™…çš„API调用
    async fetchMaterialData(barcode) {
      try {
        const response = await http.post('/api/Inbound/AllGroupPallet',
          {
            palletCode: this.trayBarcode,
            barcode: barcode,
            locationTypeDesc: this.currentLocationDesc,
            locationType: this.form.locationType, // æ·»åŠ ä»“åº“åŒºåŸŸä¿¡æ¯
            warehouseType: this.form.warehouseType
    // API请求
    fetchMaterialData(barcode) {
      return http.post('/api/Inbound/AllGroupPallet', {
        palletCode: this.trayBarcode,
        barcode: barcode,
        locationTypeDesc: this.currentLocationDesc,
        locationType: this.form.locationType,
        warehouseType: this.form.warehouseType
      })
        .then(response => {
          let materialData;
          if (typeof response.data === 'string') {
            try {
              materialData = JSON.parse(response.data);
            } catch (e) {
              console.error('解析响应数据失败:', e);
            }
          } else {
            materialData = response.data;
          }
        );
        let materialData;
        if (typeof response.data === 'string') {
          try {
            materialData = JSON.parse(response.data);
          } catch (e) {
          if (!response.status) {
            this.error = response.message || '查询条码信息失败,请重试';
            return [];
          }
        } else {
          materialData = response.data;
        }
        if (!response.status) {
          this.error = response.message || '查询条码信息失败,请重试';
        }
        return materialData;
      } catch (error) {
        console.error('API调用失败:', error);
      }
          return materialData || [];
        })
        .catch(error => {
          console.error('API调用失败:', error);
          this.$message.error('接口请求失败,请联系管理员');
          throw error;
        });
    },
    // å¤„理扫码枪输入
    handleKeyPress(event) {
      // å¦‚果是手动输入模式,不处理扫码枪逻辑
      if (this.isManualInput) {
      if (this.isManualInput || this.isSubmitting) {
        return;
      }
      const key = event.key;
      const currentTime = new Date().getTime();
      // å¿½ç•¥ç›´æŽ¥æŒ‰ä¸‹çš„回车键(由handleBarcodeSubmit处理)
      if (key === 'Enter') {
        event.preventDefault();
        if (this.scanCode.length > 0) {
          // é˜»æ­¢é»˜è®¤å›žè½¦è¡Œä¸ºï¼Œé¿å…è¡¨å•提交
          event.preventDefault();
          if (this.scanTarget === 'material' && !this.trayBarcode) {
            this.$message.warning('请先设置托盘条码');
            this.scanCode = '';
            this.lastKeyTime = null;
            return;
          }
          // æ‰«ç å®Œæˆï¼Œè‡ªåŠ¨è§¦å‘æŸ¥è¯¢
          this.isScanning = false;
          // æ ¹æ®å½“前扫码目标设置相应的输入框值
          if (this.scanTarget === 'tray') {
            this.trayBarcode = this.scanCode;
            this.handleTraySubmit();
@@ -746,7 +829,6 @@
        return;
      }
      // æž„建扫码内容(快速连续输入视为扫码)
      if (this.lastKeyTime && currentTime - this.lastKeyTime < 50) {
        this.scanCode += key;
        this.isScanning = true;
@@ -755,7 +837,6 @@
        this.isScanning = true;
      }
      // è®¾ç½®è®¡æ—¶å™¨ï¼Œå¦‚果一段时间内没有输入,则重置扫描状态
      if (this.scanTimer) {
        clearTimeout(this.scanTimer);
      }
@@ -776,6 +857,23 @@
      const seconds = String(date.getSeconds()).padStart(2, '0');
      return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
    },
    // ä»“库切换事件
    handleWarehouseChange() {
      this.form.locationType = null;
      this.trayBarcode = '';
      this.barcode = '';
      this.materials = [];
      this.error = '';
    },
    // åŒºåŸŸåˆ‡æ¢äº‹ä»¶
    handleLocationChange() {
      this.trayBarcode = '';
      this.barcode = '';
      this.materials = [];
      this.error = '';
    }
  }
}