R34: 收口搜索查看更多跳转与采购 submit 二次减重
这个提交包含在:
@@ -1457,6 +1457,7 @@ async function purchaseRequestRoutes(fastify) {
|
||||
where: { id: purchaseRequestId },
|
||||
select: {
|
||||
id: true,
|
||||
applicant_id: true,
|
||||
department_id: true,
|
||||
},
|
||||
});
|
||||
@@ -1487,6 +1488,35 @@ async function purchaseRequestRoutes(fastify) {
|
||||
throw buildPrecheckBlockedError(authoritativePrecheck);
|
||||
}
|
||||
|
||||
const workflowDefinition = await fastify.prisma.workflowDefinition.findFirst({
|
||||
where: {
|
||||
entity_type: "purchase_request",
|
||||
is_active: true,
|
||||
},
|
||||
orderBy: { version: "desc" },
|
||||
select: {
|
||||
id: true,
|
||||
definition_json: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!workflowDefinition) {
|
||||
throw buildValidationError({ workflow: "missing_definition" }, 409);
|
||||
}
|
||||
|
||||
const workflowSteps = parseWorkflowSteps(workflowDefinition.definition_json);
|
||||
const { actionable, skipped } = await resolveActionableStep({
|
||||
tx: fastify.prisma,
|
||||
steps: workflowSteps,
|
||||
startIndex: 0,
|
||||
ownerId: unlockedPurchaseRequest.applicant_id,
|
||||
logger: fastify.log,
|
||||
});
|
||||
|
||||
if (!actionable) {
|
||||
throw buildValidationError({ workflow: "no_actionable_approver" }, 409);
|
||||
}
|
||||
|
||||
const submitResult = await fastify.prisma.$transaction(async (tx) => {
|
||||
const locked = await loadPurchaseRequestForUpdate(tx, purchaseRequestId);
|
||||
ensureDraftOwner(request, locked);
|
||||
@@ -1532,6 +1562,9 @@ async function purchaseRequestRoutes(fastify) {
|
||||
if (!purchaseRequest.items?.length) {
|
||||
throw buildValidationError({ items: "at_least_one_required" });
|
||||
}
|
||||
if (purchaseRequest.applicant_id !== unlockedPurchaseRequest.applicant_id) {
|
||||
throw buildValidationError({ workflow: "no_actionable_approver" }, 409);
|
||||
}
|
||||
|
||||
const legalEntity = await ensureLegalEntityAvailable(tx, purchaseRequest.legal_entity_id);
|
||||
const costCenter = await ensureCostCenterAvailable(tx, purchaseRequest.cost_center_id, purchaseRequest.legal_entity_id);
|
||||
@@ -1575,35 +1608,6 @@ async function purchaseRequestRoutes(fastify) {
|
||||
}
|
||||
}
|
||||
|
||||
const workflowDefinition = await tx.workflowDefinition.findFirst({
|
||||
where: {
|
||||
entity_type: "purchase_request",
|
||||
is_active: true,
|
||||
},
|
||||
orderBy: { version: "desc" },
|
||||
select: {
|
||||
id: true,
|
||||
definition_json: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!workflowDefinition) {
|
||||
throw buildValidationError({ workflow: "missing_definition" }, 409);
|
||||
}
|
||||
|
||||
const workflowSteps = parseWorkflowSteps(workflowDefinition.definition_json);
|
||||
const { actionable, skipped } = await resolveActionableStep({
|
||||
tx,
|
||||
steps: workflowSteps,
|
||||
startIndex: 0,
|
||||
ownerId: purchaseRequest.applicant_id,
|
||||
logger: fastify.log,
|
||||
});
|
||||
|
||||
if (!actionable) {
|
||||
throw buildValidationError({ workflow: "no_actionable_approver" }, 409);
|
||||
}
|
||||
|
||||
let requestNo = purchaseRequest.request_no;
|
||||
if (!requestNo) {
|
||||
const issued = await issueDocumentNumber(tx, {
|
||||
|
||||
在新工单中引用
屏蔽一个用户