feat(client): 委派管理页最小运营闭环(E7)
- 新增委派 API 封装与委派管理页面(创建/列表/撤销) - 增加菜单入口与路由守卫(expense.proxy_manage)
这个提交包含在:
@@ -0,0 +1,59 @@
|
||||
import { apiRequestData } from "./http";
|
||||
|
||||
export type DelegationStatus = "active" | "scheduled" | "expired" | "revoked";
|
||||
|
||||
export type DelegationItem = {
|
||||
id: string;
|
||||
principalEmployeeId: string;
|
||||
delegateEmployeeId: string;
|
||||
scope: "reimbursement_submit" | "all";
|
||||
validFrom: string;
|
||||
validTo: string | null;
|
||||
revokedAt: string | null;
|
||||
createdAt: string;
|
||||
status: DelegationStatus;
|
||||
};
|
||||
|
||||
export type CreateDelegationRequest = {
|
||||
delegateEmployeeId: string;
|
||||
scope?: "reimbursement_submit" | "all";
|
||||
validFrom?: string;
|
||||
validTo?: string;
|
||||
};
|
||||
|
||||
export type CreateDelegationResponse = {
|
||||
delegation: DelegationItem;
|
||||
};
|
||||
|
||||
export type FetchMyDelegationsResponse = {
|
||||
status: "active" | "scheduled" | "expired" | "revoked" | "all";
|
||||
initiated: DelegationItem[];
|
||||
received: DelegationItem[];
|
||||
};
|
||||
|
||||
export async function createDelegation(payload: CreateDelegationRequest) {
|
||||
return apiRequestData<CreateDelegationResponse>("/api/delegations", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export async function fetchMyDelegations(status: FetchMyDelegationsResponse["status"] = "active") {
|
||||
const params = new URLSearchParams();
|
||||
if (status && status !== "active") {
|
||||
params.set("status", status);
|
||||
}
|
||||
const query = params.toString();
|
||||
return apiRequestData<FetchMyDelegationsResponse>(`/api/delegations/mine${query ? `?${query}` : ""}`);
|
||||
}
|
||||
|
||||
export async function revokeDelegation(delegationId: string) {
|
||||
return apiRequestData<{ delegation: DelegationItem; outcome: string }>(
|
||||
`/api/delegations/${delegationId}/revoke`,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({}),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户