heshaofeng
9 天以前 e57b06871c0a0276a308592f7906678e8be4dbe4
ÏîÄ¿´úÂë/WIDESEA_WMSClient/src/views/outbound/BatchPickingConfirm.vue
@@ -27,8 +27,8 @@
            @keyup.enter.native="onBarcodeScan">
          </el-input>
          <el-button type="success" @click="confirmPicking">确认拣选</el-button>
          <el-button type="warning" @click="openSplitDialog">拆包</el-button>
          <el-button type="info" @click="openRevertSplitDialog">撤销拆包</el-button>
          <!-- <el-button type="warning" @click="openSplitDialog">拆包</el-button>
          <el-button type="info" @click="openRevertSplitDialog">撤销拆包</el-button> -->
          <el-button type="info" @click="handleEmptyPallet">取空箱</el-button>
          <el-button type="primary" @click="openBatchReturnDialog">回库</el-button>
        </div>
@@ -83,7 +83,7 @@
              <el-table-column type="selection" width="55"></el-table-column>
              <el-table-column prop="materielCode" label="物料编码" width="120"></el-table-column>
              <el-table-column prop="pickedQty" label="已拣数量" width="100"></el-table-column>
              <el-table-column prop="locationCode" label="货位" width="100"></el-table-column>
              <!-- <el-table-column prop="locationCode" label="货位" width="100"></el-table-column> -->
              <el-table-column prop="currentBarcode" label="条码"></el-table-column>
            </el-table>
          </el-card>
@@ -92,7 +92,7 @@
    </div>
    <!-- æ‹†åŒ…弹窗 -->
    <div v-if="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-if="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-if="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' }
