fix(报表定义): 编辑时剔除类型注册清单中不存在的失效字段
This commit is contained in:
parent
ae95560aef
commit
d02d68867a
@ -170,6 +170,19 @@ function handleTypeChange() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑时对比报表定义既有字段与该类型注册字段清单(getReportTypeFields,来自 report.definition.typeList):
|
||||||
|
* - 类型命中注册清单时,仅保留清单中仍存在的字段 —— 类型字段清单变更后,自动剔除 list 中残留的失效字段
|
||||||
|
* - 类型未命中注册清单(历史遗留/已下架类型)时,保留全部既有字段,交由 currentTypeFields 兜底展示,避免全部被过滤导致无法提交
|
||||||
|
*/
|
||||||
|
function resolveEditableFields(fields: any[] | undefined, typeKey: string): string[] {
|
||||||
|
if (!Array.isArray(fields)) return []
|
||||||
|
const registered = getReportTypeFields(typeKey)
|
||||||
|
if (!registered.length) return fields.map(String)
|
||||||
|
const registeredKeys = new Set(registered.map((f) => f.key))
|
||||||
|
return fields.map(String).filter((k) => registeredKeys.has(k))
|
||||||
|
}
|
||||||
|
|
||||||
watch(() => props.visible, async (v) => {
|
watch(() => props.visible, async (v) => {
|
||||||
if (v) {
|
if (v) {
|
||||||
// 打开前确保类型注册清单已加载
|
// 打开前确保类型注册清单已加载
|
||||||
@ -177,7 +190,8 @@ watch(() => props.visible, async (v) => {
|
|||||||
form.name = props.name ?? ''
|
form.name = props.name ?? ''
|
||||||
form.type = props.type ?? ''
|
form.type = props.type ?? ''
|
||||||
form.file_name = props.file_name ?? ''
|
form.file_name = props.file_name ?? ''
|
||||||
form.fields = Array.isArray(props.fields) ? [...props.fields] : []
|
// 编辑时对比字段:剔除当前类型注册清单中不存在的失效字段
|
||||||
|
form.fields = resolveEditableFields(props.fields, form.type)
|
||||||
form.is_enabled = props.is_enabled ?? 1
|
form.is_enabled = props.is_enabled ?? 1
|
||||||
form.remark = props.remark ?? ''
|
form.remark = props.remark ?? ''
|
||||||
formRef.value?.clearValidate?.()
|
formRef.value?.clearValidate?.()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user