迁移合同费用通用附件

1、删除旧费用附件 API、CRUD、模型和专用前端面板,统一改用通用附件能力。

2、调整合同费用接口为 study_id 语义,并补充合同、凭证、发票等附件类型的权限映射。

3、将合同费用新建和编辑改为抽屉流程,详情页与列表页复用同一编辑组件。

4、补充数据库迁移、附件列表、合同费用抽屉和权限场景测试,覆盖旧权限移除与新流程。
This commit is contained in:
Cheng Zhou
2026-06-04 11:07:13 +08:00
parent ab4f0d93ed
commit 720c98765f
36 changed files with 2576 additions and 1875 deletions
+72 -16
View File
@@ -1,25 +1,81 @@
export type AttachmentPermissionAction = "create" | "read" | "delete";
const ATTACHMENT_PERMISSION_PREFIXES: Record<string, string> = {
contract_fee_contract: "fees_contracts_attachments",
contract_fee_voucher: "fees_contracts_attachments",
contract_fee_invoice: "fees_contracts_attachments",
startup_feasibility: "startup_initiation_attachments",
startup_ethics: "startup_ethics_attachments",
startup_kickoff: "startup_auth_attachments",
startup_kickoff_minutes: "startup_auth_attachments",
startup_kickoff_signin: "startup_auth_attachments",
startup_kickoff_ppt: "startup_auth_attachments",
training_authorization: "startup_auth_attachments",
drug_shipment: "drug_shipments_attachments",
precaution: "precautions_attachments",
faq_replies: "faq_attachments",
const PERMISSIONS_BY_ENTITY_ACTION: Record<string, Record<AttachmentPermissionAction, string>> = {
contract_fee_contract: {
create: "fees_contracts:create",
read: "fees_contracts:read",
delete: "fees_contracts_attachments:delete",
},
contract_fee_voucher: {
create: "fees_contracts:create",
read: "fees_contracts:read",
delete: "fees_contracts_attachments:delete",
},
contract_fee_invoice: {
create: "fees_contracts:create",
read: "fees_contracts:read",
delete: "fees_contracts_attachments:delete",
},
startup_feasibility: {
create: "startup_initiation:create",
read: "startup_initiation:read",
delete: "startup_initiation_attachments:delete",
},
startup_ethics: {
create: "startup_ethics:create",
read: "startup_ethics:read",
delete: "startup_ethics_attachments:delete",
},
startup_kickoff: {
create: "startup_auth:create",
read: "startup_auth:read",
delete: "startup_auth_attachments:delete",
},
startup_kickoff_minutes: {
create: "startup_auth:create",
read: "startup_auth:read",
delete: "startup_auth_attachments:delete",
},
startup_kickoff_signin: {
create: "startup_auth:create",
read: "startup_auth:read",
delete: "startup_auth_attachments:delete",
},
startup_kickoff_ppt: {
create: "startup_auth:create",
read: "startup_auth:read",
delete: "startup_auth_attachments:delete",
},
training_authorization: {
create: "startup_auth:create",
read: "startup_auth:read",
delete: "startup_auth_attachments:delete",
},
drug_shipment: {
create: "drug_shipments:create",
read: "drug_shipments:read",
delete: "drug_shipments_attachments:delete",
},
material_equipment: {
create: "material_equipments:update",
read: "material_equipments:read",
delete: "material_equipments_attachments:delete",
},
precaution: {
create: "precautions:create",
read: "precautions:read",
delete: "precautions_attachments:delete",
},
faq_replies: {
create: "faq_reply:create",
read: "faq:read",
delete: "faq_attachments:delete",
},
};
export const getAttachmentPermissionKey = (
entityType: string,
action: AttachmentPermissionAction
): string | null => {
const prefix = ATTACHMENT_PERMISSION_PREFIXES[entityType];
return prefix ? `${prefix}:${action}` : null;
return PERMISSIONS_BY_ENTITY_ACTION[entityType]?.[action] || null;
};