feat(performance、workReport、workbench): 添加绩效表预填功能并优化工作台组件
This commit is contained in:
@@ -65,6 +65,11 @@ type MonthlyResultResponse = Omit<Api.Performance.Sheet.MonthlyResult, 'sheetId'
|
||||
employeeId: StringIdResponse;
|
||||
};
|
||||
|
||||
type PrefillResponse = Omit<Api.Performance.Sheet.PrefillData, 'sourceSheetId' | 'cellValues'> & {
|
||||
sourceSheetId?: StringIdResponse | null;
|
||||
cellValues?: Record<string, string | number | null | undefined> | null;
|
||||
};
|
||||
|
||||
type TeamSummaryResponse = Omit<
|
||||
Api.Performance.Team.Summary,
|
||||
| 'expectedSheetCount'
|
||||
@@ -185,6 +190,28 @@ function normalizeMonthlyResult(response: MonthlyResultResponse): Api.Performanc
|
||||
};
|
||||
}
|
||||
|
||||
function normalizePrefillData(response: PrefillResponse): Api.Performance.Sheet.PrefillData {
|
||||
const cellValues = Object.fromEntries(
|
||||
Object.entries(response.cellValues || {}).flatMap(([address, value]) => {
|
||||
const normalizedAddress = String(address || '')
|
||||
.trim()
|
||||
.toUpperCase();
|
||||
|
||||
if (!normalizedAddress || value === null || value === undefined) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [[normalizedAddress, String(value)]];
|
||||
})
|
||||
);
|
||||
|
||||
return {
|
||||
sourceSheetId: normalizeNullableStringId(response.sourceSheetId),
|
||||
sourcePeriodMonth: response.sourcePeriodMonth ?? null,
|
||||
cellValues
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeTeamSummary(response: TeamSummaryResponse): Api.Performance.Team.Summary {
|
||||
return {
|
||||
...response,
|
||||
@@ -464,6 +491,17 @@ export async function fetchPerformanceMonthlyResult(employeeId: string, periodMo
|
||||
);
|
||||
}
|
||||
|
||||
export async function fetchPerformanceSheetPrefill(employeeId: string, periodMonth: string) {
|
||||
const result = await request<PrefillResponse>({
|
||||
...safeJsonRequestConfig,
|
||||
url: `${SHEET_PREFIX}/prefill`,
|
||||
method: 'get',
|
||||
params: { employeeId, periodMonth }
|
||||
});
|
||||
|
||||
return mapServiceResult(result as ServiceRequestResult<PrefillResponse>, normalizePrefillData);
|
||||
}
|
||||
|
||||
export function fetchPerformanceSheetStatusDict() {
|
||||
return request<Api.Performance.Sheet.StatusDict[]>({
|
||||
...safeJsonRequestConfig,
|
||||
|
||||
Reference in New Issue
Block a user