From 78caa769e452f63288743b8997f7b4c21bb06ce5 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 06 十一月 2026 19:00:38 +0800
Subject: [PATCH] feat(crm,mes): 扩展客户字段与重构批次号生成逻辑

---
 src/views/mes/pro/scan-in/index.vue |   71 ++++++-----------------------------
 1 files changed, 12 insertions(+), 59 deletions(-)

diff --git a/src/views/mes/pro/scan-in/index.vue b/src/views/mes/pro/scan-in/index.vue
index 3a5d2b9..4eb95f8 100644
--- a/src/views/mes/pro/scan-in/index.vue
+++ b/src/views/mes/pro/scan-in/index.vue
@@ -12,14 +12,6 @@
   type MesProScanEventApi,
 } from '#/api/mes/pro/scanEvent';
 import { getLineSimpleList, type MesProLineApi } from '#/api/mes/pro/line';
-import {
-  getWarehouseLocationSimpleList,
-  type MesWmWarehouseLocationApi,
-} from '#/api/mes/wm/warehouse/location';
-import {
-  getWarehouseAreaSimpleList,
-  type MesWmWarehouseAreaApi,
-} from '#/api/mes/wm/warehouse/area';
 
 interface ScanRecord extends MesProScanEventApi.ScanEvent {
   key: number;
@@ -28,11 +20,7 @@
 const code = ref('');
 const scanType = ref<MesProScanEventApi.ScanType>('BAG');
 const lineCode = ref('');
-const locationId = ref<number>();
-const areaId = ref<number>();
 const lines = ref<MesProLineApi.Line[]>([]);
-const locations = ref<MesWmWarehouseLocationApi.WarehouseLocation[]>([]);
-const areas = ref<MesWmWarehouseAreaApi.WarehouseArea[]>([]);
 const loading = ref(false);
 const refreshing = ref(false);
 const records = ref<ScanRecord[]>([]);
@@ -55,27 +43,12 @@
 const latest = computed(() => dashboard.value.latest);
 const successCount = computed(() => dashboard.value.success ?? records.value.filter((item) => item.status === 'SUCCESS').length);
 const failedCount = computed(() => dashboard.value.failed ?? records.value.filter((item) => item.status === 'FAILED').length);
-const isReady = computed(() => Boolean(locationId.value && areaId.value));
 const lineOptions = computed(() =>
   lines.value.map((item) => ({
     label: item.code ? `${item.code} ${item.name ?? ''}`.trim() : (item.name ?? ''),
     value: item.code ?? '',
   })),
 );
-const locationOptions = computed(() =>
-  locations.value.map((item) => ({
-    label: item.code ? `${item.code} ${item.name ?? ''}`.trim() : (item.name ?? ''),
-    value: item.id ?? 0,
-  })),
-);
-const areaOptions = computed(() =>
-  areas.value.map((item) => ({
-    label: item.code ? `${item.code} ${item.name ?? ''}`.trim() : (item.name ?? ''),
-    value: item.id ?? 0,
-  })),
-);
-const locationName = computed(() => locations.value.find((item) => item.id === locationId.value)?.name ?? '');
-const areaName = computed(() => areas.value.find((item) => item.id === areaId.value)?.name ?? '');
 const pageRoot = ref<HTMLElement>();
 let animationContext: gsap.Context | undefined;
 let feedbackTimeline: gsap.core.Timeline | undefined;
@@ -96,26 +69,9 @@
 
 async function loadOptions() {
   try {
-    const [lineList, locationList] = await Promise.all([
-      getLineSimpleList(),
-      getWarehouseLocationSimpleList(),
-    ]);
-    lines.value = lineList ?? [];
-    locations.value = locationList ?? [];
+    lines.value = (await getLineSimpleList()) ?? [];
   } catch {
     lines.value = [];
-    locations.value = [];
-  }
-}
-
-async function loadAreas() {
-  areas.value = [];
-  areaId.value = undefined;
-  if (!locationId.value) return;
-  try {
-    areas.value = (await getWarehouseAreaSimpleList(locationId.value)) ?? [];
-  } catch {
-    areas.value = [];
   }
 }
 
@@ -129,21 +85,20 @@
     message.warning('璇峰厛鎵弿杩芥函鐮�');
     return;
   }
