From b43b03f83a14dcfefeae74ed7a93a8f1d3bba01a Mon Sep 17 00:00:00 2001 From: ssw Date: Wed, 1 Jul 2026 16:57:52 +0800 Subject: [PATCH] feat(test-render): add 6 TC-C cross-module real contract validation (role/msg/schedule/monitor/user/log, v0.14+) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit v0.14+ §8.3.4 阶段 6: 加 6 个 TC-C 批量子模块, 跨模块真实契约校验, 跟 dict/form/menu/portal/workflow/di 标杆同模式. 每个模块 4 关卡 (list 字段 ⊆ api / form 字段 ⊆ api / 必填/外键/关联完整性 / schema 完整性), 可选 --id 追加第 5 关卡单条 getInfo 完整性. 模块差异: - role: userColumns/Form.vue + conditionJson JSON.parse + enCode 格式 (Form.vue L44 formValidate) - msg: notice (4 关卡 list/form/必填/schema) + msgTemplate (1 关卡 必填), notice webapi 修正 (system/message.ts) - schedule: FullCalendar 6 事件字段 + Form.vue 19 字段 + 必填 10 + repetition JSON.parse + 时间序 - monitor: 4 视图 (msgMonitor/userOnline/flowMonitor/platformMonitor schema) - user: 8 列表字段 + 27 表单字段 + 必填 3 + enabledMark/organizeId/gender schema - log: 4 类别 (login=1/operate=3/error=4/request=5) list 字段 ⊆ api 已知 limitation: - schedule webapi 镜像 Quartz cron (system/task.ts), 非日历日程. 需扩展加 getScheduleList. Co-Authored-By: Claude --- src/commands/test/render.ts | 1531 ++++++++++++++++++++++++++++++++++- src/webapi/message.ts | 2 +- 2 files changed, 1531 insertions(+), 2 deletions(-) diff --git a/src/commands/test/render.ts b/src/commands/test/render.ts index 0d08547..01b2846 100644 --- a/src/commands/test/render.ts +++ b/src/commands/test/render.ts @@ -77,6 +77,7 @@ import { initWebapi as initWebapiSchedule, loadSchedule } from '../../webapi/sch import { initWebapi as initWebapiMonitor, loadMonitor } from '../../webapi/monitor.ts' import { initWebapi as initWebapiUser, loadUser } from '../../webapi/user.ts' import { initWebapi as initWebapiLog, loadLog } from '../../webapi/log.ts' +import { initWebapi as initWebapiReport, loadReport } from '../../webapi/report.ts' import { installAiHelpHook } from '../../core/help.ts' import { log, printJson } from '../../core/log.ts' import * as fs from 'node:fs/promises' @@ -117,7 +118,7 @@ export function buildTestRenderCommand(): Command { const cmd = new Command('render') .alias('source') .description('源码渲染验证 (镜像 web 端渲染契约, 替代浏览器验证) — 读 vue 渲染契约 + 调 API, 检查字段完整性') - .requiredOption('--module ', '模块名: dict | form | di | menu | portal | workflow | role | msg | schedule | monitor | user | log') + .requiredOption('--module ', '模块名: dict | form | di | menu | portal | workflow | role | msg | schedule | monitor | user | log | report') .option('--typeId ', '字典类型 id (dict module 验证数据时必填)') .option('--id ', '实体 id (验证单条数据时用, menu module 验证单条菜单 propertyJson schema)') .option('--formId ', '表单 id (form module 必填)') @@ -166,6 +167,8 @@ export function buildTestRenderCommand(): Command { await renderUser(c, opts, results, opts.json ? silent : real) } else if (opts.module === 'log') { await renderLog(c, opts, results, opts.json ? silent : real) + } else if (opts.module === 'report') { + await renderReport(c, opts, results, opts.json ? silent : real) } else { log.error(`暂不支持 module=${opts.module}`) process.exit(2) @@ -233,6 +236,8 @@ export function buildTestRenderCommand(): Command { 'dacli test render --module=monitor # 验证监控 4 视图 schema (userOnline loginIPAddress + msgMonitor title + flowMonitor currentNodeName + platformMonitor getSysMonitor)', 'dacli test render --module=user # 验证用户 list + form 字段 ⊆ api (getUserList account/realName/gender + Form.vue 30+ 字段)', 'dacli test render --module=log # 验证日志 4 类别 schema (loginLog + operateLog + errorLog + requestLog, category=1/3/4/5)', + 'dacli test render --module=report # 验证报表 list + form 字段 ⊆ api (BACKEND-7: list 受 nginx 301 影响, fallback Selector 端点; info/templates/update 路径正常)', + 'dacli test render --module=report --id=623204233482601029 # 验证某条报表 getInfo 必填 + cells/snapshot/allowExport 等 schema 完整性 (Form.vue 编辑元数据 + univer Designer 编辑报表设计)', ], source: { web: 'web/.../sysData/dictionary/{index,Form,components/index,components/Form}.vue + web/.../FormGenerator/ + web/.../dataCenter/dataInterface/{index,Form,Preview}.vue + web/.../permission/menu/{index,Form}.vue + web/.../onlineDev/visualPortal/{index,Form,components/ReleaseModal}.vue', @@ -246,6 +251,7 @@ export function buildTestRenderCommand(): Command { '**v0.14+ portal module (2026-07-01)**: 添加 portal module, 镜像 web visualPortal 渲染 + category 字典 UUID 校验 + formData + platformRelease schema (dacli test render --module=portal)', '**v0.14+ workflow module (2026-07-01)**: 添加 workflow module, 镜像 web flowEngine 渲染 + flowNodes start/end/userTask 校验 + BPMN XML + flowConfig schema (dacli test render --module=workflow)', '**v0.14+ role/msg/schedule/monitor/user/log module (2026-07-01)**: 添加 6 个 TC-C 批量子模块, 跨模块真实契约校验 (role.ts/permission, msg.ts/msgCenter, schedule.ts/teamwork, monitor.ts/system, user.ts/permission, log.ts/system)', + '**v0.14+ report module (2026-07-01)**: 添加 report module, 镜像 web Report 渲染契约 (BACKEND-7 workaround: list 受 nginx 301 影响, fallback getReportSelector; info/templates/update 端点 /api/Report/{id} /api/Report/Selector 正常, 走 webapi/report.ts 镜像)', '**vs 浏览器测试**: 速度 2s vs 30s, 不需 playwright, 不依赖 SPA 路由 (JNPF admin 经常菜单 404)', '**能查**: 字段缺失 / schema 漂移 / API 返字段不对 / enCode 不匹配渲染契约', '**查不出**: vmodel bind bug (浏览器 JS) / 控件渲染异常 → 这些仍需 ssw-e2e-test', @@ -256,6 +262,13 @@ export function buildTestRenderCommand(): Command { '**算法 (menu)**: 读 views/permission/menu/{index,Form}.vue 提取 BasicColumn.dataIndex + useForm schemas.field → 与 loadMenu.getMenuList/getInfo webapi 镜像对比 → 4 关卡 (list 字段 ⊆ api / form 字段 ⊆ api / 必填 parentId 树形 + systemId 应用隔离 + moduleId 关联 / propertyJson schema 完整性 moduleId/webType/isTree/iconBackgroundColor)', '**算法 (portal)**: 读 views/onlineDev/visualPortal/{index,Form,components/ReleaseModal}.vue 提取 BasicColumn.dataIndex + useForm schemas.field → 与 loadPortal.getPortalList/getInfo webapi 镜像对比 → 4 关卡 (list 字段 ⊆ api / form 字段 ⊆ api / 必填 4 字段 (fullName/enCode/category/type) + category 字典 UUID 真实 + type=1 必填 linkType/customUrl / schema 完整性 formData JSON.parse OK + platformRelease {pc,app})', '**算法 (workflow)**: 读 views/onlineDev/flowEngine/{index,Form}.vue 提取 BasicColumn.dataIndex + useForm schemas.field → 与 loadWorkflow.getList/getInfo/getFlowInfo webapi 镜像对比 → 4 关卡 (list 字段 ⊆ api / form 字段 ⊆ api / 必填 4 字段 (fullName/enCode/category/icon) + enabledMark status / schema 完整性 flowNodes start+end+userTask + BPMN XML + flowConfig JSON.parse)', + '**算法 (report)**: 读 views/onlineDev/report/{index,Form}.vue 提取 BasicColumn.dataIndex + useForm schemas.field → 与 loadReport.getReportList/getReportInfo webapi 镜像对比 → 4 关卡 (list 字段 ⊆ api / form 字段 ⊆ api / 必填 fullName/enCode/category + systemId 应用隔离 + enabledMark 状态 / schema 完整性 cells 至少 1 + snapshot JSON.parse + allowExport/Print/Watermark boolean + watermarkConfig JSON.parse + platformRelease JSON.parse {pc,app})', + '**算法 (role)**: 读 views/permission/role/{index,Form}.vue (BasicColumn.dataIndex + useForm schemas.field) → 与 loadRole.getRoleList/getInfo webapi 镜像对比 → 4 关卡 (list 字段 ⊆ api / form 字段 ⊆ list+getInfo ∪ conditionJson.* / 必填 fullName/enCode/enabledMark / schema 完整性 conditionJson JSON.parse + enCode 格式)', + '**算法 (msg)**: 5 关卡 (notice 4 + msgTemplate 1): notice 走 loadNotice.getNoticeList + getInfo → 4 关卡 (list 字段 ⊆ api / form 字段 ⊆ api / 必填 title/category/remindCategory/sendConfigId / schema category UUID + remindCategory number); msgTemplate 走 loadMsgTemplate.getMsgTemplateList → 必填 fullName/enCode/messageSource/messageType', + '**算法 (schedule)**: 4 关卡 (FullCalendar 事件字段 id/title/start/end/allDay/color + Form.vue schemas 18 字段) → loadSchedule.getTaskList (注: 当前镜像 Quartz cron 而非日历日程, 已知 limitation, 需扩展 webapi/schedule.ts 加 getScheduleList 走 /api/teamwork/ScheduleList) → getInfo → 必填 10 字段 + schema repetition JSON.parse + startDay/endDay 时间序', + '**算法 (monitor)**: 4 视图契约: msgMonitor (BasicColumn ⊆ /msgCenter/MsgMonitor) + userOnline (/system/OnlineUser) + flowMonitor (/workflow/FlowMonitor type=0) + platformMonitor schema (getSysMonitor 必含 cpu/memory/disk/system 根字段 + 3 percentage number)', + '**算法 (user)**: 读 views/permission/user/{index,Form}.vue (8 列表字段 + 27 表单字段) → loadUser.getUserList/getUserInfo → 4 关卡 (list 字段 ⊆ api / form 字段 ⊆ list+info / 必填 account/realName/gender / schema enabledMark number + organizeId UUID + gender 字典)', + '**算法 (log)**: 4 类别契约 (loginLog category=1 + operateLog category=3 + errorLog category=4 + requestLog category=5), 镜像 web sysLog/{loginLog,operateLog,errorLog,requestLog}/index.vue BasicColumn → loadLog.getLogList({category}) → 字段 ⊆ api 校验', ], }) return cmd @@ -2204,6 +2217,1522 @@ async function renderWorkflow( } } +// ============================================================================ +// Role module (角色, v0.14+ NEW, 2026-07-01 — 镜像 §TC-C 4 关卡真实契约) +// +// 镜像 web 端: +// - web/.../permission/role/index.vue L49-66 userColumns/organizeColumns/positionColumns BasicColumn +// - web/.../permission/role/Form.vue L29-110 useForm.schemas (10 field + conditionJson.*) +// - web/.../permission/role/Form.vue L119-137 init(data): getInfo(id) → JSON.parse(conditionJson) +// - web/.../api/permission/role.ts getRoleList/getInfo/getRoleSelector +// ============================================================================ + +async function renderRole( + c: JnpfClient, + opts: RenderOpts, + results: RenderCheckResult[], + logFn: { info: (...a: unknown[]) => void; warn: (...a: unknown[]) => void; error: (...a: unknown[]) => void } = real, +): Promise { + await initWebapiRole(c) + const lg = logFn + + // 镜像 web/.../permission/role/index.vue L49-56 userColumns BasicColumn + const listFields = ['account', 'realName', 'gender', 'mobilePhone', 'position', 'enabledMark'] + // 镜像 web/.../permission/role/Form.vue L29-110 schemas field + const formFields = [ + 'fullName', 'enCode', 'isCondition', + 'conditionJson', 'sortCode', 'description', + 'type', 'isPrePosition', + ] + const requiredForm = ['fullName', 'enCode'] + + let apiFlat: any[] = [] + let apiSource: 'live-data' | 'empty' = 'empty' + try { + // type=0=user (与 userColumns 对应) + const r: any = await loadRole.getRoleList({ type: '0', keyword: '' }) + const list = Array.isArray(r?.data?.list) ? r.data.list : Array.isArray(r?.list) ? r.list : [] + apiFlat = list + apiSource = apiFlat.length > 0 ? 'live-data' : 'empty' + } catch (e) { + lg.warn(`getRoleList 失败: ${(e as Error).message}`) + } + + if (apiSource === 'empty') { + try { + const r: any = await loadRole.getRoleSelector('0', null) + const list = Array.isArray(r?.data?.list) ? r.data.list : Array.isArray(r?.list) ? r.list : [] + if (list.length > 0) { + apiFlat = list + apiSource = 'live-data' + lg.info(`role 列表: getRoleList 空, fallback getRoleSelector (${list.length} 条)`) + } + } catch { /* keep empty */ } + } + + const apiFieldSet = new Set() + for (const item of apiFlat) { + if (item && typeof item === 'object') { + for (const k of Object.keys(item)) apiFieldSet.add(k) + } + } + const apiFields = Array.from(apiFieldSet).sort() + if (apiSource === 'empty') { + lg.warn('role API 返回空, 字段对比会标记全部缺失 (可通过 dacli role create 创建测试角色)') + } + + // === Gate 1: 列表字段 ⊆ api 字段 === + { + const renderSet = new Set(listFields) + const missing = listFields.filter(f => !apiFieldSet.has(f)) + const extra = apiFields.filter(f => !renderSet.has(f)) + const status: 'PASS' | 'FAIL' = missing.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'role', + page: '角色列表', + sourceFile: 'views/permission/role/index.vue (userColumns L49-56)', + renderFields: listFields, + apiFields, + missing, + extra, + status, + }) + const icon = status === 'PASS' ? '✓' : '✗' + lg.info(`${icon} 角色列表: ${status} (${listFields.length} 渲染字段, ${apiFields.length} API 字段 [源:${apiSource}]${missing.length ? `, 缺 ${missing.length}` : ''})`) + } + + // === Gate 2: form 字段 ⊆ list ∪ getInfo (含 conditionJson.* 解析) === + let infoUnionSet = new Set() + let infoSource = 'list-only' + if (apiFlat.length > 0) { + const sample = opts.id || apiFlat[0].id + try { + const infoResp: any = await loadRole.getInfo(sample) + const data = (infoResp as any)?.data || infoResp + if (data && typeof data === 'object') { + infoSource = 'list+info' + for (const k of Object.keys(data)) infoUnionSet.add(k) + if (typeof data.conditionJson === 'string') { + try { + const parsed = JSON.parse(data.conditionJson || '{}') + if (parsed && typeof parsed === 'object') { + for (const k of Object.keys(parsed)) infoUnionSet.add(`conditionJson.${k}`) + } + } catch { /* ignore */ } + } + } + } catch (e) { + lg.warn(`getRoleInfo(${sample}) 失败 (Gate 2 仅用 list): ${(e as Error).message}`) + } + } + const formApiFieldSet = new Set([...apiFieldSet, ...infoUnionSet]) + { + const missing = formFields.filter(f => !formApiFieldSet.has(f) && !infoUnionSet.has(`conditionJson.${f}`)) + const status: 'PASS' | 'FAIL' = missing.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'role', + page: '角色表单', + sourceFile: 'views/permission/role/Form.vue (schemas L29-110) + getInfo (L119-137)', + renderFields: formFields, + apiFields: Array.from(formApiFieldSet).sort(), + missing, + extra: [], + status, + }) + const icon = status === 'PASS' ? '✓' : '✗' + lg.info(`${icon} 角色表单: ${status} (${formFields.length} 渲染字段, ${formApiFieldSet.size} API 字段 [源:${infoSource}]${missing.length ? `, 缺 ${missing.length}` : ''})`) + } + + // === Gate 3: 必填字段完整性 (fullName required + enCode formValidate + enabledMark) === + const requiredIssues: string[] = [] + for (const r of apiFlat) { + const label = r.fullName || r.enCode || r.id || '<无标识>' + if (!r.fullName) requiredIssues.push(`${label}: fullName 缺失 (Form.vue L37 required)`) + if (!r.enCode) requiredIssues.push(`${label}: enCode 缺失 (Form.vue L44 formValidate)`) + if (r.enabledMark === undefined || r.enabledMark === null) { + requiredIssues.push(`${label}: enabledMark 缺失 (index.vue L55 Tag 列)`) + } + } + if (apiFlat.length === 0) requiredIssues.push('无角色数据 (跳过必填校验)') + { + const status: 'PASS' | 'FAIL' = requiredIssues.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'role', + page: '角色必填字段', + sourceFile: 'Form.vue L37-44 + index.vue L55 enabledMark Tag', + renderFields: requiredForm.concat(['enabledMark']), + apiFields: requiredForm.concat(['enabledMark']), + missing: requiredIssues, + extra: [], + status, + }) + if (requiredIssues.length === 0) { + lg.info(`✓ 角色必填字段: PASS (${apiFlat.length} 个角色, fullName/enCode/enabledMark 全部非空)`) + } else { + lg.error(`✗ 角色必填字段: FAIL (${requiredIssues.slice(0, 3).join(' | ')}${requiredIssues.length > 3 ? '...' : ''})`) + } + } + + // === Gate 4: schema 完整性 (conditionJson JSON.parse + enCode 格式) === + const schemaIssues: string[] = [] + let conditionJsonParsed = 0 + const enCodeRegex = /^[A-Za-z0-9.]+$/ + for (const r of apiFlat) { + const label = r.fullName || r.enCode || r.id || '<无标识>' + if (r.enCode && !enCodeRegex.test(String(r.enCode))) { + schemaIssues.push(`${label}: enCode="${r.enCode}" 不符合英文/数字/小数点规则 (Form.vue L44 formValidate)`) + } + if (r.conditionJson !== undefined && r.conditionJson !== null && r.conditionJson !== '') { + if (typeof r.conditionJson !== 'string') { + schemaIssues.push(`${label}: conditionJson 类型不对 (期望 string JSON, 实际 ${typeof r.conditionJson})`) + } else { + try { + const parsed = JSON.parse(r.conditionJson) + if (typeof parsed !== 'object' || parsed === null) { + schemaIssues.push(`${label}: conditionJson 解析后非对象`) + } else { + conditionJsonParsed++ + } + } catch (e) { + schemaIssues.push(`${label}: conditionJson JSON.parse 失败: ${(e as Error).message.slice(0, 60)}`) + } + } + } + } + { + const status: 'PASS' | 'FAIL' = schemaIssues.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'role', + page: '角色 schema', + sourceFile: 'conditionJson: Form.vue L127 JSON.parse; enCode: Form.vue L44 formValidate', + renderFields: ['conditionJson (JSON.parse)', 'enCode (格式)'], + apiFields: ['conditionJson', 'enCode'], + missing: schemaIssues, + extra: [], + status, + }) + if (schemaIssues.length === 0) { + lg.info(`✓ 角色 schema: PASS (${conditionJsonParsed} 个 conditionJson JSON.parse OK + enCode 格式合规)`) + } else { + lg.error(`✗ 角色 schema: FAIL (${schemaIssues.slice(0, 3).join(' | ')}${schemaIssues.length > 3 ? '...' : ''})`) + } + } + + // === Gate 5 (可选, --id): 单条角色 getInfo 完整性 === + if (opts.id) { + let infoDetail: any + try { + infoDetail = await loadRole.getInfo(opts.id) + } catch (e) { + lg.error(`getInfo(${opts.id}) 失败: ${(e as Error).message}`) + return + } + const data = (infoDetail as any)?.data || infoDetail + if (!data || typeof data !== 'object') { + lg.error(`getInfo(${opts.id}) 返回非对象`) + return + } + const infoFieldSet = new Set(Object.keys(data)) + const requiredInfoFields = ['id', 'fullName', 'enCode', 'enabledMark', 'sortCode', 'conditionJson'] + const missing = requiredInfoFields.filter(f => !infoFieldSet.has(f)) + const details = `fullName=${data.fullName || '<空>'}, enCode=${data.enCode || '<空>'}` + const status: 'PASS' | 'FAIL' = missing.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'role', + page: '单条角色 getInfo 完整性', + sourceFile: `getInfo (roleId=${opts.id}, ${details})`, + renderFields: requiredInfoFields, + apiFields: Array.from(infoFieldSet).sort(), + missing, + extra: [], + status, + }) + if (status === 'PASS') { + lg.info(`✓ 单条角色 getInfo: PASS (${infoFieldSet.size} 字段, ${details})`) + } else { + lg.error(`✗ 单条角色 getInfo: FAIL (${missing.slice(0, 3).join(' | ')}${missing.length > 3 ? '...' : ''})`) + } + } +} + +// ============================================================================ +// Msg module (消息, v0.14+ NEW, 2026-07-01 — 镜像 §TC-C 4 关卡真实契约) +// +// 包含 2 子模块 (镜像 web 视图 + API): +// - notice : 系统公告 (views/msgCenter/notice/{index,Form}.vue + getNoticeList) +// - msgTemplate : 消息模板 (views/msgCenter/msgTemplate/{index,Form}.vue + getMsgTemplateList) +// +// 镜像 web 端: +// - web/.../msgCenter/notice/index.vue L24-33 columns BasicColumn +// - web/.../msgCenter/notice/Form.vue L25-101 schemas (10 字段) +// - web/.../msgCenter/msgTemplate/index.vue L37-50 columns +// - web/.../msgCenter/msgTemplate/Form.vue L51-64 rules.required (9 字段) +// ============================================================================ + +async function renderMsg( + c: JnpfClient, + opts: RenderOpts, + results: RenderCheckResult[], + logFn: { info: (...a: unknown[]) => void; warn: (...a: unknown[]) => void; error: (...a: unknown[]) => void } = real, +): Promise { + await initWebapiMessage(c) + const lg = logFn + + // --- Notice 子模块 --- + const noticeListFields = ['title', 'category', 'expirationTime', 'creatorUser', 'creatorTime', 'releaseUser', 'releaseTime', 'enabledMark'] + const noticeFormFields = ['title', 'toUserIds', 'category', 'expirationTime', 'files', 'coverImage', 'bodyText', 'excerpt', 'remindCategory', 'sendConfigId'] + const noticeRequired = ['title', 'category', 'remindCategory', 'sendConfigId'] + + let noticeFlat: any[] = [] + let noticeSource: 'live-data' | 'empty' = 'empty' + try { + const r: any = await loadNotice.getNoticeList({ currentPage: 1, pageSize: 50 }) + const list = Array.isArray(r?.data?.list) ? r.data.list : Array.isArray(r?.list) ? r.list : [] + noticeFlat = list + noticeSource = noticeFlat.length > 0 ? 'live-data' : 'empty' + } catch (e) { + lg.warn(`getNoticeList 失败: ${(e as Error).message}`) + } + const noticeApiFieldSet = new Set() + for (const item of noticeFlat) { + if (item && typeof item === 'object') { + for (const k of Object.keys(item)) noticeApiFieldSet.add(k) + } + } + const noticeApiFields = Array.from(noticeApiFieldSet).sort() + if (noticeSource === 'empty') { + lg.warn('notice API 返回空, 字段对比会标记全部缺失') + } + + // Gate 1: notice 列表 ⊆ api + { + const renderSet = new Set(noticeListFields) + const missing = noticeListFields.filter(f => !noticeApiFieldSet.has(f)) + const status: 'PASS' | 'FAIL' = missing.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'msg', + page: '公告列表', + sourceFile: 'views/msgCenter/notice/index.vue (columns L24-33)', + renderFields: noticeListFields, + apiFields: noticeApiFields, + missing, + extra: noticeApiFields.filter(f => !renderSet.has(f)), + status, + }) + const icon = status === 'PASS' ? '✓' : '✗' + lg.info(`${icon} 公告列表: ${status} (${noticeListFields.length} 渲染字段, ${noticeApiFields.length} API 字段 [源:${noticeSource}]${missing.length ? `, 缺 ${missing.length}` : ''})`) + } + + // Gate 2: notice form ⊆ list ∪ getInfo + let noticeInfoSet = new Set() + let noticeInfoSource = 'list-only' + if (noticeFlat.length > 0) { + const sample = opts.id || noticeFlat[0].id + try { + const infoResp: any = await loadNotice.getInfo(sample) + const data = (infoResp as any)?.data || infoResp + if (data && typeof data === 'object') { + noticeInfoSource = 'list+info' + for (const k of Object.keys(data)) noticeInfoSet.add(k) + } + } catch (e) { + lg.warn(`getNoticeInfo(${sample}) 失败 (Gate 2 仅用 list): ${(e as Error).message}`) + } + } + const noticeFormApi = new Set([...noticeApiFieldSet, ...noticeInfoSet]) + { + const missing = noticeFormFields.filter(f => !noticeFormApi.has(f)) + const status: 'PASS' | 'FAIL' = missing.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'msg', + page: '公告表单', + sourceFile: 'views/msgCenter/notice/Form.vue (schemas L25-101) + getInfo', + renderFields: noticeFormFields, + apiFields: Array.from(noticeFormApi).sort(), + missing, + extra: [], + status, + }) + const icon = status === 'PASS' ? '✓' : '✗' + lg.info(`${icon} 公告表单: ${status} (${noticeFormFields.length} 渲染字段, ${noticeFormApi.size} API 字段 [源:${noticeInfoSource}]${missing.length ? `, 缺 ${missing.length}` : ''})`) + } + + // Gate 3: notice 必填 + { + const issues: string[] = [] + for (const n of noticeFlat) { + const label = n.title || n.id || '<无标识>' + if (!n.title) issues.push(`${label}: title 缺失 (Form.vue L29 required)`) + if (!n.category) issues.push(`${label}: category 缺失 (Form.vue L43 required)`) + if (n.remindCategory === undefined || n.remindCategory === null) { + issues.push(`${label}: remindCategory 缺失 (Form.vue L92 required type=number)`) + } + if (!n.sendConfigId) issues.push(`${label}: sendConfigId 缺失 (Form.vue L101 required)`) + } + if (noticeFlat.length === 0) issues.push('无公告数据 (跳过必填校验)') + const status: 'PASS' | 'FAIL' = issues.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'msg', + page: '公告必填字段', + sourceFile: 'Form.vue L29/L43/L92/L101 rules.required', + renderFields: noticeRequired, + apiFields: noticeRequired, + missing: issues, + extra: [], + status, + }) + if (issues.length === 0) { + lg.info(`✓ 公告必填字段: PASS (${noticeFlat.length} 条公告, title/category/remindCategory/sendConfigId 全部非空)`) + } else { + lg.error(`✗ 公告必填字段: FAIL (${issues.slice(0, 3).join(' | ')}${issues.length > 3 ? '...' : ''})`) + } + } + + // Gate 4: notice schema (category UUID + remindCategory number) + const UUID_HEX_32 = /^[0-9a-f]{32}$/i + { + const issues: string[] = [] + let uuidCount = 0 + for (const n of noticeFlat) { + const label = n.title || n.id || '<无标识>' + if (n.category && UUID_HEX_32.test(String(n.category))) uuidCount++ + if (n.category && !UUID_HEX_32.test(String(n.category))) { + lg.warn(`msg notice: ${label} category="${n.category}" 不是 UUID 32hex (list 端可能返 fullName, info 端才返 UUID)`) + } + if (n.remindCategory !== undefined && n.remindCategory !== null && typeof n.remindCategory !== 'number' && typeof n.remindCategory !== 'string') { + issues.push(`${label}: remindCategory 类型不对 (期望 number/string, 实际 ${typeof n.remindCategory})`) + } + } + const status: 'PASS' | 'FAIL' = issues.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'msg', + page: '公告 schema', + sourceFile: 'category 字典 UUID (Bug 5 类似, list 返 fullName) + remindCategory number', + renderFields: ['category (UUID/32hex)', 'remindCategory (number)'], + apiFields: ['category', 'remindCategory'], + missing: issues, + extra: [], + status, + }) + if (issues.length === 0) { + lg.info(`✓ 公告 schema: PASS (${uuidCount} 个 category UUID 真实, remindCategory 类型合规)`) + } else { + lg.error(`✗ 公告 schema: FAIL (${issues.slice(0, 3).join(' | ')}${issues.length > 3 ? '...' : ''})`) + } + } + + // --- MsgTemplate 子模块 --- + const templateListFields = ['fullName', 'enCode', 'messageSource', 'messageType', 'templateType', 'creatorUser', 'creatorTime', 'lastModifyTime', 'sortCode', 'enabledMark'] + const templateRequired = ['fullName', 'enCode', 'messageSource', 'messageType'] + + let templateFlat: any[] = [] + let templateSource: 'live-data' | 'empty' = 'empty' + try { + const r: any = await loadMsgTemplate.getMsgTemplateList({ currentPage: 1, pageSize: 50 }) + const list = Array.isArray(r?.data?.list) ? r.data.list : Array.isArray(r?.list) ? r.list : [] + templateFlat = list + templateSource = templateFlat.length > 0 ? 'live-data' : 'empty' + } catch (e) { + lg.warn(`getMsgTemplateList 失败: ${(e as Error).message}`) + } + const templateApiFieldSet = new Set() + for (const item of templateFlat) { + if (item && typeof item === 'object') { + for (const k of Object.keys(item)) templateApiFieldSet.add(k) + } + } + const templateApiFields = Array.from(templateApiFieldSet).sort() + if (templateSource === 'empty') { + lg.warn('msgTemplate API 返回空, 字段对比会标记全部缺失') + } + { + const issues: string[] = [] + for (const t of templateFlat) { + const label = t.fullName || t.enCode || t.id || '<无标识>' + if (!t.fullName) issues.push(`${label}: fullName 缺失 (Form.vue L53 required)`) + if (!t.enCode) issues.push(`${label}: enCode 缺失 (Form.vue L55 required)`) + if (!t.messageSource) issues.push(`${label}: messageSource 缺失 (Form.vue L58 required)`) + if (!t.messageType) issues.push(`${label}: messageType 缺失 (Form.vue L59 required)`) + } + if (templateFlat.length === 0) issues.push('无消息模板数据 (跳过必填校验)') + const status: 'PASS' | 'FAIL' = issues.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'msg', + page: '消息模板列表 + 必填', + sourceFile: 'msgTemplate/index.vue (columns L37-50) + Form.vue L53-64 rules.required', + renderFields: templateListFields.concat(templateRequired), + apiFields: templateApiFields, + missing: issues, + extra: templateApiFields.filter(f => !new Set([...templateListFields, ...templateRequired]).has(f)), + status, + }) + if (issues.length === 0) { + lg.info(`✓ 消息模板列表 + 必填: PASS (${templateFlat.length} 个模板, 核心必填字段非空)`) + } else { + lg.error(`✗ 消息模板列表 + 必填: FAIL (${issues.slice(0, 3).join(' | ')}${issues.length > 3 ? '...' : ''})`) + } + } +} + +// ============================================================================ +// Schedule module (日程, v0.14+ NEW, 2026-07-01 — 镜像 §TC-C 4 关卡真实契约) +// +// 镜像 web 端: +// - web/.../teamwork/schedule/index.vue L37-87 CalendarOptions events +// - web/.../teamwork/schedule/Form.vue L65-202 schemas (18 字段) +// - web/.../api/system/task.ts (Quartz cron 任务, 当前 webapi 镜像, 已知 limitation: +// 日历视图走 /api/teamwork/ScheduleList, 需扩展 webapi/schedule.ts 加 getScheduleList) +// ============================================================================ + +async function renderSchedule( + c: JnpfClient, + opts: RenderOpts, + results: RenderCheckResult[], + logFn: { info: (...a: unknown[]) => void; warn: (...a: unknown[]) => void; error: (...a: unknown[]) => void } = real, +): Promise { + await initWebapiSchedule(c) + const lg = logFn + + const calendarEventFields = ['id', 'title', 'start', 'end', 'allDay', 'color'] + const formFields = [ + 'category', 'urgent', 'title', 'content', 'files', 'allDay', + 'startDay', 'startTime', 'duration', 'endDay', 'endTime', + 'creatorUserId', 'toUserIds', 'color', 'reminderTime', 'reminderType', + 'send', 'repetition', 'repeatTime', + ] + const requiredFields = ['category', 'urgent', 'title', 'startDay', 'duration', 'reminderTime', 'reminderType', 'send', 'repeatTime', 'endDay'] + + let apiFlat: any[] = [] + let apiSource: 'live-data' | 'empty' = 'empty' + try { + const r: any = await loadSchedule.getTaskList({ currentPage: 1, pageSize: 50 }) + const list = Array.isArray(r?.data?.list) ? r.data.list : Array.isArray(r?.list) ? r.list : [] + apiFlat = list + apiSource = apiFlat.length > 0 ? 'live-data' : 'empty' + } catch (e) { + lg.warn(`getTaskList 失败 (注: schedule webapi 镜像 Quartz cron 任务, 非日历日程): ${(e as Error).message}`) + } + + const apiFieldSet = new Set() + for (const item of apiFlat) { + if (item && typeof item === 'object') { + for (const k of Object.keys(item)) apiFieldSet.add(k) + } + } + const apiFields = Array.from(apiFieldSet).sort() + if (apiSource === 'empty') { + lg.warn('schedule API 返回空 (注: webapi/schedule 镜像 Quartz cron, 建议扩展加 getScheduleList 走 /api/teamwork/ScheduleList)') + } + + // === Gate 1: FullCalendar 事件字段 === + { + const resolveScheduleField = (f: string) => { + if (apiFieldSet.has(f)) return true + if (f === 'start' && apiFieldSet.has('startDay')) return true + if (f === 'end' && (apiFieldSet.has('endDay') || apiFieldSet.has('endTime'))) return true + return false + } + const missing = calendarEventFields.filter(f => !resolveScheduleField(f)) + const status: 'PASS' | 'FAIL' = missing.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'schedule', + page: '日历事件渲染 (FullCalendar)', + sourceFile: 'views/teamwork/schedule/index.vue (CalendarOptions events L37-87)', + renderFields: calendarEventFields, + apiFields, + missing, + extra: apiFields.filter(f => !new Set(calendarEventFields).has(f)), + status, + }) + const icon = status === 'PASS' ? '✓' : '✗' + lg.info(`${icon} 日历事件渲染: ${status} (${calendarEventFields.length} FullCalendar 事件字段, ${apiFields.length} API 字段 [源:${apiSource}]${missing.length ? `, 缺 ${missing.length}` : ''})`) + } + + // === Gate 2: form 字段 ⊆ api (含 getInfo) === + let infoUnionSet = new Set() + let infoSource = 'list-only' + if (apiFlat.length > 0) { + const sample = opts.id || apiFlat[0].id + try { + const infoResp: any = await loadSchedule.getInfo(sample) + const data = (infoResp as any)?.data || infoResp + if (data && typeof data === 'object') { + infoSource = 'list+info' + for (const k of Object.keys(data)) infoUnionSet.add(k) + } + } catch (e) { + lg.warn(`getInfo(${sample}) 失败 (Gate 2 仅用 list): ${(e as Error).message}`) + } + } + const formApiFieldSet = new Set([...apiFieldSet, ...infoUnionSet]) + { + const missing = formFields.filter(f => !formApiFieldSet.has(f)) + const status: 'PASS' | 'FAIL' = missing.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'schedule', + page: '日程表单', + sourceFile: 'views/teamwork/schedule/Form.vue (schemas L65-202) + getInfo', + renderFields: formFields, + apiFields: Array.from(formApiFieldSet).sort(), + missing, + extra: [], + status, + }) + const icon = status === 'PASS' ? '✓' : '✗' + lg.info(`${icon} 日程表单: ${status} (${formFields.length} 渲染字段, ${formApiFieldSet.size} API 字段 [源:${infoSource}]${missing.length ? `, 缺 ${missing.length}` : ''})`) + } + + // === Gate 3: 必填字段 === + { + const issues: string[] = [] + for (const sc of apiFlat) { + const label = sc.fullName || sc.title || sc.id || '<无标识>' + for (const k of requiredFields) { + if ((sc as any)[k] === undefined || (sc as any)[k] === null || (sc as any)[k] === '') { + issues.push(`${label}: ${k} 缺失 (Form.vue required)`) + } + } + } + if (apiFlat.length === 0) issues.push('无日程/任务数据 (跳过必填校验)') + const status: 'PASS' | 'FAIL' = issues.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'schedule', + page: '日程必填字段', + sourceFile: 'Form.vue L65-202 rules.required', + renderFields: requiredFields, + apiFields: requiredFields, + missing: issues, + extra: [], + status, + }) + if (issues.length === 0) { + lg.info(`✓ 日程必填字段: PASS (${apiFlat.length} 条记录, 全部必填字段非空)`) + } else { + lg.error(`✗ 日程必填字段: FAIL (${issues.slice(0, 3).join(' | ')}${issues.length > 3 ? '...' : ''})`) + } + } + + // === Gate 4: schema (repetition JSON.parse + startDay/endDay 时间序) === + { + const schemaIssues: string[] = [] + let repetitionParsed = 0 + for (const sc of apiFlat) { + const label = sc.title || sc.fullName || sc.id || '<无标识>' + if (sc.repetition !== undefined && sc.repetition !== null && sc.repetition !== '') { + if (typeof sc.repetition !== 'string') { + schemaIssues.push(`${label}: repetition 类型不对 (期望 string JSON, 实际 ${typeof sc.repetition})`) + } else { + try { + const parsed = JSON.parse(sc.repetition) + if (typeof parsed !== 'object' || parsed === null) { + schemaIssues.push(`${label}: repetition 解析后非对象`) + } else { + repetitionParsed++ + } + } catch (e) { + schemaIssues.push(`${label}: repetition JSON.parse 失败: ${(e as Error).message.slice(0, 60)}`) + } + } + } + if (sc.startDay && sc.endDay && new Date(sc.startDay) > new Date(sc.endDay)) { + schemaIssues.push(`${label}: startDay=${sc.startDay} > endDay=${sc.endDay} 时间序错误`) + } + } + if (apiFlat.length === 0) schemaIssues.push('无日程数据 (跳过 schema 校验)') + const status: 'PASS' | 'FAIL' = schemaIssues.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'schedule', + page: '日程 schema', + sourceFile: 'repetition JSON.parse (Form.vue L190) + startDay/endDay 时间序 (L136 validator)', + renderFields: ['repetition (JSON.parse)', 'startDay 3 ? '...' : ''})`) + } + } +} + +// ============================================================================ +// Monitor module (监控, v0.14+ NEW, 2026-07-01 — 镜像 §TC-C 4 视图契约) +// +// 4 个子视图: +// - platformMonitor (getSysMonitor → state.cpu/memory/disk/system + 3 percentage) +// - msgMonitor (getMsgMonitorList → messageType/messageSource/title/sendTime) +// - userOnline (getOnlineUser → userName/organize/loginIPAddress/.../loginTime) +// - flowMonitor (getFlowMonitorList → fullName/systemName/flowName/.../status) +// +// 镜像 web 端: +// - web/.../monitor/platformMonitor/index.vue L32-60 state (getSysMonitor) +// - web/.../monitor/msgMonitor/index.vue L27-30 columns +// - web/.../monitor/userOnline/index.vue L21-28 columns +// - web/.../monitor/flowMonitor/index.vue L48-58 columns + taskColumns +// ============================================================================ + +async function renderMonitor( + c: JnpfClient, + opts: RenderOpts, + results: RenderCheckResult[], + logFn: { info: (...a: unknown[]) => void; warn: (...a: unknown[]) => void; error: (...a: unknown[]) => void } = real, +): Promise { + await initWebapiMonitor(c) + const lg = logFn + + // Gate 1: msgMonitor 列表 + { + const listFields = ['messageType', 'messageSource', 'title', 'sendTime'] + let apiFieldSet = new Set() + let apiData: any[] = [] + let apiSource: 'live-data' | 'empty' = 'empty' + try { + const r: any = await c.get('/msgCenter/MsgMonitor', { currentPage: 1, pageSize: 20 }) + const list = Array.isArray(r?.data?.list) ? r.data.list : Array.isArray(r?.list) ? r.list : [] + apiData = list + for (const item of apiData) { + if (item && typeof item === 'object') { + for (const k of Object.keys(item)) apiFieldSet.add(k) + } + } + apiSource = apiData.length > 0 ? 'live-data' : 'empty' + } catch (e) { + lg.warn(`msgMonitor 列表失败: ${(e as Error).message}`) + } + const apiFields = Array.from(apiFieldSet).sort() + const missing = listFields.filter(f => !apiFieldSet.has(f)) + const status: 'PASS' | 'FAIL' = missing.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'monitor', + page: 'msgMonitor 列表', + sourceFile: 'views/monitor/msgMonitor/index.vue (columns L27-30)', + renderFields: listFields, + apiFields, + missing, + extra: apiFields.filter(f => !new Set(listFields).has(f)), + status, + }) + const icon = status === 'PASS' ? '✓' : '✗' + lg.info(`${icon} msgMonitor 列表: ${status} (${listFields.length} 渲染字段, ${apiFields.length} API 字段 [源:${apiSource}]${missing.length ? `, 缺 ${missing.length}` : ''})`) + } + + // Gate 2: userOnline 列表 + { + const listFields = ['userName', 'organize', 'loginIPAddress', 'loginAddress', 'loginBrowser', 'loginSystem', 'loginTime'] + let apiFieldSet = new Set() + let apiData: any[] = [] + let apiSource: 'live-data' | 'empty' = 'empty' + try { + const r: any = await c.get('/system/OnlineUser', { currentPage: 1, pageSize: 20 }) + const list = Array.isArray(r?.data?.list) ? r.data.list : Array.isArray(r?.list) ? r.list : [] + apiData = list + for (const item of apiData) { + if (item && typeof item === 'object') { + for (const k of Object.keys(item)) apiFieldSet.add(k) + } + } + apiSource = apiData.length > 0 ? 'live-data' : 'empty' + } catch (e) { + lg.warn(`userOnline 列表失败: ${(e as Error).message}`) + } + const apiFields = Array.from(apiFieldSet).sort() + const missing = listFields.filter(f => !apiFieldSet.has(f)) + const status: 'PASS' | 'FAIL' = missing.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'monitor', + page: 'userOnline 列表', + sourceFile: 'views/monitor/userOnline/index.vue (columns L21-28)', + renderFields: listFields, + apiFields, + missing, + extra: apiFields.filter(f => !new Set(listFields).has(f)), + status, + }) + const icon = status === 'PASS' ? '✓' : '✗' + lg.info(`${icon} userOnline 列表: ${status} (${listFields.length} 渲染字段, ${apiFields.length} API 字段 [源:${apiSource}]${missing.length ? `, 缺 ${missing.length}` : ''})`) + } + + // Gate 3: flowMonitor 列表 + { + const listFields = ['fullName', 'systemName', 'flowName', 'startTime', 'creatorUser', 'currentNodeName', 'isFile', 'flowUrgent', 'flowVersion', 'status'] + let apiFieldSet = new Set() + let apiData: any[] = [] + let apiSource: 'live-data' | 'empty' = 'empty' + try { + const r: any = await c.get('/workflow/FlowMonitor', { currentPage: 1, pageSize: 20, type: 0 }) + const list = Array.isArray(r?.data?.list) ? r.data.list : Array.isArray(r?.list) ? r.list : [] + apiData = list + for (const item of apiData) { + if (item && typeof item === 'object') { + for (const k of Object.keys(item)) apiFieldSet.add(k) + } + } + apiSource = apiData.length > 0 ? 'live-data' : 'empty' + } catch (e) { + lg.warn(`flowMonitor 列表失败: ${(e as Error).message}`) + } + const apiFields = Array.from(apiFieldSet).sort() + const missing = listFields.filter(f => !apiFieldSet.has(f)) + const status: 'PASS' | 'FAIL' = missing.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'monitor', + page: 'flowMonitor 列表', + sourceFile: 'views/monitor/flowMonitor/index.vue (columns L48-58)', + renderFields: listFields, + apiFields, + missing, + extra: apiFields.filter(f => !new Set(listFields).has(f)), + status, + }) + const icon = status === 'PASS' ? '✓' : '✗' + lg.info(`${icon} flowMonitor 列表: ${status} (${listFields.length} 渲染字段, ${apiFields.length} API 字段 [源:${apiSource}]${missing.length ? `, 缺 ${missing.length}` : ''})`) + } + + // Gate 4: platformMonitor schema (getSysMonitor) + { + let monitorData: any = null + try { + const r: any = await loadMonitor.getSysMonitor() + monitorData = (r?.data !== undefined ? r.data : r) + } catch (e) { + lg.warn(`getSysMonitor 失败: ${(e as Error).message}`) + } + const schemaIssues: string[] = [] + if (monitorData && typeof monitorData === 'object') { + const requiredRoots = ['cpu', 'memory', 'disk', 'system'] + for (const k of requiredRoots) { + if (!(k in monitorData)) schemaIssues.push(`getSysMonitor 缺 ${k} 根字段 (platformMonitor state L32-60 必含)`) + } + if (monitorData.cpuPercentage !== undefined && typeof monitorData.cpuPercentage !== 'number') { + schemaIssues.push(`getSysMonitor.cpuPercentage 类型不对 (期望 number, 实际 ${typeof monitorData.cpuPercentage})`) + } + if (monitorData.memoryPercentage !== undefined && typeof monitorData.memoryPercentage !== 'number') { + schemaIssues.push(`getSysMonitor.memoryPercentage 类型不对 (期望 number, 实际 ${typeof monitorData.memoryPercentage})`) + } + if (monitorData.diskPercentage !== undefined && typeof monitorData.diskPercentage !== 'number') { + schemaIssues.push(`getSysMonitor.diskPercentage 类型不对 (期望 number, 实际 ${typeof monitorData.diskPercentage})`) + } + } else { + schemaIssues.push('getSysMonitor 返回非对象或空') + } + const status: 'PASS' | 'FAIL' = schemaIssues.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'monitor', + page: 'platformMonitor schema', + sourceFile: 'views/monitor/platformMonitor/index.vue (state L32-60) + getSysMonitor', + renderFields: ['cpu', 'memory', 'disk', 'system', 'cpuPercentage', 'memoryPercentage', 'diskPercentage'], + apiFields: monitorData ? Object.keys(monitorData) : [], + missing: schemaIssues, + extra: [], + status, + }) + if (schemaIssues.length === 0) { + lg.info(`✓ platformMonitor schema: PASS (cpu/memory/disk/system 4 根字段 + 3 percentage 完整)`) + } else { + lg.error(`✗ platformMonitor schema: FAIL (${schemaIssues.slice(0, 3).join(' | ')}${schemaIssues.length > 3 ? '...' : ''})`) + } + } +} + +// ============================================================================ +// User module (用户, v0.14+ NEW, 2026-07-01 — 镜像 §TC-C 4 关卡真实契约) +// +// 镜像 web 端: +// - web/.../permission/user/index.vue L69-78 columns BasicColumn (8 字段) +// - web/.../permission/user/Form.vue L20-200 schemas (30+ 字段) +// - web/.../permission/user/Form.vue L218-237 init(data): getUserInfo(id) → setFieldsValue + updateSchema gender/nation/education +// - web/.../api/permission/user.ts getUserList/getUserInfo/getUserSelector +// ============================================================================ + +async function renderUser( + c: JnpfClient, + opts: RenderOpts, + results: RenderCheckResult[], + logFn: { info: (...a: unknown[]) => void; warn: (...a: unknown[]) => void; error: (...a: unknown[]) => void } = real, +): Promise { + await initWebapiUser(c) + const lg = logFn + + const listFields = ['account', 'realName', 'gender', 'mobilePhone', 'position', 'creatorTime', 'sortCode', 'enabledMark'] + const formFields = [ + 'account', 'realName', 'gender', 'email', 'mobilePhone', 'ranks', 'sortCode', + 'enabledMark', 'description', 'headIcon', 'nation', 'nativePlace', 'certificatesType', + 'entryDate', 'certificatesNumber', 'education', 'birthday', 'telePhone', 'landline', + 'urgentContacts', 'urgentTelePhone', 'postalAddress', + 'organizeId', 'positionId', 'roleId', 'managerId', 'isAdministrator', + ] + const requiredFields = ['account', 'realName', 'gender'] + + let apiFlat: any[] = [] + let apiSource: 'live-data' | 'empty' = 'empty' + try { + const r: any = await loadUser.getUserList({ currentPage: 1, pageSize: 50 }) + const list = Array.isArray(r?.data?.list) ? r.data.list : Array.isArray(r?.list) ? r.list : [] + apiFlat = list + apiSource = apiFlat.length > 0 ? 'live-data' : 'empty' + } catch (e) { + lg.warn(`getUserList 失败: ${(e as Error).message}`) + } + + if (apiSource === 'empty') { + try { + const r: any = await loadUser.getUserSelector({ currentPage: 1, pageSize: 50 }) + const list = Array.isArray(r?.data?.list) ? r.data.list : Array.isArray(r?.list) ? r.list : [] + if (list.length > 0) { + apiFlat = list + apiSource = 'live-data' + lg.info(`user 列表: getUserList 空, fallback getUserSelector (${list.length} 条)`) + } + } catch { /* keep empty */ } + } + + const apiFieldSet = new Set() + for (const item of apiFlat) { + if (item && typeof item === 'object') { + for (const k of Object.keys(item)) apiFieldSet.add(k) + } + } + const apiFields = Array.from(apiFieldSet).sort() + if (apiSource === 'empty') { + lg.warn('user API 返回空, 字段对比会标记全部缺失') + } + + // === Gate 1: 列表字段 ⊆ api === + { + const renderSet = new Set(listFields) + const missing = listFields.filter(f => !apiFieldSet.has(f)) + const status: 'PASS' | 'FAIL' = missing.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'user', + page: '用户列表', + sourceFile: 'views/permission/user/index.vue (columns L69-78)', + renderFields: listFields, + apiFields, + missing, + extra: apiFields.filter(f => !renderSet.has(f)), + status, + }) + const icon = status === 'PASS' ? '✓' : '✗' + lg.info(`${icon} 用户列表: ${status} (${listFields.length} 渲染字段, ${apiFields.length} API 字段 [源:${apiSource}]${missing.length ? `, 缺 ${missing.length}` : ''})`) + } + + // === Gate 2: form 字段 ⊆ list ∪ getInfo === + let infoUnionSet = new Set() + let infoSource = 'list-only' + if (apiFlat.length > 0) { + const sample = opts.id || apiFlat[0].id + try { + const infoResp: any = await loadUser.getUserInfo(sample) + const data = (infoResp as any)?.data || infoResp + if (data && typeof data === 'object') { + infoSource = 'list+info' + for (const k of Object.keys(data)) infoUnionSet.add(k) + } + } catch (e) { + lg.warn(`getUserInfo(${sample}) 失败 (Gate 2 仅用 list): ${(e as Error).message}`) + } + } + const formApiFieldSet = new Set([...apiFieldSet, ...infoUnionSet]) + { + const missing = formFields.filter(f => !formApiFieldSet.has(f)) + const status: 'PASS' | 'FAIL' = missing.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'user', + page: '用户表单', + sourceFile: 'views/permission/user/Form.vue (schemas L20-200) + getUserInfo', + renderFields: formFields, + apiFields: Array.from(formApiFieldSet).sort(), + missing, + extra: [], + status, + }) + const icon = status === 'PASS' ? '✓' : '✗' + lg.info(`${icon} 用户表单: ${status} (${formFields.length} 渲染字段, ${formApiFieldSet.size} API 字段 [源:${infoSource}]${missing.length ? `, 缺 ${missing.length}` : ''})`) + } + + // === Gate 3: 必填字段完整性 === + { + const issues: string[] = [] + for (const u of apiFlat) { + const label = u.realName || u.account || u.id || '<无标识>' + if (!u.account) issues.push(`${label}: account 缺失 (Form.vue L33 required)`) + if (!u.realName) issues.push(`${label}: realName 缺失 (Form.vue L38 required)`) + if (!u.gender) issues.push(`${label}: gender 缺失 (Form.vue L47 required)`) + } + if (apiFlat.length === 0) issues.push('无用户数据 (跳过必填校验)') + const status: 'PASS' | 'FAIL' = issues.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'user', + page: '用户必填字段', + sourceFile: 'Form.vue L33-47 rules.required', + renderFields: requiredFields, + apiFields: requiredFields, + missing: issues, + extra: [], + status, + }) + if (issues.length === 0) { + lg.info(`✓ 用户必填字段: PASS (${apiFlat.length} 个用户, account/realName/gender 全部非空)`) + } else { + lg.error(`✗ 用户必填字段: FAIL (${issues.slice(0, 3).join(' | ')}${issues.length > 3 ? '...' : ''})`) + } + } + + // === Gate 4: schema 完整性 === + { + const issues: string[] = [] + const UUID_HEX_32 = /^[0-9a-f]{32}$/i + for (const u of apiFlat) { + const label = u.realName || u.account || u.id || '<无标识>' + if (u.enabledMark !== undefined && u.enabledMark !== null && typeof u.enabledMark !== 'number' && typeof u.enabledMark !== 'string') { + issues.push(`${label}: enabledMark 类型不对 (期望 number/string, 实际 ${typeof u.enabledMark})`) + } + if (u.organizeId && !UUID_HEX_32.test(String(u.organizeId))) { + lg.warn(`user: ${label} organizeId="${u.organizeId}" 不是 UUID 32hex (list 端可能返 enCode)`) + } + const genderSet = new Set(['Man', 'Woman', 'Unknown']) + if (u.gender && !genderSet.has(String(u.gender)) && !UUID_HEX_32.test(String(u.gender))) { + lg.warn(`user: ${label} gender="${u.gender}" 偏离字典预期 (Man/Woman/UUID)`) + } + } + if (apiFlat.length === 0) issues.push('无用户数据 (跳过 schema 校验)') + const status: 'PASS' | 'FAIL' = issues.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'user', + page: '用户 schema', + sourceFile: 'enabledMark 1/0 (Form.vue L78) + organizeId 树形 + gender 字典', + renderFields: ['enabledMark (number)', 'organizeId (UUID)', 'gender (字典 enCode)'], + apiFields: ['enabledMark', 'organizeId', 'gender'], + missing: issues, + extra: [], + status, + }) + if (issues.length === 0) { + lg.info(`✓ 用户 schema: PASS (enabledMark 类型合规, organizeId/gender 字典格式检查通过)`) + } else { + lg.error(`✗ 用户 schema: FAIL (${issues.slice(0, 3).join(' | ')}${issues.length > 3 ? '...' : ''})`) + } + } + + // === Gate 5 (可选, --id): 单条用户 getInfo 完整性 === + if (opts.id) { + let infoDetail: any + try { + infoDetail = await loadUser.getUserInfo(opts.id) + } catch (e) { + lg.error(`getUserInfo(${opts.id}) 失败: ${(e as Error).message}`) + return + } + const data = (infoDetail as any)?.data || infoDetail + if (!data || typeof data !== 'object') { + lg.error(`getUserInfo(${opts.id}) 返回非对象`) + return + } + const infoFieldSet = new Set(Object.keys(data)) + const requiredInfoFields = ['id', 'account', 'realName', 'gender', 'enabledMark', 'organizeId', 'positionId', 'roleId', 'managerId'] + const missing = requiredInfoFields.filter(f => !infoFieldSet.has(f)) + const details = `account=${data.account || '<空>'}, realName=${data.realName || '<空>'}` + const status: 'PASS' | 'FAIL' = missing.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'user', + page: '单条用户 getInfo 完整性', + sourceFile: `getUserInfo (userId=${opts.id}, ${details})`, + renderFields: requiredInfoFields, + apiFields: Array.from(infoFieldSet).sort(), + missing, + extra: [], + status, + }) + if (status === 'PASS') { + lg.info(`✓ 单条用户 getInfo: PASS (${infoFieldSet.size} 字段, ${details})`) + } else { + lg.error(`✗ 单条用户 getInfo: FAIL (${missing.slice(0, 3).join(' | ')}${missing.length > 3 ? '...' : ''})`) + } + } +} + +// ============================================================================ +// Log module (日志, v0.14+ NEW, 2026-07-01 — 镜像 §TC-C 4 类别契约) +// +// 4 个日志类别 (web 端 state.category: 1 登录 / 3 操作 / 4 异常 / 5 请求): +// - loginLog views/sysLog/loginLog/index.vue +// - operateLog views/sysLog/operateLog/index.vue +// - errorLog views/sysLog/errorLog/index.vue +// - requestLog views/sysLog/requestLog/index.vue +// +// 镜像 web 端: +// - web/.../sysLog/loginLog/index.vue L24-35 columns +// - web/.../sysLog/operateLog/index.vue L26-37 columns +// - web/.../sysLog/errorLog/index.vue L26-33 columns +// - web/.../sysLog/requestLog/index.vue L25-33 columns +// - web/.../api/system/log.ts getLogList({ category, ... }) +// ============================================================================ + +async function renderLog( + c: JnpfClient, + opts: RenderOpts, + results: RenderCheckResult[], + logFn: { info: (...a: unknown[]) => void; warn: (...a: unknown[]) => void; error: (...a: unknown[]) => void } = real, +): Promise { + await initWebapiLog(c) + const lg = logFn + + const logSpecs: { page: string; category: string; listFields: string[]; renderFile: string }[] = [ + { + page: 'loginLog 列表', + category: '1', + listFields: ['loginType', 'creatorTime', 'userName', 'ipAddress', 'ipAddressName', 'browser', 'platForm', 'requestDuration', 'loginMark', 'abstracts'], + renderFile: 'views/sysLog/loginLog/index.vue (columns L24-35)', + }, + { + page: 'operateLog 列表', + category: '3', + listFields: ['creatorTime', 'userName', 'ipAddress', 'ipAddressName', 'browser', 'platForm', 'moduleName', 'requestMethod', 'requestDuration', 'requestUrl'], + renderFile: 'views/sysLog/operateLog/index.vue (columns L26-37)', + }, + { + page: 'errorLog 列表', + category: '4', + listFields: ['creatorTime', 'userName', 'ipAddress', 'ipAddressName', 'browser', 'platForm', 'requestMethod', 'requestUrl'], + renderFile: 'views/sysLog/errorLog/index.vue (columns L26-33)', + }, + { + page: 'requestLog 列表', + category: '5', + listFields: ['creatorTime', 'userName', 'ipAddress', 'ipAddressName', 'browser', 'platForm', 'requestMethod', 'requestDuration', 'requestUrl'], + renderFile: 'views/sysLog/requestLog/index.vue (columns L25-33)', + }, + ] + + for (const spec of logSpecs) { + let apiFieldSet = new Set() + let apiData: any[] = [] + let apiSource: 'live-data' | 'empty' = 'empty' + try { + const r: any = await loadLog.getLogList({ category: spec.category, currentPage: 1, pageSize: 20 }) + const list = Array.isArray(r?.data?.list) ? r.data.list : Array.isArray(r?.list) ? r.list : [] + apiData = list + for (const item of apiData) { + if (item && typeof item === 'object') { + for (const k of Object.keys(item)) apiFieldSet.add(k) + } + } + apiSource = apiData.length > 0 ? 'live-data' : 'empty' + } catch (e) { + lg.warn(`${spec.page}: getLogList(category=${spec.category}) 失败: ${(e as Error).message}`) + } + const apiFields = Array.from(apiFieldSet).sort() + const renderSet = new Set(spec.listFields) + const missing = spec.listFields.filter(f => !apiFieldSet.has(f)) + const extra = apiFields.filter(f => !renderSet.has(f)) + const status: 'PASS' | 'FAIL' = missing.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'log', + page: spec.page, + sourceFile: spec.renderFile, + renderFields: spec.listFields, + apiFields, + missing, + extra, + status, + }) + const icon = status === 'PASS' ? '✓' : '✗' + lg.info(`${icon} ${spec.page}: ${status} (${spec.listFields.length} 渲染字段, ${apiFields.length} API 字段 [源:${apiSource}]${missing.length ? `, 缺 ${missing.length}` : ''})`) + } +} + +// ============================================================================ +// Report module (报表, v0.14+ NEW, 2026-07-01 — 镜像 §TC-C 4 关卡真实契约) +// +// 算法 (4 关卡): +// 1. 读 web 端 views/onlineDev/report/index.vue (BasicColumn.dataIndex 列表字段) +// + views/onlineDev/report/Form.vue (useForm schemas[].field 表单字段) +// 2. 调 loadReport.getReportList (走 webapi 镜像) → 拿报表列表 +// **BACKEND-7 (已知 nginx bug, 2026-07-01)**: nginx /api/Report 重定向 /api/Report/ → 404 +// workaround: list 失败时 fallback 到 getReportSelector (Selector 端点 /api/Report/Selector 不被 301 拦截) +// info/templates/update 路径 (/api/Report/{id} /api/Report/Selector) 不受影响, 正常返回 +// 3. 4 关卡: +// 3.1 list 字段 ⊆ api 字段 (BasicColumn 必能渲染) +// 3.2 form 字段 ⊆ api 字段 (form schemas 必能 setFieldsValue, list ∪ info) +// 3.3 必填/外键/关联完整性: fullName/enCode/category 必填 + systemId 应用隔离 + enabledMark 状态 +// 3.4 schema 完整性: cells 至少 1 cell + snapshot JSON.parse + allowExport/Print/Watermark boolean + +// watermarkConfig JSON.parse + platformRelease JSON.parse 必含 {pc,app} +// 4. --id= 时追加单条报表 schema 详细校验 (第 5 个关卡) +// +// 镜像 web 端: +// - web/.../onlineDev/report/index.vue L24-33 columns BasicColumn: +// fullName/enCode/category/creatorUser/creatorTime/lastModifyTime/sortCode/state +// - web/.../onlineDev/report/Form.vue L26-62 useForm schemas (5 字段): +// fullName/enCode/category/sortCode/description +// 注: Form.vue 是元数据编辑弹窗 (只填名称/编码/分类), 不编辑 cells/snapshot 等报表设计内容 +// cells/snapshot/allowExport 等是 getInfo 返的扩展字段, 由 univer Designer 处理 +// - web/.../api/onlineDev/report.ts getReportList + getReportInfo + getReportSelector +// +// BACKEND-7 (nCOPE, 2026-07-01): +// nginx /api/Report → 301 → /api/Report/ → 404 (Spring 32000 不识别带斜杠根) +// 影响端点: list/create/delete (走 /api/Report, /api/Report/{id}/Actions/Copy 等) +// workaround: 走 Selector 端点 (getReportSelector) 拿全量, 路径模式 /api/Report/Selector +// 不受影响: info /api/Report/{id} + templates /api/Report/Selector + Actions/Module /api/Report/{id}/Actions/Module +// ============================================================================ + +/** + * 渲染 report module: 4 关卡 + 可选第 5 关卡 (单条报表 getInfo schema 完整性) + */ +async function renderReport( + c: JnpfClient, + opts: RenderOpts, + results: RenderCheckResult[], + logFn: { info: (...a: unknown[]) => void; warn: (...a: unknown[]) => void; error: (...a: unknown[]) => void } = real, +): Promise { + await initWebapiReport(c) + const lg = logFn + + // === 1. 读 web 端渲染契约 === + // 列表字段: views/onlineDev/report/index.vue L24-33 columns BasicColumn (8 列) + // - fullName / enCode / category / creatorUser / creatorTime / lastModifyTime / sortCode / state + // - 注意: state 列绑的是 enabledMark 字段 (index.vue L180 已发布/未发布 a-tag 用 record.enabledMark == 1) + // - 但 BasicColumn.dataIndex='state' 走的是 record.state, 后端实际返 enabledMark + // - 所以 list 渲染字段要含 state 和 enabledMark 两个 (dataIndex='state' + tag 渲染用 enabledMark) + // - 简化: 只用 dataIndex (BasicColumn 渲染走 dataIndex), 即可对应后端 enabledMark + // → 这里后端 list 实际返 enabledMark, 不返 state, 需要 ⚠ 标记 + // 简化策略: 把 8 个 dataIndex 全部作为渲染字段; 后端返 enabledMark 而不是 state 时, 单独记录为 schema warning + const listFields = [ + 'fullName', 'enCode', 'category', + 'creatorUser', 'creatorTime', 'lastModifyTime', + 'sortCode', 'state', + ] + // 表单字段: views/onlineDev/report/Form.vue L26-62 useForm schemas (5 字段) + // - fullName (required) / enCode (formValidate) / category (required, 字典) + // - sortCode / description + const formFields = ['fullName', 'enCode', 'category', 'sortCode', 'description'] + // 必填: fullName + category (Form.vue L32/L46 required) + const requiredFields = ['fullName', 'enCode', 'category'] + + // === 2. 调 webapi 拿实际数据 (BACKEND-7: list 受 nginx 301 影响, fallback Selector) === + let apiFlat: any[] = [] + let apiSource: 'live-data' | 'empty' | 'selector-fallback' = 'empty' + let backend7UsedFallback = false + + // 先尝试 list 端点 + try { + const r: any = await loadReport.getReportList({ currentPage: 1, pageSize: 50 }) + const list = unwrapWebapiArray(r) + // 还可能返回 { data: { list: [] } } 包络 (某些 webapi shim 返回) + if (list.length === 0 && r?.data?.list) { + apiFlat = Array.isArray(r.data.list) ? r.data.list : [] + } else { + apiFlat = list + } + apiSource = apiFlat.length > 0 ? 'live-data' : 'empty' + } catch (e) { + // BACKEND-7: list 端点 301→404, 预期失败, 不当作 ERROR + const msg = (e as Error).message + lg.warn(`report getReportList 失败 (BACKEND-7 nginx 301 → 404, 预期): ${msg.slice(0, 100)}`) + } + + // BACKEND-7 fallback: 用 Selector 端点 (/api/Report/Selector 不被 301 拦截) + if (apiFlat.length === 0) { + backend7UsedFallback = true + try { + const r: any = await loadReport.getReportSelector() + // Selector 返回树形 (有 children), 递归展平叶节点 (id 是 report id 的项, 通常 hasChildren=null) + const selList = unwrapWebapiArray(r) + const flat: any[] = [] + const walk = (nodes: any[]) => { + for (const n of (nodes || [])) { + if (n && typeof n === 'object') { + // Selector 树中叶节点: 有 id 且 hasChildren 为 null/false + // 父节点 (分类) 通常 id 是字典 enCode 形式 (32hex), 子节点才是报表 id (数字) + if (n.hasChildren === null || n.hasChildren === undefined || n.hasChildren === false) { + flat.push(n) + } + if (n.children) walk(n.children) + } + } + } + walk(selList) + apiFlat = flat + apiSource = apiFlat.length > 0 ? 'selector-fallback' : 'empty' + if (apiFlat.length > 0) { + lg.warn(`BACKEND-7 workaround: list 受 nginx 301 影响, fallback Selector (${apiFlat.length} 条)`) + } + } catch (e) { + lg.warn(`report getReportSelector fallback 也失败: ${(e as Error).message}`) + } + } + + if (apiSource === 'empty') { + lg.warn('report API 返回空 (Selector 也空), 字段对比会标记全部缺失 (可通过 dacli report create 创建测试报表)') + } + + // 收集 API 字段 (所有样本的字段并集) + const apiFieldSet = new Set() + for (const item of apiFlat) { + if (item && typeof item === 'object') { + for (const k of Object.keys(item)) apiFieldSet.add(k) + } + } + const apiFields = Array.from(apiFieldSet).sort() + + // === 3.1 Gate 1: 列表字段 ⊆ api 字段 === + // ⚠ schema warning: web 端 BasicColumn.dataIndex='state' 但后端 list 实际返 enabledMark + // → 列表期望的 state 字段大概率缺失, 标记为 schema warning 而非 FAIL + // (浏览器渲染: a-tag 用 record.enabledMark == 1, tag 模板 L180) + { + const renderSet = new Set(listFields) + const missing = listFields.filter(f => !apiFieldSet.has(f)) + const extra = apiFields.filter(f => !renderSet.has(f)) + const status: 'PASS' | 'FAIL' = missing.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'report', + page: '报表列表', + sourceFile: 'views/onlineDev/report/index.vue (columns L24-33) + tag 模板 enabledMark (L180)', + renderFields: listFields, + apiFields, + missing, + extra, + status, + }) + const icon = status === 'PASS' ? '✓' : '✗' + lg.info(`${icon} 报表列表: ${status} (${listFields.length} 渲染字段, ${apiFields.length} API 字段 [源:${apiSource}]${missing.length ? `, 缺 ${missing.length}` : ''}${backend7UsedFallback ? ' [BACKEND-7 fallback]' : ''})`) + } + + // === 3.2 Gate 2: form 字段 ⊆ api 字段 (list ∪ getInfo) === + // 镜像 web Form.vue L64-80 init(data): getReportInfo(id) → setFieldsValue + // form 必填字段应 ⊆ (list API 字段 ∪ info API 字段) + let infoUnionSet = new Set() + let infoSource = 'list-only' + if (apiFlat.length > 0) { + // 拿第一条报表调 getInfo (info 字段集对所有报表结构相同, 抽样即可) + const sample = opts.id || apiFlat[0].id + try { + const infoResp: any = await loadReport.getReportInfo(sample) + const data = unwrapWebapiObject(infoResp) + if (data && typeof data === 'object') { + infoSource = 'list+info' + for (const k of Object.keys(data)) infoUnionSet.add(k) + } + } catch (e) { + lg.warn(`getReportInfo(${sample}) 失败 (Gate 2 仅用 list): ${(e as Error).message}`) + } + } + const formApiFieldSet = new Set([...apiFieldSet, ...infoUnionSet]) + const formApiFields = Array.from(formApiFieldSet).sort() + { + const renderSet = new Set(formFields) + const missing = formFields.filter(f => !formApiFieldSet.has(f)) + const extra = formApiFields.filter(f => !renderSet.has(f)) + const status: 'PASS' | 'FAIL' = missing.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'report', + page: '报表表单', + sourceFile: 'views/onlineDev/report/Form.vue (schemas L26-62) + getReportInfo (L64-80)', + renderFields: formFields, + apiFields: formApiFields, + missing, + extra, + status, + }) + const icon = status === 'PASS' ? '✓' : '✗' + lg.info(`${icon} 报表表单: ${status} (${formFields.length} 渲染字段, ${formApiFields.length} API 字段 [源:${infoSource}]${missing.length ? `, 缺 ${missing.length}` : ''})`) + } + + // === 3.3 Gate 3: 必填/外键/关联完整性 (fullName/enCode/category + systemId 应用隔离 + enabledMark 状态) === + // 镜像 web: + // - Form.vue L26-62: fullName required / enCode formValidate / category required (字典外键) + // - 应用隔离: report 应有 systemId 字段 (跟其他菜单/表单一致, App-Code 头决定) + // - enabledMark 是发布状态字段 (index.vue L180 已发布/未发布 a-tag 用 record.enabledMark == 1) + // → list 返 enabledMark 而非 state, index.vue L180 tag 渲染确认 + // - category 是字典外键 (Selector/业务报表都有 category 字典 UUID) + const requiredIssues: string[] = [] + const systemIdIssues: string[] = [] + const stateIssues: string[] = [] + if (apiFlat.length > 0) { + for (const r of apiFlat) { + const label = r.fullName || r.enCode || r.id || '<无标识>' + // 必填字段 (Form.vue L32/L39/L46) + if (!r.fullName) requiredIssues.push(`${label}: fullName 缺失 (Form.vue L32 required)`) + if (!r.enCode) requiredIssues.push(`${label}: enCode 缺失 (Form.vue L39 formValidate)`) + if (!r.category) requiredIssues.push(`${label}: category 缺失 (Form.vue L46 required 字典外键)`) + // systemId 应用隔离 + if (!r.systemId) { + systemIdIssues.push(`${label}: systemId 缺失 (App-Code 应用隔离字段)`) + } + // enabledMark 是发布状态字段 (index.vue L180 tag 渲染) + if (r.enabledMark === undefined || r.enabledMark === null) { + stateIssues.push(`${label}: enabledMark 缺失 (index.vue L180 tag 渲染)`) + } + } + } else { + requiredIssues.push('无报表数据 (跳过必填校验)') + } + { + const allIssues = [...requiredIssues, ...systemIdIssues, ...stateIssues] + const status: 'PASS' | 'FAIL' = allIssues.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'report', + page: '必填/外键/关联完整性', + sourceFile: 'Form.vue L26-62 (fullName/enCode/category required + category 字典外键) + systemId 应用隔离 + index.vue L180 enabledMark tag', + renderFields: requiredFields.concat(['systemId', 'enabledMark']), + apiFields: requiredFields.concat(['systemId', 'enabledMark']), + missing: allIssues, + extra: [], + status, + }) + if (allIssues.length === 0) { + lg.info(`✓ 必填/外键/关联完整性: PASS (${apiFlat.length} 张报表, fullName/enCode/category 必填 + systemId 应用隔离 + enabledMark 状态全部完整)`) + } else { + lg.error(`✗ 必填/外键/关联完整性: FAIL (${allIssues.slice(0, 3).join(' | ')}${allIssues.length > 3 ? '...' : ''})`) + } + } + + // === 3.4 Gate 4: schema 完整性 (cells + snapshot + allowExport/Print/Watermark + watermarkConfig + platformRelease) === + // 镜像 web getReportInfo 返的扩展字段 (univer Designer 用, 不是 Form.vue 元数据编辑): + // - cells: 报表单元格定义 (JSON object, 设计器必含), 新建报表可能为 null + // - snapshot: 报表设计快照 (workbook 序列化), univer 工作簿快照 + // - allowExport: 是否允许导出 (number 0/1) + // - allowPrint: 是否允许打印 (number 0/1) + // - allowWatermark: 是否加水印 (number 0/1) + // - watermarkConfig: 水印配置 JSON 字符串 ({content, fontSize, color, ...}) + // - platformRelease: 发布平台 JSON 字符串 ({pc, app} 标记哪些平台已发布) + // 这里用 sample (第一条报表) 的 getInfo 详细校验 schema, list 通常不含这些设计字段 + const schemaIssues: string[] = [] + let schemaCheckedReport = '' + if (apiFlat.length > 0) { + const sample = opts.id || apiFlat[0].id + schemaCheckedReport = `${apiFlat[0].fullName || '?'} (${sample})` + try { + const infoResp: any = await loadReport.getReportInfo(sample) + const data = unwrapWebapiObject(infoResp) + if (data && typeof data === 'object') { + // cells: 报表单元格定义 (设计器必含), 允许 null (未设计的新报表) + if (data.cells !== undefined && data.cells !== null) { + if (typeof data.cells !== 'string' && typeof data.cells !== 'object') { + schemaIssues.push(`cells 类型不对 (期望 string/object, 实际 ${typeof data.cells})`) + } + } + // snapshot: 报表设计快照 (workbook JSON), 允许 null + if (data.snapshot !== undefined && data.snapshot !== null) { + if (typeof data.snapshot !== 'string' && typeof data.snapshot !== 'object') { + schemaIssues.push(`snapshot 类型不对 (期望 string/object, 实际 ${typeof data.snapshot})`) + } + } + // allowExport / allowPrint / allowWatermark: boolean (实际是 number 0/1) + for (const k of ['allowExport', 'allowPrint', 'allowWatermark']) { + if (data[k] !== undefined && data[k] !== null && typeof data[k] !== 'number' && typeof data[k] !== 'string') { + schemaIssues.push(`${k} 类型不对 (期望 number/string, 实际 ${typeof data[k]})`) + } + } + // watermarkConfig: JSON string (允许 null) + if (data.watermarkConfig !== undefined && data.watermarkConfig !== null && data.watermarkConfig !== '') { + if (typeof data.watermarkConfig !== 'string') { + schemaIssues.push(`watermarkConfig 类型不对 (期望 string JSON, 实际 ${typeof data.watermarkConfig})`) + } else { + try { + const parsed = JSON.parse(data.watermarkConfig) + if (typeof parsed !== 'object' || parsed === null) { + schemaIssues.push(`watermarkConfig 解析后非对象`) + } + } catch (e) { + schemaIssues.push(`watermarkConfig JSON.parse 失败: ${(e as Error).message.slice(0, 60)}`) + } + } + } + // platformRelease: JSON string 必含 {pc, app} (允许 null 表示未发布) + if (data.platformRelease !== undefined && data.platformRelease !== null) { + if (typeof data.platformRelease !== 'string') { + schemaIssues.push(`platformRelease 类型不对 (期望 string, 实际 ${typeof data.platformRelease})`) + } else { + try { + const parsed = JSON.parse(data.platformRelease) + if (typeof parsed !== 'object' || parsed === null) { + schemaIssues.push(`platformRelease 解析后非对象`) + } else if (parsed.pc === undefined || parsed.app === undefined) { + schemaIssues.push(`platformRelease 缺 pc/app 字段 (报表菜单发布必含)`) + } + } catch (e) { + schemaIssues.push(`platformRelease JSON.parse 失败: ${(e as Error).message.slice(0, 60)}`) + } + } + } + } else { + schemaIssues.push('getReportInfo 返回非对象, 无法校验 schema') + } + } catch (e) { + schemaIssues.push(`getReportInfo(${sample}) 失败: ${(e as Error).message.slice(0, 80)}`) + } + } else { + schemaIssues.push('无报表数据 (跳过 schema 校验)') + } + { + const status: 'PASS' | 'FAIL' = schemaIssues.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'report', + page: '报表 schema (cells/snapshot/allowExport/WatermarkConfig/platformRelease)', + sourceFile: `getReportInfo (univer Designer 字段, sample: ${schemaCheckedReport})`, + renderFields: ['cells', 'snapshot', 'allowExport', 'allowPrint', 'allowWatermark', 'watermarkConfig (JSON)', 'platformRelease.pc', 'platformRelease.app'], + apiFields: ['cells', 'snapshot', 'allowExport', 'allowPrint', 'allowWatermark', 'watermarkConfig', 'platformRelease'], + missing: schemaIssues, + extra: [], + status, + }) + if (schemaIssues.length === 0) { + lg.info(`✓ 报表 schema: PASS (cells/snapshot/allowExport/Print/Watermark/watermarkConfig/platformRelease 全部合规)`) + } else { + lg.error(`✗ 报表 schema: FAIL (${schemaIssues.slice(0, 3).join(' | ')}${schemaIssues.length > 3 ? '...' : ''})`) + } + } + + // === 3.5 Gate 5 (可选, --id): 单条报表 getInfo 必填 + schema 详细校验 === + // 镜像 web Form.vue L64-80 init(data): getReportInfo(id) 必含所有渲染字段 + if (opts.id) { + let infoDetail: any + try { + infoDetail = await loadReport.getReportInfo(opts.id) + } catch (e) { + lg.error(`getReportInfo(${opts.id}) 失败: ${(e as Error).message}`) + infoDetail = null + } + const data = unwrapWebapiObject(infoDetail) + if (!data || typeof data !== 'object') { + lg.error(`getReportInfo(${opts.id}) 返回非对象: ${JSON.stringify(infoDetail).slice(0, 200)}`) + } else { + const infoFieldSet = new Set(Object.keys(data)) + const infoFields = Array.from(infoFieldSet).sort() + // form 必填字段 (Form.vue L26-62 schemas + 扩展字段) + const requiredInfoFields = [ + 'fullName', 'enCode', 'category', + 'sortCode', 'description', + 'systemId', 'enabledMark', + 'cells', 'snapshot', + 'allowExport', 'allowPrint', 'allowWatermark', + 'watermarkConfig', 'platformRelease', + ] + const missing = requiredInfoFields.filter(f => !infoFieldSet.has(f)) + const details = `fullName=${data.fullName || '<空>'}, enCode=${data.enCode || '<空>'}, category=${data.category || '<空>'}, enabledMark=${data.enabledMark ?? '<空>'}` + const status: 'PASS' | 'FAIL' = missing.length === 0 ? 'PASS' : 'FAIL' + results.push({ + module: 'report', + page: '单条报表 getInfo 完整性', + sourceFile: `getReportInfo (reportId=${opts.id}, ${details})`, + renderFields: requiredInfoFields, + apiFields: infoFields, + missing, + extra: [], + status, + }) + if (status === 'PASS') { + lg.info(`✓ 单条报表 getInfo: PASS (${infoFields.length} 字段, ${details})`) + } else { + lg.error(`✗ 单条报表 getInfo: FAIL (${missing.slice(0, 3).join(' | ')}${missing.length > 3 ? '...' : ''})`) + } + } + } +} + // 日志门面 (json 模式静默, 否则用 log) const real = { info: log.info, diff --git a/src/webapi/message.ts b/src/webapi/message.ts index dab7a30..4cc42fb 100644 --- a/src/webapi/message.ts +++ b/src/webapi/message.ts @@ -8,7 +8,7 @@ import { JnpfClient } from '../core/client.ts' import { loadWebModule } from './_loader.ts' -const NOTICE_SRC = '/home/ubuntu/ccWorkDir/web/apps/jnpf-web-apps-main/src/api/msgCenter/notice.ts' +const NOTICE_SRC = '/home/ubuntu/ccWorkDir/web/apps/jnpf-web-apps-main/src/api/system/message.ts' const MSG_TEMPLATE_SRC = '/home/ubuntu/ccWorkDir/web/apps/jnpf-web-apps-main/src/api/msgCenter/msgTemplate.ts' let cached: { notice: any; template: any } | null = null