参考 boot/ 仓库结构初始化, 同步到 gitea:3000/ssw/dacli (private). 包括: - src/ 8 父命令 (form/menu/dm/dict/di/apis/doc/workflow + login/status) + core (client/crypto/help/log/types/config) - src/schema/ FieldBuilder (从 JNPF web 源码提取, 避免 53 个手写 builder) - tests/ vitest 单元 + playwright E2E (含 workSystem/developSystem baseline regression) - scripts/ extract-all.mjs (从 jnpf-web 源码生成 schema) + seed-tds-baseline.ts - doc/ architecture/plan/api/extractors/baseline/RESUME/help-system + v0.6/v0.7 changelog - .claude/skills/dacli-ts/ Claude 集成 skill (SKILL.md + 5 references + 7 examples + 3 baseline) - CLAUDE.md (项目说明) + README.md + prompt.md (开发任务说明书) - 配置文件: package.json/lock, tsconfig, vitest.config, playwright.config
51 lines
1.8 KiB
TypeScript
51 lines
1.8 KiB
TypeScript
/**
|
|
* commands/workflow/approve.ts — 审批流程
|
|
*
|
|
* API: POST /api/workflow/operator/Audit/{operatorId}
|
|
*/
|
|
import { Command } from 'commander'
|
|
import { JnpfClient } from '../../core/client.ts'
|
|
import { installAiHelpHook } from '../../core/help.ts'
|
|
import { log, printJson } from '../../core/log.ts'
|
|
|
|
interface Opts {
|
|
operatorId: string
|
|
status: string
|
|
opinion?: string
|
|
json?: boolean
|
|
}
|
|
|
|
export function buildWorkflowApproveCommand(): Command {
|
|
const cmd = new Command('approve')
|
|
.description('审批一个流程任务 (operatorId 来自 --todo=1 列表)')
|
|
.requiredOption('--operatorId <id>', '审批节点 id (operatorId)')
|
|
.requiredOption('--status <0|1|2>', '0=同意 1=不同意 2=退回', '0')
|
|
.option('--opinion <text>', '审批意见')
|
|
.option('--json', '原始 JSON 输出', false)
|
|
.action(async (opts: Opts) => {
|
|
const c = await JnpfClient.fromToken()
|
|
const body = {
|
|
status: Number(opts.status),
|
|
opinion: opts.opinion || '',
|
|
}
|
|
log.info(`POST /workflow/operator/Audit/${opts.operatorId} status=${opts.status}`)
|
|
const r = await c.postJson<unknown>(`/workflow/operator/Audit/${opts.operatorId}`, body)
|
|
if (r.code !== 200) {
|
|
log.error(`approve 失败: ${r.msg}`)
|
|
if (opts.json) printJson(r)
|
|
process.exit(1)
|
|
}
|
|
log.ok('审批成功')
|
|
if (opts.json) printJson(r.data)
|
|
})
|
|
|
|
installAiHelpHook(cmd, {
|
|
purpose: '审批流程节点. 0=同意 1=不同意 2=退回.',
|
|
required: { '--operatorId': '审批节点 id', '--status': '0/1/2' },
|
|
optional: { '--opinion': '审批意见' },
|
|
example: 'dacli workflow approve --operatorId=123 --status=0 --opinion=同意',
|
|
source: { api: 'POST /api/workflow/operator/Audit/{operatorId}' },
|
|
})
|
|
return cmd
|
|
}
|