-  if (!locationId.value || !areaId.value) {
-    message.warning('璇峰厛閫夋嫨 WIP 鏆傚瓨搴撳尯鍜屽簱浣�');
-    return;
-  }
   loading.value = true;
   try {
-    await inboundScanEvent({
+    const result = await inboundScanEvent({
       eventId: `${scanType.value}-${Date.now()}`,
       bagCode,
       scanType: scanType.value,
       quantity: 1,
       lineCode: lineCode.value || undefined,
-      locationId: locationId.value,
-      areaId: areaId.value,
     });
+    if (result.status === 'FAILED') {
+      message.error(result.errorMessage || `${SCAN_TYPE_LABEL[scanType.value]} ${bagCode} 鍏ュ簱澶辫触`);
+      await refresh();
+      return;
+    }
     message.success(`${SCAN_TYPE_LABEL[scanType.value]} ${bagCode} 宸插畬鎴愬叆搴揱);
     if (animationContext && pageRoot.value && !window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
       feedbackTimeline?.kill();
@@ -170,7 +125,7 @@
     if (errorMessage && /鍏ュ簱浜嬪姟鏁伴噺蹇呴』涓烘鏁皘鏁伴噺.*涓� 0|quantity.*positive/i.test(errorMessage)) {
       message.error('鍏ュ簱鏁伴噺涓嶈兘涓� 0锛岃妫�鏌ヨ鎵规鐨勮鏁伴厤缃�');
     } else if (!errorMessage || /UnexpectedRollbackException|绯荤粺寮傚父|Internal Server Error/i.test(errorMessage)) {
-      message.error('鎵爜鍏ュ簱澶辫触锛岃妫�鏌ユ壒娆℃暟閲忓拰搴撲綅閰嶇疆');
+      message.error('鎵爜鍏ュ簱澶辫触锛岃妫�鏌ユ壒娆℃暟閲忓拰浠撳簱閰嶇疆');
     } else {
       message.error(errorMessage);
     }
@@ -262,23 +217,21 @@
         <a-divider />
         <a-form layout="vertical" class="config-form">
           <a-form-item label="鐢熶骇浜х嚎"><a-select v-model:value="lineCode" :options="lineOptions" allow-clear show-search option-filter-prop="label" placeholder="璇烽�夋嫨浜х嚎" /></a-form-item>
-          <a-form-item label="WIP 鏆傚瓨搴撳尯" required><a-select v-model:value="locationId" :options="locationOptions" show-search option-filter-prop="label" placeholder="璇烽�夋嫨搴撳尯" @change="loadAreas" /></a-form-item>
-          <a-form-item label="WIP 鏆傚瓨搴撲綅" required><a-select v-model:value="areaId" :options="areaOptions" show-search option-filter-prop="label" :disabled="!locationId" placeholder="璇烽�夋嫨搴撲綅" /></a-form-item>
         </a-form>
       </a-card>
 
       <a-card class="status-card" :bordered="false">
         <template #title><div class="card-title"><ApiOutlined />閲囬泦璁惧鐘舵��</div></template>
-        <div class="device-state"><span class="online-badge"><span class="status-dot" aria-hidden="true" /><span>{{ isReady ? '浣嶇疆宸插氨缁�' : '绛夊緟閰嶇疆' }}</span></span><span class="muted">15 绉掕嚜鍔ㄥ埛鏂�</span></div>
-        <div class="status-list"><div><span>鐢熶骇浜х嚎</span><strong>{{ lineCode || '鏈厤缃�' }}</strong></div><div><span>鏆傚瓨浣嶇疆</span><strong>{{ locationId && areaId ? `${locationName || locationId} / ${areaName || areaId}` : '鏈厤缃�' }}</strong></div><div><span>鏈�杩戝叆搴撴椂闂�</span><strong>{{ latest?.eventTime || '-' }}</strong></div><div><span>鏈�杩戠敓浜ф壒娆�</span><strong>{{ latest?.batchCode || '-' }}</strong></div><div><span>鏈�杩戞壂鐮佺被鍨�</span><strong>{{ latest?.scanType ? SCAN_TYPE_LABEL[latest.scanType] : '-' }}</strong></div></div>
+        <div class="device-state"><span class="online-badge"><span class="status-dot" aria-hidden="true" /><span>璁惧宸插氨缁�</span></span><span class="muted">15 绉掕嚜鍔ㄥ埛鏂�</span></div>
+        <div class="status-list"><div><span>鐢熶骇浜х嚎</span><strong>{{ lineCode || '鏈厤缃�' }}</strong></div><div><span>鏈�杩戝叆搴撴椂闂�</span><strong>{{ latest?.eventTime || '-' }}</strong></div><div><span>鏈�杩戠敓浜ф壒娆�</span><strong>{{ latest?.batchCode || '-' }}</strong></div><div><span>鏈�杩戞壂鐮佺被鍨�</span><strong>{{ latest?.scanType ? SCAN_TYPE_LABEL[latest.scanType] : '-' }}</strong></div></div>
         <div class="sync-box"><IconifyIcon icon="ant-design:check-circle-outlined" /><div><strong>浠撳偍绯荤粺鍚屾姝e父</strong><span>鎵爜浜嬩欢涓庡簱瀛樹簨鍔″疄鏃跺啓鍏�</span></div></div>
       </a-card>
     </section>
 
     <a-card class="records-card" :bordered="false">
       <template #title><div class="card-title"><IconifyIcon icon="ant-design:clock-circle-outlined" />鏈�杩戞壂鐮佷簨浠� <span class="record-count">鏈�杩� 20 鏉�</span></div></template>
-      <a-table :data-source="records" :pagination="false" :scroll="{ x: 1050 }" row-key="key" size="middle">
-        <a-table-column key="bagCode" title="杩芥函鐮�" data-index="bagCode" /><a-table-column key="scanType" title="绫诲瀷"><template #default="{ record }">{{ record.scanType ? SCAN_TYPE_LABEL[record.scanType as MesProScanEventApi.ScanType] : '琚嬬爜' }}</template></a-table-column><a-table-column key="batchCode" title="鐢熶骇鎵规" data-index="batchCode" /><a-table-column key="lineCode" title="浜х嚎"><template #default="{ record }">{{ record.lineCode || '-' }}</template></a-table-column>
+      <a-table :data-source="records" :pagination="false" :scroll="{ x: 1250 }" row-key="key" size="middle">
+        <a-table-column key="bagCode" title="杩芥函鐮�" data-index="bagCode" /><a-table-column key="scanType" title="绫诲瀷"><template #default="{ record }">{{ record.scanType ? SCAN_TYPE_LABEL[record.scanType as MesProScanEventApi.ScanType] : '琚嬬爜' }}</template></a-table-column><a-table-column key="palletCode" title="鎵樼洏鐮�"><template #default="{ record }">{{ record.palletCode || '-' }}</template></a-table-column><a-table-column key="batchCode" title="鎵规鐮�"><template #default="{ record }">{{ record.batchCode || '-' }}</template></a-table-column><a-table-column key="lineCode" title="浜х嚎"><template #default="{ record }">{{ record.lineCode || '-' }}</template></a-table-column>
         <a-table-column key="status" title="鐘舵��"><template #default="{ record }"><a-tag :color="record.status === 'SUCCESS' ? 'success' : 'error'">{{ record.status === 'SUCCESS' ? '鎴愬姛鍏ュ簱' : '澶辫触' }}</a-tag></template></a-table-column><a-table-column key="errorCode" title="閿欒鐮�" data-index="errorCode" /><a-table-column key="errorMessage" title="澶辫触鍘熷洜" data-index="errorMessage" /><a-table-column key="eventTime" title="澶勭悊鏃堕棿" data-index="eventTime" /><a-table-column key="transactionId" title="搴撳瓨浜嬪姟" data-index="transactionId" />
       </a-table>
     </a-card>

--
Gitblit v1.9.3