| | |
| | | |
| | | import { |
| | | approveSeedQualityBatch, |
| | | getSeedIndicatorRanges, |
| | | getSeedQualityPage, |
| | | resolveSeedQuality, |
| | | resolveSeedRetestScope, |
| | |
| | | |
| | | 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) |
| | |
| | | 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 = '当前托盘或生产批次没有可处理的质检记录。'; |
| | | } |
| | |
| | | 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; } |
| | | } |
| | |
| | | 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} 袋检验。`); |
| | |
| | | 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> |
| | |
| | | <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 ? '正在提交…' : `提交 ${Math.min(initialIds.length, 500)} 袋初检` }}</button> |
| | | </template> |
| | |
| | | <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 ? '正在提交…' : `提交 ${Math.min(targetIds.length, 500)} 袋检验` }}</button> |
| | | </form> |
| | |
| | | <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 ? '正在查询…' : '查询记录' }}</button> |