feat(projects): 工作台部分组件调成真实数据
This commit is contained in:
@@ -40,6 +40,42 @@ export type ProjectExecutionResponse = Omit<
|
||||
priorityName?: string | null;
|
||||
};
|
||||
|
||||
export type MyExecutionResponse = Omit<
|
||||
Api.Project.MyExecutionItem,
|
||||
| 'id'
|
||||
| 'projectId'
|
||||
| 'projectRequirementId'
|
||||
| 'priority'
|
||||
| 'progressRate'
|
||||
| 'plannedStartDate'
|
||||
| 'plannedEndDate'
|
||||
| 'actualStartDate'
|
||||
| 'actualEndDate'
|
||||
> & {
|
||||
id: StringIdResponse;
|
||||
projectId: StringIdResponse;
|
||||
projectRequirementId?: StringIdResponse | null;
|
||||
priority?: string | number | null;
|
||||
progressRate?: number | null;
|
||||
plannedStartDate?: ProjectLocalDateValue;
|
||||
plannedEndDate?: ProjectLocalDateValue;
|
||||
actualStartDate?: ProjectLocalDateValue;
|
||||
actualEndDate?: ProjectLocalDateValue;
|
||||
};
|
||||
|
||||
export type MyParticipatedProjectResponse = Omit<Api.Project.MyParticipatedProjectItem, 'id'> & {
|
||||
id: StringIdResponse;
|
||||
};
|
||||
|
||||
export type MyOwnedProjectMemberResponse = Omit<Api.Project.MyOwnedProjectMember, 'userId'> & {
|
||||
userId: StringIdResponse;
|
||||
};
|
||||
|
||||
export type MyOwnedProjectResponse = Omit<Api.Project.MyOwnedProjectItem, 'id' | 'members'> & {
|
||||
id: StringIdResponse;
|
||||
members?: MyOwnedProjectMemberResponse[] | null;
|
||||
};
|
||||
|
||||
export type ExecutionAssigneeResponse = Omit<Api.Project.ExecutionAssignee, 'id' | 'executionId' | 'userId'> & {
|
||||
id: StringIdResponse;
|
||||
executionId: StringIdResponse;
|
||||
@@ -286,6 +322,50 @@ export function normalizeProjectExecution(response: ProjectExecutionResponse): A
|
||||
};
|
||||
}
|
||||
|
||||
export function normalizeMyExecution(response: MyExecutionResponse): Api.Project.MyExecutionItem {
|
||||
return {
|
||||
...response,
|
||||
id: normalizeStringId(response.id),
|
||||
projectId: normalizeStringId(response.projectId),
|
||||
statusName: response.statusName ?? null,
|
||||
priority: normalizePriority(response.priority),
|
||||
progressRate: typeof response.progressRate === 'number' ? response.progressRate : 0,
|
||||
plannedStartDate: normalizeProjectLocalDate(response.plannedStartDate),
|
||||
plannedEndDate: normalizeProjectLocalDate(response.plannedEndDate),
|
||||
actualStartDate: normalizeProjectLocalDate(response.actualStartDate),
|
||||
actualEndDate: normalizeProjectLocalDate(response.actualEndDate),
|
||||
projectRequirementId: normalizeNullableStringId(response.projectRequirementId),
|
||||
projectRequirementName: response.projectRequirementName ?? null
|
||||
};
|
||||
}
|
||||
|
||||
export function normalizeMyParticipatedProject(
|
||||
response: MyParticipatedProjectResponse
|
||||
): Api.Project.MyParticipatedProjectItem {
|
||||
return {
|
||||
...response,
|
||||
id: normalizeStringId(response.id),
|
||||
code: response.code ?? null,
|
||||
statusName: response.statusName ?? null,
|
||||
myRole: response.myRole ?? null
|
||||
};
|
||||
}
|
||||
|
||||
export function normalizeMyOwnedProject(response: MyOwnedProjectResponse): Api.Project.MyOwnedProjectItem {
|
||||
return {
|
||||
...response,
|
||||
id: normalizeStringId(response.id),
|
||||
code: response.code ?? null,
|
||||
myRole: response.myRole ?? null,
|
||||
plannedEndDate: response.plannedEndDate ?? null,
|
||||
members: (response.members ?? []).map(member => ({
|
||||
...member,
|
||||
userId: normalizeStringId(member.userId),
|
||||
userName: member.userName ?? null
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
export function normalizeExecutionAssignee(response: ExecutionAssigneeResponse): Api.Project.ExecutionAssignee {
|
||||
return {
|
||||
...response,
|
||||
|
||||
@@ -10,6 +10,9 @@ import {
|
||||
import {
|
||||
type ExecutionAssigneeLogResponse,
|
||||
type ExecutionAssigneeResponse,
|
||||
type MyExecutionResponse,
|
||||
type MyOwnedProjectResponse,
|
||||
type MyParticipatedProjectResponse,
|
||||
type ProjectExecutionResponse,
|
||||
type ProjectLocalDateValue,
|
||||
type ProjectMemberResponse,
|
||||
@@ -20,6 +23,9 @@ import {
|
||||
getProjectLifecycleActions,
|
||||
normalizeExecutionAssignee,
|
||||
normalizeExecutionAssigneeLog,
|
||||
normalizeMyExecution,
|
||||
normalizeMyOwnedProject,
|
||||
normalizeMyParticipatedProject,
|
||||
normalizeProjectExecution,
|
||||
normalizeProjectLocalDate,
|
||||
normalizeProjectMember,
|
||||
@@ -365,6 +371,54 @@ export async function fetchGetProjectExecutionPage(
|
||||
}));
|
||||
}
|
||||
|
||||
/** 获取工作台「我负责的执行」(跨项目聚合,owner 隐式取当前登录用户) */
|
||||
export async function fetchGetMyExecutionPage(params?: Api.Project.MyExecutionSearchParams) {
|
||||
type MyExecutionPageResponse = Api.Project.PageResult<MyExecutionResponse>;
|
||||
const result = await request<MyExecutionPageResponse>({
|
||||
...safeJsonRequestConfig,
|
||||
url: `${PROJECT_PREFIX}/me/executions/page`,
|
||||
method: 'get',
|
||||
params
|
||||
});
|
||||
|
||||
return mapServiceResult(result as ServiceRequestResult<MyExecutionPageResponse>, data => ({
|
||||
...data,
|
||||
list: data.list.map(normalizeMyExecution)
|
||||
}));
|
||||
}
|
||||
|
||||
/** 获取工作台「我参与的项目」(成员视角,附我的角色与任务量;隐式取当前登录用户) */
|
||||
export async function fetchGetMyParticipatedProjectPage(params?: Api.Project.MyProjectSearchParams) {
|
||||
type MyParticipatedProjectPageResponse = Api.Project.PageResult<MyParticipatedProjectResponse>;
|
||||
const result = await request<MyParticipatedProjectPageResponse>({
|
||||
...safeJsonRequestConfig,
|
||||
url: `${PROJECT_PREFIX}/me/participated/page`,
|
||||
method: 'get',
|
||||
params
|
||||
});
|
||||
|
||||
return mapServiceResult(result as ServiceRequestResult<MyParticipatedProjectPageResponse>, data => ({
|
||||
...data,
|
||||
list: data.list.map(normalizeMyParticipatedProject)
|
||||
}));
|
||||
}
|
||||
|
||||
/** 获取工作台「我负责的项目」(项目负责人视角,附聚合统计与成员负载;隐式取当前登录用户) */
|
||||
export async function fetchGetMyOwnedProjectPage(params?: Api.Project.MyProjectSearchParams) {
|
||||
type MyOwnedProjectPageResponse = Api.Project.PageResult<MyOwnedProjectResponse>;
|
||||
const result = await request<MyOwnedProjectPageResponse>({
|
||||
...safeJsonRequestConfig,
|
||||
url: `${PROJECT_PREFIX}/me/owned/page`,
|
||||
method: 'get',
|
||||
params
|
||||
});
|
||||
|
||||
return mapServiceResult(result as ServiceRequestResult<MyOwnedProjectPageResponse>, data => ({
|
||||
...data,
|
||||
list: data.list.map(normalizeMyOwnedProject)
|
||||
}));
|
||||
}
|
||||
|
||||
/** 获取项目执行状态看板 */
|
||||
export function fetchGetProjectExecutionStatusBoard(
|
||||
projectId: string,
|
||||
|
||||
Reference in New Issue
Block a user