diff --git a/src/commands/form/create.ts b/src/commands/form/create.ts index c73e117..eb93263 100644 --- a/src/commands/form/create.ts +++ b/src/commands/form/create.ts @@ -55,13 +55,11 @@ interface CreateOpts { ai?: string /** 5.10.2 AI 推荐字段 — 自然语言描述, 平台 LLM 推荐单字段, 不建表单 */ aiField?: string - /** - * v0.11+ Task 10: --ai-json 直入 JSON (跳过 AI 调用) - * 接受 List 数组, 直接喂给 web 端 buildFormData - * 用于: AI/用户在会话里已生成 JSON, 不需要再调 LLM - * 例: --ai-json '[{"tableTitle":"客户表","tableName":"customer","isMain":true,"fields":[...]}]' - */ - aiJson?: string + // v0.12+ BS-新28: 删除 --ai-json 选项 (逻辑重复) + // --ai-json: 用户直传 JSON → web buildFormData (跟 --ai 后半段完全一样) + // --ai: NCPF backend AI → VisualAiModel → web buildFormData + // 区别只在 AI 那步, 后面 buildFormData + create 路径一致 + // 保留 --ai 和 --ai-field, 删 --ai-json 避免两条相似代码路径漂移 /** Phase 3: 浏览器层验证开关 (默认硬阻塞) */ noVerify?: boolean verifyMode?: string @@ -234,7 +232,7 @@ async function autoDeriveCategoryFromBusinessType( export function buildFormCreateCommand(): Command { const cmd = new Command('create') - .description('★ AI 快速建表单 (默认 --ai-json --autoRelease 一条命令完整: 不建物理表, dacli 自动 fallback schema, 走 formDesign Web 设计器调字段). 高级模式: --tables=... 显式引用已存在物理表') + .description('★ AI 快速建表单 (--ai "<描述>" 一条命令: NCPF backend AI + web buildFormData + 自动发布. --ai-field 只问 AI 不建表单. 高级模式: --tables=... 显式引用已存在物理表)') .option('--fullName ', '中文名 (--ai 自动填, 否则必填)') .option('--enCode ', '英文编码 (--ai 自动填, 否则必填)') .option('--type ', '1=自定义(formDesign) 2=系统(sysForm) 3=接口 4=视图', '1') @@ -250,9 +248,8 @@ export function buildFormCreateCommand(): Command { .option('--autoCreateMenu', '发布后自动挂菜单 (需传 --menuParentId, 避免浏览器验证找不到 list 页)', false) .option('--menuParentId ', '挂菜单的父目录 id (--autoCreateMenu 时必传; 走 dacli menu list --keyword=... 拿)') .option('--no-relation-form-auto', '关闭 relationForm 字段自动注入 (v0.11h+ BS-18 fix, 默认 ON; 用于 *_code 等业务编码字段被误判为关系字段时)') - .option('--ai ', '白皮书 5.10.1 AI 快速建表 — 自然语言描述, 平台 LLM 生成 enCode/fullName/fields (推荐走 --ai-json 路径跳过 LLM 调用, v0.11+)') + .option('--ai ', '白皮书 5.10.1 AI 快速建表 — 自然语言描述, 平台 LLM 生成 enCode/fullName/fields (走 NCPF backend /api/visualdev/ai/form, v0.12+ 默认 autoRelease=true)') .option('--ai-field ', '白皮书 5.10.2 AI 推荐字段 — 自然语言描述, 平台 LLM 推荐单字段, 只输出建议不建表单') - .option('--ai-json ', 'v0.11+ Task 10: AI 描述直接转 JSON 直入 — 跳过 LLM 调用, AI/用户在会话里生成 List 喂给 buildFormData. 适合会话内已有 JSON 的场景') .option('--no-verify', '跳过浏览器层验证') .option('--verify ', '失败模式: warn (默认, v0.12+ jxcj) | block', 'warn') .option('--verify-timeout ', '浏览器验证超时 (默认 60s)', '60000') @@ -266,304 +263,6 @@ export function buildFormCreateCommand(): Command { if (opts.json) printJson(data) return } - // v0.11+ Task 10: --ai-json 直入 JSON (跳过 AI 调用) - // 接受 List JSON, 直接喂给 buildFormData - if (opts.aiJson) { - log.info(`--ai-json — 直入 JSON (跳过 LLM 调用, v0.11+ 新路径)`) - let aiModelList: any[] - try { - aiModelList = JSON.parse(opts.aiJson) - } catch (e: any) { - log.error(`--ai-json JSON 解析失败: ${e.message}`) - log.error('期望格式: [{"tableTitle":"...", "tableName":"...", "isMain":true, "fields":[...]}])') - process.exit(2) - } - if (!Array.isArray(aiModelList) || aiModelList.length === 0) { - log.error('--ai-json 必须是 List 非空数组') - process.exit(2) - } - // 2026-06-26 v0.11d 兼容: AI prompt 规范字段名是 fieldName, 但 dacli 历史示例用 field - // web buildFormData (formUtils.ts:29) 读 child.fieldName, 缺则 __vModel__=undefined → form 字段丢 vmodel - // 这里兼容映射: field → fieldName (有 fieldName 优先用, 没有再 fallback field) - for (const m of aiModelList) { - if (Array.isArray(m?.fields)) { - for (const fld of m.fields) { - if (fld && !fld.fieldName && fld.field) { - fld.fieldName = fld.field - log.info(` 字段兼容映射: field → fieldName (${fld.field})`) - } - // v0.11f+ DEV-4 fix (2026-06-27 tds_batch2): dataType 自动映射 → fieldComponent - // 原 dacli 仅兼容 `field` → `fieldName`, 但 buildFormData 读 `child.fieldComponent` - // 缺 fieldComponent 时回退到 componentList[0] = input, datetime 字段变 input - // → 后端 swapDatetime 不触发 → "Data truncation: Incorrect datetime value" - // 修: dataType → fieldComponent 映射 (兼容 v0.11a 旧 AI JSON 写法) - // - // v0.12+ jxcj-2026-06-29 fix: dictType 优先级最高 → select 控件 - // 根因: 之前 dataType=int 走 dtMap → inputNumber, 但有 dictType 时 web 端 - // 期望 select 控件 (下拉选字典项), 导致 "录入都是字符串" 错位 - // 镜像: web FormGenerator.vue 选字段时, dictType 字段强制 select 控件 - // 修: dictType 优先于 dataType, 先判断 dictType - // - // v0.12+ BS-New-5 fix (2026-06-30 jxcj): fieldRelationConfig 强制 relationForm - // 根因: 用户在 --ai-json 写 fieldRelationConfig 但没写 fieldComponent, - // dataType 走 dtMap → 'input' (因为 varchar 不在 dtMap) - // → 字段变普通输入框, relationForm 配置被忽略 - // 镜像: web FormGenerator.vue:218 选关联表单时, jnpfKey='relationForm' - // 修: fieldRelationConfig 优先级最高, 强制 fieldComponent='relationForm' - if (fld && !fld.fieldComponent) { - if (fld.fieldRelationConfig?.modelId) { - // v0.12+ BS-New-5: relationForm 最高优先级, 强制 jnpfKey - fld.fieldComponent = 'relationForm' - log.info(` BS-New-5: fieldRelationConfig.modelId=${fld.fieldRelationConfig.modelId} → fieldComponent=relationForm (${fld.fieldName || fld.field})`) - } else if (fld.dictType) { - // dictType 优先 → select (下拉字典项) - fld.fieldComponent = 'select' - log.info(` dictType ${fld.dictType} → fieldComponent=select (${fld.fieldName || fld.field})`) - } else if (fld.dataType) { - const dtMap: Record = { - datetime: 'datePicker', - date: 'datePicker', - time: 'timePicker', - int: 'inputNumber', - bigint: 'inputNumber', - decimal: 'inputNumber', - text: 'textarea', - longtext: 'textarea', - boolean: 'switch', - tinyint: 'switch', - } - const fc = dtMap[String(fld.dataType).toLowerCase()] - if (fc) { - fld.fieldComponent = fc - log.info(` dataType ${fld.dataType} → fieldComponent ${fc} (${fld.fieldName || fld.field})`) - } - } - } - } - } - } - // 强制 isMain (对齐 JNPF 后端 VisualAiServiceImpl.setIsMain(0, i==0)) - aiModelList.forEach((m: any, i: number) => { m.isMain = (i === 0) }) - // 自动填 enCode/fullName (用户未传时) - if (!opts.enCode) opts.enCode = aiModelList[0].tableName || `form_${Date.now().toString(36)}` - if (!opts.fullName) opts.fullName = aiModelList[0].tableTitle || opts.enCode - log.info(` enCode: ${opts.enCode} fullName: ${opts.fullName}`) - log.info(` 表数: ${aiModelList.length} (主表 ${aiModelList[0].fields?.length || 0} 字段)`) - - // dacli-2026-06-29-01 fix: 主子表 form create --ai-json 必传 --tables (auto 推空) 修复 - // 根因: web buildFormData (formUtils.ts:55-78) 返回 tables: '[]' (永远空), - // dacli 把空 tables 透传给后端 → 后端 create() 找不到 typeId='1' 主表 - // → "The database table name should remain unique" / "集合条件过滤获得目标为空" - // 修复: 检测到 aiModelList.length > 1 (主子表) 时, 自动从 aiModelList 构造 tables JSON - // 主表 typeId='1', 子表 typeId='2' (与 web formDesign/Form.vue:288 + 实战一致) - // 子表 relationTable 指向主表 tableName, 子表自动加 f_{主表名}_id 外键字段 - // 用户已经显式传了 --tables 则跳过 (优先用户) - if (aiModelList.length > 1 && !opts.tables) { - // 拿 appCode (此阶段 c 还没初始化, fromToken 读 token 即可) - const token = loadToken() - const appCodeForStrip = token?.appCode || null - const strip = (t: string) => - appCodeForStrip && t.startsWith(`${appCodeForStrip}_`) - ? t.slice(appCodeForStrip.length + 1) - : t - const mainTableName = strip(aiModelList[0].tableName || '') - // 约定: 子表外键 = f_{主表名}_id - const fkField = mainTableName ? `f_${mainTableName}_id` : 'f_main_id' - const constructedTables: any[] = [] - for (let i = 0; i < aiModelList.length; i++) { - const m = aiModelList[i] - const tName = strip(m.tableName || '') - if (!tName) continue - const tbl: any = { - table: tName, - tableName: m.tableTitle || tName, - typeId: i === 0 ? '1' : '2', // 主表 1, 子表 2 - comment: m.tableTitle || tName, - tableField: 'f_id', - fields: (m.fields || []).map((f: any) => ({ - field: f.field, - fieldName: f.fieldTitle || f.fieldName || f.field, - dataType: f.dataType || 'varchar', - dataLength: f.dataLength || '50', - primaryKey: f.field === 'f_id' ? 1 : 0, - allowNull: f.required ? 0 : 1, - })), - } - if (i > 0 && mainTableName) { - // 子表: 加 relationTable + relationField 关联主表 - tbl.relationTable = mainTableName - tbl.relationField = fkField - // 子表自动加外键字段 (放最前, 后端 createMast 期望) - tbl.fields.unshift({ - field: fkField, - fieldName: '主表ID', - dataType: 'varchar', - dataLength: '50', - primaryKey: 0, - allowNull: 0, - }) - } - constructedTables.push(tbl) - } - // 直接覆盖 opts.tables (跳过下方空 __aiBuildFormData.tables 推导) - opts.tables = JSON.stringify(constructedTables) - log.info(` ✓ dacli-2026-06-29-01 fix: --ai-json 主子表 (${aiModelList.length} 张), 自动构造 tables JSON (主表 typeId='1' + 子表 typeId='2' + relationTable=${mainTableName})`) - } - - // BS-18 fix (2026-06-27 + 2026-06-29 复盘强化): relationForm 字段自动检测 - // 启发式: 字段名符合 *_space / *_id 模式 → 拉 form list 匹配 enCode → - // 自动注入 fieldRelationConfig + fieldComponent='relationForm' - // v0.11h+ 修复: 去掉 _code 后缀 (业务编码如 f_team_code 误判为关系字段, BS-18) - // --no-relation-form-auto 强制关闭 (Commander.js 把 --no-xxx 转 opts.xxx=false) - // 镜像 web FormGenerator.vue:272-276 校验逻辑反向应用 (web 校验"必填", 我们主动填) - // 解决: tds_product 5 个 *_space 字段之前默认变 input (CLAUDE.md §6 违反) - if (opts.relationFormAuto !== false) { - const { autoDetectAndInjectRelationForm } = await import('./_relationForm_auto.ts') - await autoDetectAndInjectRelationForm(aiModelList) - } else { - log.info(` --no-relation-form-auto 已关闭 relationForm 自动注入 (v0.11h+ BS-18 fix, 用户主动控制)`) - } - - // 走 buildFormData (同 --ai 路径) - await initBuildFormData() - const bfdResult = webBuildFormData(aiModelList) - // v0.11f+ (2026-06-27 B-13 fix): 注入 relationForm 字段必填 3 项 - // web FormGenerator.vue:272-276 校验: !modelId → "关联功能不能为空" - // web buildFormData 不识别 AiFormModel.fields[].fieldRelationConfig, 需手动注入 - // 主子表场景: 子表字段在 formData.fields[].__config__.children[] 里 (jnpfKey=table) - const formDataObjInject = JSON.parse(bfdResult.formData) - const aiFieldsMap = new Map() // vmodel → ai field (含 fieldRelationConfig) - for (const m of aiModelList) { - if (Array.isArray(m?.fields)) { - for (const fld of m.fields) { - if (fld?.fieldName) aiFieldsMap.set(fld.fieldName, fld) - } - } - } - let relationInjected = 0 - const injectRelationForm = (fld: any) => { - const cfg = fld?.__config__ - if (cfg?.jnpfKey === 'relationForm') { - const vmodel = fld.__vModel__ - const aiFld = aiFieldsMap.get(vmodel) - const relCfg = aiFld?.fieldRelationConfig - if (!relCfg) { - log.warn(` ⚠ B-13: relationForm 字段 ${vmodel} 缺 fieldRelationConfig, 必填 modelId/propsValue/relationField (web 校验会拒)`) - } else { - // 注入 modelId / propsValue / relationField / columnOptions (镜像 web componentMap.ts:1386-1400) - if (relCfg.modelId) fld.modelId = relCfg.modelId - if (relCfg.propsValue) fld.propsValue = relCfg.propsValue - if (relCfg.relationField) fld.relationField = relCfg.relationField - if (Array.isArray(relCfg.columnOptions) && relCfg.columnOptions.length > 0) { - fld.columnOptions = relCfg.columnOptions.map((c: any) => ({ - label: c.label || c.value || c.enCode || '', - value: c.value || c.enCode || c.label || '', - enCode: c.enCode || c.value || '', - })) - } - // 默认补全 web 默认值 (用户没传时) - fld.hasPage = fld.hasPage ?? false - fld.pageSize = fld.pageSize ?? 20 - fld.popupType = fld.popupType ?? 'dialog' - fld.popupTitle = fld.popupTitle ?? '选择数据' - fld.popupWidth = fld.popupWidth ?? '800px' - relationInjected++ - } - } - // 递归: 主子表场景下子表字段在 jnpfKey=table 的 __config__.children[] 里 - if (Array.isArray(cfg?.children)) { - for (const child of cfg.children) injectRelationForm(child) - } - } - for (const fld of formDataObjInject.fields || []) injectRelationForm(fld) - if (relationInjected > 0) { - log.info(`v0.11f+ B-13 fix: 注入 ${relationInjected} 个 relationForm 字段 modelId/propsValue/relationField`) - } - // v0.12+ BS-New-5 fix (2026-06-30 jxcj): 备份注入路径, 即使 aiFieldsMap 没匹配也强制注入 - // 根因: aiFieldsMap 按 vmodel 查 fieldRelationConfig, 但 buildFormData 重组字段时 vmodel 不变 - // 字段类型已正确 → jnpfKey=relationForm, 但 modelId 等仍空 - // 镜像 web RightPanel.vue 拖拽关联表单时直接写 __config__.modelId - // 修: 用 aiModelList[i].fields (原始字段, 含 fieldRelationConfig) 直接遍历 - let explicitRelInjected = 0 - for (const m of aiModelList) { - for (const srcFld of m?.fields || []) { - if (srcFld?.fieldRelationConfig?.modelId) { - // 在 formData fields 里找对应 vmodel - for (const dstFld of formDataObjInject.fields || []) { - if (dstFld?.__vModel__ === srcFld.fieldName) { - const cfg = dstFld.__config__ || (dstFld.__config__ = {}) - if (cfg.jnpfKey !== 'relationForm') { - cfg.jnpfKey = 'relationForm' - log.info(` BS-New-5 备份注入: ${srcFld.fieldName} → jnpfKey=relationForm`) - } - cfg.modelId = srcFld.fieldRelationConfig.modelId - cfg.propsValue = srcFld.fieldRelationConfig.propsValue || srcFld.fieldName - cfg.relationField = srcFld.fieldRelationConfig.relationField - if (Array.isArray(srcFld.fieldRelationConfig.columnOptions)) { - cfg.columnOptions = srcFld.fieldRelationConfig.columnOptions.map((c: any) => ({ - label: c.label || c.value || c.enCode || '', - value: c.value || c.enCode || c.label || '', - enCode: c.enCode || c.value || '', - })) - } - cfg.hasPage = cfg.hasPage ?? false - cfg.pageSize = cfg.pageSize ?? 20 - cfg.popupType = cfg.popupType ?? 'dialog' - cfg.popupTitle = cfg.popupTitle ?? '选择数据' - cfg.popupWidth = cfg.popupWidth ?? '800px' - explicitRelInjected++ - } - } - } - } - } - if (explicitRelInjected > 0) { - log.info(`BS-New-5 fix: 强制注入 ${explicitRelInjected} 个 relationForm 字段完整配置 (modelId/propsValue/relationField)`) - } - // v0.11g+ B-16 fix (2026-06-27 tds_batch3): 注入主子表 tableName + 子表字段 relationTable - // web buildFormData (formUtils.ts:39-50) 不设置 table 容器 __config__.tableName (web 端由用户拖拽触发 RightPanel.vue:137/342 设) - // web buildFormData 不设置子表字段 __config__.relationTable (web 端由拖拽触发 FormGenerator.vue:491 设) - // 后端 FlowFormDataUtil.createTable:758 查 tableModelList.filter(k.getTable()==tableName), tableName 来自 childModel.getTableName() - // tableName 为空 → 找不到 tableModel → NPE "tableModel is null" → 400 "Failed to add data" - // 修复: 镜像 web 拖拽行为, 根据 aiModelList[i].tableName 注入 formData 字段 __config__.tableName - let subTableInjected = 0 - const mainTable = aiModelList.find((m: any) => m.isMain) - if (mainTable && mainTable.tableName) { - // 主表字段 tableName 设为物理主表名 (对齐 web 主表字段行为) - let mainFieldSet = false - for (const fld of formDataObjInject.fields || []) { - if (fld?.__config__?.jnpfKey && fld.__config__.jnpfKey !== 'table' && fld.__config__.layout === 'colFormItem' && !mainFieldSet) { - fld.__config__.tableName = mainTable.tableName - mainFieldSet = true - } - } - } - for (const m of aiModelList) { - if (!m.isMain && m.tableName) { - const idx = (formDataObjInject.fields || []).findIndex((f: any) => f?.__config__?.jnpfKey === 'table') - if (idx >= 0) { - const tbl = formDataObjInject.fields[idx] - tbl.__config__.tableName = m.tableName - const children = tbl.__config__.children || [] - for (const c of children) { - c.__config__.relationTable = m.tableName - c.__config__.tableName = mainTable?.tableName || '' - } - subTableInjected++ - } - } - } - if (subTableInjected > 0) { - log.info(`v0.11g+ B-16 fix: 注入 ${subTableInjected} 个主子表 tableName + 子表字段 relationTable (避免后端 createTable NPE)`) - } - // 序列化回 bfdResult - ;(opts as any).__aiBuildFormData = { ...bfdResult, formData: JSON.stringify(formDataObjInject) } - log.info(`v0.11+ --ai-json 走 web buildFormData, formData.fields=${formDataObjInject.fields.length}`) - // v0.11+ cleanup: 不再强制 type=4, 保持 --type 用户传入 (默认 1 formDesign) - // ai-json 含完整 tableName, 用户可走 type=1 + 物理表 (type=1 是 formDesign 列表) - // 2026-06-26: webType 默认 '1' → '2' (生产场景 99% 都要列表页) - opts.webType = opts.webType || '2' - } // 5.10.1: --ai 自动建表单 if (opts.ai) { log.info(`--ai "${opts.ai}" — 调用平台 AI 生成表单 (白皮书 5.10.1)`) @@ -701,10 +400,10 @@ export function buildFormCreateCommand(): Command { } handleGuardResult('form create', runGuards(guardCtx.ctx, guardOpts, 'form create')) - // v0.11+ cleanup: --fields 简化版已废弃, 走 --ai-json (web 端 buildFormData 自动保证 schema 完整性) + // v0.11+ cleanup: --fields 简化版已废弃, 走 --ai (web 端 buildFormData 自动保证 schema 完整性) if (opts.fields) { - log.error('--fields 已废弃, 请用 --ai-json (v0.11+ 走 web 端 buildFormData, schema 自动完整)') - log.error('例: --ai-json \'[{"tableTitle":"客户表","tableName":"customer","isMain":true,"fields":[...]}]\'') + log.error('--fields 已废弃, 请用 --ai "<描述>" (v0.12+ 走 web 端 buildFormData, schema 自动完整)') + log.error('例: --ai "客户管理:姓名、电话、邮箱"') process.exit(2) } // ai-json 路径下从 buildFormData 拿完整 fields (含 __config__ 全部 18 键) @@ -984,33 +683,23 @@ export function buildFormCreateCommand(): Command { hasDefaultValue: false, // dacli 自有 hasSuperQuery: false, } - // v0.11+ cleanup: --ai-json 路径下从 ai-json 推导 tables (含字段 schema) - // 优先 --tables 用户传入, 否则从 ai-json 推, 否则 type=4 空, 否则默认主表 + // v0.12+ BS-新28: --ai-json 删了, tables 推导只剩 2 路径 + // 优先 --tables 用户传入, 否则 type=4 空, 否则空 (web 端 buildFormData 推 schema) const stripAppPrefix = (t: string) => c.appCode && t.startsWith(`${c.appCode}_`) ? t.slice(c.appCode.length + 1) : t - let aiJsonTables: any[] | null = null - if (opts.aiJson && (opts as any).__aiBuildFormData?.tables) { - // 从 buildFormData.tables 拿 (web 端已生成, 含 use*Permission 等关键字段) - try { aiJsonTables = JSON.parse((opts as any).__aiBuildFormData.tables) } catch { /* fallthrough */ } - } const tables = opts.tables ? // BS-55: 用户传 --tables 时, 同步去前缀 JSON.parse(opts.tables).map((t: any) => { if (t && t.table) t.table = stripAppPrefix(t.table) return t }) - : (Array.isArray(aiJsonTables) && aiJsonTables.length > 0) // 2026-06-26 修复: [] 在 JS 里 truthy, 必须查 length - ? aiJsonTables.map((t: any) => { - if (t && t.table) t.table = stripAppPrefix(t.table) - return t - }) - : type === 4 - // type=4 视图不能带物理表 (后端会 Database exception), 强制空数组 - ? [] - : [] // 2026-06-26 v0.11d 修复: 兜底不再生成 [{f_id,f_tenant_id}], 发 [] - // web 浏览器场景: tables=[] 跳过 create() getPrimaryDbField 校验 - // publish() (Actions/Release) line 628 自动从 formData.fields 推 schema 建表 - // 之前兜底 2-PK schema 会触发 create() line 527 循环, 表不存在抛 "请在数据库中添加对应的数据表" + : type === 4 + // type=4 视图不能带物理表 (后端会 Database exception), 强制空数组 + ? [] + : [] // 2026-06-26 v0.11d 修复: 兜底不再生成 [{f_id,f_tenant_id}], 发 [] + // web 浏览器场景: tables=[] 跳过 create() getPrimaryDbField 校验 + // publish() (Actions/Release) line 628 自动从 formData.fields 推 schema 建表 + // 之前兜底 2-PK schema 会触发 create() line 527 循环, 表不存在抛 "请在数据库中添加对应的数据表" // 2026-06-27 B-9 修复: tables 推导后, 自动给第一个表加 typeId='1' (主表标识) // 后端 jnpf/.../FlowFormDataUtil.java:831 查 typeId='1' 找主表, 找不到抛 MsgCode.COD001 @@ -1148,10 +837,10 @@ export function buildFormCreateCommand(): Command { } else { log.warn(`v0.7.4 webType=${webType} 但 tables[0] 无用户字段, ★ 场景 A 走 Web 设计器勾选 (columnList 留空)`) } - } else if (webType !== 1 && (opts.aiJson || opts.ai)) { - // v0.11f+ B-15 修复 (2026-06-27 tds_batch3): --ai-json / --ai 路径下, 从 formData.fields 推 columnList - // 根因: --ai-json/--ai 走 web buildFormData, formData.fields 有完整 __config__/__vModel__/jnpfKey - // 旧逻辑只对 --tables 路径 (场景 B) 自动推 columnList, --ai-json (场景 A) 留空 + } else if (webType !== 1 && opts.ai) { + // v0.11f+ B-15 修复 (2026-06-27 tds_batch3): --ai 路径下, 从 formData.fields 推 columnList + // 根因: --ai 走 web buildFormData, formData.fields 有完整 __config__/__vModel__/jnpfKey + // 旧逻辑只对 --tables 路径 (场景 B) 自动推 columnList, --ai (场景 A) 留空 // → webType=2 校验失败: "列表字段不允许为空" // 修: 复用 buildColumnListEntry (与场景 B 同结构), 数据源从 formData.fields 来 // v0.12+ BS-新28: 同样覆盖 --ai 路径 (NCPF backend AI + web buildFormData) @@ -1180,9 +869,9 @@ export function buildFormCreateCommand(): Command { }) columnDataObj.columnList = entries columnDataObj.searchList = entries.map(buildSearchListEntry) - log.info(`B-15 修复: --ai/--ai-json 路径从 formData.fields 自动生成 columnList: ${entries.length} 个字段`) + log.info(`B-15 修复: --ai 路径从 formData.fields 自动生成 columnList: ${entries.length} 个字段`) } else { - log.warn(`B-15: --ai-json 路径 formData.fields 为空, ★ 走 Web 设计器勾选`) + log.warn(`B-15: --ai 路径 formData.fields 为空, ★ 走 Web 设计器勾选`) } } else if (webType !== 1) { log.info(`★ 场景 A: columnList 留空, 去 formDesign Web 设计器第二步"列表设计"手动勾选字段`) @@ -1389,13 +1078,13 @@ export function buildFormCreateCommand(): Command { }, example: [ 'dacli form create --fullName="POC 视图" --enCode=pocView', - 'dacli form create --fullName="请假" --enCode=leave --type=2 --webType=2 --dbLinkId=664... --ai-json=\'[{"tableTitle":"请假","tableName":"leave","isMain":true,"fields":[{"field":"f_name","fieldTitle":"姓名","dataType":"varchar","dataLength":"100","required":true}]}]\' --autoRelease', + 'dacli form create --fullName="请假" --enCode=leave --type=2 --webType=2 --dbLinkId=664... --ai "请假申请:姓名、请假天数、原因" --autoRelease', 'dacli form create --ai "请假管理表单, 含姓名/部门/请假天数/原因/审批人"', 'dacli form create --ai-field "请假天数, 含字典 [事假/病假/年假]" # 只问不建', ], source: { web: 'web/.../formDesign/Form.vue:444-465 + AI助手.vue', api: 'POST /api/visualdev/Base | POST /api/visualdev/ai/form' }, notes: [ - 'v0.11+ 推荐 dm→form 两步: dm create 建物理表 → form create --ai-json 建表单', + 'v0.11+ 推荐 dm→form 两步: dm create 建物理表 → form create --ai "<描述>" 建表单', 'autoRelease 对 type=4 自动跳过 (release 会 400)', '--ai 走 web buildFormData 路径, 默认 type=2 (老 type=4 兜底策略已废弃)', '--ai-field 只输出建议, 不建表单, 用于 AI 辅助字段设计',