feat(P17A-1,P17A-2): 新增采购模型权限与系统种子

这个提交包含在:
2026-03-07 20:59:28 +08:00
父节点 9de1169d78
当前提交 1cd4290b4d
共修改 8 个文件,包含 354 行新增和 18 行删除
+48 -2
查看文件
@@ -105,6 +105,18 @@ const DEFAULT_LEAVE_WORKFLOW_DEFINITION = {
],
};
const DEFAULT_PURCHASE_WORKFLOW_DEFINITION = {
steps: [
{
id: "approval_1_manager",
name: "直属经理审批",
type: "approval",
assignee_rule: {
type: "department_manager",
},
},
],
};
const DEFAULT_DOCUMENT_CATEGORIES = [
{
@@ -128,8 +140,8 @@ const DEFAULT_DOCUMENT_CATEGORIES = [
enabled: true,
},
{
code: "purchase_general",
name: "日常采购申请",
code: "PR_STANDARD",
name: "标准采购申请",
entity_type: "purchase_request",
sequence_prefix: "CG",
number_length: 4,
@@ -478,6 +490,38 @@ async function seedWorkflowDefinition(prisma) {
created_by: null,
},
});
await prisma.workflowDefinition.updateMany({
where: {
entity_type: "purchase_request",
},
data: {
is_active: false,
},
});
await prisma.workflowDefinition.upsert({
where: {
entity_type_version: {
entity_type: "purchase_request",
version: 1,
},
},
update: {
name: "采购申请审批流程(V1)",
definition_json: DEFAULT_PURCHASE_WORKFLOW_DEFINITION,
is_active: true,
created_by: null,
},
create: {
name: "采购申请审批流程(V1)",
entity_type: "purchase_request",
definition_json: DEFAULT_PURCHASE_WORKFLOW_DEFINITION,
version: 1,
is_active: true,
created_by: null,
},
});
}
async function main() {
@@ -508,6 +552,8 @@ async function main() {
// eslint-disable-next-line no-console
console.log("- workflow definition: leave v1 (1-step department_manager)");
// eslint-disable-next-line no-console
console.log("- workflow definition: purchase_request v1 (1-step department_manager)");
// eslint-disable-next-line no-console
console.log(`- leave types: ${DEFAULT_LEAVE_TYPES.length} seeded with default policies`);
// eslint-disable-next-line no-console
console.log(`- feature flags: ${DEFAULT_FEATURE_FLAGS.length} seeded`);