@@ -505,8 +509,17 @@
      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: {
    // æ˜¯å¦å¯ä»¥å–消整个拆包链
    canCancelWholeChain() {
      return this.splitChainInfo.splitChain && 
             this.splitChainInfo.splitChain.some(item => !item.isReverted);
@@ -519,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(){
@@ -550,8 +567,8 @@
          this.$message.success('拣选确认成功');
          this.scanData.barcode = '';
          await this.loadPalletData();
          if(res.data && res.data.splitResults && res.data.splitResults.length>0){
            this.$refs.childs.open(res.data.splitResults);
          if(res.data && res.data && res.data.length>0){
            this.$refs.childs.open(res.data);
          }
          this.$nextTick(() => {
            this.$refs.barcodeInput.focus();
@@ -568,16 +585,445 @@
      }
    },
    // æ‹†åŒ…相关方法
    openSplitDialog() {
   openSplitDialog() {
      console.log('紧急修复版:打开拆包弹窗');
      if (!this.scanData.palletCode) {
        this.$message.warning('请先扫描托盘码');
        return;
      }
      this.showCustomSplitDialog = true;
      this.resetSplitForm();
      this.splitForm.orderNo = this.scanData.orderNo;
      this.splitForm.palletCode = this.scanData.palletCode;
      // 1. å…³é—­æ‰€æœ‰Vue弹窗
      this.closeAllDialogs();
      // 2. å¼ºåˆ¶ä»ŽDOM中移除所有弹窗
      setTimeout(() => {
        const dialogs = document.querySelectorAll('.custom-dialog-overlay');
        dialogs.forEach(dialog => {
          if (dialog.parentNode) {
            dialog.parentNode.removeChild(dialog);
          }
        });
        // å¦‚果已经存在手动弹窗,先移除
        if (this.manualDialog && this.manualDialog.parentNode) {
          this.manualDialog.parentNode.removeChild(this.manualDialog);
        }
        // 3. ç­‰å¾…一帧
        requestAnimationFrame(() => {
          // 4. ç›´æŽ¥åˆ›å»ºæ–°å¼¹çª—,不依赖Vue的响应式系统
          this.createManualSplitDialog();
        });
      }, 10);
    },
    // åˆ›å»ºæ‰‹åŠ¨æ‹†åŒ…å¼¹çª—
    createManualSplitDialog() {
      const newDialog = document.createElement('div');
      newDialog.className = 'custom-dialog-overlay emergency-fix';
      // ç”ŸæˆéšæœºID用于事件绑定
      const dialogId = 'manual-dialog-' + Date.now();
      newDialog.id = dialogId;
      // å­˜å‚¨å¼•用
      this.manualDialog = newDialog;
      // å¼¹çª—内容
      newDialog.innerHTML = `
        <div class="custom-dialog-wrapper">
          <div class="custom-dialog" style="width: 500px;">
            <div class="custom-dialog-header">
              <h3 style="margin: 0; color: #303133;">拆包操作</h3>
              <button class="close-button" onclick="document.getElementById('${dialogId}').remove()" style="
                font-size: 18px;
                color: #909399;
                padding: 0;
                width: 24px;
                height: 24px;
                display: flex;
                align-items: center;
                justify-content: center;
                background: none;
                border: none;
                cursor: pointer;
              ">×</button>
            </div>
            <div class="custom-dialog-body" style="padding: 20px;">
              <div style="margin-bottom: 15px;">
                <div style="display: flex; align-items: center; margin-bottom: 5px;">
                  <span style="width: 100px; text-align: right; padding-right: 12px; color: #606266;">订单编号:</span>
                  <input type="text" value="${this.scanData.orderNo}" disabled style="
                    flex: 1;
                    padding: 8px 12px;
                    border: 1px solid #dcdfe6;
                    border-radius: 4px;
                    background-color: #f5f7fa;
                    color: #909399;
                  ">
                </div>
              </div>
              <div style="margin-bottom: 15px;">
                <div style="display: flex; align-items: center; margin-bottom: 5px;">
                  <span style="width: 100px; text-align: right; padding-right: 12px; color: #606266;">托盘编号:</span>
                  <input type="text" value="${this.scanData.palletCode}" disabled style="
                    flex: 1;
                    padding: 8px 12px;
                    border: 1px solid #dcdfe6;
                    border-radius: 4px;
                    background-color: #f5f7fa;
                    color: #909399;
                  ">
                </div>
              </div>
              <div style="margin-bottom: 15px;">
                <div style="display: flex; align-items: center; margin-bottom: 5px;">
                  <span style="width: 100px; text-align: right; padding-right: 12px; color: #606266;">原条码:</span>
                  <div style="flex: 1; display: flex; align-items: center; gap: 10px;">
                    <input type="text" id="${dialogId}-barcode" placeholder="扫描原条码" style="
                      flex: 1;
                      padding: 8px 12px;
                      border: 1px solid #dcdfe6;
                      border-radius: 4px;
                    ">
                    <button id="${dialogId}-viewChain" style="
                      padding: 8px 16px;
                      background: #409eff;
                      color: white;
                      border: none;
                      border-radius: 4px;
                      cursor: pointer;
                      white-space: nowrap;
                    ">查看拆包链</button>
                  </div>
                </div>
              </div>
              <div style="margin-bottom: 15px;">
                <div style="display: flex; align-items: center; margin-bottom: 5px;">
                  <span style="width: 100px; text-align: right; padding-right: 12px; color: #606266;">物料编码:</span>
                  <input type="text" id="${dialogId}-materiel" disabled style="
                    flex: 1;
                    padding: 8px 12px;
                    border: 1px solid #dcdfe6;
                    border-radius: 4px;
                    background-color: #f5f7fa;
                    color: #909399;
                  ">
                </div>
              </div>
              <div style="margin-bottom: 15px;">
                <div style="display: flex; align-items: center; margin-bottom: 5px;">
                  <span style="width: 100px; text-align: right; padding-right: 12px; color: #606266;">剩余数量:</span>
                  <input type="text" id="${dialogId}-remain" disabled style="
                    flex: 1;
                    padding: 8px 12px;
                    border: 1px solid #dcdfe6;
                    border-radius: 4px;
                    background-color: #f5f7fa;
                    color: #909399;
                  ">
                </div>
              </div>
              <div style="margin-bottom: 15px;">
                <div style="display: flex; align-items: center; margin-bottom: 5px;">
                  <span style="width: 100px; text-align: right; padding-right: 12px; color: #606266;">拆包数量:</span>
                  <div style="flex: 1;">
                    <input type="number" id="${dialogId}-splitQty" value="1" min="0.01" step="0.01" style="
                      width: 100%;
                      padding: 8px 12px;
                      border: 1px solid #dcdfe6;
                      border-radius: 4px;
                    ">
                  </div>
                </div>
              </div>
            </div>
            <div class="custom-dialog-footer" style="
              padding: 10px 20px 20px;
              text-align: right;
              border-top: 1px solid #ebeef5;
            ">
              <button id="${dialogId}-cancel" style="
                padding: 9px 15px;
                background: white;
                color: #606266;
                border: 1px solid #dcdfe6;
                border-radius: 4px;
                cursor: pointer;
                margin-right: 10px;
              ">取消</button>
              <button id="${dialogId}-confirm" style="
                padding: 9px 15px;
                background: #409eff;
                color: white;
                border: none;
                border-radius: 4px;
                cursor: pointer;
              ">确认拆包</button>
            </div>
          </div>
        </div>
      `;
      // æ·»åŠ æ ·å¼
      newDialog.style.cssText = `
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 999999;
      `;
      // å¼¹çª—容器样式
      const wrapper = newDialog.querySelector('.custom-dialog-wrapper');
      if (wrapper) {
        wrapper.style.position = 'relative';
        wrapper.style.zIndex = '1000000';
      }
      // å¼¹çª—内容样式
      const dialog = newDialog.querySelector('.custom-dialog');
      if (dialog) {
        dialog.style.background = 'white';
        dialog.style.borderRadius = '4px';
        dialog.style.maxWidth = '90vw';
        dialog.style.maxHeight = '90vh';
        dialog.style.boxShadow = '0 2px 12px 0 rgba(0, 0, 0, 0.1)';
        dialog.style.overflow = 'auto';
      }
      // å¼¹çª—头部样式
      const header = newDialog.querySelector('.custom-dialog-header');
      if (header) {
        header.style.display = 'flex';
        header.style.justifyContent = 'space-between';
        header.style.alignItems = 'center';
        header.style.padding = '20px 20px 10px';
        header.style.borderBottom = '1px solid #ebeef5';
      }
      document.body.appendChild(newDialog);
      console.log('紧急弹窗已创建');
      // ç»‘定事件
      this.bindManualDialogEvents(dialogId);
      // è‡ªåŠ¨èšç„¦åˆ°æ¡ç è¾“å…¥æ¡†
      setTimeout(() => {
        const barcodeInput = document.getElementById(`${dialogId}-barcode`);
        if (barcodeInput) {
          barcodeInput.focus();
          // æ·»åŠ å›žè½¦é”®ç›‘å¬
          barcodeInput.addEventListener('keyup', (event) => {
            if (event.key === 'Enter') {
              this.onManualSplitBarcodeScan(dialogId);
            }
          });
        }
      }, 100);
    },
    // ç»‘定手动弹窗事件
    bindManualDialogEvents(dialogId) {
      const vm = this; // ä¿å­˜Vue实例引用
      // æŸ¥çœ‹æ‹†åŒ…链按钮
      const viewChainBtn = document.getElementById(`${dialogId}-viewChain`);
      if (viewChainBtn) {
        viewChainBtn.onclick = () => {
          const barcodeInput = document.getElementById(`${dialogId}-barcode`);
          if (barcodeInput && barcodeInput.value.trim()) {
            vm.viewSplitChainFromManualDialog(barcodeInput.value.trim(), dialogId);
          } else {
            ElMessage.warning('请先输入条码');
          }
        };
      }
      // å–消按钮
      const cancelBtn = document.getElementById(`${dialogId}-cancel`);
      if (cancelBtn) {
        cancelBtn.onclick = () => {
          const dialog = document.getElementById(dialogId);
          if (dialog && dialog.parentNode) {
            dialog.parentNode.removeChild(dialog);
          }
        };
      }
      // ç¡®è®¤æ‹†åŒ…按钮
      const confirmBtn = document.getElementById(`${dialogId}-confirm`);
      if (confirmBtn) {
        confirmBtn.onclick = () => {
          vm.handleManualSplitPackage(dialogId);
        };
      }
      // æ¡ç è¾“入框变化事件
      const barcodeInput = document.getElementById(`${dialogId}-barcode`);
      if (barcodeInput) {
        // é˜²æŠ–处理
        let timeout;
        barcodeInput.addEventListener('input', () => {
          clearTimeout(timeout);
          timeout = setTimeout(() => {
            if (barcodeInput.value.trim()) {
              vm.onManualSplitBarcodeScan(dialogId);
            }
          }, 500);
        });
      }
    },
    // æ‰‹åŠ¨å¼¹çª—çš„æ¡ç æ‰«æå¤„ç†
    async onManualSplitBarcodeScan(dialogId) {
      const barcodeInput = document.getElementById(`${dialogId}-barcode`);
      if (!barcodeInput || !barcodeInput.value.trim()) return;
      const barcode = barcodeInput.value.trim();
      try {
        const res = await http.post('/api/OutboundBatchPicking/split-package-info', {
          orderNo: this.scanData.orderNo,
          palletCode: this.scanData.palletCode,
          barcode: barcode
        });
        if (res.status) {
          // æ›´æ–°ç‰©æ–™ç¼–码
          const materielInput = document.getElementById(`${dialogId}-materiel`);
          if (materielInput) {
            materielInput.value = res.data.materielCode || '';
          }
          // æ›´æ–°å‰©ä½™æ•°é‡
          const remainInput = document.getElementById(`${dialogId}-remain`);
          if (remainInput) {
            remainInput.value = res.data.remainQuantity || 0;
          }
          // æ›´æ–°æ‹†åŒ…数量(默认为1,不超过剩余数量)
          const splitQtyInput = document.getElementById(`${dialogId}-splitQty`);
          if (splitQtyInput) {
            const maxQty = res.data.remainQuantity || 0;
            splitQtyInput.max = maxQty;
            const currentVal = parseFloat(splitQtyInput.value) || 1;
            if (currentVal > maxQty) {
              splitQtyInput.value = Math.min(1, maxQty);
            }
          }
        } else {
          ElMessage.error(res.message || '获取拆包信息失败');
        }
      } catch (error) {
        console.error('获取拆包信息失败:', error);
        ElMessage.error('获取拆包信息失败');
      }
    },
    // ä»Žæ‰‹åŠ¨å¼¹çª—æŸ¥çœ‹æ‹†åŒ…é“¾
    viewSplitChainFromManualDialog(barcode, dialogId) {
      // å…ˆå…³é—­æ‰‹åŠ¨å¼¹çª—
      const dialog = document.getElementById(dialogId);
      if (dialog && dialog.parentNode) {
        dialog.parentNode.removeChild(dialog);
      }
      // å»¶è¿Ÿä¸€ä¸‹ï¼Œç„¶åŽæ‰“å¼€Vue的拆包链弹窗
      setTimeout(() => {
        this.viewSplitChain(barcode);
      }, 50);
    },
    // å¤„理手动弹窗的拆包操作
    async handleManualSplitPackage(dialogId) {
      const barcodeInput = document.getElementById(`${dialogId}-barcode`);
      const splitQtyInput = document.getElementById(`${dialogId}-splitQty`);
      if (!barcodeInput || !barcodeInput.value.trim()) {
        ElMessage.warning('请输入原条码');
        return;
      }
      if (!splitQtyInput || !splitQtyInput.value || parseFloat(splitQtyInput.value) <= 0) {
        ElMessage.warning('请输入有效的拆包数量');
        return;
      }
      const originalBarcode = barcodeInput.value.trim();
      const splitQuantity = parseFloat(splitQtyInput.value);
      try {
        // æ˜¾ç¤ºåŠ è½½çŠ¶æ€
        const confirmBtn = document.getElementById(`${dialogId}-confirm`);
        if (confirmBtn) {
          confirmBtn.disabled = true;
          confirmBtn.textContent = '处理中...';
        }
        const res = await http.post('/api/OutboundBatchPicking/split-package', {
          orderNo: this.scanData.orderNo,
          palletCode: this.scanData.palletCode,
          originalBarcode: originalBarcode,
          splitQuantity: splitQuantity
        });
        if (res.status) {
          ElMessage.success('拆包成功');
          // å…³é—­æ‰‹åŠ¨å¼¹çª—
          const dialog = document.getElementById(dialogId);
          if (dialog && dialog.parentNode) {
            dialog.parentNode.removeChild(dialog);
          }
          // é‡æ–°åŠ è½½æ•°æ®
          await this.loadPalletData();
        } else {
          ElMessage.error(res.message || '拆包失败');
          // æ¢å¤æŒ‰é’®çŠ¶æ€
          if (confirmBtn) {
            confirmBtn.disabled = false;
            confirmBtn.textContent = '确认拆包';
          }
        }
      } catch (error) {
        console.error('拆包失败:', error);
        ElMessage.error('拆包失败');
        // æ¢å¤æŒ‰é’®çŠ¶æ€
        const confirmBtn = document.getElementById(`${dialogId}-confirm`);
        if (confirmBtn) {
          confirmBtn.disabled = false;
          confirmBtn.textContent = '确认拆包';
        }
      }
    },
      closeAllDialogsImmediately() {
      console.log('立即关闭所有弹窗');
      // ç›´æŽ¥è®¾ç½®ä¸º false,不等待任何异步操作
      this.showCustomSplitDialog = false;
      this.showRevertSplitDialog = false;
      this.showBatchReturnDialog = false;
      this.showEmptyPalletDialog = false;
      this.showSplitChainDialog = false;
      // å¼ºåˆ¶DOM更新
      this.$forceUpdate();
    },
    async onSplitBarcodeScan() {
@@ -592,6 +1038,9 @@
        });
        if (res.status) {
            if(res.data && res.data.length>0){
            this.$refs.childs.open(res.data);
          }
          this.splitForm.materielCode = res.data.materielCode;
          this.splitForm.maxQuantity = res.data.remainQuantity;
          this.splitForm.splitQuantity = Math.min(1, this.splitForm.maxQuantity);
@@ -617,7 +1066,7 @@
              });
              if (res.status) {
                this.$message.success('拆包成功');
                this.showCustomSplitDialog = false;
                this.closeAllDialogs();
                await this.loadPalletData();
              } else {
                this.$message.error(res.message || '拆包失败');
@@ -631,28 +1080,24 @@
        });
      }
    },
