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/qc/seedQuality/index.vue |   69 ++++++++++++++++------------------
 1 files changed, 33 insertions(+), 36 deletions(-)

diff --git a/src/views/mes/qc/seedQuality/index.vue b/src/views/mes/qc/seedQuality/index.vue
index e69dfe3..6f7a3a7 100644
--- a/src/views/mes/qc/seedQuality/index.vue
+++ b/src/views/mes/qc/seedQuality/index.vue
@@ -11,7 +11,6 @@
 import {
   resolveSeedQuality,
   submitSeedQualityGroup,
-  getSeedIndicatorRanges,
 } from '#/api/mes/qc/seedQuality';
 import { getWarehouseSimpleList } from '#/api/mes/wm/warehouse';
 
@@ -54,29 +53,27 @@
 const qualifiedWarehouses = ref<MesWmWarehouseApi.Warehouse[]>([]);
 const qualifiedWarehouseId = ref<number>();
 
-const indicators = ref<IndicatorForm[]>([
-  { code: 'purity', label: '绾害', unit: '%' },
-  { code: 'cleanliness', label: '鍑�搴�', unit: '%' },
-  { code: 'germination_rate', label: '鍙戣娊鐜�', unit: '%' },
-  { code: 'moisture', label: '姘村垎', unit: '%' },
-]);
-const rangesReady = computed(() => indicators.value.every((item) =>
+const indicators = ref<IndicatorForm[]>([]);
+const rangesReady = computed(() => indicators.value.length > 0 && indicators.value.every((item) =>
   item.minValue !== undefined && item.maxValue !== undefined));
 
-async function loadRanges() {
-  const ranges = await getSeedIndicatorRanges();
-  for (const item of indicators.value) {
-    const range = ranges.find((row) => row.indicatorCode === item.code);
-    item.minValue = range?.minValue === undefined ? undefined : Number(range.minValue);
-    item.maxValue = range?.maxValue === undefined ? undefined : Number(range.maxValue);
-  }
+/** 璇嗗埆瀵硅薄鍚庯紝鎸変骇鍝佺敓鏁堢殑璐ㄦ椤归噸寤哄綍鍏ラ」 */
+function applyIndicators(scan: SeedQualityScan) {
+  indicators.value = (scan.indicators ?? []).map((item) => ({
+    code: item.code,
+    label: item.name || item.code,
+    unit: item.unit || '',
+    value: undefined,
+    minValue: item.minValue === null || item.minValue === undefined ? undefined : Number(item.minValue),
+    maxValue: item.maxValue === null || item.maxValue === undefined ? undefined : Number(item.maxValue),
+  }));
 }
 
 const pendingCount = computed(() => target.value?.pendingBagIds?.length ?? 0);
 const completedCount = computed(() => target.value?.completedBagIds?.length ?? 0);
 const enteredCount = computed(() => indicators.value.filter((item) => item.value !== undefined && item.value !== null).length);
 const passedCount = computed(() => indicators.value.filter(isPassed).length);
-const allEntered = computed(() => indicators.value.every((item) =>
+const allEntered = computed(() => indicators.value.length > 0 && indicators.value.every((item) =>
   item.value !== undefined && item.value !== null
   && item.minValue !== undefined && item.minValue !== null
   && item.maxValue !== undefined && item.maxValue !== null));
@@ -142,8 +139,7 @@
   resolving.value = true;
   submittedCount.value = undefined;
   try {
-    await loadRanges().catch(() => undefined);
-    const data = await resolveSeedQuality(value, scanType.value);
+    const data = await resolveSeedQuality(value, scanType.value, 1);
     if (data.canceled) {
       target.value = undefined;
       message.error('璇ヨ川妫�瀵硅薄宸蹭綔搴燂紝涓嶈兘璐ㄦ');
@@ -159,7 +155,13 @@
       message.error('璇ュ璞℃病鏈夊緟璐ㄦ琚嬬爜锛岃鍦ㄨ川妫�璁板綍涓煡鐪嬪凡鏈夌粨鏋�');
       return;
     }
+    if (!data.indicators?.length) {
+      target.value = undefined;
+      message.error('璇ヤ骇鍝佸皻鏈厤缃川妫�椤癸紝璇峰厛鍦ㄣ�岃川妫�椤瑰悎鏍艰寖鍥撮厤缃�嶄腑缁存姢');
+      return;
+    }
     target.value = data;
+    applyIndicators(data);
     resetIndicators();
     message.success(`${SCAN_TYPE_LABEL[scanType.value]} ${data.code} 宸茶瘑鍒紝鏈寰呮 ${data.pendingBagIds.length} 琚媊);
   } catch (error) {
@@ -177,7 +179,7 @@
     return;
   }
   if (!allEntered.value) {
-    message.warning('璇峰~鍐欏洓椤规寚鏍囩殑瀹炴祴鍊煎拰鏈鍚堟牸涓婁笅闄�');
+    message.warning('璇峰~鍐欏叏閮ㄨ川妫�椤圭殑瀹炴祴鍊煎拰鏈鍚堟牸涓婁笅闄�');
     return;
   }
   if (indicators.value.some((item) => item.minValue === undefined || item.maxValue === undefined || item.minValue > item.maxValue)) {
@@ -201,8 +203,8 @@
     Modal.confirm({
       title: overallPassed.value ? '纭鎻愪氦鍚堟牸缁撴灉锛�' : '纭鎻愪氦涓嶅悎鏍肩粨鏋滐紵',
       content: overallPassed.value
-        ? `鏈 ${count} 琚嬪皢缁熶竴璁板綍涓哄垵妫�鍚堟牸锛屽緟鍒濇瀹℃牳閫氳繃鍚庡妫�锛涘妫�瀹℃牳閫氳繃鍚庢墠杞叆鍚堟牸搴撱��${scopeNote}`
-        : `鏈 ${count} 琚嬪皢璁板綍涓哄垵妫�涓嶅悎鏍硷紝淇濈暀鏆傚瓨搴撳瓨锛涘垵妫�瀹℃牳鍚庡喅瀹氭槸鍚﹁繘鍏ュ妫�銆�${scopeNote}`,
+        ? `鏈 ${count} 琚嬪皢缁熶竴璁板綍涓哄垵妫�鍚堟牸锛岃繘鍏ラ儴闂ㄥ鎵癸紱鍙岀嚎瀹℃壒鍜屽叕鍙歌川妫�瀹℃壒瀹屾垚鍚庢墠杞叆鍚堟牸搴撱��${scopeNote}`
+        : `鏈 ${count} 琚嬪皢璁板綍涓哄垵妫�涓嶅悎鏍硷紝淇濈暀鏆傚瓨搴撳瓨骞惰繘鍏ュ妫�銆�${scopeNote}`,
       okText: '纭鎻愪氦',
       cancelText: '杩斿洖淇敼',
       okButtonProps: { danger: !overallPassed.value },
@@ -230,7 +232,7 @@
       })),
     });
     submittedCount.value = result.processedCount;
-    message.success(`鏈 ${result.processedCount} 琚嬪凡鎻愪氦鍒濇锛屽緟鍒濇瀹℃牳`);
+    message.success(`鏈 ${result.processedCount} 琚嬭川妫�宸叉彁浜わ紝宸插悓姝ョ敓鎴愬姞宸ラ儴銆侀攢鍞儴涓ゆ潯璐ㄦ璁板綍`);
     if (pageRoot.value && !window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
       gsap.fromTo('.result-card', { scale: 0.97, autoAlpha: 0.5 }, { scale: 1, autoAlpha: 1, duration: 0.35, ease: 'power2.out' });
     }
@@ -246,11 +248,6 @@
 }
 
 onMounted(async () => {
-  try {
-    await loadRanges();
-  } catch (error) {
-    message.error(errorText(error));
-  }
   try {
     const warehouses = await getWarehouseSimpleList();
     qualifiedWarehouses.value = (warehouses ?? []).filter(
@@ -282,15 +279,15 @@
       <div>
         <div class="eyebrow">MES / 璐ㄩ噺绠$悊</div>
         <h1>绉嶅瓙璐ㄦ</h1>
-        <p>璇嗗埆寰呮鑼冨洿骞跺綍鍏ュ洓椤规寚鏍囷紱鍒濇瀹℃牳鍚庡妫�锛屽妫�瀹℃牳鍚庡叆搴撴垨澶勭疆</p>
+        <p>涓�娆℃彁浜ゅ悓鏃剁敓鎴愬姞宸ラ儴銆侀攢鍞儴涓ゆ潯璐ㄦ璁板綍锛涘垵妫�涓嶅悎鏍煎厛澶嶆锛屽弻绾块儴闂ㄥ鎵瑰悗杩涘叆鍏徃璐ㄦ瀹℃壒</p>
       </div>
       <div class="header-badge"><IconifyIcon icon="ep:checked" /> 琚嬬爜 / 鎵樼洏鐮� / 鎵规鐮�</div>
     </header>
 
     <section class="summary-grid" aria-label="璐ㄦ鎽樿">
-      <div class="summary-card blue"><IconifyIcon icon="ep:document-checked" /><div><span>妫�楠岄」鐩�</span><strong>4</strong><small>绾害銆佸噣搴︺�佸彂鑺界巼銆佹按鍒�</small></div></div>
+      <div class="summary-card blue"><IconifyIcon icon="ep:document-checked" /><div><span>妫�楠岄」鐩�</span><strong>{{ indicators.length }}</strong><small>{{ indicators.length ? indicators.map((item) => item.label).join('銆�') : '璇嗗埆鍚庢寜浜у搧甯﹀嚭' }}</small></div></div>
       <div class="summary-card" :class="target ? 'green' : 'blue'"><IconifyIcon icon="ep:box" /><div><span>鏈寰呮</span><strong>{{ target ? `${pendingCount} 琚媊 : '寰呰瘑鍒�' }}</strong><small>{{ target ? `${SCAN_TYPE_LABEL[scanType]} ${target.code}` : `璇烽�夋嫨绫诲瀷鍚庤瘑鍒�${SCAN_TYPE_LABEL[scanType]}` }}</small></div></div>
-      <div class="summary-card" :class="overallPassed ? 'green' : allEntered ? 'red' : 'blue'"><IconifyIcon :icon="overallPassed ? 'ep:circle-check-filled' : allEntered ? 'ep:warning-filled' : 'ep:edit-pen'" /><div><span>鎬讳綋缁撹</span><strong>{{ overallPassed ? '鍚堟牸' : allEntered ? '涓嶅悎鏍�' : '寰呭綍鍏�' }}</strong><small>{{ overallPassed ? '鍙彁浜ゅ悎鏍肩粨鏋�' : allEntered ? '璇峰~鍐欎笉鍚堟牸鍘熷洜' : `宸插綍鍏� ${enteredCount} / 4 椤筦 }}</small></div></div>
+      <div class="summary-card" :class="overallPassed ? 'green' : allEntered ? 'red' : 'blue'"><IconifyIcon :icon="overallPassed ? 'ep:circle-check-filled' : allEntered ? 'ep:warning-filled' : 'ep:edit-pen'" /><div><span>鎬讳綋缁撹</span><strong>{{ overallPassed ? '鍚堟牸' : allEntered ? '涓嶅悎鏍�' : '寰呭綍鍏�' }}</strong><small>{{ overallPassed ? '鍙彁浜ゅ悎鏍肩粨鏋�' : allEntered ? '璇峰~鍐欎笉鍚堟牸鍘熷洜' : `宸插綍鍏� ${enteredCount} / ${indicators.length} 椤筦 }}</small></div></div>
     </section>
 
     <section class="content-grid">
@@ -334,7 +331,7 @@
             </a-form-item>
           </div>
           <p v-if="!qualifiedWarehouses.length" class="target-warning">鏆傛棤鍙敤鍚堟牸搴擄紝璇疯仈绯荤鐞嗗憳閰嶇疆鍚庡啀鎻愪氦璐ㄦ銆�</p>
-          <a-alert v-if="!rangesReady" class="target-empty" type="info" show-icon message="鏈璇锋墜鍔ㄥ~鍐欏悎鏍艰寖鍥�" description="绠$悊鍛樺皻鏈厤缃畬鏁撮粯璁よ寖鍥达紱浠嶅彲鎵嬪姩濉啓鍥涢」鎸囨爣鐨勫悎鏍间笂涓嬮檺銆�" />
+          <a-alert v-if="target && !rangesReady" class="target-empty" type="info" show-icon message="鏈璇锋墜鍔ㄥ~鍐欏悎鏍艰寖鍥�" description="璇ヤ骇鍝侀儴鍒嗚川妫�椤规湭閰嶇疆榛樿鑼冨洿锛屼粛鍙墜鍔ㄥ~鍐欐湰娆″悎鏍间笂涓嬮檺銆�" />
 
           <a-divider orientation="left">鎸囨爣缁撴灉</a-divider>
           <div class="indicator-list">
@@ -342,9 +339,9 @@
               <div class="indicator-name"><span class="indicator-dot" :class="isPassed(item) ? 'pass' : 'fail'" /><strong>{{ item.label }}</strong><small>{{ item.unit }}</small></div>
               <a-input-number v-model:value="item.value" class="indicator-input" :disabled="loading" :min="0" :precision="3" placeholder="瀹炴祴鍊�" />
               <span class="range-separator">鑼冨洿</span>
-              <a-input-number v-model:value="item.minValue" class="range-input" :disabled="loading" :min="0" :max="100" :precision="3" placeholder="涓嬮檺" />
+              <a-input-number v-model:value="item.minValue" class="range-input" :disabled="loading" :min="0" :precision="3" placeholder="涓嬮檺" />
               <span>鈥�</span>
-              <a-input-number v-model:value="item.maxValue" class="range-input" :disabled="loading" :min="0" :max="100" :precision="3" placeholder="涓婇檺" />
+              <a-input-number v-model:value="item.maxValue" class="range-input" :disabled="loading" :min="0" :precision="3" placeholder="涓婇檺" />
               <a-tag :color="!allEntered ? 'default' : isPassed(item) ? 'success' : 'error'">{{ !allEntered ? '寰呭綍鍏�' : isPassed(item) ? '鍚堟牸' : '瓒呭嚭鑼冨洿' }}</a-tag>
             </div>
           </div>
@@ -356,9 +353,9 @@
 
       <a-card class="result-card" :bordered="false">
         <template #title><div class="card-title"><IconifyIcon icon="ep:data-analysis" />鍒ゅ畾璇存槑</div></template>
-        <div class="result-hero" :class="overallPassed ? 'passed' : allEntered ? 'failed-result' : 'pending-result'"><IconifyIcon :icon="overallPassed ? 'ep:circle-check-filled' : allEntered ? 'ep:warning-filled' : 'ep:edit-pen'" /><strong>{{ overallPassed ? '褰撳墠缁撴灉鍚堟牸' : allEntered ? '褰撳墠瀛樺湪涓嶅悎鏍奸」' : '绛夊緟褰曞叆鎸囨爣' }}</strong><span>{{ allEntered ? '瀹炴祴鍊奸渶澶勪簬鏈�灏忓�间笌鏈�澶у�间箣闂�' : `宸插綍鍏� ${enteredCount} / 4 椤瑰疄娴嬪�糮 }}</span></div>
-        <div class="rule-list"><div><IconifyIcon icon="ep:check" /><span>鍏堣瘑鍒爜鍊煎啀褰曞叆鎸囨爣锛屽洓椤规寚鏍囧繀椤诲叏閮ㄦ彁浜�</span></div><div><IconifyIcon icon="ep:check" /><span>杈圭晫鍊兼寜鍚堟牸澶勭悊</span></div><div><IconifyIcon icon="ep:check" /><span>鎵樼洏鐮併�佹壒娆$爜鐨勭粨璁哄簲鐢ㄤ簬鏈鍏ㄩ儴寰呮琚�</span></div><div><IconifyIcon icon="ep:check" /><span>涓嶅悎鏍肩粨鏋滈渶淇濈暀鍘熷洜</span></div><div><IconifyIcon icon="ep:check" /><span>璐ㄦ鍛樹笌妫�楠屾椂闂寸敱鏈嶅姟绔褰�</span></div></div>
-        <a-alert message="澶嶆瀹℃牳瀹屾垚鍚庢祦杞簱瀛�" description="鍒濇鍙婂妫�鏈熼棿琚嬬爜鐣欏湪鏆傚瓨搴撱�傚垵妫�瀹℃牳閫氳繃鍚庤繘鍏ュ妫�锛涘妫�鍚堟牸骞跺鏍搁�氳繃鎵嶈浆鍏ュ悎鏍煎簱锛屽妫�涓嶅悎鏍肩粡纭鍚庢墠鎶ュ簾銆�" type="info" show-icon />
+        <div class="result-hero" :class="overallPassed ? 'passed' : allEntered ? 'failed-result' : 'pending-result'"><IconifyIcon :icon="overallPassed ? 'ep:circle-check-filled' : allEntered ? 'ep:warning-filled' : 'ep:edit-pen'" /><strong>{{ overallPassed ? '褰撳墠缁撴灉鍚堟牸' : allEntered ? '褰撳墠瀛樺湪涓嶅悎鏍奸」' : '绛夊緟褰曞叆鎸囨爣' }}</strong><span>{{ allEntered ? '瀹炴祴鍊奸渶澶勪簬鏈�灏忓�间笌鏈�澶у�间箣闂�' : `宸插綍鍏� ${enteredCount} / ${indicators.length} 椤瑰疄娴嬪�糮 }}</span></div>
+        <div class="rule-list"><div><IconifyIcon icon="ep:check" /><span>鍏堣瘑鍒爜鍊煎啀褰曞叆鎸囨爣锛屼骇鍝侀厤缃殑璐ㄦ椤瑰繀椤诲叏閮ㄦ彁浜�</span></div><div><IconifyIcon icon="ep:check" /><span>鍔犲伐閮ㄣ�侀攢鍞儴鍚勮嚜鎻愪氦瀹炴祴鍊间笌妫�楠岀粨璁�</span></div><div><IconifyIcon icon="ep:check" /><span>杈圭晫鍊兼寜鍚堟牸澶勭悊</span></div><div><IconifyIcon icon="ep:check" /><span>鎵樼洏鐮併�佹壒娆$爜鐨勭粨璁哄簲鐢ㄤ簬鏈鍏ㄩ儴寰呮琚�</span></div><div><IconifyIcon icon="ep:check" /><span>涓嶅悎鏍肩粨鏋滈渶淇濈暀鍘熷洜</span></div><div><IconifyIcon icon="ep:check" /><span>璐ㄦ鍛樹笌妫�楠屾椂闂寸敱鏈嶅姟绔褰�</span></div></div>
+        <a-alert message="鍙岀嚎瀹℃壒瀹屾垚鍚庤繘鍏ュ叕鍙歌川妫�瀹℃壒" description="鍒濇涓嶅悎鏍煎厛澶嶆锛屾湡闂磋鐮佺暀鍦ㄦ殏瀛樺簱銆備袱鏉¤川妫�绾垮悇鑷畬鎴愰儴闂ㄥ鎵瑰悗鍙戣捣鍏徃璐ㄦ瀹℃壒锛涘叕鍙稿鎵归�氳繃鎵嶈浆鍏ュ悎鏍煎簱锛屼换涓�鏉$嚎涓嶅悎鏍煎垯鏁磋鎶ュ簾銆�" type="info" show-icon />
         <div v-if="submittedCount" class="success-note"><IconifyIcon icon="ep:success-filled" /><span>鏈�杩戞彁浜よ川妫�锛�<strong>{{ submittedCount }} 琚�</strong></span></div>
       </a-card>
     </section>

--
Gitblit v1.9.3