diff --git a/src/commands/form/_validate.ts b/src/commands/form/_validate.ts index 6a19d8c..352bab8 100644 --- a/src/commands/form/_validate.ts +++ b/src/commands/form/_validate.ts @@ -101,10 +101,16 @@ export function validateBasicInfo(opts: { } // v0.11e+ 新增 category 必填校验 (镜像 Form.vue:60-66 schemas required: true) + // v0.12+ jxcj-2026-06-29 fix: 加可执行建议 (按 appCode 派生 + 复用 crmOrder 通用) if (!opts.category || !opts.category.trim()) { errors.push({ field: 'category', - message: '表单分类不能为空 (镜像 web Form.vue:60-66 schemas required)', + message: + 'VS-CATEGORY: 表单分类不能为空 (镜像 web Form.vue:60-66 schemas required). ' + + '每个 app 推荐独立 category. 修复: ' + + '(1) web 端 "应用设置 > 应用管理 > {appCode} > 表单分类" 建一个, 记 id; ' + + '(2) 或复用通用 category --category=8f65bbe3bce341c8b3625d93544a044a (crmOrder 业务表单, 跨 app 共享); ' + + '(3) 或用 dacli dict / dacli form info 查现有 form 的 category id', code: 'VS-CATEGORY', }) } diff --git a/src/commands/form/create.ts b/src/commands/form/create.ts index eed2595..89ab8c8 100644 --- a/src/commands/form/create.ts +++ b/src/commands/form/create.ts @@ -83,7 +83,7 @@ export function buildFormCreateCommand(): Command { .option('--enCode ', '英文编码 (--ai 自动填, 否则必填)') .option('--type ', '1=自定义(formDesign) 2=系统(sysForm) 3=接口 4=视图', '1') .option('--webType ', '1=仅表单 2=表单+列表(默认) 3=树+表单 4=数据视图', '2') - .option('--category ', '分类 id (form list 看真实值)') + .option('--category ', '分类 id (form list 看真实值; 镜像 web Form.vue:60-66 必填; 推荐每个 appCode 派独立 category, 通用复用 8f65bbe3bce341c8b3625d93544a044a=crmOrder 业务表单)') .option('--dbLinkId ', 'db link id (type≠4 时必传, 默认从 token.dbLinkId)') .option('--fields ', 'formData.fields JSON 数组 (--ai 自动填)') .option('--tables ', 'tables JSON 数组 (type=1/2 必传)') @@ -141,23 +141,35 @@ export function buildFormCreateCommand(): Command { // 缺 fieldComponent 时回退到 componentList[0] = input, datetime 字段变 input // → 后端 swapDatetime 不触发 → "Data truncation: Incorrect datetime value" // 修: dataType → fieldComponent 映射 (兼容 v0.11a 旧 AI JSON 写法) - if (fld && !fld.fieldComponent && 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})`) + // + // v0.12+ jxcj-2026-06-29 fix: dictType 优先级最高 → select 控件 + // 根因: 之前 dataType=int 走 dtMap → inputNumber, 但有 dictType 时 web 端 + // 期望 select 控件 (下拉选字典项), 导致 "录入都是字符串" 错位 + // 镜像: web FormGenerator.vue 选字段时, dictType 字段强制 select 控件 + // 修: dictType 优先于 dataType, 先判断 dictType + if (fld && !fld.fieldComponent) { + 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})`) + } } } }