diff --git a/src/commands/workflow/create.ts b/src/commands/workflow/create.ts index b682b9d..4490bbe 100644 --- a/src/commands/workflow/create.ts +++ b/src/commands/workflow/create.ts @@ -2,7 +2,8 @@ * commands/workflow/create.ts — 新建流程模板 * * API: POST /api/workflow/template body=TemplateNodeCrFrom - * - {fullName, enCode, category, flowType, flowXml, flowNodes, flowConfig, ...} + * - {fullName, enCode, category, type, flowXml, flowNodes, flowConfig, ...} + * - v0.11: 与后端 TemplateCrForm.java 字段名 1:1 对齐 (type/iconBackground/showType) * * AI 集成 (白皮书 5.10.3): --ai "<描述>" 调用 POST /api/workflow/ai, * LLM 返回 flowXml, 自动塞进 body。 @@ -17,10 +18,15 @@ interface CreateOpts { fullName?: string enCode?: string category?: string - flowType?: string + /** v0.11 修复: 后端字段名是 `type` (TemplateCrForm.java:19), dacli 旧称 flowType 错配 */ + type?: string flowXml?: string flowNodes?: string flowConfig?: string + /** v0.11 修复: 后端字段名是 `iconBackground` (TemplateCrForm.java:28) */ + iconBackground?: string + /** v0.11 修复: 后端字段名是 `showType` (TemplateCrForm.java:42), visibleType 是别名 */ + showType?: string json?: boolean /** 5.10.3 AI 创建流程 — 自然语言描述, 平台 LLM 生成 flowXml */ ai?: string @@ -32,10 +38,14 @@ export function buildWorkflowCreateCommand(): Command { .option('--fullName ', '中文名 (--ai 自动填, 否则必填)') .option('--enCode ', '英文编码 (--ai 自动填, 否则必填)') .option('--category ', '分类 id (workflow list 看真实值)') - .option('--flowType ', '流程类型 (1=简易 2=标准 3=任务流 4=自由流, 默认 2)', '2') + // v0.11 修复: 与后端 TemplateCrForm.java:type 对齐 (0=标准 1=简流) + .option('--type ', '流程类型 (0=标准 1=简流, 默认 0=标准)', '0') .option('--flowXml ', 'BPMN xml (--ai 自动填, 否则必填)') .option('--flowNodes ', 'flowNodes JSON 字符串 (节点结构, --ai 自动填)') .option('--flowConfig ', 'flowConfig JSON 字符串') + .option('--iconBackground ', '图标背景色 (默认 #108ee9)', '#108ee9') + // v0.11 修复: 后端 showType (TemplateCrForm.java:42) + .option('--showType ', '显示位置 (0=全局 1=流程 2=菜单, 默认 0)', '0') .option('--ai ', '白皮书 5.10.3 AI 创建流程 — 自然语言描述, 平台 LLM 生成 flowXml') .option('--json', '原始 JSON 输出', false) .action(async (opts: CreateOpts) => { @@ -75,18 +85,19 @@ export function buildWorkflowCreateCommand(): Command { fullName: opts.fullName, enCode: opts.enCode, category: opts.category || null, - flowType: Number(opts.flowType || '2'), + // v0.11 修复: 与后端 TemplateCrForm.java:type 对齐 (旧称 flowType) + type: Number(opts.type ?? '0'), flowXml: opts.flowXml, flowNodes, flowConfig: opts.flowConfig || '{}', sortCode: 0, - // 关键: TemplateCrForm 还需 visibleType / onLineformId 等, 走默认 - visibleType: 0, - onLineformId: '', + // v0.11 修复: 与后端 TemplateCrForm.java:showType 对齐 (旧称 visibleType, 是别名) + showType: Number(opts.showType ?? '0'), + // v0.11 修复: 与后端 TemplateCrForm.java:iconBackground 对齐 (旧称 color) + iconBackground: opts.iconBackground ?? '#108ee9', icon: 'icon-ym icon-ym-flow', - color: '#108ee9', } - log.info(`POST /workflow/template ${opts.enCode} flowType=${body.flowType}`) + log.info(`POST /workflow/template ${opts.enCode} type=${body.type} showType=${body.showType}`) const r = await c.postJson('/workflow/template', body) if (r.code !== 200) { log.error(`创建流程失败 (code=${r.code}): ${r.msg}`) @@ -104,14 +115,14 @@ export function buildWorkflowCreateCommand(): Command { optional: { '--enCode': '英文编码 (--ai 自动填)', '--category': '分类 id', - '--flowType': '1=简易 2=标准 3=任务流 4=自由流', + '--type': '0=标准 1=简流 (v0.11 与后端 TemplateCrForm.java:type 对齐)', '--flowXml': 'BPMN xml (--ai 自动填)', '--flowNodes': '节点结构 JSON', '--flowConfig': '流程配置 JSON', '--ai': '白皮书 5.10.3 AI 创建流程 — 自然语言描述生成 BPMN', }, example: [ - 'dacli workflow create --fullName="请假流程" --enCode=leave_flow --flowType=2 --flowXml=\'\'', + 'dacli workflow create --fullName="请假流程" --enCode=leave_flow --type=0 --flowXml=\'\'', 'dacli workflow create --ai "员工请假, 直属领导审批, HR 备案"', ], source: {