LP6 完善请假采购体验与审批说明

这个提交包含在:
2026-05-12 13:02:00 +08:00
父节点 21887ce28a
当前提交 3d1e4c43f6
共修改 14 个文件,包含 502 行新增和 39 行删除
+43 -14
查看文件
@@ -225,10 +225,6 @@ const PURCHASE_DETAIL_SELECT = {
},
},
workflow_instances: {
where: {
entity_type: "purchase_request",
current_status: "pending",
},
orderBy: { created_at: "desc" },
take: 1,
select: {
@@ -247,6 +243,24 @@ const PURCHASE_DETAIL_SELECT = {
assignee_role: true,
},
},
workflow_history: {
orderBy: { created_at: "desc" },
take: 8,
select: {
id: true,
task_id: true,
actor_id: true,
action: true,
comment: true,
created_at: true,
actor: {
select: {
employee_no: true,
name: true,
},
},
},
},
},
},
};
@@ -537,20 +551,34 @@ function mapPurchaseOrderArchive(item) {
};
}
function mapWorkflowHistoryItem(item) {
return {
id: item.id,
taskId: item.task_id ?? null,
actorId: item.actor_id,
actorName: item.actor?.name ?? null,
actorEmployeeNo: item.actor?.employee_no ?? null,
action: item.action,
comment: item.comment ?? null,
createdAt: toIsoDateTime(item.created_at),
};
}
function mapPurchaseRequestDetail(item, request) {
const summary = mapPurchaseRequestSummary(item);
const pendingWorkflow = item.workflow_instances?.[0]
const latestWorkflow = item.workflow_instances?.[0] ?? null;
const pendingWorkflow = latestWorkflow?.current_status === "pending"
? {
instanceId: item.workflow_instances[0].id,
currentStatus: item.workflow_instances[0].current_status,
currentStepId: item.workflow_instances[0].current_step_id,
task: item.workflow_instances[0].workflow_tasks?.[0]
instanceId: latestWorkflow.id,
currentStatus: latestWorkflow.current_status,
currentStepId: latestWorkflow.current_step_id,
task: latestWorkflow.workflow_tasks?.[0]
? {
id: item.workflow_instances[0].workflow_tasks[0].id,
stepId: item.workflow_instances[0].workflow_tasks[0].step_id,
stepName: item.workflow_instances[0].workflow_tasks[0].step_name,
assigneeId: item.workflow_instances[0].workflow_tasks[0].assignee_id,
assigneeRole: item.workflow_instances[0].workflow_tasks[0].assignee_role,
id: latestWorkflow.workflow_tasks[0].id,
stepId: latestWorkflow.workflow_tasks[0].step_id,
stepName: latestWorkflow.workflow_tasks[0].step_name,
assigneeId: latestWorkflow.workflow_tasks[0].assignee_id,
assigneeRole: latestWorkflow.workflow_tasks[0].assignee_role,
}
: null,
}
@@ -580,6 +608,7 @@ function mapPurchaseRequestDetail(item, request) {
})),
archiveOrder: mapPurchaseOrderArchive(item.order_archive),
pendingWorkflow,
approvalHistory: (latestWorkflow?.workflow_history ?? []).map(mapWorkflowHistoryItem),
permissions: {
canEditDraft: item.status === "draft" && item.applicant_id === request.employee.id,
canSubmit: item.status === "draft" && item.applicant_id === request.employee.id && request.employee.permissionCodes.includes("procurement.submit"),