feat(P17A-3,P17A-4): 实现采购申请接口附件与前端入口
这个提交包含在:
@@ -38,6 +38,7 @@ const notificationsRoutes = require("./routes/notifications");
|
||||
const exportsRoutes = require("./routes/exports");
|
||||
const dashboardRoutes = require("./routes/dashboard");
|
||||
const budgetsRoutes = require("./routes/budgets");
|
||||
const purchaseRequestRoutes = require("./routes/purchaseRequests");
|
||||
const integrationsRoutes = require("./routes/integrations");
|
||||
const travelOrdersRoutes = require("./routes/travelOrders");
|
||||
const { startJobs } = require("./jobs/jobSystem");
|
||||
@@ -295,6 +296,7 @@ async function buildApp() {
|
||||
await app.register(notificationsRoutes, { prefix: "/api" });
|
||||
await app.register(dashboardRoutes, { prefix: "/api" });
|
||||
await app.register(budgetsRoutes, { prefix: "/api" });
|
||||
await app.register(purchaseRequestRoutes, { prefix: "/api" });
|
||||
await app.register(integrationsRoutes, { prefix: "/api" });
|
||||
await app.register(travelOrdersRoutes, { prefix: "/api" });
|
||||
await app.register(exportsRoutes, { prefix: "/api" });
|
||||
|
||||
文件差异内容过多而无法显示
加载差异
@@ -638,6 +638,53 @@ async function workflowRoutes(fastify) {
|
||||
},
|
||||
},
|
||||
},
|
||||
purchase_request: {
|
||||
select: {
|
||||
id: true,
|
||||
request_no: true,
|
||||
status: true,
|
||||
title: true,
|
||||
reason: true,
|
||||
currency_code: true,
|
||||
total_amount: true,
|
||||
expected_delivery_date: true,
|
||||
applicant: {
|
||||
select: {
|
||||
id: true,
|
||||
employee_no: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
supplier: {
|
||||
select: {
|
||||
id: true,
|
||||
code: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
legal_entity: {
|
||||
select: {
|
||||
id: true,
|
||||
code: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
cost_center: {
|
||||
select: {
|
||||
id: true,
|
||||
code: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
document_category: {
|
||||
select: {
|
||||
id: true,
|
||||
code: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -784,6 +831,53 @@ async function workflowRoutes(fastify) {
|
||||
: null,
|
||||
}
|
||||
: null,
|
||||
purchaseRequest: task.workflow_instance?.purchase_request
|
||||
? {
|
||||
id: task.workflow_instance.purchase_request.id,
|
||||
requestNo: task.workflow_instance.purchase_request.request_no ?? null,
|
||||
status: task.workflow_instance.purchase_request.status,
|
||||
title: task.workflow_instance.purchase_request.title,
|
||||
reason: task.workflow_instance.purchase_request.reason ?? null,
|
||||
currencyCode: task.workflow_instance.purchase_request.currency_code,
|
||||
totalAmount: toMoneyString(task.workflow_instance.purchase_request.total_amount),
|
||||
expectedDeliveryDate: formatDateOnly(task.workflow_instance.purchase_request.expected_delivery_date),
|
||||
applicant: task.workflow_instance.purchase_request.applicant
|
||||
? {
|
||||
id: task.workflow_instance.purchase_request.applicant.id,
|
||||
employeeNo: task.workflow_instance.purchase_request.applicant.employee_no,
|
||||
name: task.workflow_instance.purchase_request.applicant.name,
|
||||
}
|
||||
: null,
|
||||
supplier: task.workflow_instance.purchase_request.supplier
|
||||
? {
|
||||
id: task.workflow_instance.purchase_request.supplier.id,
|
||||
code: task.workflow_instance.purchase_request.supplier.code,
|
||||
name: task.workflow_instance.purchase_request.supplier.name,
|
||||
}
|
||||
: null,
|
||||
legalEntity: task.workflow_instance.purchase_request.legal_entity
|
||||
? {
|
||||
id: task.workflow_instance.purchase_request.legal_entity.id,
|
||||
code: task.workflow_instance.purchase_request.legal_entity.code,
|
||||
name: task.workflow_instance.purchase_request.legal_entity.name,
|
||||
}
|
||||
: null,
|
||||
costCenter: task.workflow_instance.purchase_request.cost_center
|
||||
? {
|
||||
id: task.workflow_instance.purchase_request.cost_center.id,
|
||||
code: task.workflow_instance.purchase_request.cost_center.code,
|
||||
name: task.workflow_instance.purchase_request.cost_center.name,
|
||||
}
|
||||
: null,
|
||||
documentCategory: task.workflow_instance.purchase_request.document_category
|
||||
? {
|
||||
id: task.workflow_instance.purchase_request.document_category.id,
|
||||
code: task.workflow_instance.purchase_request.document_category.code,
|
||||
name: task.workflow_instance.purchase_request.document_category.name,
|
||||
}
|
||||
: null,
|
||||
}
|
||||
: null,
|
||||
allowedActions: listAllowedActionsForTask(request, task, actionable),
|
||||
history: historyItems.map((item) => ({
|
||||
id: item.id,
|
||||
@@ -1068,6 +1162,14 @@ async function workflowRoutes(fastify) {
|
||||
createdBy: request.employee.id,
|
||||
});
|
||||
}
|
||||
} else if (workflowInstance.entity_type === "purchase_request") {
|
||||
await tx.purchaseRequest.update({
|
||||
where: { id: workflowInstance.entity_id },
|
||||
data: {
|
||||
status: "approved",
|
||||
updated_by: request.employee.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
await tx.workflowHistory.create({
|
||||
@@ -1130,6 +1232,7 @@ async function workflowRoutes(fastify) {
|
||||
workflowInstanceId: workflowInstance.id,
|
||||
nextTaskId: null,
|
||||
reimbursementStatus: workflowInstance.entity_type === "reimbursement" ? "approved" : null,
|
||||
purchaseRequestStatus: workflowInstance.entity_type === "purchase_request" ? "approved" : null,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1240,6 +1343,14 @@ async function workflowRoutes(fastify) {
|
||||
createdBy: request.employee.id,
|
||||
});
|
||||
}
|
||||
} else if (workflowInstance.entity_type === "purchase_request") {
|
||||
await tx.purchaseRequest.update({
|
||||
where: { id: workflowInstance.entity_id },
|
||||
data: {
|
||||
status: "rejected",
|
||||
updated_by: request.employee.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
await tx.workflowHistory.create({
|
||||
@@ -1301,6 +1412,7 @@ async function workflowRoutes(fastify) {
|
||||
outcome: "rejected",
|
||||
workflowInstanceId: workflowInstance.id,
|
||||
reimbursementStatus: workflowInstance.entity_type === "reimbursement" ? "rejected" : null,
|
||||
purchaseRequestStatus: workflowInstance.entity_type === "purchase_request" ? "rejected" : null,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1411,6 +1523,14 @@ async function workflowRoutes(fastify) {
|
||||
createdBy: request.employee.id,
|
||||
});
|
||||
}
|
||||
} else if (workflowInstance.entity_type === "purchase_request") {
|
||||
await tx.purchaseRequest.update({
|
||||
where: { id: workflowInstance.entity_id },
|
||||
data: {
|
||||
status: "draft",
|
||||
updated_by: request.employee.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
await tx.workflowHistory.create({
|
||||
@@ -1472,6 +1592,7 @@ async function workflowRoutes(fastify) {
|
||||
outcome: "returned",
|
||||
workflowInstanceId: workflowInstance.id,
|
||||
reimbursementStatus: workflowInstance.entity_type === "reimbursement" ? "draft" : null,
|
||||
purchaseRequestStatus: workflowInstance.entity_type === "purchase_request" ? "draft" : null,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
在新工单中引用
屏蔽一个用户