fix(storage-cert-qc): 保存时忽略无权预填字段,避免质检账号 403 (#196)

前端仅提交 editableFieldKeys;后端 merge 对无权键改为忽略不落库,防止预填只读值整表提交误伤保存。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-12-03 17:24:27 +08:00
1 parent feb9e0f655
commit f5359ff516
8 files changed
+76 -31

No files matched your search

@@ -164,6 +164,7 @@
import StorageCertQcAclDialog from '@/components/business/storage-cert-qc-acl-dialog/index.vue'
import {
STORAGE_CERT_QC_GROUPS,
buildStorageCertQcSavePayload,
isPerinatalQualField,
mergeStorageCertPrefill,
normalizeQualValue,
@@ -299,12 +300,14 @@
ElMessage.warning('当前无字段编辑权限')
return
}
const payload: Record<string, unknown> = {}
for (const group of groups.value) {
for (const field of group.fields) {
const v = form[field.key]
payload[field.key] = v == null ? '' : v
}
const payload = buildStorageCertQcSavePayload(
form,
editableKeySet.value,
typeKey.value
)
if (Object.keys(payload).length === 0) {
ElMessage.warning('当前无字段编辑权限')
return
}
saving.value = true
try {
@@ -205,3 +205,28 @@ export function mergeStorageCertPrefill(
}
return out
}
/**
* 保存时只带可编辑字段,避免预填只读值(如生产专属 cryo_volume_ml)被整表提交。
*/
export function buildStorageCertQcSavePayload(
form: Record<string, unknown>,
editableKeys: Iterable<string>,
typeKey: StorageCertQcTypeKey | null | undefined
): Record<string, unknown> {
const allowed = new Set(
Array.from(editableKeys || [])
.map((k) => String(k || '').trim())
.filter(Boolean)
)
const payload: Record<string, unknown> = {}
if (!typeKey || allowed.size === 0) return payload
for (const group of STORAGE_CERT_QC_GROUPS[typeKey] || []) {
for (const field of group.fields) {
if (!allowed.has(field.key)) continue
const v = form[field.key]
payload[field.key] = v == null ? '' : v
}
}
return payload
}