dacli: BS-60 guard columnList jnpfKey + relationForm columnOptions
This commit is contained in:
1 parent
32a5a566e2
commit
12af1db98f
1 file changed
+49
@@ -682,6 +682,55 @@ export const BLINDSPOT_GUARDS: BlindspotGuard[] = [
|
||||
message: 'BS-54: select 字段需 (dataType=static + options) / (dataType=dictionary + dictionaryType) / (dataType=dynamic + propsUrl) 之一; relationForm 字段需 modelId 非空 (RelationForm.vue:201 缺 modelId 直接 return)',
|
||||
fix: '用 FieldBuilder.build("select"/"relationForm") 自动补默认值; 或显式传 dataType/options/dictionaryType/propsUrl/modelId',
|
||||
},
|
||||
|
||||
// BS-60 (2026-06-25 tdd9): columnList[*].jnpfKey 必须是控件类型 (input/select/...) 不是物理列名
|
||||
// 根因: 前端 vxe-table 渲染 columnList 用 jnpfKey 决定单元格组件, 错值(f_name/f_code)→ 列空白
|
||||
// relationForm columnOptions[*].value 必须是真实字段名, 不能用占位 (code_field/name_field) → 弹窗取不到数据
|
||||
{
|
||||
id: 'BS-60',
|
||||
trigger: 'columnList[*].jnpfKey 用了物理列名 / relationForm columnOptions 用占位字段',
|
||||
level: 'ERROR',
|
||||
check: (_ctx, opts) => {
|
||||
const fields = opts?.fields as Array<Record<string, unknown>> | undefined
|
||||
if (!fields || !Array.isArray(fields)) return false
|
||||
// 物理列名前缀 (dm 默认规范)
|
||||
const PHYSICAL_PREFIX = /^f_/
|
||||
// 合法 jnpfKey 控件类型
|
||||
const VALID_JNPF_KEYS = new Set([
|
||||
'input', 'textarea', 'inputNumber', 'select', 'datePicker', 'timePicker',
|
||||
'userSelect', 'relationForm', 'uploadImg', 'uploadFile', 'switch', 'checkbox',
|
||||
'radio', 'cascader', 'createUser', 'createTime', 'modifyUser', 'modifyTime',
|
||||
'billRule', 'groupTitle', 'divider', 'qrcode', 'barcode', 'slider', 'rate',
|
||||
'colorPicker', 'editor', 'popup', 'popupAttr', 'table', 'collapse',
|
||||
])
|
||||
for (const f of fields) {
|
||||
const cfg = (f.__config__ as Record<string, unknown>) || {}
|
||||
const vmodel = f.__vModel__ as string | undefined
|
||||
const jk = cfg.jnpfKey as string | undefined
|
||||
// formData 字段: __vModel__ 可以是 f_xxx (物理列名), jnpfKey 必须是控件类型
|
||||
if (jk && !VALID_JNPF_KEYS.has(jk)) return true
|
||||
// vmodel = f_xxx 但 jnpfKey 不是 createTime/createUser 等 (这些系统字段也用 f_create_xxx)
|
||||
// 业务字段 jnpfKey 应是 'input' 等控件类型
|
||||
if (vmodel && PHYSICAL_PREFIX.test(vmodel) && jk && !jk.startsWith('create') && !jk.startsWith('modify') && !VALID_JNPF_KEYS.has(jk)) {
|
||||
return true
|
||||
}
|
||||
// relationForm columnOptions value 必是真实字段 (f_xxx 或非 code_field/name_field)
|
||||
if (jk === 'relationForm') {
|
||||
const colOpts = f.columnOptions as Array<{ value?: string }> | undefined
|
||||
if (Array.isArray(colOpts)) {
|
||||
for (const co of colOpts) {
|
||||
if (co && co.value && (co.value === 'code_field' || co.value === 'name_field')) {
|
||||
return true // 占位符
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
},
|
||||
message: 'BS-60: formData.fields[*].__config__.jnpfKey 必须是控件类型 (input/select/...) 不是物理列名; relationForm fields[*].columnOptions[*].value 必须用真实字段名 (f_xxx), 不能用 code_field/name_field 占位',
|
||||
fix: 'columnList/fields jnpfKey 改用 input/select/userSelect/relationForm 等控件类型; relationForm columnOptions value 改用 f_xxx 真实字段名 (前端弹窗拿真实数据)',
|
||||
},
|
||||
]
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user