diff --git a/src/commands/form/create.ts b/src/commands/form/create.ts index 6b16079..e75fad9 100644 --- a/src/commands/form/create.ts +++ b/src/commands/form/create.ts @@ -775,6 +775,41 @@ export function buildFormCreateCommand(): Command { } else { log.warn(`v0.7.4 webType=${webType} 但 tables[0] 无用户字段, ★ 场景 A 走 Web 设计器勾选 (columnList 留空)`) } + } else if (webType !== 1 && opts.aiJson) { + // v0.11f+ B-15 修复 (2026-06-27 tds_batch3): --ai-json 路径下, 从 formData.fields 推 columnList + // 根因: --ai-json 走 web buildFormData, formData.fields 有完整 __config__/__vModel__/jnpfKey + // 旧逻辑只对 --tables 路径 (场景 B) 自动推 columnList, --ai-json (场景 A) 留空 + // → webType=2 校验失败: "列表字段不允许为空" + // 修: 复用 buildColumnListEntry (与场景 B 同结构), 数据源从 formData.fields 来 + const formFields = (formData?.fields || []) as any[] + // 排除子表容器 (jnpfKey='table') + 子表内字段 (isSubTable=true) + const userFormFields: any[] = [] + for (const f of formFields) { + if (!f) continue + const cfg = f.__config__ + if (!cfg) continue + if (cfg.jnpfKey === 'table') continue // 子表容器 + // 主子表: 子表内字段的 __config__.isSubTable=true, 不要进主表 columnList + if (cfg.isSubTable) continue + // 排除系统字段 (f_id / f_tenant_id / f_flow_* / f_sort_code / f_create_* / f_modify_* / f_description) + const vmodel = f.__vModel__ || '' + if (SYSTEM_FIELDS.has(String(vmodel).toLowerCase())) continue + userFormFields.push(f) + } + if (userFormFields.length > 0) { + const entries = userFormFields.map((f: any) => { + const jnpfKey = f.__config__?.jnpfKey || 'input' + const label = f.__config__?.label || f.__vModel__ || '' + const prop = f.__vModel__ || f.id || label + const e = buildColumnListEntry({ field: prop, fieldName: label }, jnpfKey) + return e + }) + columnDataObj.columnList = entries + columnDataObj.searchList = entries.map(buildSearchListEntry) + log.info(`B-15 修复: --ai-json 路径从 formData.fields 自动生成 columnList: ${entries.length} 个字段`) + } else { + log.warn(`B-15: --ai-json 路径 formData.fields 为空, ★ 走 Web 设计器勾选`) + } } else if (webType !== 1) { log.info(`★ 场景 A: columnList 留空, 去 formDesign Web 设计器第二步"列表设计"手动勾选字段`) }