fix(form create): v0.7.4 自动生成 columnList + searchList (盲点 50)
浏览器实测发现 webType≠1 (有列表) 的 form 保存时, jnpf 强制要求 columnList 至少 1 个 entry, 否则报 '列表字段不允许为空' toast 2 次. v0.7.4 改动: 1. columnDataObj 加完整 39 字段结构 (e2eTest1 baseline 反推) 2. 自动从 tables[0].fields 生成 columnList + searchList 3. 排除系统字段: f_id, f_tenant_id, f_flow_*, f_sort_code, f_create_*, f_modify_*, f_description 4. 优先用 rawFields 的 label (jnpf 控件标题), 退到 fieldName 5. type 字段必须是 number (parseInt 校验), 不是 string 验证: dacliFix02 form (id=836694902208210117) 创建+发布+挂菜单+加数据+列数据 全部 200 - 列数据: 2 行 (新加 1 + e2eTest1 复用 1) 参考: docs/tdd/e2e-formDesign-2026-06-16-r2/summary-r2.md (盲点 50 闭环) Co-Authored-By: Claude <[email protected]>
This commit is contained in:
1 parent
7b16fd941d
commit
7e4f13353a
1 file changed
+83
-5
@@ -193,16 +193,63 @@ export function buildFormCreateCommand(): Command {
|
||||
// v0.7.1 fix (盲点 23): 必须显式 4 个 use*Permission 字段, 否则后端 VisualUtil.setPcPermission
|
||||
// 解开 Boolean (columnData.getUseBtnPermission().booleanValue()) NPE → 返 "System abnormality"
|
||||
// 见 jnpf VisualUtil.java:139 + 后端 log_error.log
|
||||
const columnDataObj = {
|
||||
columnOptions: [],
|
||||
searchList: [],
|
||||
formData: {},
|
||||
//
|
||||
// v0.7.4 (盲点 50): 必传 columnList + searchList, 否则 webType≠1 (有列表) 保存报
|
||||
// "列表字段不允许为空" toast 2 次. 参考 e2eTest1 (id=836658473499370693) columnData 结构:
|
||||
// columnList[0] = {label, labelI18nCode, prop, fixed, headerAlign, align, sortable,
|
||||
// width, jnpfKey, __vModel__, __config__, fullName, id}
|
||||
// searchList[0] = {... + sourceType, value, searchType, searchMultiple, isKeyword, noShow}
|
||||
// 排除系统字段 (f_id / f_tenant_id / f_flow_* / f_sort_code / f_create_* / f_modify_* / f_description)
|
||||
const SYSTEM_FIELDS = new Set([
|
||||
'f_id', 'f_tenant_id',
|
||||
'f_flow_task_id', 'f_flow_id', 'f_flow_state',
|
||||
'f_sort_code',
|
||||
'f_create_user', 'f_create_time', 'f_modify_user', 'f_modify_time',
|
||||
'f_description',
|
||||
])
|
||||
const buildColumnListEntry = (field: any) => {
|
||||
const label = field.fieldName || field.field
|
||||
const prop = field.field
|
||||
return {
|
||||
label, labelI18nCode: '', prop,
|
||||
fixed: 'none', headerAlign: 'left', align: 'left',
|
||||
sortable: false, width: null,
|
||||
jnpfKey: 'input',
|
||||
__vModel__: prop,
|
||||
__config__: { jnpfKey: 'input', label, showLabel: true, tableName: opts.enCode, formId: `formItem${opts.enCode}` },
|
||||
fullName: label, id: prop,
|
||||
}
|
||||
}
|
||||
const buildSearchListEntry = (entry: any) => ({
|
||||
...entry,
|
||||
sourceType: 2, value: '', searchType: 1, searchMultiple: 0, isKeyword: false, noShow: false,
|
||||
})
|
||||
|
||||
const columnDataObj: any = {
|
||||
// type: 1=table 2=tree 3=group (JNPF 后端 parseInt, 必须 number, 不是 string)
|
||||
type: 1, pageSize: 20,
|
||||
showSummary: false, summaryField: '',
|
||||
btnsList: [], btnsPosition: 'right', rowBtnsList: [], columnBtnsList: [],
|
||||
sortList: [],
|
||||
useColumnPermission: false, columnPermissions: [],
|
||||
defaultSortConfig: {},
|
||||
useDataInterface: false, dataInterfaceId: '',
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
showCheckbox: false,
|
||||
usePage: true, useAdvancedQuery: true, useFilter: true, useSort: true,
|
||||
useOverflow: true, useDragSort: true,
|
||||
hasPrint: false, printId: '', printBtnPosition: 'right',
|
||||
cardListConfig: {},
|
||||
complexHeaderList: [], complexHeaderConfig: {},
|
||||
useCustomBtns: false, customBtnsList: [],
|
||||
columnList: [], searchList: [],
|
||||
appColumnOptions: [], appColumnList: [],
|
||||
tableConfig: { border: true, stripe: false, size: 'default', showRadio: false, showRowNumber: true },
|
||||
relationForm: { ' popupTable': '', columnOptions: [], searchForms: [] },
|
||||
useBtnPermission: false,
|
||||
useColumnPermission: false,
|
||||
useFormPermission: false,
|
||||
useDataPermission: false,
|
||||
hasPage: true, hasDefaultValue: false, hasSuperQuery: false, hasTreeQuery: false,
|
||||
}
|
||||
const tables = opts.tables
|
||||
? JSON.parse(opts.tables)
|
||||
@@ -223,6 +270,37 @@ export function buildFormCreateCommand(): Command {
|
||||
},
|
||||
]
|
||||
|
||||
// v0.7.4 (盲点 50): 自动从 tables[0].fields 生成 columnList + searchList
|
||||
// 排除系统字段; 仅在 webType != 1 (有列表) 时生成; 优先取 rawFields 的 label
|
||||
if (webType !== 1 && Array.isArray(tables) && tables.length > 0) {
|
||||
const mainTable = tables[0] as { fields?: any[] }
|
||||
const userFields = (mainTable.fields || []).filter((f: any) => f && f.field && !SYSTEM_FIELDS.has(f.field))
|
||||
if (userFields.length > 0) {
|
||||
// 用 rawFields 的 label 优先 (jnpf 字段有 "控件标题"), 否则用 field.fieldName
|
||||
const labelByField = new Map<string, string>()
|
||||
for (const rf of rawFields as any[]) {
|
||||
const v = rf.__vModel__ || rf.__id__ || rf.id || rf.vmodel
|
||||
const lbl = (rf.__config__ && rf.__config__.label) || rf.label || rf.fieldName
|
||||
if (v && lbl) labelByField.set(v, lbl)
|
||||
}
|
||||
const entries = userFields.map((f: any) => {
|
||||
const e = buildColumnListEntry(f)
|
||||
const lbl = labelByField.get(f.field)
|
||||
if (lbl) {
|
||||
e.label = lbl
|
||||
e.fullName = lbl
|
||||
if (e.__config__) (e.__config__ as any).label = lbl
|
||||
}
|
||||
return e
|
||||
})
|
||||
columnDataObj.columnList = entries
|
||||
columnDataObj.searchList = entries.map(buildSearchListEntry)
|
||||
log.info(`v0.7.4 自动生成 columnList + searchList: ${entries.length} 个字段 (排除系统字段)`)
|
||||
} else {
|
||||
log.warn(`v0.7.4 webType=${webType} 但 tables[0] 无用户字段, 仍可能报"列表字段不允许为空"`)
|
||||
}
|
||||
}
|
||||
|
||||
const body: Record<string, unknown> = {
|
||||
fullName: opts.fullName,
|
||||
enCode: opts.enCode,
|
||||
|
||||
Reference in new issue
Block a user