R32-1 R32-4 R33-2: 收口工作台交互与报销链路
这个提交包含在:
@@ -231,7 +231,7 @@ function isoOrNull(value) {
|
||||
return value.toISOString();
|
||||
}
|
||||
|
||||
function mapTaskSummary(task) {
|
||||
function mapTaskSummary(task, allowedActions = []) {
|
||||
const workflowInstance = task.workflow_instance
|
||||
? {
|
||||
entity_type: task.workflow_instance.entity_type,
|
||||
@@ -260,6 +260,7 @@ function mapTaskSummary(task) {
|
||||
assigneeRole: task.assignee_role,
|
||||
createdAt: isoOrNull(task.created_at),
|
||||
completedAt: isoOrNull(task.completed_at),
|
||||
allowedActions,
|
||||
workflowInstance: workflowInstance
|
||||
? {
|
||||
entityType: workflowInstance.entity_type,
|
||||
@@ -860,11 +861,31 @@ async function workflowRoutes(fastify) {
|
||||
fastify.prisma.workflowTask.count({ where }),
|
||||
]);
|
||||
|
||||
const taskSummaries = await Promise.all(
|
||||
tasks.map(async (task) => {
|
||||
let actionable = false;
|
||||
if (task.status === "pending") {
|
||||
try {
|
||||
await ensureTaskAssignableToCurrentEmployee(fastify.prisma, task, request);
|
||||
actionable = true;
|
||||
} catch (error) {
|
||||
if (error instanceof AppError && error.code === "PERM_002") {
|
||||
actionable = false;
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mapTaskSummary(task, listAllowedActionsForTask(request, task, actionable));
|
||||
}),
|
||||
);
|
||||
|
||||
return sendData(reply, request, {
|
||||
page: query.page,
|
||||
pageSize: query.pageSize,
|
||||
total,
|
||||
items: tasks.map(mapTaskSummary),
|
||||
items: taskSummaries,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
在新工单中引用
屏蔽一个用户