2026-05-09 11:30:34 +08:00
|
|
|
|
import { normalizeNullableStringId, normalizeStringId } from './shared';
|
|
|
|
|
|
|
|
|
|
|
|
type ProjectStatusCode = Api.Project.ProjectStatusCode;
|
|
|
|
|
|
type ProjectStatusActionCode = Exclude<Api.Project.ProjectStatusActionCode, 'auto_start'>;
|
|
|
|
|
|
|
|
|
|
|
|
type StringIdResponse = string | number;
|
|
|
|
|
|
|
|
|
|
|
|
export type ProjectLocalDateValue = string | number[] | null;
|
|
|
|
|
|
|
|
|
|
|
|
export type LifecycleActionResponse<ActionCode extends string> = Partial<Api.Project.LifecycleAction<ActionCode>> & {
|
|
|
|
|
|
actionCode: ActionCode;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export type ProjectExecutionResponse = Omit<
|
|
|
|
|
|
Api.Project.ProjectExecution,
|
|
|
|
|
|
| 'id'
|
|
|
|
|
|
| 'projectId'
|
|
|
|
|
|
| 'projectRequirementId'
|
|
|
|
|
|
| 'ownerId'
|
|
|
|
|
|
| 'availableActions'
|
|
|
|
|
|
| 'plannedStartDate'
|
|
|
|
|
|
| 'plannedEndDate'
|
|
|
|
|
|
| 'actualStartDate'
|
|
|
|
|
|
| 'actualEndDate'
|
|
|
|
|
|
| 'progressRate'
|
2026-05-21 21:42:23 +08:00
|
|
|
|
| 'priority'
|
|
|
|
|
|
| 'priorityName'
|
2026-05-09 11:30:34 +08:00
|
|
|
|
> & {
|
|
|
|
|
|
id: StringIdResponse;
|
|
|
|
|
|
projectId: StringIdResponse;
|
|
|
|
|
|
projectRequirementId?: StringIdResponse | null;
|
|
|
|
|
|
ownerId: StringIdResponse;
|
|
|
|
|
|
availableActions?: LifecycleActionResponse<Api.Project.ProjectExecutionActionCode>[] | null;
|
|
|
|
|
|
plannedStartDate?: ProjectLocalDateValue;
|
|
|
|
|
|
plannedEndDate?: ProjectLocalDateValue;
|
|
|
|
|
|
actualStartDate?: ProjectLocalDateValue;
|
|
|
|
|
|
actualEndDate?: ProjectLocalDateValue;
|
|
|
|
|
|
progressRate?: number | null;
|
2026-05-21 21:42:23 +08:00
|
|
|
|
priority?: string | number | null;
|
|
|
|
|
|
priorityName?: string | null;
|
2026-05-09 11:30:34 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2026-05-12 21:41:39 +08:00
|
|
|
|
export type ExecutionAssigneeResponse = Omit<Api.Project.ExecutionAssignee, 'id' | 'executionId' | 'userId'> & {
|
2026-05-09 11:30:34 +08:00
|
|
|
|
id: StringIdResponse;
|
|
|
|
|
|
executionId: StringIdResponse;
|
|
|
|
|
|
userId: StringIdResponse;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-05-12 21:41:39 +08:00
|
|
|
|
export type ExecutionAssigneeLogResponse = Omit<
|
|
|
|
|
|
Api.Project.ExecutionAssigneeLog,
|
2026-05-09 11:30:34 +08:00
|
|
|
|
'id' | 'executionId' | 'userId' | 'operatorUserId'
|
|
|
|
|
|
> & {
|
|
|
|
|
|
id: StringIdResponse;
|
|
|
|
|
|
executionId: StringIdResponse;
|
|
|
|
|
|
userId: StringIdResponse;
|
|
|
|
|
|
operatorUserId: StringIdResponse;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-05-12 21:41:39 +08:00
|
|
|
|
type TaskAssigneeRefResponse = Omit<Api.Project.TaskAssigneeRef, 'id' | 'userId'> & {
|
|
|
|
|
|
id: StringIdResponse;
|
|
|
|
|
|
userId: StringIdResponse;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 后端 attachments 项的兼容形态:历史/当前响应字段名是 `id`,前端类型统一用 `fileId`。
|
|
|
|
|
|
* normalizeAttachments 负责把两者归一成 `fileId`。
|
|
|
|
|
|
*/
|
|
|
|
|
|
type AttachmentItemResponse = Omit<Api.Project.AttachmentItem, 'fileId'> & {
|
|
|
|
|
|
fileId?: StringIdResponse;
|
|
|
|
|
|
id?: StringIdResponse;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function normalizeAttachments(list?: AttachmentItemResponse[] | null): Api.Project.AttachmentItem[] | null {
|
|
|
|
|
|
if (!list) {
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
return list.map(item => {
|
|
|
|
|
|
const rawId = item.fileId ?? item.id;
|
|
|
|
|
|
return {
|
|
|
|
|
|
...item,
|
|
|
|
|
|
fileId: rawId === null || rawId === undefined ? '' : String(rawId)
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 5.6 单独接口返的协办人字段(与 5.3 嵌入字段命名口径不一致:返 userNickname 而非 nickname)。
|
|
|
|
|
|
* 经 normalizeTaskAssignee 归一化后对外统一为 Api.Project.TaskAssigneeRef。
|
|
|
|
|
|
*/
|
|
|
|
|
|
export type TaskAssigneeFromApiResponse = {
|
|
|
|
|
|
id: StringIdResponse;
|
|
|
|
|
|
taskId: StringIdResponse;
|
|
|
|
|
|
userId: StringIdResponse;
|
|
|
|
|
|
userNickname?: string | null;
|
|
|
|
|
|
joinedAt?: string | null;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export type TaskAssigneeLogResponse = Omit<
|
|
|
|
|
|
Api.Project.TaskAssigneeLog,
|
|
|
|
|
|
'id' | 'taskId' | 'userId' | 'operatorUserId'
|
|
|
|
|
|
> & {
|
|
|
|
|
|
id: StringIdResponse;
|
|
|
|
|
|
taskId: StringIdResponse;
|
|
|
|
|
|
userId: StringIdResponse;
|
|
|
|
|
|
operatorUserId: StringIdResponse;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-05-09 11:30:34 +08:00
|
|
|
|
export type ProjectTaskResponse = Omit<
|
|
|
|
|
|
Api.Project.ProjectTask,
|
|
|
|
|
|
| 'id'
|
|
|
|
|
|
| 'projectId'
|
|
|
|
|
|
| 'executionId'
|
|
|
|
|
|
| 'parentTaskId'
|
|
|
|
|
|
| 'ownerId'
|
2026-05-23 14:22:58 +08:00
|
|
|
|
| 'executionOwnerId'
|
|
|
|
|
|
| 'parentTaskOwnerId'
|
2026-05-09 11:30:34 +08:00
|
|
|
|
| 'availableActions'
|
|
|
|
|
|
| 'plannedStartDate'
|
|
|
|
|
|
| 'plannedEndDate'
|
|
|
|
|
|
| 'actualStartDate'
|
|
|
|
|
|
| 'actualEndDate'
|
|
|
|
|
|
| 'progressRate'
|
2026-05-12 21:41:39 +08:00
|
|
|
|
| 'assignees'
|
|
|
|
|
|
| 'attachments'
|
2026-05-21 21:42:23 +08:00
|
|
|
|
| 'priority'
|
|
|
|
|
|
| 'priorityName'
|
2026-05-09 11:30:34 +08:00
|
|
|
|
> & {
|
|
|
|
|
|
id: StringIdResponse;
|
|
|
|
|
|
projectId: StringIdResponse;
|
|
|
|
|
|
executionId: StringIdResponse;
|
2026-05-23 14:22:58 +08:00
|
|
|
|
executionName?: string | null;
|
|
|
|
|
|
executionStatusCode?: Api.Project.ProjectExecutionStatusCode | null;
|
2026-05-09 11:30:34 +08:00
|
|
|
|
parentTaskId?: StringIdResponse | null;
|
|
|
|
|
|
ownerId: StringIdResponse;
|
2026-05-23 14:22:58 +08:00
|
|
|
|
executionOwnerId?: StringIdResponse | null;
|
|
|
|
|
|
parentTaskOwnerId?: StringIdResponse | null;
|
2026-05-09 11:30:34 +08:00
|
|
|
|
availableActions?: LifecycleActionResponse<Api.Project.ProjectTaskActionCode>[] | null;
|
|
|
|
|
|
plannedStartDate?: ProjectLocalDateValue;
|
|
|
|
|
|
plannedEndDate?: ProjectLocalDateValue;
|
|
|
|
|
|
actualStartDate?: ProjectLocalDateValue;
|
|
|
|
|
|
actualEndDate?: ProjectLocalDateValue;
|
|
|
|
|
|
progressRate?: number | null;
|
2026-05-12 21:41:39 +08:00
|
|
|
|
assignees?: TaskAssigneeRefResponse[] | null;
|
|
|
|
|
|
attachments?: AttachmentItemResponse[] | null;
|
|
|
|
|
|
totalSpentHours?: number | null;
|
2026-05-21 21:42:23 +08:00
|
|
|
|
priority?: string | number | null;
|
|
|
|
|
|
priorityName?: string | null;
|
2026-05-12 21:41:39 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2026-05-21 14:06:05 +08:00
|
|
|
|
export type TaskWorklogResponse = Omit<
|
|
|
|
|
|
Api.Project.TaskWorklog,
|
2026-05-21 22:05:30 +08:00
|
|
|
|
'id' | 'taskId' | 'userId' | 'difficulty' | 'attachments' | 'startDate' | 'endDate'
|
2026-05-21 14:06:05 +08:00
|
|
|
|
> & {
|
2026-05-12 21:41:39 +08:00
|
|
|
|
id: StringIdResponse;
|
|
|
|
|
|
taskId: StringIdResponse;
|
|
|
|
|
|
userId: StringIdResponse;
|
2026-05-21 14:06:05 +08:00
|
|
|
|
difficulty?: string | null;
|
2026-05-12 21:41:39 +08:00
|
|
|
|
attachments?: AttachmentItemResponse[] | null;
|
2026-05-21 22:05:30 +08:00
|
|
|
|
startDate?: ProjectLocalDateValue;
|
|
|
|
|
|
endDate?: ProjectLocalDateValue;
|
2026-05-09 11:30:34 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export interface ProjectMemberResponse {
|
|
|
|
|
|
id: string | number;
|
|
|
|
|
|
userId: string | number;
|
|
|
|
|
|
userNickname: string;
|
|
|
|
|
|
roleId: string | number;
|
|
|
|
|
|
roleName: string;
|
|
|
|
|
|
roleCode: string;
|
|
|
|
|
|
managerFlag: boolean;
|
|
|
|
|
|
status: 0 | 1;
|
|
|
|
|
|
joinedTime: string;
|
|
|
|
|
|
leftTime?: string | null;
|
|
|
|
|
|
remark?: string | null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const projectLifecycleActionNameMap: Record<ProjectStatusActionCode, string> = {
|
|
|
|
|
|
pause: '暂停项目',
|
|
|
|
|
|
resume: '恢复项目',
|
|
|
|
|
|
complete: '完成项目',
|
|
|
|
|
|
cancel: '取消项目',
|
|
|
|
|
|
reopen: '重新开启',
|
|
|
|
|
|
archive: '归档项目'
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const projectLifecycleActionReasonRequiredMap: Record<ProjectStatusActionCode, boolean> = {
|
|
|
|
|
|
pause: true,
|
|
|
|
|
|
resume: false,
|
|
|
|
|
|
complete: true,
|
|
|
|
|
|
cancel: true,
|
|
|
|
|
|
reopen: true,
|
|
|
|
|
|
archive: false
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const projectLifecycleActionMap: Record<ProjectStatusCode, ProjectStatusActionCode[]> = {
|
|
|
|
|
|
pending: ['cancel'],
|
|
|
|
|
|
active: ['pause', 'complete', 'cancel'],
|
|
|
|
|
|
paused: ['resume', 'cancel'],
|
|
|
|
|
|
completed: ['reopen', 'archive'],
|
|
|
|
|
|
cancelled: [],
|
|
|
|
|
|
archived: []
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export function getProjectLifecycleActions(statusCode: ProjectStatusCode): Api.Project.ProjectLifecycleAction[] {
|
|
|
|
|
|
return projectLifecycleActionMap[statusCode].map(actionCode => ({
|
|
|
|
|
|
actionCode,
|
|
|
|
|
|
actionName: projectLifecycleActionNameMap[actionCode],
|
|
|
|
|
|
needReason: projectLifecycleActionReasonRequiredMap[actionCode]
|
|
|
|
|
|
}));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function normalizeProjectLocalDate(value: ProjectLocalDateValue | undefined) {
|
|
|
|
|
|
if (value === null || value === undefined || value === '') {
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (Array.isArray(value)) {
|
|
|
|
|
|
const [year, month, day] = value;
|
|
|
|
|
|
|
|
|
|
|
|
if (!year || !month || !day) {
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return [year, month, day].map(item => String(item).padStart(2, '0')).join('-');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return String(value);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function normalizeLifecycleActions<ActionCode extends string>(
|
|
|
|
|
|
actions: LifecycleActionResponse<ActionCode>[] | null | undefined
|
|
|
|
|
|
): Api.Project.LifecycleAction<ActionCode>[] {
|
|
|
|
|
|
return (actions ?? []).map(action => ({
|
|
|
|
|
|
actionCode: action.actionCode,
|
|
|
|
|
|
actionName: action.actionName ?? '',
|
|
|
|
|
|
needReason: Boolean(action.needReason)
|
|
|
|
|
|
}));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function normalizeProjectMember(response: ProjectMemberResponse): Api.Project.ProjectMember {
|
|
|
|
|
|
return {
|
|
|
|
|
|
id: normalizeStringId(response.id),
|
|
|
|
|
|
userId: normalizeStringId(response.userId),
|
|
|
|
|
|
userNickname: response.userNickname || '',
|
|
|
|
|
|
roleId: normalizeStringId(response.roleId),
|
|
|
|
|
|
roleName: response.roleName || '',
|
|
|
|
|
|
roleCode: response.roleCode || '',
|
|
|
|
|
|
managerFlag: Boolean(response.managerFlag),
|
|
|
|
|
|
status: response.status,
|
|
|
|
|
|
joinedTime: response.joinedTime,
|
|
|
|
|
|
leftTime: response.leftTime ?? null,
|
|
|
|
|
|
remark: response.remark ?? null
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-21 21:42:23 +08:00
|
|
|
|
function normalizePriority(value: string | number | null | undefined): string {
|
|
|
|
|
|
if (value === null || value === undefined || value === '') {
|
|
|
|
|
|
return '1';
|
|
|
|
|
|
}
|
|
|
|
|
|
return String(value);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-09 11:30:34 +08:00
|
|
|
|
export function normalizeProjectExecution(response: ProjectExecutionResponse): Api.Project.ProjectExecution {
|
|
|
|
|
|
return {
|
|
|
|
|
|
...response,
|
|
|
|
|
|
id: normalizeStringId(response.id),
|
|
|
|
|
|
projectId: normalizeStringId(response.projectId),
|
|
|
|
|
|
projectRequirementId: normalizeNullableStringId(response.projectRequirementId),
|
2026-05-21 21:42:23 +08:00
|
|
|
|
projectRequirementName: response.projectRequirementName ?? null,
|
|
|
|
|
|
projectRequirementStatusCode: response.projectRequirementStatusCode ?? null,
|
2026-05-09 11:30:34 +08:00
|
|
|
|
ownerId: normalizeStringId(response.ownerId),
|
|
|
|
|
|
ownerNickname: response.ownerNickname ?? null,
|
|
|
|
|
|
statusName: response.statusName ?? null,
|
|
|
|
|
|
terminal: Boolean(response.terminal),
|
|
|
|
|
|
allowEdit: Boolean(response.allowEdit),
|
|
|
|
|
|
availableActions: normalizeLifecycleActions(response.availableActions),
|
|
|
|
|
|
plannedStartDate: normalizeProjectLocalDate(response.plannedStartDate),
|
|
|
|
|
|
plannedEndDate: normalizeProjectLocalDate(response.plannedEndDate),
|
|
|
|
|
|
actualStartDate: normalizeProjectLocalDate(response.actualStartDate),
|
|
|
|
|
|
actualEndDate: normalizeProjectLocalDate(response.actualEndDate),
|
|
|
|
|
|
progressRate: typeof response.progressRate === 'number' ? response.progressRate : 0,
|
2026-05-21 21:42:23 +08:00
|
|
|
|
priority: normalizePriority(response.priority),
|
|
|
|
|
|
priorityName: response.priorityName ?? null,
|
2026-05-09 11:30:34 +08:00
|
|
|
|
executionDesc: response.executionDesc ?? null,
|
|
|
|
|
|
lastStatusReason: response.lastStatusReason ?? null
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-12 21:41:39 +08:00
|
|
|
|
export function normalizeExecutionAssignee(response: ExecutionAssigneeResponse): Api.Project.ExecutionAssignee {
|
2026-05-09 11:30:34 +08:00
|
|
|
|
return {
|
|
|
|
|
|
...response,
|
|
|
|
|
|
id: normalizeStringId(response.id),
|
|
|
|
|
|
executionId: normalizeStringId(response.executionId),
|
|
|
|
|
|
userId: normalizeStringId(response.userId),
|
|
|
|
|
|
userNickname: response.userNickname ?? null,
|
|
|
|
|
|
joinedAt: response.joinedAt ?? null,
|
|
|
|
|
|
removedAt: response.removedAt ?? null,
|
|
|
|
|
|
removedReason: response.removedReason ?? null
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-12 21:41:39 +08:00
|
|
|
|
export function normalizeExecutionAssigneeLog(
|
|
|
|
|
|
response: ExecutionAssigneeLogResponse
|
|
|
|
|
|
): Api.Project.ExecutionAssigneeLog {
|
2026-05-09 11:30:34 +08:00
|
|
|
|
return {
|
|
|
|
|
|
...response,
|
|
|
|
|
|
id: normalizeStringId(response.id),
|
|
|
|
|
|
executionId: normalizeStringId(response.executionId),
|
|
|
|
|
|
userId: normalizeStringId(response.userId),
|
|
|
|
|
|
operatorUserId: normalizeStringId(response.operatorUserId),
|
|
|
|
|
|
userNicknameSnapshot: response.userNicknameSnapshot ?? null,
|
|
|
|
|
|
operatorNicknameSnapshot: response.operatorNicknameSnapshot ?? null,
|
|
|
|
|
|
reason: response.reason ?? null
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function normalizeProjectTask(response: ProjectTaskResponse): Api.Project.ProjectTask {
|
|
|
|
|
|
return {
|
|
|
|
|
|
...response,
|
|
|
|
|
|
id: normalizeStringId(response.id),
|
|
|
|
|
|
projectId: normalizeStringId(response.projectId),
|
|
|
|
|
|
executionId: normalizeStringId(response.executionId),
|
2026-05-23 14:22:58 +08:00
|
|
|
|
executionName: response.executionName ?? null,
|
|
|
|
|
|
executionStatusCode: response.executionStatusCode ?? null,
|
2026-05-09 11:30:34 +08:00
|
|
|
|
parentTaskId: normalizeNullableStringId(response.parentTaskId),
|
2026-05-21 21:42:23 +08:00
|
|
|
|
projectRequirementId: normalizeNullableStringId(response.projectRequirementId),
|
|
|
|
|
|
projectRequirementName: response.projectRequirementName ?? null,
|
|
|
|
|
|
projectRequirementStatusCode: response.projectRequirementStatusCode ?? null,
|
2026-05-21 14:06:05 +08:00
|
|
|
|
type: response.type ?? '',
|
2026-05-09 11:30:34 +08:00
|
|
|
|
ownerId: normalizeStringId(response.ownerId),
|
|
|
|
|
|
ownerNickname: response.ownerNickname ?? null,
|
2026-05-23 14:22:58 +08:00
|
|
|
|
executionOwnerId: normalizeNullableStringId(response.executionOwnerId),
|
|
|
|
|
|
parentTaskOwnerId: normalizeNullableStringId(response.parentTaskOwnerId),
|
2026-05-09 11:30:34 +08:00
|
|
|
|
statusName: response.statusName ?? null,
|
|
|
|
|
|
terminal: Boolean(response.terminal),
|
|
|
|
|
|
allowEdit: Boolean(response.allowEdit),
|
|
|
|
|
|
availableActions: normalizeLifecycleActions(response.availableActions),
|
|
|
|
|
|
progressRate: typeof response.progressRate === 'number' ? response.progressRate : 0,
|
|
|
|
|
|
plannedStartDate: normalizeProjectLocalDate(response.plannedStartDate),
|
|
|
|
|
|
plannedEndDate: normalizeProjectLocalDate(response.plannedEndDate),
|
|
|
|
|
|
actualStartDate: normalizeProjectLocalDate(response.actualStartDate),
|
|
|
|
|
|
actualEndDate: normalizeProjectLocalDate(response.actualEndDate),
|
2026-05-21 21:42:23 +08:00
|
|
|
|
priority: normalizePriority(response.priority),
|
|
|
|
|
|
priorityName: response.priorityName ?? null,
|
2026-05-09 11:30:34 +08:00
|
|
|
|
taskDesc: response.taskDesc ?? null,
|
2026-05-12 21:41:39 +08:00
|
|
|
|
lastStatusReason: response.lastStatusReason ?? null,
|
|
|
|
|
|
assignees:
|
|
|
|
|
|
response.assignees?.map(item => ({
|
|
|
|
|
|
id: normalizeStringId(item.id),
|
|
|
|
|
|
userId: normalizeStringId(item.userId),
|
|
|
|
|
|
nickname: item.nickname ?? ''
|
|
|
|
|
|
})) ?? null,
|
|
|
|
|
|
attachments: normalizeAttachments(response.attachments),
|
|
|
|
|
|
totalSpentHours: response.totalSpentHours ?? null
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function normalizeTaskWorklog(response: TaskWorklogResponse): Api.Project.TaskWorklog {
|
|
|
|
|
|
return {
|
|
|
|
|
|
...response,
|
|
|
|
|
|
id: normalizeStringId(response.id),
|
|
|
|
|
|
taskId: normalizeStringId(response.taskId),
|
|
|
|
|
|
userId: normalizeStringId(response.userId),
|
|
|
|
|
|
userNickname: response.userNickname ?? null,
|
|
|
|
|
|
workContent: response.workContent ?? null,
|
|
|
|
|
|
attachments: normalizeAttachments(response.attachments),
|
2026-05-21 21:42:23 +08:00
|
|
|
|
progressRate: typeof response.progressRate === 'number' ? response.progressRate : 0,
|
2026-05-21 22:05:30 +08:00
|
|
|
|
// 后端 LocalDate 默认序列化为 [year, month, day] 数组,必须归一为 'YYYY-MM-DD' 字符串供 ElDatePicker 使用
|
|
|
|
|
|
startDate: normalizeProjectLocalDate(response.startDate) ?? '',
|
|
|
|
|
|
endDate: normalizeProjectLocalDate(response.endDate) ?? '',
|
2026-05-21 21:42:23 +08:00
|
|
|
|
// 历史记录或异常缺失时兜底为字典默认档位 "2"
|
|
|
|
|
|
difficulty: response.difficulty ?? '2',
|
|
|
|
|
|
difficultyName: response.difficultyName ?? null
|
2026-05-12 21:41:39 +08:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function normalizeTaskAssignee(response: TaskAssigneeFromApiResponse): Api.Project.TaskAssigneeRef {
|
|
|
|
|
|
return {
|
|
|
|
|
|
id: normalizeStringId(response.id),
|
|
|
|
|
|
userId: normalizeStringId(response.userId),
|
|
|
|
|
|
nickname: response.userNickname ?? '',
|
|
|
|
|
|
joinedAt: response.joinedAt ?? null
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function normalizeTaskAssigneeLog(response: TaskAssigneeLogResponse): Api.Project.TaskAssigneeLog {
|
|
|
|
|
|
return {
|
|
|
|
|
|
...response,
|
|
|
|
|
|
id: normalizeStringId(response.id),
|
|
|
|
|
|
taskId: normalizeStringId(response.taskId),
|
|
|
|
|
|
userId: normalizeStringId(response.userId),
|
|
|
|
|
|
operatorUserId: normalizeStringId(response.operatorUserId),
|
|
|
|
|
|
userNicknameSnapshot: response.userNicknameSnapshot ?? null,
|
|
|
|
|
|
operatorNicknameSnapshot: response.operatorNicknameSnapshot ?? null,
|
|
|
|
|
|
reason: response.reason ?? null
|
2026-05-09 11:30:34 +08:00
|
|
|
|
};
|
|
|
|
|
|
}
|