feat(bill): resolve referenced IDs for approval details

This commit is contained in:
gitea committed 2026-09-05 19:59:15 +08:00
1 parent dbf8dd942e
commit 60866efa2e
9 files changed
+320 -7

No files matched your search

+30 -1
View File
@@ -7,6 +7,7 @@ import {
getBillByCodeOrId,
getBillFlow,
getBillRisk,
getBillReferences,
getFieldDictionary,
} from "../../domains/bill/tools.js";
@@ -268,6 +269,34 @@ export async function handleBillCommand(
return { stdout: output, stderr: "", exitCode: 0 };
}
case "refs":
case "references":
case "resolve": {
const target = parsed.args[0] || stringOption(parsed.options, ["code", "id"]);
if (!target) throw new Error("请提供要解析引用的单号或单据 ID: hose bill refs <单号|ID>");
const report = await getBillReferences(client, corpId, target);
if (!report) {
if (runtime.jsonMode) return { stdout: printJson({ found: false, target }, runtime.outputOptions), stderr: "", exitCode: 1 };
return { stdout: "", stderr: `[NOT FOUND] 未找到单据引用: ${target}\n`, exitCode: 1 };
}
if (runtime.jsonMode) {
return { stdout: printJson({ corpId, corpName: corp.name, ...report }, runtime.outputOptions), stderr: "", exitCode: 0 };
}
const person = (value: typeof report.submitter) => value ? `${value.name || "未解析"}${value.code ? ` (${value.code})` : ""} [${value.id}]` : "-";
const output = [
`====== 单据引用解析 (单号: ${report.billCode || target}) ======`,
`标题: ${report.title || "-"}`,
`提交人: ${person(report.submitter)}`,
`归属人: ${person(report.owner)}`,
`费用承担部门: ${report.department?.path || report.department?.name || "-"}${report.department?.id ? ` [${report.department.id}]` : ""}`,
`法人实体: ${report.legalEntity ? `${report.legalEntity.name || "未解析"}${report.legalEntity.id ? ` [${report.legalEntity.id}]` : ""}` : "-"}`,
`费用类型: ${report.feeTypes.length ? report.feeTypes.map((item) => `${item.name || "未解析"}${item.code ? ` (${item.code})` : ""} [${item.id}]`).join("、") : "-"}`,
report.unresolved.length ? `未解析 ID: ${report.unresolved.join("、")}` : "引用均已解析",
"",
].join("\n");
return { stdout: output, stderr: "", exitCode: 0 };
}
case "link":
case "url": {
const target = parsed.args[0] || stringOption(parsed.options, ["code", "id", "c"]);
@@ -330,6 +359,6 @@ export async function handleBillCommand(
}
default:
throw new Error(`未知 bill 子命令: ${action}。支持: list, get <单号>, flow <单号>, risk <单号>, schema, link <单号>`);
throw new Error(`未知 bill 子命令: ${action}。支持: list, get <单号>, refs <单号>, flow <单号>, risk <单号>, schema, link <单号>`);
}
}
+2 -1
View File
@@ -119,7 +119,7 @@ export function printHelp(): string {
corps 多企业租户管理 (list, switch, current)
config 全局运行模式与路径诊断 (show, paths, mode <stateful|stateless>, set)
workflow 工作流管理 (list, get, find, toggle)
bill 单据与费用明细检索 (list, get <单号|ID>, flow <单号|ID>, risk <单号|ID>, schema, link <单号|ID>)
bill 单据与费用明细检索 (list, get <单号|ID>, refs <单号|ID>, flow <单号|ID>, risk <单号|ID>, schema, link <单号|ID>)
contact 企业通讯录与人员检索 (list, search <关键词>, get <staffId>)
task 待办中心与审批任务 (todo, approved, records, submitted, cc)
message 消息中心与通知管理 (list, count, read, read-all)
@@ -162,6 +162,7 @@ export function printHelp(): string {
hose-use bill list # 查看当前企业单据与报销列表
hose-use bill flow S26000001 # 查看单据审批历史与后续节点
hose-use bill risk S26000001 # 查看风控预警、预算与发票风险
hose-use bill refs S26000001 # 二级解析提交人、部门、法人实体与费用类型引用
hose-use bill link CL20260901001 # 获取单据 Web 详情直达免密跳转链接
hose-use bill list --json -o /tmp/bills.json # 导出单据报文到本地磁盘并防爆
hose-use bill get n0GMIM0dkQmKbS # 根据单号精准查询单据结构化详情