feat(P17A-1,P17A-2): 新增采购模型权限与系统种子
这个提交包含在:
@@ -16,6 +16,12 @@ const LEAVE_SELF_SERVICE_PERMISSIONS = [
|
||||
"leave.submit",
|
||||
];
|
||||
|
||||
const PROCUREMENT_SELF_SERVICE_PERMISSIONS = [
|
||||
"procurement.create",
|
||||
"procurement.view_own",
|
||||
"procurement.submit",
|
||||
];
|
||||
|
||||
const MASTERDATA_VIEW_PERMISSIONS = ["masterdata.view"];
|
||||
const MASTERDATA_MANAGE_PERMISSIONS = ["masterdata.manage"];
|
||||
|
||||
@@ -74,25 +80,34 @@ const ENTITY_PERMISSION_MAP = {
|
||||
};
|
||||
|
||||
const ROLE_PERMISSIONS = {
|
||||
employee: EMPLOYEE_BASE_PERMISSIONS,
|
||||
employee: [
|
||||
...EMPLOYEE_BASE_PERMISSIONS,
|
||||
...PROCUREMENT_SELF_SERVICE_PERMISSIONS,
|
||||
],
|
||||
manager: [
|
||||
...EMPLOYEE_BASE_PERMISSIONS,
|
||||
...PROCUREMENT_SELF_SERVICE_PERMISSIONS,
|
||||
"expense.approve",
|
||||
"expense.transfer",
|
||||
"expense.view_all",
|
||||
"leave.approve",
|
||||
"procurement.approve",
|
||||
"procurement.view_all",
|
||||
"report.dashboard.view",
|
||||
"budget.view",
|
||||
"budget.manage",
|
||||
],
|
||||
ceo: [
|
||||
...EMPLOYEE_BASE_PERMISSIONS,
|
||||
...PROCUREMENT_SELF_SERVICE_PERMISSIONS,
|
||||
...MASTERDATA_VIEW_PERMISSIONS,
|
||||
"expense.approve",
|
||||
"expense.transfer",
|
||||
"expense.view_all",
|
||||
"leave.approve",
|
||||
"leave.view_all",
|
||||
"procurement.approve",
|
||||
"procurement.view_all",
|
||||
"report.dashboard.view",
|
||||
"budget.view",
|
||||
],
|
||||
@@ -106,6 +121,7 @@ const ROLE_PERMISSIONS = {
|
||||
"expense.approve",
|
||||
"expense.finance.pay",
|
||||
"expense.view_all",
|
||||
"procurement.view_all",
|
||||
],
|
||||
finance_mgr: [
|
||||
...EMPLOYEE_BASE_PERMISSIONS,
|
||||
@@ -121,12 +137,16 @@ const ROLE_PERMISSIONS = {
|
||||
"expense.finance.pay",
|
||||
"expense.view_all",
|
||||
"expense.finance.override_duplicate",
|
||||
"procurement.view_all",
|
||||
"procurement.manage",
|
||||
"system.settings",
|
||||
"system.audit.view",
|
||||
],
|
||||
administration: [
|
||||
"expense.proxy_submit",
|
||||
...EMPLOYEE_BASE_PERMISSIONS,
|
||||
"procurement.view_all",
|
||||
"procurement.manage",
|
||||
],
|
||||
hr: [
|
||||
...LEAVE_SELF_SERVICE_PERMISSIONS,
|
||||
|
||||
@@ -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`);
|
||||
|
||||
@@ -29,7 +29,7 @@ const DOCUMENT_TYPE_CONFIG = {
|
||||
},
|
||||
},
|
||||
purchase_request: {
|
||||
defaultCategoryCode: "purchase_general",
|
||||
defaultCategoryCode: "PR_STANDARD",
|
||||
preferLegacySequence: false,
|
||||
fallback: {
|
||||
prefix: "CG",
|
||||
|
||||
在新工单中引用
屏蔽一个用户