From 7e4444e13de92938bcbd4a639b4b00545124007c Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期一, 30 十一月 2026 09:31:25 +0800
Subject: [PATCH] feat(mes): 托盘绑定增加下一步提示和冲突袋码高亮

---
 src/views/mes/qrGateway/workbench/index.vue |   85 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 83 insertions(+), 2 deletions(-)

diff --git a/src/views/mes/qrGateway/workbench/index.vue b/src/views/mes/qrGateway/workbench/index.vue
index 86b1b88..ec4f034 100644
--- a/src/views/mes/qrGateway/workbench/index.vue
+++ b/src/views/mes/qrGateway/workbench/index.vue
@@ -271,10 +271,38 @@
 const reprintingJobId = ref<number>();
 const palletDetailOpen = ref(false);
 const palletDetailCopied = ref(false);
+const palletError = ref('');
 const detailBagPageNo = ref(1);
 const detailBagPageSize = ref(20);
 const removingBagCode = ref('');
 const detailBagCodes = computed(() => data.value.palletBagCodes ?? []);
+/** 浠庨敊璇彁绀轰腑鎻愬彇琚叾瀹冩墭鐩樺崰鐢ㄧ殑琚嬬爜锛屼究浜庡湪璇︽儏閲岄珮浜� */
+const conflictBagCodes = computed(() => {
+  const match = palletError.value.match(/鍗犵敤锛�(.+?)銆�/);
+  if (!match) {
+    return [] as string[];
+  }
+  return (match[1] ?? '')
+    .split('銆�')
+    .map((item) => item.split('锛�')[0]?.trim())
+    .filter((code): code is string => !!code);
+});
+/** 褰撳墠鎵樼洏涓嬩竴姝ユ搷浣滄彁绀� */
+const nextStepHint = computed(() => {
+  if (!data.value.palletStatus) {
+    return '褰撳墠鏈惎鍔細鐐瑰嚮銆屽惎鍔ㄧ粦瀹氥�嶅悗寮�濮嬫壂鐮併��';
+  }
+  if (data.value.palletStatus === 'PAUSED') {
+    return '宸插仠姝㈠苟淇濈暀杩涘害锛氱偣鍑汇�岀户缁粦瀹氥�嶅彲鎺ョ潃鎵��';
+  }
+  const remain = (data.value.palletCapacity ?? 0) - (data.value.palletScanned ?? 0);
+  if (remain > 0) {
+    return remain === 1
+      ? '鍐嶆壂 1 琚嬪氨浼氳嚜鍔ㄧ粦瀹氭墭鐩樺苟鎵撳嵃銆�'
+      : `杩橀渶鎵� ${remain} 琚嬪嵆鍙嚜鍔ㄧ粦瀹氭墭鐩樸�俙;
+  }
+  return '宸叉弧鎵橈紝姝e湪缁戝畾锛涘闀挎椂闂存湭瀹屾垚锛岃鏌ョ湅涓婃柟澶辫触鍘熷洜銆�';
+});
 const detailPageBagCodes = computed(() => {
   const start = (detailBagPageNo.value - 1) * detailBagPageSize.value;
   return detailBagCodes.value.slice(start, start + detailBagPageSize.value);
@@ -476,6 +504,7 @@
   printJobPageNo.value = 1;
   printJobs.value = [];
   printJobTotal.value = 0;
+  palletError.value = '';
   if (realtimeEnabled.value) {
     realtimeEnabled.value = false;
     stopPolling();
@@ -650,6 +679,7 @@
       try {
         await resetQrPalletSession(deviceId);
         lastLatestEventId = undefined;
+        palletError.value = '';
         message.success('鎵爜杩涘害宸叉竻绌猴紝鍙互閲嶆柊鎵爜');
         await loadData();
       } catch (error) {
@@ -688,6 +718,7 @@
     }
   }
   realtimeEnabled.value = true;
+  palletError.value = '';
   receivedCount.value = 0;
   lastReceivedAt.value = '';
   lastLatestEventId = undefined;
@@ -1165,6 +1196,8 @@
 }
 
 let lastLatestEventId: number | undefined;
+let lastScanErrorMsg = '';
+let lastScanErrorAt = 0;
 
 /** 杞妯″紡涓嬬敤鏈�鏂版壂鐮佷簨浠� ID 鍒ゆ柇鏄惁鏈夋柊鏁版嵁锛岃ˉ涓婃彁绀洪煶鍜屾闈㈤�氱煡 */
 function handlePolledLatest(silent: boolean) {
@@ -1225,17 +1258,28 @@
     if (msg.type === 'qr-pallet-scan') {
       scheduleReload();
       void playScanSound(voiceKindOfResult(content.resultType));
+      if (content.resultType === 'FAILED' && content.errorMessage) {
+        const now = Date.now();
+        if (content.errorMessage !== lastScanErrorMsg || now - lastScanErrorAt > 10_000) {
+          lastScanErrorMsg = content.errorMessage;
+          lastScanErrorAt = now;
+          message.warning(`鎵爜澶辫触锛�${content.errorMessage}`, 6);
+        }
+      }
       return;
     }
     if (msg.type === 'qr-pallet-completed') {
+      palletError.value = '';
       scheduleReload();
       void playScanSound('PALLET_DONE');
       return;
     }
     if (msg.type === 'qr-pallet-error') {
+      const text = content.errorMessage || '鎵樼洏缁戝畾澶辫触锛岃鏌ョ湅褰撳墠鎵樼洏琚嬬爜';
+      palletError.value = text;
       scheduleReload();
       void playScanSound('ERROR');
-      message.error(`鎵樼洏缁戝畾澶辫触锛�${content.errorMessage || '鏈煡閿欒'}`);
+      message.error(text, 8);
       return;
     }
     if (msg.type === 'qr-print-job') {
@@ -1454,6 +1498,27 @@
                 </a-button>
               </a-space>
             </div>
+            <div class="next-step-hint">{{ nextStepHint }}</div>
+            <a-alert
+              v-if="palletError"
+              class="pallet-error"
+              closable
+              show-icon
+              type="error"
+              @close="palletError = ''"
+            >
+              <template #message>鎵樼洏缁戝畾澶辫触</template>
+              <template #description>
+                <div>{{ palletError }}</div>
+                <div class="pallet-error-tip">
+                  璇锋寜鎻愮ず澶勭悊锛涗篃鍙互鍏堛�屾煡鐪嬭鎯呫�嶆牳瀵瑰綋鍓嶈鐮侊紝鎴栫洿鎺ユ竻绌鸿繘搴﹂噸鏂版壂鐮併��
+                </div>
+                <div class="pallet-error-actions">
+                  <a-button danger size="small" @click="handleResetProgress">娓呯┖杩涘害骞堕噸鏂版壂鐮�</a-button>
+                  <a-button size="small" @click="openPalletDetail">鏌ョ湅褰撳墠鎵樼洏琚嬬爜</a-button>
+                </div>
+              </template>
+            </a-alert>
             <div v-if="(data.palletScanned ?? 0) <= 0" class="progress-hint">
               鍚姩鎵樼洏缁戝畾骞舵壂鍏ヨ嚦灏戜竴涓鐮佸悗锛屻�岃鎯� / 鎻愬墠缁戝畾鎵撳嵃 / 娓呯┖杩涘害銆嶆墠鍙搷浣溿��
             </div>
@@ -1710,10 +1775,19 @@
         鍏� {{ data.palletScanned ?? 0 }} 琚� 路 鍝佺 {{ data.palletItemName || '-' }} 路 鎵规
         {{ data.palletBatchCode || '-' }}
       </p>
+      <div v-if="conflictBagCodes.length" class="detail-conflict-tip">
+        妫�娴嬪埌 {{ conflictBagCodes.length }} 涓鐮佸凡琚叾瀹冩墭鐩樺崰鐢紝宸叉爣绾€�傝鐐瑰嚮瀵瑰簲琛岀殑銆岀Щ闄ゃ�嶏紝鐒跺悗琛ユ壂鐩稿悓鏁伴噺鐨勮鐮併��
+      </div>
       <div v-if="detailBagCodes.length" class="detail-list">
-        <div v-for="(code, index) in detailPageBagCodes" :key="code" class="detail-item">
+        <div
+          v-for="(code, index) in detailPageBagCodes"
+          :key="code"
+          class="detail-item"
+          :class="{ 'detail-item-conflict': conflictBagCodes.includes(code) }"
+        >
           <span>{{ (detailBagPageNo - 1) * detailBagPageSize + index + 1 }}</span>
           <code>{{ code }}</code>
+          <a-tag v-if="conflictBagCodes.includes(code)" color="error">鍐茬獊</a-tag>
           <a-button
             :loading="removingBagCode === code"
             danger
@@ -1799,6 +1873,13 @@
 .pallet-progress { margin-top: 18px; padding-top: 16px; border-top: 1px solid #edf0f5; }
 .progress-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 600; }
 .progress-hint { margin-bottom: 8px; color: #d58a17; font-size: 12px; font-weight: 400; }
+.next-step-hint { margin: 4px 0 8px; color: #1677ff; font-size: 12px; font-weight: 400; }
+.pallet-error { margin: 8px 0 12px; }
+.detail-conflict-tip { margin-bottom: 8px; padding: 8px 10px; color: #cf1322; background: #fff1f0; border: 1px solid #ffa39e; border-radius: 6px; font-size: 12px; }
+.detail-item-conflict { background: #fff1f0; }
+.detail-item-conflict code { color: #cf1322; font-weight: 600; }
+.pallet-error-tip { margin-top: 4px; color: #7b8799; font-size: 12px; }
+.pallet-error-actions { display: flex; gap: 8px; margin-top: 8px; }
 .progress-bar { height: 8px; overflow: hidden; background: #eef2f7; border-radius: 4px; }
 .progress-fill { height: 100%; background: #1677ff; transition: width .3s; }
 .progress-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 10px; color: #7b8799; font-size: 12px; }

--
Gitblit v1.9.3