diff --git a/src/commands/form/_form_repair.ts b/src/commands/form/_form_repair.ts index 860b5a9..85aaa00 100644 --- a/src/commands/form/_form_repair.ts +++ b/src/commands/form/_form_repair.ts @@ -66,12 +66,12 @@ const LABEL_PATTERNS: Array<[RegExp, string]> = [ [/时长|耗时|秒数|毫秒|分钟|小时/, 'inputNumber'], [/^num|count|num_|number$/, 'inputNumber'], - [/部门|组织|机构|单位|公司/, 'depSelect'], + [/部门|组织|机构|分公司/, 'depSelect'], // P1-2 (2026-07-16): 去掉"单位/公司" — 主办/承办/协办方都是 varchar, 不是部门实体 (BS-新117 #1) [/人员|用户|员工|申请人|审批人|负责人|操作人/, 'userSelect'], [/姓名$|name$/, 'userSelect'], [/日期|日$/, 'datePicker'], - [/时间|时刻/, 'timePicker'], + [/时刻|^at |at$|hour$/i, 'timePicker'], // P1-2 (2026-07-16): 去掉"时间" — 报名/创建/更新时间都含日期, 走 datePicker (BS-新117 #2) [/年$|月$|日$/, 'datePicker'], [/邮箱|email|邮件|mail/, 'input'], @@ -173,6 +173,46 @@ const VM_RULES: Array<{ to: 'textarea', reason: 'varchar(>500) + 长文本标签, 强制 textarea', }, + // 7. P1-2 (2026-07-16, BS-新117 #1): AI 误选 depSelect (label 无强部门暗示) → input + // 根因 (jxcj M1): "主办单位" (varchar 200, label=主办单位) AI 兜底选 depSelect. + // depSelect 是 JNPF 部门选择器 (选 sys_org 实体), 仅 label 强含 "组织/部门/机构" 才合理. + // 启发: 主办方/承办方/协办方/合作方/赞助商 都是字符串 ("XXX有限公司"), 不是部门实体. + { + match: ctx => + ctx.currentKey === 'depSelect' && + !/组织|部门|机构|分公司/.test(ctx.label || ''), + to: 'input', + reason: 'BS-新117 #1: label 无强部门暗示, AI 误选 depSelect, 强制 input (varchar 主办/承办/协办方)', + }, + // 8. P1-2 (2026-07-16, BS-新117 #2): AI 误选 timePicker (label/vmodel 暗示含日期) → datePicker + // 根因: 规则 1 仅当 fieldDbType=datetime 触发; AI 兜底 (Login expired) schema 常缺 fieldDbType. + // 启发: label 含 "报名/提交/创建/更新/开始/结束/截止/审核/发布/上线/下线/dateline/deadline/datetime" + // 暗示含日期; 或 vmodel 含 "_time" 后缀但不含 "_hour/_min/_sec" 暗示含日期. + // timePicker 只选时分秒, 不含日期; 业务字段几乎都是含日期的"时间点". + { + match: ctx => + ctx.currentKey === 'timePicker' && + ( + /(报名|提交|创建|更新|开始|结束|截止|审核|发布|上线|下线|生效|失效|dateline|deadline|datetime|日期)/i.test(ctx.label || '') || + (/_\w*_time$/i.test(ctx.vmodel || '') && !/hour|minute|sec/i.test(ctx.vmodel || '')) + ), + to: 'datePicker', + reason: 'BS-新117 #2: label/vmodel 暗示含日期, AI 误选 timePicker, 强制 datePicker', + }, + // 9. P1-2 (2026-07-16, BS-新117 #3): FK 字段 (vmodel 末 _id, 非系统字段) → relationForm 兜底 + // 根因: auto-injection (create.ts line 319-334) 在 aiModelList 阶段注入 fieldComponent='relationForm', + // 但 NCPF AI 兜底 (Login expired) schema 不含 fieldComponent, buildFormData fallback 到 input. + // 兜底: formData 完成后, FK vmodel + currentKey=input → 强制 relationForm jnpfKey. + // 限制: 仅设 jnpfKey, modelId/propsValue/relationField 由 --relation-form-auto 路径另行注入. + // CLAUDE.md §6: 关联字段必须用 relationForm 组件. + { + match: ctx => + ctx.currentKey === 'input' && + /^f_\w+_id$/i.test(ctx.vmodel || '') && + !/^f_(id|tenant_id|user_id|create_user_id|modify_user_id|en_code|flow_id|flow_task_id|version|delete_mark|delete_time|delete_user_id)$/i.test(ctx.vmodel || ''), + to: 'relationForm', + reason: 'BS-新117 #3: FK 字段(vmodel=*_id) AI 选 input, 强制 relationForm (CLAUDE.md §6)', + }, ] /**