jordium-gantt-vue3
Version:
A Vue 3 Gantt chart component for project management, task scheduling, resource planning, calendar, resource usage and timeline visualization.
177 lines (176 loc) • 4.46 kB
TypeScript
import { Task } from '../classes/Task';
import { Milestone } from '../classes/Milestone';
import { TimelineScale } from './TimelineScale';
export interface TimelineHour {
hour: number;
label: string;
shortLabel?: string;
hourLabel?: string;
date?: Date;
isToday?: boolean;
isWorkingHour?: boolean;
isWeekend?: boolean;
}
export interface TimelineDay {
year: number;
month: number;
day: number;
date: Date;
dateLabel: string;
label?: string;
dayOfWeek?: number;
isToday?: boolean;
isWeekend?: boolean;
hours?: TimelineHour[];
hourOffset?: number;
}
export interface TimelineWeek {
label: string;
startDate: Date;
endDate: Date;
weekStart?: Date;
weekEnd?: Date;
weekNumber?: number;
isToday?: boolean;
belongsToYear?: number;
belongsToMonth?: number;
subDays?: Array<{
date: Date;
dayOfWeek?: number;
}>;
}
export interface TimelineMonth {
year: number;
month: number;
startDate: Date;
endDate: Date;
monthLabel?: string;
yearMonthLabel?: string;
isToday?: boolean;
isMonthView?: boolean;
monthData?: {
dayCount: number;
monthLabel?: string;
isToday?: boolean;
};
isWeekView?: boolean;
weeks?: Array<{
weekStart: Date;
weekEnd: Date;
subDays: Array<{
date: Date;
dayOfWeek?: number;
}>;
}>;
days?: Array<{
day: number;
date: Date;
label: string;
isToday: boolean;
isWeekend: boolean;
}>;
subDays?: Array<{
date: Date;
dayOfWeek?: number;
}>;
_debugInfo?: Record<string, unknown>;
}
export interface TimelineQuarter {
quarter: number;
label?: string;
fullLabel?: string;
quarterLabel: string;
startDate: Date;
endDate: Date;
isToday?: boolean;
year?: number;
}
export interface TimelineYear {
year: number;
yearLabel: string;
startDate: Date;
endDate: Date;
isToday?: boolean;
quarters?: TimelineQuarter[];
halfYears?: Array<{
startDate: Date;
endDate: Date;
label: string;
}>;
}
export type TimelineData = TimelineMonth[] | TimelineYear[] | TimelineDay[];
export type TimelineDataItem = TimelineMonth | TimelineYear | TimelineDay;
export interface TimelineCacheKey {
startDate: string;
endDate: string;
scale: string;
workingHours: string;
}
/**
* TaskBar 向 Timeline emit tooltip-show 时携带的数据
*/
export interface TooltipShowPayload {
task: Task;
taskStatus: {
color: string;
label: string;
type?: string;
};
resourcePercent: number;
hasResourceConflict: boolean;
/** TaskBar 元素的 DOMRect,用于 Timeline 计算定位 */
targetRect: DOMRect;
mouseX?: number;
mouseY?: number;
/** 父级任务自动调度信息(仅 isParent=true 时携带) */
parentAutoSchedule?: {
enabled: boolean;
childrenRange: {
minStart: Date;
maxEnd: Date;
maxEndRaw?: Task['endDate'];
} | null;
hasOverflow: boolean;
};
}
/**
* #taskbar-tooltip scoped slot 向消费方暴露的数据
*/
export interface TaskbarTooltipSlotScope {
task: Task;
taskStatus: {
color: string;
label: string;
};
resourcePercent: number;
}
/**
* MilestonePoint 向 Timeline emit milestone-tooltip-show 时携带的数据
*/
export interface MilestoneTooltipShowPayload {
milestone: Milestone;
milestoneColor: string;
/** MilestonePoint 元素的 DOMRect,用于 Timeline 计算定位 */
targetRect: DOMRect;
/** 停靠位置,用于 tooltip 方向判断 */
stickyPosition: 'left' | 'right';
}
/**
* #milestone-tooltip scoped slot 向消费方暴露的数据
*/
export interface MilestoneTooltipSlotScope {
milestone: Milestone;
}
/**
* #custom-milestone-content scoped slot 向消费方暴露的数据
* 字段裁剪依据见 .ai/.claude/requirments/v1.13.5.md 8.2.2
*/
export interface MilestoneSlotProps {
milestone: Milestone;
task: Task;
rowHeight: number;
dayWidth: number;
currentTimeScale?: TimelineScale | null;
/** 当前生效的标签展示位置,供自定义内容按需调整自身布局(如 top/bottom 时纵向堆叠) */
labelPosition: 'right' | 'left' | 'top' | 'bottom';
}