// åœ¨æ‹†åŒ…弹窗中查看拆包链
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;
      this.revertSplitForm.newBarcode = this.revertSplitForm.newBarcode.replace(/\n/g, '').trim();
      // æ–°å¢žï¼šæ‰«æåŽè‡ªåŠ¨æ˜¾ç¤ºæ‹†åŒ…é“¾ä¿¡æ¯
      await this.viewSplitChain(this.revertSplitForm.newBarcode);
    },
    async handleRevertSplit() {
@@ -668,7 +1113,7 @@
              });
              if (res.status) {
                this.$message.success('撤销拆包成功');
                this.showRevertSplitDialog = false;
                this.closeAllDialogs();
                await this.loadPalletData();
              } else {
                this.$message.error(res.message || '撤销拆包失败');
@@ -682,216 +1127,140 @@
        });
      }
    },
// æŸ¥æ‰¾å®Œæ•´æ‹†åŒ…链(从根条码开始)
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;
  }
  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;
      // æ˜¾ç¤ºæç¤ºä¿¡æ¯ï¼Œå‘Šè¯‰ç”¨æˆ·è¿™æ˜¯ä»€ä¹ˆç±»åž‹çš„æ‹†åŒ…链
      let chainType = "当前条码的拆包链";
      if (this.splitChainInfo.chainType === 'root') {
        chainType = "完整拆包链(从原始条码开始)";
      } else if (this.splitChainInfo.chainType === 'branch') {
        chainType = "分支拆包链";
    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;
      }
      
      this.$message.info(`已加载${chainType},共${this.splitChainInfo.totalSplitTimes}次拆包`);
      this.showSplitChainDialog = true;
    } else {
      this.$message.error(res.message || '获取拆包链信息失败');
    }
  } catch (error) {
    this.$message.error('获取拆包链信息失败');
  } finally {
    this.splitChainLoading = false;
  }
},
      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;
          this.activeDialog = 'splitChain';
        } else {
          this.$message.error(res.message || '获取拆包链信息失败');
        }
      } catch (error) {
        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) {
  // å…ˆè®°å½•当前信息,然后关闭弹窗
  const originalBarcode = this.splitChainInfo.originalBarcode;
  this.closeSplitChainDialog();
  await this.$nextTick();
  try {
    await this.$confirm(
      `确定要取消条码 ${newBarcode} çš„æ‹†åŒ…操作吗?`,
      '取消单个拆包',
      {
        confirmButtonText: '确定取消',
        cancelButtonText: '再想想',
        type: 'warning'
      }
    );
    this.revertSplitLoading = true;
    const res = await http.post('/api/OutboundBatchPicking/cancel-split', {
      orderNo: this.scanData.orderNo,
      palletCode: this.scanData.palletCode,
      newBarcode: newBarcode
    });
    if (res.status) {
      this.$message.success('取消拆包成功');
      await this.loadPalletData();
      // é‡æ–°æ‰“开弹窗显示更新后的状态
      await this.viewSplitChain(originalBarcode);
    } else {
      this.$message.error(res.message || '取消拆包失败');
      await this.viewSplitChain(originalBarcode);
    }
  } catch (error) {
    if (error === 'cancel') {
      // ç”¨æˆ·å–消后重新打开弹窗
      await this.viewSplitChain(originalBarcode);
    } else {
      this.$message.error('取消拆包失败');
      await this.viewSplitChain(originalBarcode);
    }
  } finally {
    this.revertSplitLoading = false;
  }
},
// å–消整个拆包链
async cancelWholeSplitChain() {
  // å…ˆè®°å½•当前拆包链信息,然后关闭弹窗
  const originalBarcode = this.splitChainInfo.originalBarcode;
  this.closeSplitChainDialog();
  // ç»™ä¸€ç‚¹æ—¶é—´è®©å¼¹çª—完全关闭
  await this.$nextTick();
  try {
    // çŽ°åœ¨æ˜¾ç¤ºç¡®è®¤å¯¹è¯æ¡†ï¼Œç¡®ä¿å®ƒåœ¨æœ€å‰é¢
    await this.$confirm(
      `确定要取消整个拆包链吗?\n这将取消从条码 ${originalBarcode} å¼€å§‹çš„æ‰€æœ‰æ‹†åŒ…操作。`,
      '取消拆包链确认',
      {
        confirmButtonText: '确定取消',
        cancelButtonText: '再想想',
        type: 'warning',
        center: true,
        closeOnClickModal: false
    // å–消单个拆包记录
    async cancelSingleSplit(newBarcode) {
      const originalBarcode = this.splitChainInfo.originalBarcode;
      try {
        await this.$confirm(
          `确定要取消条码 ${newBarcode} çš„æ‹†åŒ…操作吗?`,
          '取消单个拆包',
          {
            confirmButtonText: '确定取消',
            cancelButtonText: '再想想',
            type: 'warning'
          }
        );
        this.revertSplitLoading = true;
        const res = await http.post('/api/OutboundBatchPicking/cancel-split', {
          orderNo: this.scanData.orderNo,
          palletCode: this.scanData.palletCode,
          newBarcode: newBarcode
        });
        if (res.status) {
          this.$message.success('取消拆包成功');
          await this.loadPalletData();
          this.closeAllDialogs();
          setTimeout(() => {
            this.viewSplitChain(originalBarcode);
          }, 50);
        } else {
          this.$message.error(res.message || '取消拆包失败');
        }
      } catch (error) {
        if (error !== 'cancel') {
          this.$message.error('取消拆包失败');
        }
      } finally {
        this.revertSplitLoading = false;
      }
    );
    // ç”¨æˆ·ç¡®è®¤åŽæ‰§è¡Œå–消操作
    this.revertSplitLoading = true;
    const res = await http.post('/api/OutboundBatchPicking/cancel-split-chain', {
      orderNo: this.scanData.orderNo,
      palletCode: this.scanData.palletCode,
      startBarcode: originalBarcode
    });
    console.log('取消拆包链响应:', res);
    if (res.status) {
      this.$message.success('取消拆包链成功');
      await this.loadPalletData();
      // å¯é€‰ï¼šé‡æ–°æ‰“开拆包链信息弹窗显示更新后的状态
      // await this.viewSplitChain(originalBarcode);
    } else {
      this.$message.error(res.message || '取消拆包链失败');
      // å¤±è´¥åŽé‡æ–°æ‰“开弹窗
      await this.viewSplitChain(originalBarcode);
    }
  } catch (error) {
    // ç”¨æˆ·å–消操作
    if (error === 'cancel') {
      console.log('用户取消了拆包链操作');
      // ç”¨æˆ·å–消后重新打开弹窗
      await this.viewSplitChain(originalBarcode);
    } else {
      console.error('取消拆包链错误:', error);
      this.$message.error('取消拆包链失败: ' + error.message);
      // å‡ºé”™åŽé‡æ–°æ‰“开弹窗
      await this.viewSplitChain(originalBarcode);
    }
  } finally {
    this.revertSplitLoading = false;
  }
},
    },
    // å–消整个拆包链
    async cancelWholeSplitChain() {
      try {
        await this.$confirm(
          `确定要取消整个拆包链吗?\n这将取消从条码 ${this.splitChainInfo.originalBarcode} å¼€å§‹çš„æ‰€æœ‰æ‹†åŒ…操作。`,
          '取消拆包链确认',
          {
            confirmButtonText: '确定取消',
            cancelButtonText: '再想想',
            type: 'warning',
            center: true,
            closeOnClickModal: false
          }
        );
        this.revertSplitLoading = true;
        const res = await http.post('/api/OutboundBatchPicking/cancel-split-chain', {
          orderNo: this.scanData.orderNo,
          palletCode: this.scanData.palletCode,
          startBarcode: this.splitChainInfo.originalBarcode
        });
        if (res.status) {
          this.$message.success('取消拆包链成功');
          this.closeAllDialogs();
          await this.loadPalletData();
        } else {
          this.$message.error(res.message || '取消拆包链失败');
        }
      } catch (error) {
        if (error !== 'cancel') {
          this.$message.error('取消拆包链失败: ' + error.message);
        }
      } finally {
        this.revertSplitLoading = false;
      }
    },
    // æ£€æŸ¥æ¡ç æ˜¯å¦å·²è¢«åˆ†æ‹£
    hasPicked(barcode) {
@@ -905,17 +1274,58 @@
      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() {
      this.activeDialog = null;
      // ç¡®ä¿æ‰€æœ‰å¼¹çª—状态都被重置
// å…³é—­Vue弹窗
      this.showCustomSplitDialog = false;
      this.showRevertSplitDialog = false;
      this.showBatchReturnDialog = false;
      this.showEmptyPalletDialog = false;
      this.showSplitChainDialog = false;
      // å…³é—­æ‰‹åŠ¨å¼¹çª—
      if (this.manualDialog && this.manualDialog.parentNode) {
        this.manualDialog.parentNode.removeChild(this.manualDialog);
        this.manualDialog = null;
      }
      // ç§»é™¤æ‰€æœ‰ç´§æ€¥å¼¹çª—
      const emergencyDialogs = document.querySelectorAll('.emergency-fix');
      emergencyDialogs.forEach(dialog => {
        if (dialog.parentNode) {
          dialog.parentNode.removeChild(dialog);
        }
      });
    },
    // å›žåº“相关方法
    openBatchReturnDialog() {
      if (!this.scanData.palletCode) {
        this.$message.warning('请先扫描托盘码');
        return;
      }
      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;
      if (this.isOpeningDialog) return;
      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() {
@@ -927,7 +1337,7 @@
        });
        if (res.status) {
          this.$message.success('回库成功');
          this.showBatchReturnDialog = false;
          this.closeAllDialogs();
          await this.loadPalletData();
        } else {
          this.$message.error(res.message || '回库失败');
@@ -940,10 +1350,24 @@
    },
    // å–空箱方法
    handleEmptyPallet() {
      this.showEmptyPalletDialog = true;
      this.emptypalletOutForm.orderNo = this.scanData.orderNo;
      this.emptypalletOutForm.palletCode = '';
handleEmptyPallet() {
      if (this.isOpeningDialog) return;
      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() {
@@ -955,7 +1379,7 @@
        });
        if (res.status) {
          this.$message.success('取走空箱成功');
          this.showEmptyPalletDialog = false;
          this.closeAllDialogs();
          await this.loadPalletData();
        } else {
          this.$message.error(res.message || '取走空箱失败');
@@ -971,9 +1395,13 @@
    async loadPalletData() {
      if (!this.scanData.orderNo || !this.scanData.palletCode) return;
      
      await this.loadUnpickedList();
      await this.loadPickedList();
      await this.loadPalletStatus();
      try {
        await this.loadUnpickedList();
        await this.loadPickedList();
        await this.loadPalletStatus();
      } catch (error) {
        console.error('加载托盘数据失败:', error);
      }
    },
    async loadUnpickedList() {
@@ -983,7 +1411,7 @@
          palletCode: this.scanData.palletCode
        });
        if (res.status) {
          this.unpickedList = res.data || [];
          this.unpickedList = (res.data || []).filter(item => item.canPick === true);
          this.summary.unpickedCount = this.unpickedList.length;
          this.summary.unpickedQuantity = this.unpickedList.reduce((sum, item) => sum + (item.remainQuantity || 0), 0);
        }
@@ -999,7 +1427,10 @@
          palletCode: this.scanData.palletCode
        });
        if (res.status) {
          this.pickedList = res.data || [];
          this.pickedList = res.data.map(item => ({
            ...item,
            currentBarcode: item.barcode
          }));
          this.summary.pickedCount = this.pickedList.length;
        }
      } catch (error) {
@@ -1103,17 +1534,31 @@
      this.resetSplitForm();
    },
    openRevertSplitDialog() {
      this.showRevertSplitDialog = true;
      this.revertSplitForm.newBarcode = '';
openRevertSplitDialog() {
      if (this.isOpeningDialog) return;
      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;
    },
@@ -1122,7 +1567,7 @@
      this.emptypalletOutForm.palletCode = this.emptypalletOutForm.palletCode.replace(/\n/g, '').trim();
    },
    closeEmptyPalletDialog() {
     closeEmptyPalletDialog() {
      this.showEmptyPalletDialog = false;
      this.emptypalletOutForm.palletCode = '';
    },
@@ -1169,19 +1614,7 @@
  color: #909399;
}
/* è‡ªå®šä¹‰å¼¹çª—样式 */
:deep(.el-message-box) {
  z-index: 10010 !important;
}
:deep(.el-overlay) {
  z-index: 10009 !important;
}
:deep(.el-message) {
  z-index: 10011 !important;
}
/* è‡ªå®šä¹‰å¼¹çª—样式 - å…³é”®ä¿®å¤ */
.custom-dialog-overlay {
  position: fixed;
  top: 0;
@@ -1192,7 +1625,130 @@
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000; /* ä¿æŒä¸€ä¸ªåˆç†çš„ z-index */
  z-index: 9999; /* æé«˜z-index确保在最上层 */
}
.custom-dialog-wrapper {
  position: relative;
  z-index: 10000;
}
.custom-dialog {
  background: white;
  border-radius: 4px;
  width: 500px;
  max-width: 90vw;
  max-height: 90vh;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  overflow: auto;
}
.custom-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px 10px;
  border-bottom: 1px solid #ebeef5;
}
.custom-dialog-header h3 {
  margin: 0;
  color: #303133;
}
.close-button {
  font-size: 18px;
  color: #909399;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.close-button:hover {
  color: #409EFF;
  background-color: transparent;
}
.custom-dialog-body {
  padding: 20px;
}
.custom-dialog-footer {
  padding: 10px 20px 20px;
  text-align: right;
  border-top: 1px solid #ebeef5;
}
.custom-dialog-footer .el-button {
  margin-left: 10px;
}
@media (max-width: 768px) {
  .custom-dialog {
    width: 95vw;
    margin: 10px;
  }
  .scanner-form {
    flex-direction: column;
    align-items: stretch;
  }
  .scanner-form .el-input {
    width: 100%;
  }
}
/* åŽŸæœ‰çš„æ ·å¼ä¿æŒä¸å˜ */
.OutboundPicking-container {
  padding: 20px;
}
.scanner-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.scanner-form .el-input {
  width: 200px;
}
.summary-info {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.table-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 0 10px;
}
.selection-count {
  font-size: 12px;
  color: #909399;
}
/* åŽŸæœ‰çš„è‡ªå®šä¹‰å¼¹çª—æ ·å¼ */
.custom-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.custom-dialog-wrapper {
@@ -1263,16 +1819,22 @@
    flex-direction: column;
    align-items: stretch;
  }
  /* ç¡®ä¿ç¡®è®¤å¯¹è¯æ¡†åœ¨æœ€å‰é¢ */
.el-message-box__wrapper {
  z-index: 10001 !important;
}
.el-message {
  z-index: 10002 !important;
}
  .scanner-form .el-input {
    width: 100%;
  }
}
/* æ–°å¢žï¼šæ‰‹åŠ¨å¼¹çª—çš„æŒ‰é’®æ‚¬åœæ•ˆæžœ */
:deep(button) {
  transition: all 0.3s;
}
:deep(button:hover) {
  opacity: 0.8;
}
:deep(button:active) {
  opacity: 0.6;
}
</style>