fix(form create): jxcj 2026-06-29 — dictType 自动 select + category 报错增强

P0: int + dictType 字段自动 fieldComponent=select (避免录入都是字符串)
  - 改 src/commands/form/create.ts:139-167 dtMap 逻辑
  - 优先级: dictType 字段强制 select > dataType→fieldComponent 映射
  - 镜像 web FormGenerator.vue 选字段时 dictType 字段强制 select 控件

P1: category 校验报错加 3 个可执行建议
  - 改 src/commands/form/_validate.ts:60-78
  - 加 (1) web 端建 (2) 通用 category 复用 (3) dacli form info 查 现有 id

--help 注解同步: --category 加 '推荐每个 appCode 派独立 category, 通用 8f65...=crmOrder 业务表单'

验证: jxcj 27 form 全部 jnpfKey=select + dictType 字段, TC-A/C/综合业务 21/21 PASS
权威源: memory/dacli-jxcj-2026-06-29-regression.md
This commit is contained in:
ssw committed 2026-06-29 21:17:00 +08:00
1 parent 86d7d8e690
commit c946299eed
2 files changed
+37 -19

No files matched your search

+7 -1
View File
@@ -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 <enCode> 查现有 form 的 category id',
code: 'VS-CATEGORY',
})
}
+30 -18
View File
@@ -83,7 +83,7 @@ export function buildFormCreateCommand(): Command {
.option('--enCode <e>', '英文编码 (--ai 自动填, 否则必填)')
.option('--type <t>', '1=自定义(formDesign) 2=系统(sysForm) 3=接口 4=视图', '1')
.option('--webType <w>', '1=仅表单 2=表单+列表(默认) 3=树+表单 4=数据视图', '2')
.option('--category <c>', '分类 id (form list 看真实值)')
.option('--category <c>', '分类 id (form list 看真实值; 镜像 web Form.vue:60-66 必填; 推荐每个 appCode 派独立 category, 通用复用 8f65bbe3bce341c8b3625d93544a044a=crmOrder 业务表单)')
.option('--dbLinkId <id>', 'db link id (type≠4 时必传, 默认从 token.dbLinkId)')
.option('--fields <json>', 'formData.fields JSON 数组 (--ai 自动填)')
.option('--tables <json>', '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<string, string> = {
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<string, string> = {
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})`)
}
}
}
}