pan
2025-12-04 f692f869d5fe2e2aee9d3487dbba83e1821b7f6c
ÏîÄ¿´úÂë/WIDESEA_WMSClient/src/views/outbound/BatchPickingConfirm.vue
@@ -92,7 +92,7 @@
    </div>
    <!-- æ‹†åŒ…弹窗 -->
    <div  v-show="showCustomSplitDialog" class="custom-dialog-overlay">
    <div v-if="showCustomSplitDialog" class="custom-dialog-overlay" style="z-index: 2000;">
      <div class="custom-dialog-wrapper">
        <div class="custom-dialog">
          <div class="custom-dialog-header">
@@ -154,7 +154,7 @@
    </div>
    <!-- æ’¤é”€æ‹†åŒ…弹窗 -->
    <div  v-show="showRevertSplitDialog" class="custom-dialog-overlay">
    <div v-if="showRevertSplitDialog" class="custom-dialog-overlay"  style="z-index: 2001;">
      <div class="custom-dialog-wrapper">
        <div class="custom-dialog">
          <div class="custom-dialog-header">
@@ -214,7 +214,7 @@
    </div>
    <!-- æ‹†åŒ…链信息弹窗 -->
<div v-show="showSplitChainDialog" class="custom-dialog-overlay">
<div v-if="showSplitChainDialog" class="custom-dialog-overlay"  style="z-index: 2002;">
  <div class="custom-dialog-wrapper">
    <div class="custom-dialog" style="width: 750px;">
      <div class="custom-dialog-header">
@@ -338,7 +338,7 @@
</div>
    <!-- æ‰¹é‡å›žåº“弹窗 -->
    <div v-if="showBatchReturnDialog" class="custom-dialog-overlay">
    <div v-if="showBatchReturnDialog" class="custom-dialog-overlay"  style="z-index: 2003;">
      <div class="custom-dialog-wrapper">
        <div class="custom-dialog">
          <div class="custom-dialog-header">
@@ -370,7 +370,7 @@
    </div>
    <!-- å–走空箱弹窗 -->
    <div v-if="showEmptyPalletDialog" class="custom-dialog-overlay">
    <div v-if="showEmptyPalletDialog" class="custom-dialog-overlay"  style="z-index: 2004;">
      <div class="custom-dialog-wrapper">
        <div class="custom-dialog">
          <div class="custom-dialog-header">
@@ -405,11 +405,12 @@
  </div>
