- 需求模块:完整 CRUD、状态流转(采纳/拒绝/关闭)、详情抽屉、产品→项目级联选择 - 加班记录:产品→项目→版本三级联动、月份筛选(MonthPicker)、CSV 导出 - 成员管理:左右布局(部门树+成员列表)、手机号脱敏、初始密码自动生成及规则设置 - 角色管理:卡片列表、系统角色保护、CRUD - 通用组件:FilterSelect 下拉、MonthPicker 月份选择器、Pagination 分页 - 样式统一:状态标签加 border、日期输入现代化、筛选组件风格一致 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
118 lines
3.2 KiB
TypeScript
118 lines
3.2 KiB
TypeScript
import { VersionStatus } from './version-status';
|
|
import type { Stage, Role } from './stage';
|
|
|
|
export interface VersionMember {
|
|
role: Role;
|
|
name: string;
|
|
}
|
|
|
|
export interface RoleProgress {
|
|
role: Role;
|
|
percent: number;
|
|
daysSpent: number;
|
|
}
|
|
|
|
export type Priority = 'P0' | 'P1' | 'P2' | 'P3' | 'P4';
|
|
|
|
export interface VersionLinks {
|
|
research?: string;
|
|
prototype?: string;
|
|
ui?: string;
|
|
}
|
|
|
|
interface ProductOverviewLike {
|
|
id: string;
|
|
name: string;
|
|
projects: { id: string; name: string; description: string; createdAt: string }[];
|
|
versions: {
|
|
id: string; name: string; status?: string; releaseDate: string | null; createdAt: string;
|
|
currentStage?: Stage; startDate?: string | null; expectedReleaseDate?: string | null;
|
|
members?: VersionMember[]; progress?: RoleProgress[];
|
|
priority?: Priority; links?: VersionLinks;
|
|
}[];
|
|
}
|
|
|
|
export interface ProjectWithContext {
|
|
id: string;
|
|
name: string;
|
|
description: string;
|
|
createdAt: string;
|
|
productId: string;
|
|
productName: string;
|
|
versions: VersionWithContext[];
|
|
}
|
|
|
|
export interface VersionWithContext {
|
|
id: string;
|
|
name: string;
|
|
status: VersionStatus;
|
|
releaseDate: string | null;
|
|
createdAt: string;
|
|
productId: string;
|
|
productName: string;
|
|
projectId: string;
|
|
projectName: string;
|
|
currentStage?: Stage;
|
|
startDate?: string | null;
|
|
expectedReleaseDate?: string | null;
|
|
members?: VersionMember[];
|
|
progress?: RoleProgress[];
|
|
priority?: Priority;
|
|
links?: VersionLinks;
|
|
}
|
|
|
|
export function flattenProjects(overview: ProductOverviewLike[]): ProjectWithContext[] {
|
|
const result: ProjectWithContext[] = [];
|
|
for (const product of overview) {
|
|
for (const project of product.projects) {
|
|
const versions = product.versions
|
|
.filter((v) => v.name.toLowerCase().startsWith(project.name.toLowerCase()))
|
|
.map((v) => ({
|
|
...v,
|
|
status: (v.status || 'released') as VersionStatus,
|
|
productId: product.id,
|
|
productName: product.name,
|
|
projectId: project.id,
|
|
projectName: project.name,
|
|
}));
|
|
result.push({
|
|
...project,
|
|
productId: product.id,
|
|
productName: product.name,
|
|
versions,
|
|
});
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
export function flattenVersions(overview: ProductOverviewLike[]): VersionWithContext[] {
|
|
const result: VersionWithContext[] = [];
|
|
for (const product of overview) {
|
|
for (const version of product.versions) {
|
|
const project = product.projects.find((p) =>
|
|
version.name.toLowerCase().startsWith(p.name.toLowerCase()),
|
|
);
|
|
result.push({
|
|
...version,
|
|
status: (version.status || 'released') as VersionStatus,
|
|
productId: product.id,
|
|
productName: product.name,
|
|
projectId: project?.id || '',
|
|
projectName: project?.name || '未关联',
|
|
});
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
export function getProjectDetail(overview: ProductOverviewLike[], projectId: string): ProjectWithContext | null {
|
|
const projects = flattenProjects(overview);
|
|
return projects.find((p) => p.id === projectId) || null;
|
|
}
|
|
|
|
export function getVersionDetail(overview: ProductOverviewLike[], versionId: string): VersionWithContext | null {
|
|
const versions = flattenVersions(overview);
|
|
return versions.find((v) => v.id === versionId) || null;
|
|
}
|