feat(G1,P16A,P16B): 收口主数据核心与节假日日历增强
这个提交包含在:
@@ -119,6 +119,58 @@ export function mapApiErrorMessage(
|
||||
if (details?.verification === "disabled") {
|
||||
return "当前环境未开启发票验真。";
|
||||
}
|
||||
if (details?.code === "duplicate") {
|
||||
return "编码已存在,请更换后重试。";
|
||||
}
|
||||
|
||||
if (details?.legalEntityId === "not_found") {
|
||||
return "所选法体不存在。";
|
||||
}
|
||||
|
||||
if (details?.legalEntityId === "archived") {
|
||||
return "所选法体已归档,无法继续使用。";
|
||||
}
|
||||
|
||||
if (details?.ownerEmployeeId === "not_found") {
|
||||
return "负责人不存在或已停用。";
|
||||
}
|
||||
|
||||
if (details?.parentId === "not_found") {
|
||||
return "上级成本中心不存在。";
|
||||
}
|
||||
|
||||
if (details?.parentId === "archived") {
|
||||
return "上级成本中心已归档,无法继续使用。";
|
||||
}
|
||||
|
||||
if (details?.parentId === "self_not_allowed") {
|
||||
return "上级成本中心不能选择自身。";
|
||||
}
|
||||
|
||||
if (details?.parentId === "cycle_not_allowed") {
|
||||
return "上级成本中心不能形成循环层级。";
|
||||
}
|
||||
|
||||
if (details?.parentId === "cross_legal_entity_not_allowed") {
|
||||
return "上级成本中心必须与当前法体一致。";
|
||||
}
|
||||
|
||||
if (details?.legalEntity === "has_cost_centers") {
|
||||
return "当前法体下仍存在未归档的成本中心,无法归档。";
|
||||
}
|
||||
|
||||
if (details?.costCenter === "has_children") {
|
||||
return "当前成本中心存在下级节点,无法归档。";
|
||||
}
|
||||
|
||||
if (details?.holidayCalendar === "bound_as_default") {
|
||||
return `当前日历仍被法体 ${details?.legalEntityCode ?? ""} 作为默认日历引用,无法归档。`;
|
||||
}
|
||||
|
||||
if (details?.date === "duplicate") {
|
||||
return "同一日历内不允许存在重复日期。";
|
||||
}
|
||||
|
||||
|
||||
if (details?.verification === "already_pending") {
|
||||
return "已有验真任务正在处理中,请稍后查看结果。";
|
||||
@@ -148,6 +200,10 @@ export function mapApiErrorMessage(
|
||||
return "请假开始/结束日期与半天时段不合法。";
|
||||
}
|
||||
|
||||
if (details?.leave === "non_working_range") {
|
||||
return "所选时间段均为非工作日,无需请假。";
|
||||
}
|
||||
|
||||
if (details?.leave === "missing_reserve_ledger") {
|
||||
return "请假冻结账本状态异常,请联系管理员处理。";
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { apiRequestData } from "./http";
|
||||
|
||||
export type FeatureFlagKey = "erp_sync" | "invoice_verification";
|
||||
export type FeatureFlagKey = "erp_sync" | "invoice_verification" | "leave_holiday_calendar";
|
||||
export type FeatureFlagOverrideMode = "inherit" | "force_on" | "force_off";
|
||||
export type FeatureFlagRolloutType = "global" | "department_allowlist";
|
||||
|
||||
|
||||
@@ -0,0 +1,347 @@
|
||||
import { apiRequestData } from "./http";
|
||||
|
||||
export type DocumentCategoryEntityType =
|
||||
| "reimbursement"
|
||||
| "leave"
|
||||
| "purchase_request"
|
||||
| "asset_card"
|
||||
| "general";
|
||||
|
||||
export type DocumentResetPeriod = "none" | "daily" | "monthly" | "yearly";
|
||||
export type HolidayCalendarDayType = "holiday" | "workday" | "adjusted_workday";
|
||||
|
||||
export type LegalEntityItem = {
|
||||
id: string;
|
||||
code: string;
|
||||
name: string;
|
||||
shortName: string | null;
|
||||
currencyCode: string;
|
||||
taxNo: string | null;
|
||||
enabled: boolean;
|
||||
archivedAt: string | null;
|
||||
createdAt: string | null;
|
||||
updatedAt: string | null;
|
||||
};
|
||||
|
||||
export type CostCenterItem = {
|
||||
id: string;
|
||||
legalEntityId: string;
|
||||
code: string;
|
||||
name: string;
|
||||
parentId: string | null;
|
||||
ownerEmployeeId: string | null;
|
||||
enabled: boolean;
|
||||
archivedAt: string | null;
|
||||
createdAt: string | null;
|
||||
updatedAt: string | null;
|
||||
legalEntity: {
|
||||
id: string;
|
||||
code: string;
|
||||
name: string;
|
||||
} | null;
|
||||
parent: {
|
||||
id: string;
|
||||
name: string;
|
||||
} | null;
|
||||
owner: {
|
||||
id: string;
|
||||
employeeNo: string;
|
||||
name: string;
|
||||
} | null;
|
||||
};
|
||||
|
||||
export type DocumentCategoryItem = {
|
||||
id: string;
|
||||
code: string;
|
||||
name: string;
|
||||
entityType: DocumentCategoryEntityType;
|
||||
sequencePrefix: string;
|
||||
numberLength: number;
|
||||
resetPeriod: DocumentResetPeriod;
|
||||
defaultWorkflowKey: string | null;
|
||||
enabled: boolean;
|
||||
archivedAt: string | null;
|
||||
createdAt: string | null;
|
||||
updatedAt: string | null;
|
||||
};
|
||||
|
||||
export type HolidayCalendarItem = {
|
||||
id: string;
|
||||
code: string;
|
||||
name: string;
|
||||
timezone: string;
|
||||
legalEntityId: string | null;
|
||||
enabled: boolean;
|
||||
archivedAt: string | null;
|
||||
createdAt: string | null;
|
||||
updatedAt: string | null;
|
||||
daysCount: number;
|
||||
isDefaultForLegalEntity: boolean;
|
||||
legalEntity: {
|
||||
id: string;
|
||||
code: string;
|
||||
name: string;
|
||||
} | null;
|
||||
};
|
||||
|
||||
export type HolidayCalendarDayItem = {
|
||||
id: string;
|
||||
date: string;
|
||||
dayType: HolidayCalendarDayType;
|
||||
name: string;
|
||||
note: string | null;
|
||||
createdAt: string | null;
|
||||
updatedAt: string | null;
|
||||
};
|
||||
|
||||
export type MasterDataListResponse<T> = {
|
||||
includeArchived: boolean;
|
||||
items: T[];
|
||||
};
|
||||
|
||||
function toQueryString(query: Record<string, string | boolean | undefined>) {
|
||||
const params = new URLSearchParams();
|
||||
for (const [key, value] of Object.entries(query)) {
|
||||
if (value == null || value === "") {
|
||||
continue;
|
||||
}
|
||||
params.set(key, typeof value === "boolean" ? String(value) : value);
|
||||
}
|
||||
const encoded = params.toString();
|
||||
return encoded ? `?${encoded}` : "";
|
||||
}
|
||||
|
||||
export async function fetchLegalEntities(params: { includeArchived?: boolean; enabled?: boolean } = {}) {
|
||||
return apiRequestData<MasterDataListResponse<LegalEntityItem>>(
|
||||
`/api/master-data/legal-entities${toQueryString(params as Record<string, string | boolean | undefined>)}`,
|
||||
);
|
||||
}
|
||||
|
||||
export async function createLegalEntity(payload: {
|
||||
code: string;
|
||||
name: string;
|
||||
shortName?: string | null;
|
||||
currencyCode: string;
|
||||
taxNo?: string | null;
|
||||
enabled?: boolean;
|
||||
}) {
|
||||
return apiRequestData<{ legalEntity: LegalEntityItem }>("/api/master-data/legal-entities", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export async function patchLegalEntity(
|
||||
legalEntityId: string,
|
||||
payload: Partial<{
|
||||
code: string;
|
||||
name: string;
|
||||
shortName: string | null;
|
||||
currencyCode: string;
|
||||
taxNo: string | null;
|
||||
enabled: boolean;
|
||||
}>,
|
||||
) {
|
||||
return apiRequestData<{ legalEntity: LegalEntityItem }>(`/api/master-data/legal-entities/${legalEntityId}`, {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export async function archiveLegalEntity(legalEntityId: string) {
|
||||
return apiRequestData<{ legalEntity: LegalEntityItem; outcome: string }>(
|
||||
`/api/master-data/legal-entities/${legalEntityId}/archive`,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({}),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export async function fetchCostCenters(params: {
|
||||
includeArchived?: boolean;
|
||||
enabled?: boolean;
|
||||
legalEntityId?: string;
|
||||
} = {}) {
|
||||
return apiRequestData<MasterDataListResponse<CostCenterItem>>(
|
||||
`/api/master-data/cost-centers${toQueryString(params as Record<string, string | boolean | undefined>)}`,
|
||||
);
|
||||
}
|
||||
|
||||
export async function createCostCenter(payload: {
|
||||
legalEntityId: string;
|
||||
code: string;
|
||||
name: string;
|
||||
parentId?: string | null;
|
||||
ownerEmployeeId?: string | null;
|
||||
enabled?: boolean;
|
||||
}) {
|
||||
return apiRequestData<{ costCenter: CostCenterItem }>("/api/master-data/cost-centers", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export async function patchCostCenter(
|
||||
costCenterId: string,
|
||||
payload: Partial<{
|
||||
legalEntityId: string;
|
||||
code: string;
|
||||
name: string;
|
||||
parentId: string | null;
|
||||
ownerEmployeeId: string | null;
|
||||
enabled: boolean;
|
||||
}>,
|
||||
) {
|
||||
return apiRequestData<{ costCenter: CostCenterItem }>(`/api/master-data/cost-centers/${costCenterId}`, {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export async function archiveCostCenter(costCenterId: string) {
|
||||
return apiRequestData<{ costCenter: CostCenterItem; outcome: string }>(
|
||||
`/api/master-data/cost-centers/${costCenterId}/archive`,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({}),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export async function fetchDocumentCategories(params: {
|
||||
includeArchived?: boolean;
|
||||
enabled?: boolean;
|
||||
entityType?: DocumentCategoryEntityType;
|
||||
} = {}) {
|
||||
return apiRequestData<MasterDataListResponse<DocumentCategoryItem>>(
|
||||
`/api/master-data/document-categories${toQueryString(params as Record<string, string | boolean | undefined>)}`,
|
||||
);
|
||||
}
|
||||
|
||||
export async function createDocumentCategory(payload: {
|
||||
code: string;
|
||||
name: string;
|
||||
entityType: DocumentCategoryEntityType;
|
||||
sequencePrefix: string;
|
||||
numberLength?: number;
|
||||
resetPeriod: DocumentResetPeriod;
|
||||
defaultWorkflowKey?: string | null;
|
||||
enabled?: boolean;
|
||||
}) {
|
||||
return apiRequestData<{ documentCategory: DocumentCategoryItem }>(
|
||||
"/api/master-data/document-categories",
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export async function patchDocumentCategory(
|
||||
documentCategoryId: string,
|
||||
payload: Partial<{
|
||||
code: string;
|
||||
name: string;
|
||||
entityType: DocumentCategoryEntityType;
|
||||
sequencePrefix: string;
|
||||
numberLength: number;
|
||||
resetPeriod: DocumentResetPeriod;
|
||||
defaultWorkflowKey: string | null;
|
||||
enabled: boolean;
|
||||
}>,
|
||||
) {
|
||||
return apiRequestData<{ documentCategory: DocumentCategoryItem }>(
|
||||
`/api/master-data/document-categories/${documentCategoryId}`,
|
||||
{
|
||||
method: "PATCH",
|
||||
body: JSON.stringify(payload),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export async function archiveDocumentCategory(documentCategoryId: string) {
|
||||
return apiRequestData<{ documentCategory: DocumentCategoryItem; outcome: string }>(
|
||||
`/api/master-data/document-categories/${documentCategoryId}/archive`,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({}),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export async function fetchHolidayCalendars(params: {
|
||||
includeArchived?: boolean;
|
||||
enabled?: boolean;
|
||||
legalEntityId?: string;
|
||||
} = {}) {
|
||||
return apiRequestData<MasterDataListResponse<HolidayCalendarItem>>(
|
||||
`/api/master-data/holiday-calendars${toQueryString(params as Record<string, string | boolean | undefined>)}`,
|
||||
);
|
||||
}
|
||||
|
||||
export async function createHolidayCalendar(payload: {
|
||||
code: string;
|
||||
name: string;
|
||||
timezone?: string;
|
||||
legalEntityId?: string | null;
|
||||
enabled?: boolean;
|
||||
}) {
|
||||
return apiRequestData<{ holidayCalendar: HolidayCalendarItem }>("/api/master-data/holiday-calendars", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export async function patchHolidayCalendar(
|
||||
holidayCalendarId: string,
|
||||
payload: Partial<{
|
||||
code: string;
|
||||
name: string;
|
||||
timezone: string;
|
||||
legalEntityId: string | null;
|
||||
enabled: boolean;
|
||||
}>,
|
||||
) {
|
||||
return apiRequestData<{ holidayCalendar: HolidayCalendarItem }>(
|
||||
`/api/master-data/holiday-calendars/${holidayCalendarId}`,
|
||||
{
|
||||
method: "PATCH",
|
||||
body: JSON.stringify(payload),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export async function archiveHolidayCalendar(holidayCalendarId: string) {
|
||||
return apiRequestData<{ holidayCalendar: HolidayCalendarItem; outcome: string }>(
|
||||
`/api/master-data/holiday-calendars/${holidayCalendarId}/archive`,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({}),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export async function fetchHolidayCalendarDays(holidayCalendarId: string) {
|
||||
return apiRequestData<{ items: HolidayCalendarDayItem[] }>(
|
||||
`/api/master-data/holiday-calendars/${holidayCalendarId}/days`,
|
||||
);
|
||||
}
|
||||
|
||||
export async function replaceHolidayCalendarDays(
|
||||
holidayCalendarId: string,
|
||||
items: Array<{
|
||||
date: string;
|
||||
dayType: HolidayCalendarDayType;
|
||||
name: string;
|
||||
note?: string | null;
|
||||
}>,
|
||||
) {
|
||||
return apiRequestData<{ holidayCalendarId: string; replacedCount: number }>(
|
||||
`/api/master-data/holiday-calendars/${holidayCalendarId}/days`,
|
||||
{
|
||||
method: "PUT",
|
||||
body: JSON.stringify({ items }),
|
||||
},
|
||||
);
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户