diff --git a/src/commands/_blindspot_guards.ts b/src/commands/_blindspot_guards.ts index a9d7de6..5c22f5e 100644 --- a/src/commands/_blindspot_guards.ts +++ b/src/commands/_blindspot_guards.ts @@ -363,6 +363,24 @@ export const BLINDSPOT_GUARDS: BlindspotGuard[] = [ message: 'better-sqlite3 native binding 未编译 / 缓存库不可写', fix: 'cd $ccWorkDir/dacli && npm rebuild better-sqlite3; 或改 DACLI_CACHE_DIR', }, + + // 盲点 52: form create 后列表页"新增"按钮空白 (tds2 复盘: 7 form btnsList=[], 28/28 TC 假 PASS) + // v0.11 起 dacli form create 自动注入 web 默认 5+3 按钮 schema (create.ts:405-418, 与 web config.ts:74-153 对齐), + // 此 guard 仅作"用户无需手动传按钮"的提示, 避免重复配置. + { + id: 'BS-52', + trigger: 'form create 担心没"新增"按钮 (v0.11+ 自动补齐, 无需手动加)', + level: 'WARN', + check: (_ctx, opts) => { + const wt = Number(opts?.webType ?? opts?.type) + // 仅 webType=1/2/3 (普通表单/表单+列表/树) 关心按钮; type=4 视图无列表页 + if (wt === 4 || Number.isNaN(wt)) return false + // 用户显式 opt-out (用 skipDefaultBtns 等禁默认按钮 flag) 才提示 + return opts?.skipDefaultBtns === true + }, + message: 'v0.11+ dacli form create 自动注入 web 默认按钮 (btnsList+columnBtnsList), 不需手动加"新增/编辑"', + fix: '去掉 --skip-default-btns 类显式禁用; 若想自定义, 仿造 web config.ts:74-153 默认 schema 后传 --columnData', + }, ] /** diff --git a/src/commands/form/_blindspots.ts b/src/commands/form/_blindspots.ts index a531903..cc9ba96 100644 --- a/src/commands/form/_blindspots.ts +++ b/src/commands/form/_blindspots.ts @@ -1,20 +1,26 @@ /** - * commands/form/_blindspots.ts — 5 类盲点规则 (设计期 lint + 运行时 validate 共享) + * commands/form/_blindspots.ts — 6 类盲点规则 (设计期 lint + 运行时 validate 共享) * - * 单一事实源: BS-23 / BS-31 / BS-32 / BS-15 / BS-V2 + * 单一事实源: BS-23 / BS-31 / BS-32 / BS-15 / BS-V2 / BS-52 * 调用方: validate.ts (运行时, 需 form id) * lint.ts (设计期, 不需 JNPF server) + * + * BS-52 (v0.11, 2026-06-22): columnData.btnsList 缺"新增"按钮 / columnBtnsList 缺"编辑"按钮 + * → 浏览器层列表页"新增"按钮空白, 数据无法创建 (tds2 复盘: 28/28 TC 假 PASS). + * web 默认值 (config.ts:74-153): btnsList=[add,download,upload,batchRemove,batchPrint] + * columnBtnsList=[edit,remove,detail] + * dacli create.ts:405-418 已对齐 web 默认 schema, BS-52 仅校验"发布后的 form 是否仍保留默认按钮". */ import type { FormDetail } from '../../core/types.ts' export interface BlindspotIssue { - id: 'BS-23' | 'BS-31' | 'BS-32' | 'BS-15' | 'BS-V2' + id: 'BS-23' | 'BS-31' | 'BS-32' | 'BS-15' | 'BS-V2' | 'BS-52' level: 'ERROR' | 'WARN' path: string message: string } -export const BLINDSPOT_IDS = ['BS-23', 'BS-31', 'BS-32', 'BS-15', 'BS-V2'] as const +export const BLINDSPOT_IDS = ['BS-23', 'BS-31', 'BS-32', 'BS-15', 'BS-V2', 'BS-52'] as const function safeParse(s: unknown): unknown { if (s == null) return null @@ -132,5 +138,76 @@ export function checkBs15(tablesRaw: unknown, enableFlow: number | undefined): B issues.push({ id: 'BS-15', level: 'ERROR', path: `tables.${t.table || '?'}.fields`, message: 'enableFlow=1 必须含 f_flow_task_id 列' }) } } + return issues +} + +/** + * BS-52 (2026-06-22): 列表页"新增"按钮存在性校验 + * + * 根因: 7 个 tds2 form 的 columnData.btnsList=[], 列表页"新增"按钮空白, 28/28 TC 假 PASS. + * 修复: 校验 columnData.btnsList 含"新增"按钮 + columnBtnsList 含"编辑"按钮. + * + * 权威参照 (web config.ts:74-153): + * btnsList 默认 5 项 (add/download/upload/batchRemove/batchPrint) + * columnBtnsList 默认 3 项 (edit/remove/detail) + * + * 例外: webType=4 (数据视图) 无列表页, 不需要这些按钮, 返回空 issues. + */ +export function checkBs52(columnDataRaw: unknown, webType?: number): BlindspotIssue[] { + // webType=4 是数据视图, 不需要列表按钮 + if (webType === 4) return [] + + const cd = safeParse(columnDataRaw) as Record | null + if (!cd) return [] + + const issues: BlindspotIssue[] = [] + + // 1. btnsList 顶部按钮 — 必须含 "新增" (show=true) + const btnsList = cd.btnsList as Array<{ label?: string; show?: boolean; value?: string }> | undefined + if (!Array.isArray(btnsList) || btnsList.length === 0) { + issues.push({ + id: 'BS-52', + level: 'ERROR', + path: 'columnData.btnsList', + message: '列表页缺顶部按钮栏 (btnsList 空) → 用户看不到"新增"按钮', + }) + } else { + const hasAdd = btnsList.some( + b => b.show === true && (b.label?.includes('新增') === true || b.value === 'add'), + ) + if (!hasAdd) { + issues.push({ + id: 'BS-52', + level: 'ERROR', + path: 'columnData.btnsList', + message: '缺"新增"按钮 (show=true, label=新增 或 value=add) → 浏览器层用户无法创建数据', + }) + } + } + + // 2. columnBtnsList 列按钮 — 必须含 "编辑" (show=true) + // 注意: web 真实字段名是 columnBtnsList, 不是 rowBtnsList (老文档误称) + const columnBtnsList = cd.columnBtnsList as Array<{ label?: string; show?: boolean; value?: string }> | undefined + if (!Array.isArray(columnBtnsList) || columnBtnsList.length === 0) { + issues.push({ + id: 'BS-52', + level: 'ERROR', + path: 'columnData.columnBtnsList', + message: '缺列按钮栏 (columnBtnsList 空) → 用户看不到行内"编辑/删除"按钮', + }) + } else { + const hasEdit = columnBtnsList.some( + b => b.show === true && (b.label?.includes('编辑') === true || b.value === 'edit'), + ) + if (!hasEdit) { + issues.push({ + id: 'BS-52', + level: 'ERROR', + path: 'columnData.columnBtnsList', + message: '缺"编辑"按钮 (show=true, label=编辑 或 value=edit)', + }) + } + } + return issues } \ No newline at end of file diff --git a/src/commands/form/lint.ts b/src/commands/form/lint.ts index 528f994..475e563 100644 --- a/src/commands/form/lint.ts +++ b/src/commands/form/lint.ts @@ -6,7 +6,10 @@ * dacli form lint --from-design=docs/{app}/design-jnpf.html * dacli form lint --from-script=... --from-design=... * - * 复用 _blindspots.ts 5 类检查 + * 复用 _blindspots.ts 6 类检查 (BS-23/31/32/15/V2/52) + * - 设计期可跑: BS-31 (label) / BS-32 (decimal 类型) — 来自 Python form 字段 + * - 设计期 N/A: BS-23/15/V2/52 — 需运行时 form 详情 (columnData/tables JSON), + * 由 `dacli form validate ` 运行时兜底 */ import { Command } from 'commander' import { readFileSync } from 'node:fs' @@ -94,14 +97,19 @@ export function buildFormLintCommand(): Command { blockIssues = r.blockIssues allIssues.push(...r.issues) } - // 汇总 — BS-23 需运行时 columnData, 设计稿无 columnData 全文, 标 N/A 由 form validate 兜底 - // BS-15/V2 设计稿无完整 tables/formData JSON, 也标 N/A + // 汇总 — 4 条盲点需运行时 columnData/tables/formData, 设计稿/Python 脚本无完整 JSON, + // 标 N/A 由 `dacli form validate ` 运行时兜底: + // BS-23 (use*Permission 必填) + // BS-15 (enableFlow=1 + f_flow_task_id) + // BS-V2 (columnData __config__ / dbLinkId) + // BS-52 (btnsList/columnBtnsList 按钮存在性, v0.11+) const bs: Record = { 'BS-23': { pass: true, fail: 0, n_a: 1 }, 'BS-31': { pass: !allIssues.some(i => i.id === 'BS-31'), fail: 0, n_a: 0 }, 'BS-32': { pass: !allIssues.some(i => i.id === 'BS-32'), fail: 0, n_a: 0 }, 'BS-15': { pass: true, fail: 0, n_a: 1 }, 'BS-V2': { pass: true, fail: 0, n_a: 1 }, + 'BS-52': { pass: true, fail: 0, n_a: 1 }, } for (const i of allIssues) bs[i.id].fail++ const report: LintReport = { @@ -136,7 +144,7 @@ export function buildFormLintCommand(): Command { }) installAiHelpHook(cmd, { - purpose: '设计期 lint: 复用 5 类盲点规则 (BS-23/31/32/15/V2), 不需 JNPF server. 阶段 2 末必跑, exit 0 才能进阶段 4.', + purpose: '设计期 lint: 复用 6 类盲点规则 (BS-23/31/32/15/V2/52), 不需 JNPF server. 阶段 2 末必跑, exit 0 才能进阶段 4.', optional: { '--from-script ': '03_forms.py 路径 (含 FORMS 列表)', '--from-design ': 'design-jnpf.html 路径 (含
dacli 命令块)', @@ -147,10 +155,11 @@ export function buildFormLintCommand(): Command { 'dacli form lint --from-script=... --from-design=...', ], notes: [ - 'BS-23 N/A 设计期: 需运行时 columnData, 由 form validate 兜底', + 'BS-23 N/A 设计期: 需运行时 columnData (use*Permission), 由 form validate 兜底', 'BS-31/32 per-field 检查: 扫每个 form 字段 label / decimal 类型', 'BS-15 N/A 设计期: 需运行时 tables (enableFlow=1 + f_flow_task_id)', 'BS-V2 N/A 设计期: 需运行时 form detail (formData/columnData/dbLinkId)', + 'BS-52 N/A 设计期: 需运行时 columnData (btnsList/columnBtnsList), 由 form validate 兜底', ], }) diff --git a/src/commands/form/validate.ts b/src/commands/form/validate.ts index 8d94f9a..1a0b63e 100644 --- a/src/commands/form/validate.ts +++ b/src/commands/form/validate.ts @@ -2,23 +2,25 @@ * commands/form/validate.ts — 校验表单结构 (columnData __config__ 完整性) * * 镜像 Java 版 `dacli form validate ` 能力 - * 共享 _blindspots.ts 的 5 类检查 (BS-23/31/32/15/V2) + * 共享 _blindspots.ts 的 6 类检查 (BS-23/31/32/15/V2/52) * - formData.fields 每项有 __config__ (新 form: {fields:[]}; 老 form 流程表单: 直接是 array) * - columnData.fields 每项有 __config__ (新版 JNPF 缺会白屏) * - tables 有 dbLinkId + * - columnData.btnsList 含"新增"按钮 + columnBtnsList 含"编辑"按钮 (BS-52, v0.11+) * * 修复 (v0.8.1): formData=null / formData="[]" / 老 formData 直接是 array 不再误报 WARN. * - 已知盲点 (v0.7.1): 老流程表单 formData 是 flat array, validate 报 "fields 不是数组" * - 修复: 兼容 {fields:[...]} 和 直接 array 两种形态, 都视为合法 * * v0.9 重构: 5 类检查抽到 _blindspots.ts, validate 与 lint 共享 (零 drift). + * v0.11 (2026-06-22): 新增 BS-52 (按钮存在性) 运行时校验, 修复 tds2 复盘 28/28 TC 假 PASS. */ import { Command } from 'commander' import { JnpfClient } from '../../core/client.ts' import { installAiHelpHook } from '../../core/help.ts' import { log, printJson } from '../../core/log.ts' import type { FormDetail } from '../../core/types.ts' -import { checkBsV2, checkBs23, checkBs31, checkBs32, checkBs15, type BlindspotIssue } from './_blindspots.ts' +import { checkBsV2, checkBs23, checkBs31, checkBs32, checkBs15, checkBs52, type BlindspotIssue } from './_blindspots.ts' export type ValidationIssue = BlindspotIssue @@ -29,6 +31,7 @@ function validate(form: FormDetail): ValidationIssue[] { ...checkBs31(form.formData), ...checkBs32(form.formData), ...checkBs15(form.tables, form.enableFlow as number | undefined), + ...checkBs52(form.columnData, form.webType as number | undefined), ] }