From a529c4e0fa9b33d6b829f17fd91e325e85638da3 Mon Sep 17 00:00:00 2001 From: ssw Date: Thu, 16 Jul 2026 00:12:14 +0800 Subject: [PATCH] =?UTF-8?q?P0-5:=20=E4=BF=AE=20form=20create=20trigger=20?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=80=BC=20(CodePreview=20=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E5=85=9C=E5=BA=95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/form/create.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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,