diff --git a/src/commands/form/create.ts b/src/commands/form/create.ts index 9281bb2..22a266e 100644 --- a/src/commands/form/create.ts +++ b/src/commands/form/create.ts @@ -1123,6 +1123,38 @@ export function buildFormCreateCommand(): Command { }) } + // P0-5 (2026-07-16): trigger 默认值兜底 + // 根因 (jxcj 复盘, docs/jxcj/dacli-fix-plan.md §7): NCPF CodePreview 在 + // formData.fields[].__config__.trigger="" 时 → PublicMacro/FormMarco.vm:1226 + // 调 substring(0,1) 抛 StringIndexOutOfBoundsException → "System abnormality" 400. + // jxcj announcement (847163467923194821) + auditrecord (847169004752602053) + // 创建后 codegen 报 CodePreview System abnormality, controller 缺失. + // 防御: 遍历 formData.fields, 凡 trigger 空字符串/空数组/缺失 → 按 jnpfKey 设默认: + // input/textarea/editor → 'blur' (文本类控件) + // 其他 (select/checkbox/radio/datePicker/timePicker/...) → 'change' (选择类控件) + // 子表容器 (jnpfKey='table') 跳过 — 它们不在 mastForm 路径. + // 镜像 web 端 ColumnDesign/src/helper/config.ts:181 trigger 默认 'blur' 的语义. + if (Array.isArray(formData?.fields)) { + const TEXT_LIKE = new Set(['input', 'textarea', 'editor']) + let triggerFixed = 0 + for (const fld of formData.fields as any[]) { + if (!fld || !fld.__config__) continue + // 子表容器不需要 trigger (它的字段在 subFormFields) + if (fld.__config__.jnpfKey === 'table') continue + const cur = fld.__config__.trigger + const isEmpty = cur === undefined || cur === null || cur === '' || + (Array.isArray(cur) && cur.length === 0) + if (isEmpty) { + const jnpfKey = String(fld.__config__.jnpfKey || '') + fld.__config__.trigger = TEXT_LIKE.has(jnpfKey) ? 'blur' : 'change' + triggerFixed++ + } + } + if (triggerFixed > 0) { + log.info(`✓ P0-5 fix: 自动设置 ${triggerFixed} 字段 __config__.trigger 默认值 (避免 CodePreview FormMarco.vm:1226 空串 crash)`) + } + } + const body: Record = { fullName: opts.fullName, enCode: opts.enCode,