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/mobile/quality-records.vue | 69 +++++++++++++---------------------
1 files changed, 26 insertions(+), 43 deletions(-)
diff --git a/src/views/mobile/quality-records.vue b/src/views/mobile/quality-records.vue
index dceff3b..cdac3ca 100644
--- a/src/views/mobile/quality-records.vue
+++ b/src/views/mobile/quality-records.vue
@@ -6,7 +6,6 @@
import {
approveSeedQualityBatch,
- getSeedIndicatorRanges,
getSeedQualityPage,
resolveSeedQuality,
resolveSeedRetestScope,
@@ -33,44 +32,27 @@
const rows = ref<SeedQualityRecord[]>([]), busy = ref(false), error = ref(''), notice = ref('');
const scanType = ref<'BATCH' | 'PALLET'>('PALLET'), scannedCode = ref('');
+const qcLine = ref<1 | 2>(1);
const scope = ref<SeedRetestScope>(), initialScope = ref<SeedQualityScan>();
const workflowStatus = ref<10 | 50>(10), reason = ref('');
const warehouseId = ref<number>();
const warehouseOptions = ref<Array<{ label: string; value: number }>>([]);
const reviewGroup = ref<ReviewGroup>(), reviewApproved = ref(true), reviewOpinion = ref('');
-const indicators = ref([
- { code: 'purity', name: '绾害', value: '', minValue: '', maxValue: '' },
- { code: 'cleanliness', name: '鍑�搴�', value: '', minValue: '', maxValue: '' },
- { code: 'germination_rate', name: '鍙戣娊鐜�', value: '', minValue: '', maxValue: '' },
- { code: 'moisture', name: '姘村垎', value: '', minValue: '', maxValue: '' },
-]);
+const indicators = ref<Array<{ code: string; name: string; unit: string; value: string; minValue: string; maxValue: string }>>([]);
const initialIds = computed(() => initialScope.value?.pendingBagIds || []);
const targetIds = computed(() => workflowStatus.value === 10 ? scope.value?.retestIds || [] : scope.value?.initialRecheckIds || []);
-const complete = computed(() => indicators.value.every((item) =>
+const complete = computed(() => indicators.value.length > 0 && indicators.value.every((item) =>
[item.value, item.minValue, item.maxValue].every((value) => String(value).trim() !== '' && Number.isFinite(Number(value)))
- && Number(item.value) >= 0 && Number(item.value) <= 100 && Number(item.minValue) >= 0
- && Number(item.maxValue) <= 100 && Number(item.minValue) <= Number(item.maxValue)));
+ && Number(item.value) >= 0 && Number(item.minValue) >= 0
+ && Number(item.maxValue) >= 0 && Number(item.minValue) <= Number(item.maxValue)));
const passed = computed(() => complete.value && indicators.value.every((item) =>
Number(item.value) >= Number(item.minValue) && Number(item.value) <= Number(item.maxValue)));
-const reviewGroups = computed<ReviewGroup[]>(() => {
- if (!scope.value) return [];
- return [
- { status: 20, stage: 'process' as const, ids: scope.value.pendingProcessIds || [] },
- { status: 25, stage: 'process' as const, ids: scope.value.pendingInitialFailIds || [] },
- { status: 30, stage: 'company' as const, ids: scope.value.pendingCompanyIds || [] },
- { status: 60, stage: 'company' as const, ids: scope.value.pendingCompanyFailIds || [] },
- ].filter((group) => group.ids.length && (group.stage === 'process' ? canProcessReview.value : canCompanyReview.value));
-});
+const reviewGroups = computed<ReviewGroup[]>(() => []);
const statusNames: Record<number, string> = {
- 10: '寰呭妫�', 20: '寰呭垵妫�瀹℃牳', 25: '寰呭垵妫�涓嶅悎鏍煎鐞�', 30: '寰呭妫�瀹℃牳',
- 40: '宸叉斁琛�', 50: '寰呴噸鏂板垵妫�', 60: '寰呭妫�涓嶅悎鏍煎鐞�', 70: '宸叉姤搴�',
+ 10: '寰呭妫�', 20: '寰呴儴闂ㄥ鎵�', 25: '寰呴儴闂ㄤ笉鍚堟牸瀹℃壒', 30: '寰呭叕鍙歌川妫�瀹℃壒',
+ 40: '宸叉斁琛�', 50: '寰呴噸鏂板垵妫�', 60: '寰呭叕鍙歌川妫�涓嶅悎鏍煎鎵�', 70: '宸叉姤搴�',
};
-
-function resetIndicators() {
- indicators.value.forEach((item) => { item.value = ''; });
- reason.value = '';
-}
async function hydrateReviewIds(current: SeedRetestScope, rawCode: string) {
const loaded = (current.pendingProcessIds?.length || 0) + (current.pendingInitialFailIds?.length || 0)
@@ -99,13 +81,18 @@
try {
const codeValue = extractCode(raw);
scannedCode.value = codeValue;
- const current = await resolveSeedRetestScope(codeValue, scanType.value);
+ const current = await resolveSeedRetestScope(codeValue, scanType.value, qcLine.value);
await hydrateReviewIds(current, codeValue);
scope.value = current;
scanType.value = current.scanType;
workflowStatus.value = current.retestIds.length ? 10 : 50;
- initialScope.value = await resolveSeedQuality(codeValue, current.scanType);
- resetIndicators();
+ initialScope.value = await resolveSeedQuality(codeValue, current.scanType, qcLine.value);
+ const source = current.indicators?.length ? current.indicators : initialScope.value?.indicators;
+ indicators.value = (source || []).map((item) => ({
+ code: item.code, name: item.name || item.code, unit: item.unit || '%',
+ value: '', minValue: String(item.minValue), maxValue: String(item.maxValue),
+ }));
+ reason.value = '';
if (!initialIds.value.length && !targetIds.value.length && !reviewGroups.value.length) {
notice.value = '褰撳墠鎵樼洏鎴栫敓浜ф壒娆℃病鏈夊彲澶勭悊鐨勮川妫�璁板綍銆�';
}
@@ -131,11 +118,12 @@
if (!window.confirm(`纭鎵归噺鎻愪氦 ${ids.length} 琚嬪垵妫�锛焋)) return;
busy.value = true; error.value = '';
try {
- const result = await submitSeedQualityGroup({ code: initialScope.value.code, batchCode: initialScope.value.batchCode,
+ const result = await submitSeedQualityGroup({ code: initialScope.value.code,
+ batchCode: initialScope.value.batchCode,
scanType: initialScope.value.scanType || scanType.value, bagIds: ids, qualifiedWarehouseId: warehouseId.value,
reason: reason.value.trim() || undefined, indicators: indicatorPayload() });
busy.value = false;
- await refreshScopeAndList(`宸插畬鎴� ${result.processedCount} 琚嬪垵妫�銆俙);
+ await refreshScopeAndList(`宸插畬鎴� ${result.processedCount} 琚嬪垵妫�锛屽凡鍚屾鐢熸垚鍔犲伐閮ㄣ�侀攢鍞儴涓ゆ潯璁板綍銆俙);
} catch (exception) { error.value = errorText(exception) + '銆傝閲嶆柊璇嗗埆鍚庢牳瀵瑰緟妫�娓呭崟銆�'; }
finally { busy.value = false; }
}
@@ -147,7 +135,7 @@
if (!window.confirm(`纭灏嗘湰娆℃寚鏍囩敤浜� ${ids.length} 琚�${workflowStatus.value === 10 ? '澶嶆' : '閲嶆柊鍒濇'}锛焋)) return;
busy.value = true; error.value = '';
try {
- const result = await submitSeedRetestScope({ code: scope.value.code, scanType: scope.value.scanType,
+ const result = await submitSeedRetestScope({ code: scope.value.code, scanType: scope.value.scanType, qcLine: qcLine.value,
workflowStatus: workflowStatus.value, qualityIds: ids, reason: reason.value.trim() || undefined, indicators: indicatorPayload() });
busy.value = false;
await refreshScopeAndList(`宸插畬鎴� ${result.processedCount} 琚嬫楠屻�俙);
@@ -198,13 +186,6 @@
if (warehouseOptions.value.length === 1) warehouseId.value = warehouseOptions.value[0]?.value;
} catch { warehouseOptions.value = []; }
}
- if (canInitial.value || canRetest.value) {
- try {
- const ranges = await getSeedIndicatorRanges();
- indicators.value.forEach((item) => { const range = ranges.find((row) => row.indicatorCode === item.code);
- if (range) { item.minValue = String(range.minValue); item.maxValue = String(range.maxValue); } });
- } catch { /* 鍚堟牸鑼冨洿浠嶅彲鎵嬪伐濉啓 */ }
- }
await load();
});
</script>
@@ -214,17 +195,19 @@
<h2 class="m-title">鎵归噺妫�楠屼笌瀹℃牳</h2>
<p class="m-muted">鎵弿鎵樼洏鐮佹垨鐢熶骇鎵规鐮侊紝绯荤粺浼氭寜褰撳墠璐﹀彿鏉冮檺鍒楀嚭鎵归噺鍒濇銆佸鏍搞�佸妫�鎿嶄綔銆�</p>
<label class="m-field"><span>鎵爜绫诲瀷</span><select v-model="scanType" :disabled="busy" @change="scope = undefined; initialScope = undefined"><option value="PALLET">鎵樼洏鐮�</option><option value="BATCH">鐢熶骇鎵规鐮�</option></select></label>
+ <label class="m-field"><span>璐ㄦ绾匡紙澶嶆/瀹℃牳锛�</span><select v-model.number="qcLine" :disabled="busy" @change="scope = undefined; initialScope = undefined"><option :value="1">鍔犲伐閮�</option><option :value="2">閿�鍞儴</option></select></label>
+ <p class="m-muted">鍒濇鎻愪氦浼氬悓鏃剁敓鎴愬姞宸ラ儴銆侀攢鍞儴涓ゆ潯璁板綍锛涜川妫�绾夸粎鐢ㄤ簬绛涢�夊妫�鍜屽鏍歌寖鍥淬��</p>
<Scanner :disabled="busy" @code="identifyScope" />
<template v-if="scope">
<div class="m-panel"><h3 class="m-title">宸茶瘑鍒寖鍥�</h3><dl><div class="m-row"><dt>鐮佸��</dt><dd>{{ scope.code }}</dd></div><div class="m-row"><dt>鐢熶骇鎵规</dt><dd>{{ scope.batchCode || '鈥�' }}</dd></div><div class="m-row"><dt>鏈夋晥琚嬫暟</dt><dd>{{ scope.totalCount }}</dd></div></dl></div>
<form v-if="canInitial && initialIds.length" class="m-panel" @submit.prevent="submitInitial">
- <h3 class="m-title">鎵归噺鍒濇锛坽{ Math.min(initialIds.length, 500) }} 琚嬶級</h3>
+ <h3 class="m-title">鎵归噺鍒濇锛坽{ Math.min(initialIds.length, 500) }} 琚嬶紝鍚屾椂鐢熸垚鍙岀嚎璁板綍锛�</h3>
<p v-if="!initialScope?.inbound" class="m-warning">璇ヨ寖鍥寸殑鏈夋晥琚嬬爜灏氭湭鍏ㄩ儴鍏ュ簱锛屾殏涓嶈兘鎻愪氦鍒濇銆�</p>
<template v-else>
<label class="m-field"><span>鐩爣鍚堟牸搴�</span><select v-model="warehouseId" required :disabled="busy"><option :value="undefined" disabled>璇烽�夋嫨鍚堟牸搴�</option><option v-for="item in warehouseOptions" :key="item.value" :value="item.value">{{ item.label }}</option></select></label>
- <fieldset v-for="item in indicators" :key="`initial-${item.code}`" class="m-panel m-quality-indicator" :disabled="busy"><legend>{{ item.name }}锛�%锛�</legend><label class="m-field"><span>瀹炴祴鍊�</span><input v-model="item.value" type="number" inputmode="decimal" min="0" max="100" step="any" required /></label><div class="m-grid"><label class="m-field"><span>鍚堟牸涓嬮檺</span><input v-model="item.minValue" type="number" inputmode="decimal" min="0" max="100" step="any" required /></label><label class="m-field"><span>鍚堟牸涓婇檺</span><input v-model="item.maxValue" type="number" inputmode="decimal" min="0" max="100" step="any" required /></label></div></fieldset>
+ <fieldset v-for="item in indicators" :key="`initial-${item.code}`" class="m-panel m-quality-indicator" :disabled="busy"><legend>{{ item.name }}锛坽{ item.unit || '%' }}锛�</legend><label class="m-field"><span>瀹炴祴鍊�</span><input v-model="item.value" type="number" inputmode="decimal" min="0" step="any" required /></label><div class="m-grid"><label class="m-field"><span>鍚堟牸涓嬮檺</span><input v-model="item.minValue" type="number" inputmode="decimal" min="0" step="any" required /></label><label class="m-field"><span>鍚堟牸涓婇檺</span><input v-model="item.maxValue" type="number" inputmode="decimal" min="0" step="any" required /></label></div></fieldset>
<label class="m-field"><span>{{ complete && !passed ? '涓嶅悎鏍煎師鍥狅紙蹇呭~锛�' : '妫�楠屽娉�' }}</span><textarea v-model="reason" rows="3" maxlength="500" /></label>
<button class="m-primary" :disabled="busy || !complete || !warehouseId">{{ busy ? '姝e湪鎻愪氦鈥�' : `鎻愪氦 ${Math.min(initialIds.length, 500)} 琚嬪垵妫�` }}</button>
</template>
@@ -244,7 +227,7 @@
<h3 class="m-title">鎵归噺澶嶆 / 閲嶆柊鍒濇</h3>
<label class="m-field"><span>璐ㄦ闃舵</span><select v-model="workflowStatus" :disabled="busy"><option v-if="scope.retestIds.length" :value="10">澶嶆锛坽{ scope.retestIds.length }} 琚嬶級</option><option v-if="scope.initialRecheckIds.length" :value="50">閲嶆柊鍒濇锛坽{ scope.initialRecheckIds.length }} 琚嬶級</option></select></label>
<p class="m-warning">鍚屼竴缁勬寚鏍囧皢鐢ㄤ簬鏈 {{ Math.min(targetIds.length, 500) }} 琚嬶紝璇锋牳瀵规娊鏍风粨鏋溿��</p>
- <fieldset v-for="item in indicators" :key="`retest-${item.code}`" class="m-panel m-quality-indicator" :disabled="busy"><legend>{{ item.name }}锛�%锛�</legend><label class="m-field"><span>瀹炴祴鍊�</span><input v-model="item.value" type="number" inputmode="decimal" min="0" max="100" step="any" required /></label><div class="m-grid"><label class="m-field"><span>鍚堟牸涓嬮檺</span><input v-model="item.minValue" type="number" inputmode="decimal" min="0" max="100" step="any" required /></label><label class="m-field"><span>鍚堟牸涓婇檺</span><input v-model="item.maxValue" type="number" inputmode="decimal" min="0" max="100" step="any" required /></label></div></fieldset>
+ <fieldset v-for="item in indicators" :key="`retest-${item.code}`" class="m-panel m-quality-indicator" :disabled="busy"><legend>{{ item.name }}锛坽{ item.unit || '%' }}锛�</legend><label class="m-field"><span>瀹炴祴鍊�</span><input v-model="item.value" type="number" inputmode="decimal" min="0" step="any" required /></label><div class="m-grid"><label class="m-field"><span>鍚堟牸涓嬮檺</span><input v-model="item.minValue" type="number" inputmode="decimal" min="0" step="any" required /></label><label class="m-field"><span>鍚堟牸涓婇檺</span><input v-model="item.maxValue" type="number" inputmode="decimal" min="0" step="any" required /></label></div></fieldset>
<label class="m-field"><span>{{ complete && !passed ? '涓嶅悎鏍煎師鍥狅紙蹇呭~锛�' : '妫�楠屽娉�' }}</span><textarea v-model="reason" rows="3" maxlength="500" /></label>
<button class="m-primary" :disabled="busy || !complete || !targetIds.length">{{ busy ? '姝e湪鎻愪氦鈥�' : `鎻愪氦 ${Math.min(targetIds.length, 500)} 琚嬫楠宍 }}</button>
</form>
@@ -257,7 +240,7 @@
<p class="m-muted">鏌ョ湅璐ㄦ缁撴灉銆佹壒娆′笌涓嶅悎鏍煎師鍥犮��</p>
<Scanner :disabled="busy" @code="value => { code = value; load(); }" />
<form class="m-panel" @submit.prevent="load()">
- <label class="m-field"><span>涓氬姟鐮� / 杩芥函鐮�</span><input v-model="code" :disabled="busy" placeholder="杈撳叆琚嬬爜" /></label>
+ <label class="m-field"><span>杩芥函鐮�</span><input v-model="code" :disabled="busy" placeholder="杈撳叆琚嬬爜" /></label>
<label class="m-field"><span>鐢熶骇鎵规</span><input v-model="batchCode" :disabled="busy" placeholder="杈撳叆鎵规鍙�" /></label>
<label class="m-field"><span>璐ㄦ缁撴灉</span><select v-model="result" :disabled="busy"><option value="">鍏ㄩ儴缁撴灉</option><option value="1">鍚堟牸</option><option value="2">涓嶅悎鏍�</option></select></label>
<button class="m-secondary" :disabled="busy">{{ busy ? '姝e湪鏌ヨ鈥�' : '鏌ヨ璁板綍' }}</button>
--
Gitblit v1.9.3