</template>
<script>
import http from '@/api/http.js'
import { ref, defineComponent } from "vue";
import { defineComponent } from "vue";
import { ElMessage } from 'element-plus' 
import { useRoute } from 'vue-router'
import printView from "@/extension/outbound/extend/printView.vue"
export default defineComponent({
@@ -417,6 +418,7 @@
  components: {printView},
  data() {
    return {
      // ä¿æŒæ‰€æœ‰åŽŸå§‹æ•°æ®ç»“æž„ä¸å˜...
      scanData: {
        orderNo: '',
        palletCode: '',
@@ -432,21 +434,24 @@
      },
      palletStatus: '未知',
      
      // å¼¹çª—状态
      // å¼¹çª—状态 - å…³é”®ä¿®å¤ï¼šåªå…è®¸ä¸€ä¸ªå¼¹çª—打开
      activeDialog: null, // 'split', 'revert', 'batchReturn', 'emptyPallet', 'splitChain'
      showCustomSplitDialog: false,
      showRevertSplitDialog: false,
      showBatchReturnDialog: false,
      showEmptyPalletDialog: false,
      showSplitChainDialog: false, // æ–°å¢žï¼šæ‹†åŒ…链信息弹窗
      showSplitChainDialog: false,
      
        // æ·»åŠ é˜²é‡å¤ç‚¹å‡»æ ‡å¿—
      isOpeningDialog: false,
      // åŠ è½½çŠ¶æ€
      splitLoading: false,
      revertSplitLoading: false,
      batchReturnLoading: false,
      emptypalletOutLoading: false,
      splitChainLoading: false, // æ–°å¢žï¼šæ‹†åŒ…链加载状态
      splitChainLoading: false,
      
      // è¡¨å•数据
      // è¡¨å•数据...
      splitForm: {
        orderNo: '',
        palletCode: '',
@@ -472,14 +477,13 @@
        palletCode: ''
      },
      
      // æ–°å¢žï¼šæ‹†åŒ…链相关数据
      splitChainInfo: {
        originalBarcode: '',
        totalSplitTimes: 0,
        splitChain: []
      },
      
      // éªŒè¯è§„则
      // éªŒè¯è§„则...
      splitFormRules: {
        originalBarcode: [
          { required: true, message: '请输入原条码', trigger: 'blur' }
@@ -501,88 +505,21 @@
          { required: true, message: '请输入托盘码', trigger: 'blur' }
        ]
      },
       // å¼¹çª—状态 - æ”¹ä¸ºä½¿ç”¨å¯¹è±¡ç®¡ç†ï¼Œé¿å…åŒæ—¶æ‰“开多个弹窗
      dialogs: {
        customSplit: false,
        revertSplit: false,
        splitChain: false,
        batchReturn: false,
        emptyPallet: false
      },
      
      // åŠ è½½çŠ¶æ€
      loading: {
        split: false,
        revertSplit: false,
        batchReturn: false,
        emptyPallet: false,
        splitChain: false
      },
      // å½“前活动的弹窗类型
      activeDialog: null,
      isProcessing: false
    }
  },
  watch: {
    // å…³é”®ä¿®å¤ï¼šç¡®ä¿åŒä¸€æ—¶é—´åªæœ‰ä¸€ä¸ªå¼¹çª—打开
    activeDialog(newVal, oldVal) {
      this.showCustomSplitDialog = newVal === 'split'
      this.showRevertSplitDialog = newVal === 'revert'
      this.showBatchReturnDialog = newVal === 'batchReturn'
      this.showEmptyPalletDialog = newVal === 'emptyPallet'
      this.showSplitChainDialog = newVal === 'splitChain'
    }
  },
  computed: {
     // è®¡ç®—属性映射到dialogs对象
    showCustomSplitDialog: {
      get() { return this.dialogs.customSplit; },
      set(val) {
        this.dialogs.customSplit = val;
        this.activeDialog = val ? 'customSplit' : null;
      }
    },
    showRevertSplitDialog: {
      get() { return this.dialogs.revertSplit; },
      set(val) {
        this.dialogs.revertSplit = val;
        this.activeDialog = val ? 'revertSplit' : null;
      }
    },
    showSplitChainDialog: {
      get() { return this.dialogs.splitChain; },
      set(val) {
        this.dialogs.splitChain = val;
        this.activeDialog = val ? 'splitChain' : null;
      }
    },
    showBatchReturnDialog: {
      get() { return this.dialogs.batchReturn; },
      set(val) {
        this.dialogs.batchReturn = val;
        this.activeDialog = val ? 'batchReturn' : null;
      }
    },
    showEmptyPalletDialog: {
      get() { return this.dialogs.emptyPallet; },
      set(val) {
        this.dialogs.emptyPallet = val;
        this.activeDialog = val ? 'emptyPallet' : null;
      },
    },
     // åŠ è½½çŠ¶æ€æ˜ å°„
    splitLoading: {
      get() { return this.loading.split; },
      set(val) { this.loading.split = val; }
    },
    revertSplitLoading: {
      get() { return this.loading.revertSplit; },
      set(val) { this.loading.revertSplit = val; }
    },
    batchReturnLoading: {
      get() { return this.loading.batchReturn; },
      set(val) { this.loading.batchReturn = val; }
    },
    emptypalletOutLoading: {
      get() { return this.loading.emptyPallet; },
      set(val) { this.loading.emptyPallet = val; }
    },
    splitChainLoading: {
      get() { return this.loading.splitChain; },
      set(val) { this.loading.splitChain = val; }
    },
    // æ˜¯å¦å¯ä»¥å–消整个拆包链
    canCancelWholeChain() {
      return this.splitChainInfo.splitChain && 
             this.splitChainInfo.splitChain.some(item => !item.isReverted);
@@ -595,9 +532,13 @@
      this.batchReturnForm.orderNo = this.$route.query.orderNo;
      this.emptypalletOutForm.orderNo = this.$route.query.orderNo;
    }
    this.$nextTick(() => {
      this.$refs.palletInput.focus();
    // ä½¿ç”¨ requestAnimationFrame ç¡®ä¿é¡µé¢å®Œå…¨åŠ è½½
    requestAnimationFrame(() => {
      if (this.$refs.palletInput) {
        this.$refs.palletInput.focus();
      }
    });
  },
  methods: {
    goBack(){
@@ -644,29 +585,77 @@
      }
    },
    // æ‹†åŒ…相关方法
    openSplitDialog() {
   openSplitDialog() {
      console.log('开始打开拆包弹窗');
      if (this.isOpeningDialog) {
        console.log('正在打开弹窗,跳过');
        return;
      }
      if (!this.scanData.palletCode) {
        this.$message.warning('请先扫描托盘码');
        return;
      }
         // å…³é—­å…¶ä»–所有弹窗
      this.closeAllDialogs();
        // å»¶è¿Ÿæ‰“开新弹窗,确保其他弹窗完全关闭
      this.$nextTick(() => {
        this.showCustomSplitDialog = true;
        this.resetSplitForm();
        this.splitForm.orderNo = this.scanData.orderNo;
        this.splitForm.palletCode = this.scanData.palletCode;
      this.isOpeningDialog = true;
      try {
        // æ–¹æ³•1: ä½¿ç”¨ setTimeout ç¡®ä¿å¼‚步执行
        setTimeout(() => {
          console.log('执行弹窗打开逻辑');
          // å…ˆå…³é—­æ‰€æœ‰å¼¹çª—
          this.closeAllDialogsImmediately();
          // ä½¿ç”¨ requestAnimationFrame ç¡®ä¿åœ¨ä¸‹ä¸€å¸§æ‰“å¼€
          requestAnimationFrame(() => {
            console.log('设置弹窗状态为 true');
            // é‡ç½®è¡¨å•
            this.resetSplitForm();
            this.splitForm.orderNo = this.scanData.orderNo;
            this.splitForm.palletCode = this.scanData.palletCode;
            // å…³é”®ï¼šç›´æŽ¥è®¾ç½®å¼¹çª—状态
            this.showCustomSplitDialog = true;
            console.log('弹窗状态已设置,等待DOM更新');
            // ä½¿ç”¨ nextTick ç¡®ä¿DOM更新完成
            this.$nextTick(() => {
              console.log('DOM更新完成,弹窗应该显示了');
              this.isOpeningDialog = false;
              // å°è¯•聚焦到输入框
              setTimeout(() => {
                const input = this.$refs.splitFormRef?.$el?.querySelector('input');
                if (input) {
                  input.focus();
                  console.log('输入框已聚焦');
                }
              }, 100);
            });
          });
        }, 0);
        
        // ç¡®ä¿è¾“入框获得焦点
        this.$nextTick(() => {
          const inputs = document.querySelectorAll('.custom-dialog input');
          if (inputs.length > 0) {
            inputs[0].focus();
          }
        });
      });
      } catch (error) {
        console.error('打开拆包弹窗出错:', error);
        this.isOpeningDialog = false;
      }
    },
      closeAllDialogsImmediately() {
      console.log('立即关闭所有弹窗');
      // ç›´æŽ¥è®¾ç½®ä¸º false,不等待任何异步操作
      this.showCustomSplitDialog = false;
      this.showRevertSplitDialog = false;
      this.showBatchReturnDialog = false;
      this.showEmptyPalletDialog = false;
      this.showSplitChainDialog = false;
      // å¼ºåˆ¶DOM更新
      this.$forceUpdate();
    },
    async onSplitBarcodeScan() {
@@ -697,103 +686,104 @@
    async handleSplitPackage() {
      if (this.$refs.splitFormRef) {
        const valid = await this.$refs.splitFormRef.validate();
        if (!valid) return;
        this.splitLoading = true;
        try {
          const res = await http.post('/api/OutboundBatchPicking/split-package', {
            orderNo: this.splitForm.orderNo,
            palletCode: this.splitForm.palletCode,
            originalBarcode: this.splitForm.originalBarcode,
            splitQuantity: this.splitForm.splitQuantity
          });
          if (res.status) {
            this.$message.success('拆包成功');
            this.showCustomSplitDialog = false;
            await this.loadPalletData();
          } else {
            this.$message.error(res.message || '拆包失败');
        this.$refs.splitFormRef.validate(async (valid) => {
          if (valid) {
            this.splitLoading = true;
            try {
              const res = await http.post('/api/OutboundBatchPicking/split-package', {
                orderNo: this.splitForm.orderNo,
                palletCode: this.splitForm.palletCode,
                originalBarcode: this.splitForm.originalBarcode,
                splitQuantity: this.splitForm.splitQuantity
              });
              if (res.status) {
                this.$message.success('拆包成功');
                this.closeAllDialogs();
                await this.loadPalletData();
              } else {
                this.$message.error(res.message || '拆包失败');
              }
            } catch (error) {
              this.$message.error('拆包失败');
            } finally {
              this.splitLoading = false;
            }
          }
        } catch (error) {
          this.$message.error('拆包失败: ' + (error.message || '网络错误'));
        } finally {
          this.splitLoading = false;
        }
        });
      }
    },
// åœ¨æ‹†åŒ…弹窗中查看拆包链
async viewSplitChainFromSplit(barcode) {
  if (!barcode) {
    this.$message.warning('请先输入条码');
    return;
  }
  // å…ˆå…³é—­æ‹†åŒ…弹窗
  this.closeCustomSplitDialog();
  await this.$nextTick();
  // ç„¶åŽæ‰“开拆包链信息弹窗
  await this.viewSplitChain(barcode);
},
    async viewSplitChainFromSplit(barcode) {
      if (!barcode) {
        this.$message.warning('请先输入条码');
        return;
      }
      this.closeAllDialogs();
      setTimeout(() => {
        this.viewSplitChain(barcode);
      }, 50);
    },
    // æ’¤é”€æ‹†åŒ…
    async onRevertSplitBarcodeScan() {
        if (!this.revertSplitForm.newBarcode) return;
      if (!this.revertSplitForm.newBarcode) return;
      this.revertSplitForm.newBarcode = this.revertSplitForm.newBarcode.replace(/\n/g, '').trim();
    },
    async handleRevertSplit() {
       if (this.$refs.revertSplitFormRef) {
        const valid = await this.$refs.revertSplitFormRef.validate();
        if (!valid) return;
        this.revertSplitLoading = true;
        try {
          const res = await http.post('/api/OutboundBatchPicking/cancel-split', {
            orderNo: this.scanData.orderNo,
            palletCode: this.scanData.palletCode,
            newBarcode: this.revertSplitForm.newBarcode
          });
          if (res.status) {
            this.$message.success('撤销拆包成功');
            this.showRevertSplitDialog = false;
            await this.loadPalletData();
          } else {
            this.$message.error(res.message || '撤销拆包失败');
      if (this.$refs.revertSplitFormRef) {
        this.$refs.revertSplitFormRef.validate(async (valid) => {
          if (valid) {
            this.revertSplitLoading = true;
            try {
              const res = await http.post('/api/OutboundBatchPicking/cancel-split', {
                orderNo: this.scanData.orderNo,
                palletCode: this.scanData.palletCode,
                newBarcode: this.revertSplitForm.newBarcode
              });
              if (res.status) {
                this.$message.success('撤销拆包成功');
                this.closeAllDialogs();
                await this.loadPalletData();
              } else {
                this.$message.error(res.message || '撤销拆包失败');
              }
            } catch (error) {
              this.$message.error('撤销拆包失败');
            } finally {
              this.revertSplitLoading = false;
            }
          }
        } catch (error) {
          this.$message.error('撤销拆包失败: ' + (error.message || '网络错误'));
        } finally {
          this.revertSplitLoading = false;
        }
        });
      }
    },
// æŸ¥æ‰¾å®Œæ•´æ‹†åŒ…链(从根条码开始)
async findRootChain(currentBarcode) {
  this.splitChainLoading = true;
  try {
    const res = await http.post('/api/OutboundBatchPicking/find-root-split-chain', {
      orderNo: this.scanData.orderNo,
      barcode: currentBarcode
    });
    if (res.status) {
      this.splitChainInfo = res.data;
      this.$message.success('已加载完整拆包链');
    } else {
      this.$message.error(res.message || '查找完整拆包链失败');
    }
  } catch (error) {
    this.$message.error('查找完整拆包链失败');
  } finally {
    this.splitChainLoading = false;
  }
},
    // æ‹†åŒ…链相关方法
   // æŸ¥çœ‹æ‹†åŒ…链信息
async viewSplitChain(barcode) {
   if (!barcode) {
    async findRootChain(currentBarcode) {
      this.splitChainLoading = true;
      try {
        const res = await http.post('/api/OutboundBatchPicking/find-root-split-chain', {
          orderNo: this.scanData.orderNo,
          barcode: currentBarcode
        });
        if (res.status) {
          this.splitChainInfo = res.data;
          this.$message.success('已加载完整拆包链');
        } else {
          this.$message.error(res.message || '查找完整拆包链失败');
        }
      } catch (error) {
        this.$message.error('查找完整拆包链失败');
      } finally {
        this.splitChainLoading = false;
      }
    },
    // æŸ¥çœ‹æ‹†åŒ…链信息
    async viewSplitChain(barcode) {
      if (!barcode) {
        this.$message.warning('请先输入条码');
        return;
      }
@@ -807,86 +797,34 @@
        
        if (res.status) {
          this.splitChainInfo = res.data;
          // å…³é—­å…¶ä»–弹窗后再打开拆包链弹窗
          this.closeAllDialogs();
          await this.$nextTick(() => {
            this.showSplitChainDialog = true;
            // æ˜¾ç¤ºæç¤ºä¿¡æ¯
            let chainType = "当前条码的拆包链";
            if (this.splitChainInfo.chainType === 'root') {
              chainType = "完整拆包链(从原始条码开始)";
            } else if (this.splitChainInfo.chainType === 'branch') {
              chainType = "分支拆包链";
            }
            this.$message.info(`已加载${chainType},共${this.splitChainInfo.totalSplitTimes}次拆包`);
          });
          this.activeDialog = 'splitChain';
        } else {
          this.$message.error(res.message || '获取拆包链信息失败');
        }
      } catch (error) {
        this.$message.error('获取拆包链信息失败: ' + (error.message || '网络错误'));
        this.$message.error('获取拆包链信息失败');
      } finally {
        this.splitChainLoading = false;
      }
},
    },
    // å…³é—­æ‹†åŒ…链信息弹窗
    closeSplitChainDialog() {
     closeSplitChainDialog() {
      this.showSplitChainDialog = false;
    },
    // åœ¨æ’¤é”€æ‹†åŒ…弹窗中查看拆包链
async viewSplitChainFromRevert(barcode) {
  if (!barcode) {
    this.$message.warning('请先输入条码');
    return;
  }
  // å…ˆå…³é—­æ’¤é”€æ‹†åŒ…弹窗
  this.closeRevertSplitDialog();
  await this.$nextTick();
  // ç„¶åŽæ‰“开拆包链信息弹窗
  await this.viewSplitChain(barcode);
},
// å¿«é€Ÿé‡æ–°æ‰“开拆包链弹窗
async quickReopenSplitChainDialog(barcode) {
  if (!barcode) return;
  this.showSplitChainDialog = true;
  this.splitChainLoading = true;
  try {
    const res = await http.post('/api/OutboundBatchPicking/split-package-chain-info', {
      orderNo: this.scanData.orderNo,
      barcode: barcode
    });
    if (res.status) {
      this.splitChainInfo = res.data;
    }
  } catch (error) {
    console.error('重新加载拆包链信息失败:', error);
  } finally {
    this.splitChainLoading = false;
  }
},
    // å–消单个拆包记录
async cancelSingleSplit(newBarcode) {
   try {
        await ElMessageBox.confirm(
    async cancelSingleSplit(newBarcode) {
      const originalBarcode = this.splitChainInfo.originalBarcode;
      try {
        await this.$confirm(
          `确定要取消条码 ${newBarcode} çš„æ‹†åŒ…操作吗?`, 
          '取消单个拆包', 
          {
            confirmButtonText: '确定取消',
            cancelButtonText: '再想想',
            type: 'warning',
            customClass: 'message-box-top'
            type: 'warning'
          }
        );
        
@@ -901,29 +839,26 @@
        if (res.status) {
          this.$message.success('取消拆包成功');
          await this.loadPalletData();
          // é‡æ–°åŠ è½½æ‹†åŒ…é“¾ä¿¡æ¯
          if (this.splitChainInfo.originalBarcode) {
            await this.viewSplitChain(this.splitChainInfo.originalBarcode);
          }
          this.closeAllDialogs();
          setTimeout(() => {
            this.viewSplitChain(originalBarcode);
          }, 50);
        } else {
          this.$message.error(res.message || '取消拆包失败');
        }
      } catch (error) {
        if (error !== 'cancel') {
          this.$message.error('取消拆包失败: ' + error.message);
          this.$message.error('取消拆包失败');
        }
      } finally {
        this.revertSplitLoading = false;
      }
},
    },
// å–消整个拆包链
async cancelWholeSplitChain() {
  if (!this.canCancelWholeChain) return;
    // å–消整个拆包链
    async cancelWholeSplitChain() {
      try {
        await ElMessageBox.confirm(
        await this.$confirm(
          `确定要取消整个拆包链吗?\n这将取消从条码 ${this.splitChainInfo.originalBarcode} å¼€å§‹çš„æ‰€æœ‰æ‹†åŒ…操作。`, 
          '取消拆包链确认', 
          {
@@ -931,8 +866,7 @@
            cancelButtonText: '再想想',
            type: 'warning',
            center: true,
            closeOnClickModal: false,
            customClass: 'message-box-top'
            closeOnClickModal: false
          }
        );
        
@@ -946,7 +880,7 @@
        
        if (res.status) {
          this.$message.success('取消拆包链成功');
          this.closeSplitChainDialog();
          this.closeAllDialogs();
          await this.loadPalletData();
        } else {
          this.$message.error(res.message || '取消拆包链失败');
@@ -958,7 +892,7 @@
      } finally {
        this.revertSplitLoading = false;
      }
},
    },
    // æ£€æŸ¥æ¡ç æ˜¯å¦å·²è¢«åˆ†æ‹£
    hasPicked(barcode) {
@@ -971,31 +905,44 @@
      const date = new Date(dateTime);
      return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')} ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}`;
    },
 closeAllDialogs() {
    // å…³é”®ä¿®å¤ï¼šæ–°å¢žå…³é—­æ‰€æœ‰å¼¹çª—的方法
    closeAllDialogs() {
      this.activeDialog = null;
      // ç¡®ä¿æ‰€æœ‰å¼¹çª—状态都被重置
      this.showCustomSplitDialog = false;
      this.showRevertSplitDialog = false;
      this.showSplitChainDialog = false;
      this.showBatchReturnDialog = false;
      this.showEmptyPalletDialog = false;
      this.activeDialog = null;
      this.showSplitChainDialog = false;
    },
    // å›žåº“相关方法
    openBatchReturnDialog() {
     if (!this.scanData.palletCode) {
      if (!this.scanData.palletCode) {
        this.$message.warning('请先扫描托盘码');
        return;
      }
      
      // å…³é—­å…¶ä»–弹窗
      this.closeAllDialogs();
      if (this.isOpeningDialog) return;
      
      this.$nextTick(() => {
        this.showBatchReturnDialog = true;
        this.batchReturnForm.orderNo = this.scanData.orderNo;
        this.batchReturnForm.palletCode = this.scanData.palletCode;
        this.batchReturnForm.unpickedCount = this.summary.unpickedCount;
        this.batchReturnForm.unpickedQuantity = this.summary.unpickedQuantity;
      });
      this.isOpeningDialog = true;
      setTimeout(() => {
        this.closeAllDialogsImmediately();
        requestAnimationFrame(() => {
          this.showBatchReturnDialog = true;
          this.batchReturnForm.orderNo = this.scanData.orderNo;
          this.batchReturnForm.palletCode = this.scanData.palletCode;
          this.batchReturnForm.unpickedCount = this.summary.unpickedCount;
          this.batchReturnForm.unpickedQuantity = this.summary.unpickedQuantity;
          this.$nextTick(() => {
            this.isOpeningDialog = false;
          });
        });
      }, 0);
    },
    async handleBatchReturnConfirm() {
@@ -1007,28 +954,37 @@
        });
        if (res.status) {
          this.$message.success('回库成功');
          this.showBatchReturnDialog = false;
          this.closeAllDialogs();
          await this.loadPalletData();
        } else {
          this.$message.error(res.message || '回库失败');
        }
      } catch (error) {
        this.$message.error('回库失败: ' + (error.message || '网络错误'));
        this.$message.error('回库失败');
      } finally {
        this.batchReturnLoading = false;
      }
    },
    // å–空箱方法
    handleEmptyPallet() {
      // å…³é—­å…¶ä»–弹窗
      this.closeAllDialogs();
handleEmptyPallet() {
      if (this.isOpeningDialog) return;
      
      this.$nextTick(() => {
        this.showEmptyPalletDialog = true;
        this.emptypalletOutForm.orderNo = this.scanData.orderNo;
        this.emptypalletOutForm.palletCode = '';
      });
      this.isOpeningDialog = true;
      setTimeout(() => {
        this.closeAllDialogsImmediately();
        requestAnimationFrame(() => {
          this.showEmptyPalletDialog = true;
          this.emptypalletOutForm.orderNo = this.scanData.orderNo;
          this.emptypalletOutForm.palletCode = '';
          this.$nextTick(() => {
            this.isOpeningDialog = false;
          });
        });
      }, 0);
    },
    async handleEmptyPalletConfirm() {
@@ -1040,13 +996,13 @@
        });
        if (res.status) {
          this.$message.success('取走空箱成功');
          this.showEmptyPalletDialog = false;
          this.closeAllDialogs();
          await this.loadPalletData();
        } else {
          this.$message.error(res.message || '取走空箱失败');
        }
      } catch (error) {
        this.$message.error('取走空箱失败: ' + (error.message || '网络错误'));
        this.$message.error('取走空箱失败');
      } finally {
        this.emptypalletOutLoading = false;
      }
@@ -1054,21 +1010,19 @@
    // æ•°æ®åŠ è½½æ–¹æ³•
    async loadPalletData() {
       if (!this.scanData.orderNo || !this.scanData.palletCode) return;
      if (!this.scanData.orderNo || !this.scanData.palletCode) return;
      
      try {
        await Promise.all([
          this.loadUnpickedList(),
          this.loadPickedList(),
          this.loadPalletStatus()
        ]);
        await this.loadUnpickedList();
        await this.loadPickedList();
        await this.loadPalletStatus();
      } catch (error) {
        console.error('加载托盘数据失败:', error);
      }
    },
    async loadUnpickedList() {
       try {
      try {
        const res = await http.post('/api/OutboundBatchPicking/pallet-locks', {
          orderNo: this.scanData.orderNo,
          palletCode: this.scanData.palletCode
@@ -1079,7 +1033,6 @@
          this.summary.unpickedQuantity = this.unpickedList.reduce((sum, item) => sum + (item.remainQuantity || 0), 0);
        }
      } catch (error) {
        console.error('加载未拣选列表失败:', error);
        this.$message.error('加载未拣选列表失败');
      }
    },
@@ -1098,13 +1051,12 @@
          this.summary.pickedCount = this.pickedList.length;
        }
      } catch (error) {
        console.error('加载已拣选列表失败:', error);
        this.$message.error('加载已拣选列表失败');
      }
    },
    async loadPalletStatus() {
          try {
      try {
        const res = await http.post('/api/OutboundBatchPicking/pallet-status', {
          orderNo: this.scanData.orderNo,
          palletCode: this.scanData.palletCode
@@ -1113,14 +1065,13 @@
          this.palletStatus = res.data.statusText || '未知';
        }
      } catch (error) {
        console.error('加载托盘状态失败:', error);
        this.palletStatus = '未知';
      }
    },
    // æ‰«ç ç›¸å…³æ–¹æ³•
    onPalletScan() {
       this.scanData.palletCode = this.scanData.palletCode.replace(/\n/g, '').trim();
      this.scanData.palletCode = this.scanData.palletCode.replace(/\n/g, '').trim();
      if (!this.scanData.palletCode) return;
      
      this.loadPalletData();
@@ -1130,7 +1081,7 @@
    },
    onBarcodeScan() {
       this.scanData.barcode = this.scanData.barcode.replace(/\n/g, '').trim();
      this.scanData.barcode = this.scanData.barcode.replace(/\n/g, '').trim();
      if (!this.scanData.barcode) return;
      this.confirmPicking();
    },
@@ -1158,40 +1109,33 @@
        return;
      }
      try {
        await ElMessageBox.confirm(
          `确定要取消选中的 ${this.selectedPickedRows.length} é¡¹å—?`,
          '提示',
          {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
            customClass: 'message-box-top'
          }
        );
        for (const row of this.selectedPickedRows) {
          try {
            const res = await http.post('/api/OutboundBatchPicking/cancel-picking', {
              orderNo: this.scanData.orderNo,
              palletCode: this.scanData.palletCode,
              barcode: row.currentBarcode
            });
            if (!res.status) {
              this.$message.warning(`取消拣选失败: ${row.currentBarcode} - ${res.message}`);
      this.$confirm(`确定要取消选中的 ${this.selectedPickedRows.length} é¡¹å—?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        try {
          for (const row of this.selectedPickedRows) {
            try {
              const res = await http.post('/api/OutboundBatchPicking/cancel-picking', {
                orderNo: this.scanData.orderNo,
                palletCode: this.scanData.palletCode,
                barcode: row.currentBarcode
              });
              if (!res.status) {
                this.$message.warning(`取消拣选失败: ${row.currentBarcode} - ${res.message}`);
              }
            } catch (error) {
              this.$message.warning(`取消拣选失败: ${row.currentBarcode} - ${error.message}`);
            }
          } catch (error) {
            this.$message.warning(`取消拣选失败: ${row.currentBarcode} - ${error.message}`);
          }
        }
        this.$message.success('批量取消完成');
        await this.loadPalletData();
        this.selectedPickedRows = [];
      } catch (error) {
        if (error !== 'cancel') {
          }
          this.$message.success('批量取消完成');
          await this.loadPalletData();
          this.selectedPickedRows = [];
        } catch (error) {
          this.$message.error('批量取消操作失败');
        }
      }
      });
    },
    // é‡ç½®æ–¹æ³•
@@ -1207,22 +1151,31 @@
      this.resetSplitForm();
    },
    openRevertSplitDialog() {
       // å…³é—­å…¶ä»–弹窗
      this.closeAllDialogs();
openRevertSplitDialog() {
      if (this.isOpeningDialog) return;
      
      this.$nextTick(() => {
        this.showRevertSplitDialog = true;
        this.revertSplitForm.newBarcode = '';
      });
      this.isOpeningDialog = true;
      setTimeout(() => {
        this.closeAllDialogsImmediately();
        requestAnimationFrame(() => {
          this.showRevertSplitDialog = true;
          this.revertSplitForm.newBarcode = '';
          this.$nextTick(() => {
            this.isOpeningDialog = false;
          });
        });
      }, 0);
    },
    closeRevertSplitDialog() {
  closeRevertSplitDialog() {
      this.showRevertSplitDialog = false;
      this.revertSplitForm.newBarcode = '';
    },
    closeBatchReturnDialog() {
 closeBatchReturnDialog() {
      this.showBatchReturnDialog = false;
    },
@@ -1231,7 +1184,7 @@
      this.emptypalletOutForm.palletCode = this.emptypalletOutForm.palletCode.replace(/\n/g, '').trim();
    },
    closeEmptyPalletDialog() {
     closeEmptyPalletDialog() {
      this.showEmptyPalletDialog = false;
      this.emptypalletOutForm.palletCode = '';
    },
@@ -1278,24 +1231,7 @@
  color: #909399;
}
/* è‡ªå®šä¹‰å¼¹çª—样式 */
:deep(.el-message-box) {
  z-index: 9999 !important;
}
:deep(.el-overlay) {
  z-index: 9998 !important;
}
:deep(.el-message) {
  z-index: 10000 !important;
}
/* ç¡®ä¿ç¡®è®¤å¯¹è¯æ¡†åœ¨æœ€å‰é¢ */
:deep(.message-box-top) {
  z-index: 10001 !important;
}
/* è‡ªå®šä¹‰å¼¹çª—样式 - å…³é”®ä¿®å¤ */
.custom-dialog-overlay {
  position: fixed;
  top: 0;
@@ -1306,12 +1242,12 @@
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  z-index: 9999; /* æé«˜z-index确保在最上层 */
}
.custom-dialog-wrapper {
  position: relative;
  z-index: 2001;
  z-index: 10000;
}
.custom-dialog {