@lee576/vue3-gantt 1.0.8 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,14 +1,35 @@
1
1
  # Vue3 Gantt 甘特图组件
2
2
 
3
- **Languages / 语言选择:** [English](#english-documentation) | [简体中文](#chinese-documentation) | [View Separate Files](.)
4
-
5
- > 💡 **提示**: GitHub 上也可查看独立语言版本文件:[README.md](README.md) (默认中文) | [README.en-US.md](README.en-US.md) (English)
3
+ **Languages / 语言选择:**
4
+ [<span style="color: #0078d4; font-weight: bold;">简体中文</span>](#chinese-documentation) |
5
+ [<span style="color: #0078d4; font-weight: bold;">English</span>](#english-documentation) |
6
+ [View Separate Files](.)
7
+
8
+ > 💡 **提示**: 点击上方语言链接可直接跳转到对应文档 | GitHub 上也可查看独立语言版本文件:[README.md](README.md) (默认中文) | [README.en-US.md](README.en-US.md) (English)
9
+ >
10
+ > <span style="color: #0078d4; font-weight: bold;">作者联系方式 QQ: 35568701 微信: wl_tww</span>
11
+
12
+ <style>
13
+ html {
14
+ scroll-behavior: smooth;
15
+ }
16
+ details > summary {
17
+ cursor: pointer;
18
+ list-style: none;
19
+ }
20
+ details > summary::-webkit-details-marker {
21
+ display: none;
22
+ }
23
+ details[open] > summary {
24
+ border-bottom: 1px solid #e0e0e0;
25
+ }
26
+ </style>
6
27
 
7
28
  ---
8
29
 
9
30
  <div id="chinese-documentation"></div>
10
31
 
11
- <details open>
32
+ <details>
12
33
  <summary><h2>🇨🇳 简体中文文档</h2></summary>
13
34
 
14
35
  一个功能丰富、高度可定制的 Vue 3 甘特图组件,支持任务管理、依赖关系、多种视图模式和主题切换。
@@ -44,11 +65,12 @@
44
65
  ## ✨ 核心特性
45
66
 
46
67
  ### 📅 多视图模式
47
- 支持四种时间粒度,满足不同场景需求:
68
+ 支持五种时间粒度,满足不同场景需求:
69
+ - **季度视图** - 超长期项目规划,按月显示
48
70
  - **月视图** - 长期项目规划,按天显示
49
- - **周视图** - 中期项目跟踪,按周显示
50
- - **日视图** - 短期任务管理,精确到天
51
- - **时视图** - 精细任务调度,按小时显示
71
+ - **周视图** - 中期项目跟踪,按周显示
72
+ - **日视图** - 短期任务管理,支持全天/半天细分模式
73
+ - **时视图** - 精细任务调度,支持小时/30分钟/15分钟细分模式
52
74
 
53
75
  ### 🔗 任务依赖管理
54
76
  - **完成-开始 (FS)** - 前置任务完成后,后续任务才能开始
@@ -62,7 +84,7 @@
62
84
  - 自动识别(开始时间=结束时间)或手动标记
63
85
 
64
86
  ### 🎨 主题系统
65
- - 内置 5 种精美主题(Metro/Dark/Modern/Classic/Colorful)
87
+ - 内置 7 种精美主题(Metro/Dark/Modern/Classic/Colorful/Apple/Liquid Glass
66
88
  - 支持深色模式,护眼舒适
67
89
  - 完整的 CSS 变量支持,轻松自定义主题
68
90
  - 主题设置自动保存到浏览器
@@ -87,6 +109,37 @@
87
109
  - 计算结果缓存,提升响应速度
88
110
  - 按需渲染连线,优化绘制性能
89
111
 
112
+ ### 📝 自定义字段
113
+ - **多种字段类型** - 支持文本、数字、日期、下拉选择等字段类型
114
+ - **灵活配置** - 可为任务添加任意数量的自定义字段
115
+ - **表单验证** - 内置字段验证规则,确保数据有效性
116
+ - **本地存储** - 字段配置自动保存到浏览器,刷新不丢失
117
+ - **动态管理** - 支持运行时添加、编辑、删除自定义字段
118
+
119
+ ### 💬 消息提示
120
+ - **三种提示类型** - 成功、错误、警告,满足不同场景需求
121
+ - **自动消失** - 提示信息自动消失,无需手动关闭
122
+ - **优雅动画** - 流畅的进入和退出动画效果
123
+ - **多语言支持** - 提示文本随语言设置自动切换
124
+
125
+ ### 🗑️ 删除确认
126
+ - **安全删除** - 删除任务前弹出确认对话框,防止误操作
127
+ - **级联删除** - 删除父任务时自动提示将同时删除所有子任务
128
+ - **友好提示** - 清晰的警告信息,让用户了解删除影响范围
129
+
130
+ ### 🎛️ 配置面板
131
+ - **连线样式配置** - 自定义任务连线的路径类型、颜色、宽度、虚线样式、箭头设置
132
+ - **父子关系样式** - 配置父子任务的连接线样式
133
+ - **列显示设置** - 灵活控制任务列表列的显示/隐藏
134
+ - **一键重置** - 快速恢复默认配置
135
+
136
+ ### 🌲 树形任务结构
137
+ - **层级展示** - 清晰的树形结构显示任务父子关系
138
+ - **折叠展开** - 支持折叠/展开子任务,简化视图
139
+ - **连接线** - 可视化连接线展示层级关系
140
+ - **快速操作** - 行内按钮快速添加/删除子任务
141
+ - **悬停高亮** - 鼠标悬停时高亮显示当前任务行
142
+
90
143
  ## 🚀 安装使用
91
144
 
92
145
  ### 方式一:通过 npm 安装(推荐)
@@ -449,19 +502,36 @@ dependencies: [
449
502
 
450
503
  | 模式 | 时间单位 | 表头示例 | 适用场景 |
451
504
  |------|----------|----------|----------|
452
- | 🗓️ **月视图** | | `01 02 03 04 05 ...` | 长期项目规划 |
505
+ | **季度视图** | | `2024-Q1 2024-Q2 2024-Q3 ...` | 超长期项目规划 |
506
+ | ��️ **月视图** | 天 | `01 02 03 04 05 ...` | 长期项目规划 |
453
507
  | 📅 **日视图** | 天 | `周一 周二 周三 ...` | 短期任务管理 |
454
508
  | 📊 **周视图** | 周 | `W50 W51 W52 ...` | 中期项目跟踪 |
455
509
  | ⏰ **时视图** | 小时 | `08 09 10 11 12 ...` | 精细任务调度 |
456
510
 
457
- 组件支持四种时间粒度视图:
511
+ 组件支持五种时间粒度视图:
458
512
 
459
- | 模式 | 说明 | 适用场景 |
460
- |------|------|----------|
461
- | | 按天显示,月份为单位 | 长期项目规划 |
462
- | | 按天显示,精确到天 | 短期任务管理 |
463
- | | 按周显示 | 中期项目跟踪 |
464
- | | 按小时显示 | 精细任务调度 |
513
+ | 模式 | 说明 | 细分模式 | 适用场景 |
514
+ |------|------|----------|----------|
515
+ | 季度 | 按月显示,以季度为单位 | - | 超长期项目规划 |
516
+ | | 按天显示,以月份为单位 | - | 长期项目规划 |
517
+ | | 按天显示,精确到天 | 全天 / 半天 | 短期任务管理 |
518
+ | | 按周显示 | - | 中期项目跟踪 |
519
+ | 时 | 按小时显示 | 小时 / 30分钟 / 15分钟 | 精细任务调度 |
520
+
521
+ ### 视图模式切换
522
+
523
+ 组件顶部提供视图模式切换按钮,点击即可在不同视图模式之间切换。
524
+
525
+ ### 细分模式说明
526
+
527
+ **日视图细分模式:**
528
+ - **全天** - 每天显示为一个完整的时间段
529
+ - **半天** - 每天分为上午和下午两个时间段
530
+
531
+ **时视图细分模式:**
532
+ - **小时** - 每小时显示为一个时间段
533
+ - **30分钟** - 每小时分为两个30分钟时间段
534
+ - **15分钟** - 每小时分为四个15分钟时间段
465
535
 
466
536
  ## 主题系统
467
537
 
@@ -472,6 +542,8 @@ dependencies: [
472
542
  | ✨ **现代简约** | `#6366f1` | 简洁现代设计,清爽舒适 |
473
543
  | 💼 **经典商务** | `#2563eb` | 传统商务风格,稳重大方 |
474
544
  | 🎨 **彩色活力** | `#f59e0b` | 活泼彩色主题,充满活力 |
545
+ | 🍎 **Apple 风格** | `#007aff` | 简约优雅的 macOS 风格,流畅自然 |
546
+ | 💧 **Liquid Glass** | `#007aff` | iOS 26 液态玻璃效果,半透明流动质感 |
475
547
 
476
548
  ### 内置主题
477
549
 
@@ -482,6 +554,8 @@ dependencies: [
482
554
  | modern | 现代简约 | 简洁现代设计 |
483
555
  | classic | 经典商务 | 传统商务风格 |
484
556
  | colorful | 彩色活力 | 活泼彩色主题 |
557
+ | apple | Apple 风格 | 简约优雅的 macOS 风格 |
558
+ | liquidGlass | Liquid Glass | iOS 26 液态玻璃效果 |
485
559
 
486
560
  ### 切换主题
487
561
 
@@ -505,9 +579,659 @@ dependencies: [
505
579
  }
506
580
  ```
507
581
 
508
- ## 国际化支持
582
+ ## 自定义字段
583
+
584
+ 组件支持强大的自定义字段功能,允许为任务添加任意数量的自定义字段,满足不同项目的个性化需求。
585
+
586
+ ### 功能特性
587
+
588
+ - **多种字段类型** - 文本、数字、日期、下拉选择
589
+ - **动态管理** - 运行时添加、编辑、删除字段
590
+ - **表单验证** - 内置验证规则,确保数据有效性
591
+ - **本地存储** - 字段配置自动保存到浏览器
592
+ - **任务绑定** - 自定义字段值与任务数据关联
593
+
594
+ ### 字段类型
595
+
596
+ | 类型 | 说明 | 示例值 |
597
+ |------|------|--------|
598
+ | 文本 | 单行文本输入 | "项目编号:PRJ-001" |
599
+ | 数字 | 数值输入,支持小数 | 100.5 |
600
+ | 日期 | 日期选择器 | "2024-12-01" |
601
+ | 下拉选择 | 预定义选项列表 | "高优先级" |
602
+
603
+ ### 使用方法
604
+
605
+ #### 1. 打开自定义字段管理
606
+
607
+ 在甘特图工具栏中点击"自定义字段"按钮,打开字段管理对话框。
608
+
609
+ #### 2. 添加自定义字段
610
+
611
+ ```typescript
612
+ // 示例:添加一个"负责人"字段
613
+ const customField = {
614
+ id: 'field-1',
615
+ name: '负责人',
616
+ type: 'text', // text | number | date | select
617
+ required: false, // 是否必填
618
+ options: [] // 下拉选择时提供选项
619
+ };
620
+ ```
621
+
622
+ #### 3. 在任务中使用自定义字段
623
+
624
+ 自定义字段的值存储在任务的 `customFieldValues` 字段中:
625
+
626
+ ```typescript
627
+ {
628
+ id: '1',
629
+ taskNo: '项目规划',
630
+ start_date: '2024-12-01',
631
+ end_date: '2024-12-06',
632
+ job_progress: '0.85',
633
+ customFieldValues: {
634
+ 'field-1': '张三', // 负责人
635
+ 'field-2': '100', // 预算
636
+ 'field-3': '2024-11-30', // 审批日期
637
+ 'field-4': '高优先级' // 优先级
638
+ }
639
+ }
640
+ ```
641
+
642
+ #### 4. 下拉选择字段配置
643
+
644
+ ```typescript
645
+ const priorityField = {
646
+ id: 'field-priority',
647
+ name: '优先级',
648
+ type: 'select',
649
+ required: true,
650
+ options: [
651
+ { label: '紧急', value: 'urgent' },
652
+ { label: '重要', value: 'important' },
653
+ { label: '一般', value: 'normal' }
654
+ ]
655
+ };
656
+ ```
657
+
658
+ ### 字段验证
659
+
660
+ 组件内置了基本的字段验证规则:
661
+
662
+ - **必填字段** - 如果字段标记为 `required: true`,则必须提供值
663
+ - **数字验证** - 数字字段只接受有效的数值
664
+ - **日期验证** - 日期字段只接受有效的日期格式
665
+ - **选项验证** - 下拉选择字段只接受预定义的选项值
666
+
667
+ ### API 集成
668
+
669
+ #### 后端存储格式
670
+
671
+ 自定义字段值需要以特定格式存储到后端:
672
+
673
+ ```typescript
674
+ // 推荐格式:JSON 字符串
675
+ customFieldValues: JSON.stringify({
676
+ 'field-1': '张三',
677
+ 'field-2': '100'
678
+ })
679
+
680
+ // 或数组格式(需要后端支持)
681
+ customFieldValues: [
682
+ { fieldId: 'field-1', value: '张三' },
683
+ { fieldId: 'field-2', value: '100' }
684
+ ]
685
+ ```
686
+
687
+ #### 数据处理示例
688
+
689
+ ```typescript
690
+ // 保存任务时
691
+ const saveTask = async (task) => {
692
+ const payload = {
693
+ ...task,
694
+ customFieldValues: JSON.stringify(task.customFieldValues)
695
+ };
696
+ await api.saveTask(payload);
697
+ };
698
+
699
+ // 加载任务时
700
+ const loadTask = async (taskId) => {
701
+ const data = await api.getTask(taskId);
702
+ return {
703
+ ...data,
704
+ customFieldValues: JSON.parse(data.customFieldValues || '{}')
705
+ };
706
+ };
707
+ ```
708
+
709
+ ### 最佳实践
710
+
711
+ 1. **字段命名** - 使用清晰、简洁的字段名称,便于理解
712
+ 2. **必填设置** - 合理设置必填字段,避免过度限制
713
+ 3. **选项管理** - 下拉选择字段提供完整的选项列表
714
+ 4. **数据验证** - 在后端也进行字段验证,确保数据完整性
715
+ 5. **性能优化** - 避免添加过多自定义字段,影响性能
716
+
717
+ ## 配置面板
718
+
719
+ 组件提供了丰富的配置选项,允许用户自定义甘特图的外观和行为。
720
+
721
+ ### 甘特图配置面板
722
+
723
+ 点击工具栏中的"设置"按钮,打开甘特图配置面板。
724
+
725
+ #### 语言设置
726
+
727
+ - 支持切换 8 种语言(中/英/日/韩/法/德/西/俄)
728
+ - 语言设置自动保存到浏览器
729
+ - 切换后界面立即更新,无需刷新
730
+
731
+ #### 主题设置
732
+
733
+ - 5 种内置主题可选
734
+ - 主题切换即时生效
735
+ - 主题设置自动保存
736
+
737
+ #### 连线样式配置
738
+
739
+ | 配置项 | 说明 | 可选值 |
740
+ |--------|------|--------|
741
+ | 路径类型 | 连线的绘制路径 | 直线 / 贝塞尔曲线 / 阶梯线 |
742
+ | 连线颜色 | 连线的颜色 | 颜色选择器 |
743
+ | 连线宽度 | 连线的粗细 | 1px - 5px |
744
+ | 虚线样式 | 是否使用虚线 | 实线 / 虚线 |
745
+ | 箭头设置 | 是否显示箭头 | 显示 / 隐藏 |
746
+
747
+ #### 父子关系样式
748
+
749
+ | 配置项 | 说明 |
750
+ |--------|------|
751
+ | 连接线颜色 | 父子任务连接线的颜色 |
752
+ | 连接线宽度 | 父子任务连接线的粗细 |
753
+ | 连接线样式 | 实线或虚线 |
754
+
755
+ ### 列显示设置面板
756
+
757
+ 点击工具栏中的"列设置"按钮,打开列显示设置面板。
758
+
759
+ #### 功能特性
760
+
761
+ - **列显示控制** - 勾选/取消勾选来显示或隐藏列
762
+ - **全部显示** - 一键显示所有列
763
+ - **全部隐藏** - 一键隐藏所有列
764
+ - **重置默认** - 恢复到默认列配置
765
+ - **实时生效** - 设置更改立即反映在界面上
766
+
767
+ #### 默认列配置
768
+
769
+ ```typescript
770
+ taskHeaders: [
771
+ { title: '序号', width: 80, property: 'no', show: true },
772
+ { title: '任务名称', width: 200, property: 'task', show: true },
773
+ { title: '优先级', width: 90, property: 'priority', show: true },
774
+ { title: '开始时间', width: 150, property: 'startdate', show: true },
775
+ { title: '结束时间', width: 150, property: 'enddate', show: true },
776
+ { title: '耗时', width: 100, property: 'takestime', show: true },
777
+ { title: '进度', width: 100, property: 'progress', show: true }
778
+ ]
779
+ ```
780
+
781
+ ### 配置持久化
782
+
783
+ 所有配置(语言、主题、连线样式、列显示等)都会自动保存到浏览器的 localStorage 中,刷新页面后配置不会丢失。
784
+
785
+ ### 编程方式配置
786
+
787
+ 除了通过界面配置,也可以通过代码直接设置配置:
788
+
789
+ ```typescript
790
+ // 设置主题
791
+ import { setTheme } from './components/gantt/theme';
792
+ setTheme('dark');
793
+
794
+ // 设置语言
795
+ import { setLocale } from './components/gantt/i18n';
796
+ setLocale('en-US');
797
+
798
+ // 修改列配置
799
+ dataConfig.value.taskHeaders = [
800
+ { title: '序号', width: 80, property: 'no', show: true },
801
+ { title: '任务名称', width: 250, property: 'task', show: true },
802
+ // ... 其他列
803
+ ];
804
+ ```
805
+
806
+ ## 任务对话框
807
+
808
+ 组件提供了完整的任务创建和编辑对话框,支持基础字段和自定义字段的编辑。
809
+
810
+ ### 对话框功能
811
+
812
+ #### 基础字段
813
+
814
+ | 字段 | 说明 | 必填 |
815
+ |------|------|------|
816
+ | 任务名称 | 任务的名称 | ✅ |
817
+ | 优先级 | 任务的优先级(紧急/重要/一般) | ✅ |
818
+ | 开始时间 | 任务的开始日期和时间 | ✅ |
819
+ | 结束时间 | 任务的结束日期和时间 | ✅ |
820
+ | 进度 | 任务的完成进度(0-100%) | ✅ |
821
+
822
+ #### 自定义字段
823
+
824
+ 根据配置的自定义字段,对话框会动态显示相应的输入控件。
825
+
826
+ ### 打开对话框
827
+
828
+ #### 创建根任务
829
+
830
+ ```typescript
831
+ // 通过工具栏按钮点击
832
+ eventConfig.value.addRootTask?.(newTask);
833
+ ```
834
+
835
+ #### 创建子任务
836
+
837
+ ```typescript
838
+ // 在任务行点击"添加子任务"按钮
839
+ eventConfig.value.addSubTask?.(parentTask);
840
+ ```
841
+
842
+ #### 编辑任务
843
+
844
+ ```typescript
845
+ // 双击任务或点击编辑按钮
846
+ eventConfig.value.editTask?.(task);
847
+ ```
848
+
849
+ ### 表单验证
850
+
851
+ 对话框内置了表单验证功能:
852
+
853
+ - **必填字段检查** - 确保所有必填字段都已填写
854
+ - **日期逻辑验证** - 结束时间不能早于开始时间
855
+ - **进度范围验证** - 进度值必须在 0-100 之间
856
+ - **自定义字段验证** - 根据字段配置进行验证
857
+
858
+ ### 对话框事件
859
+
860
+ ```typescript
861
+ const eventConfig = ref<EventConfig>({
862
+ // 添加根任务
863
+ addRootTask: (task) => {
864
+ console.log('添加根任务', task);
865
+ // 保存到后端
866
+ await api.createTask(task);
867
+ },
868
+
869
+ // 添加子任务
870
+ addSubTask: (parentTask) => {
871
+ console.log('添加子任务,父任务:', parentTask);
872
+ // 创建子任务
873
+ const subTask = {
874
+ pid: parentTask.id,
875
+ // ... 其他字段
876
+ };
877
+ await api.createTask(subTask);
878
+ },
879
+
880
+ // 编辑任务
881
+ editTask: (task) => {
882
+ console.log('编辑任务', task);
883
+ // 更新到后端
884
+ await api.updateTask(task);
885
+ }
886
+ });
887
+ ```
509
888
 
510
- 组件内置完整的国际化(i18n)系统,支持中英文双语切换,并可轻松扩展更多语言。
889
+ ### 对话框样式
890
+
891
+ 对话框采用现代化的设计风格:
892
+
893
+ - **模态窗口** - 阻止背景操作,确保用户专注
894
+ - **响应式布局** - 自适应不同屏幕尺寸
895
+ - **清晰的标签** - 每个字段都有明确的标签
896
+ - **必填标识** - 必填字段有红色星号标记
897
+ - **错误提示** - 验证失败时显示错误信息
898
+
899
+ ## 消息提示
900
+
901
+ 组件内置了优雅的消息提示系统,用于向用户反馈操作结果。
902
+
903
+ ### 提示类型
904
+
905
+ | 类型 | 说明 | 图标 | 颜色 |
906
+ |------|------|------|------|
907
+ | 成功 | 操作成功完成 | ✅ | 绿色 |
908
+ | 错误 | 操作失败或出错 | ❌ | 红色 |
909
+ | 警告 | 需要注意的问题 | ⚠️ | 黄色 |
910
+
911
+ ### 使用方法
912
+
913
+ #### 1. 通过组件内部触发
914
+
915
+ 组件内部会在以下情况自动显示消息提示:
916
+
917
+ - 任务创建成功/失败
918
+ - 任务更新成功/失败
919
+ - 任务删除成功/失败
920
+ - 自定义字段保存成功/失败
921
+ - 配置更新成功
922
+
923
+ #### 2. 编程方式调用
924
+
925
+ ```typescript
926
+ import { showToast } from './components/MessageToast';
927
+
928
+ // 显示成功消息
929
+ showToast('success', '任务创建成功!');
930
+
931
+ // 显示错误消息
932
+ showToast('error', '操作失败,请重试');
933
+
934
+ // 显示警告消息
935
+ showToast('warning', '请注意:此操作不可撤销');
936
+ ```
937
+
938
+ ### 提示特性
939
+
940
+ - **自动消失** - 提示信息在 3 秒后自动消失
941
+ - **手动关闭** - 点击关闭按钮可立即关闭
942
+ - **优雅动画** - 流畅的淡入淡出动画
943
+ - **多语言支持** - 提示文本随语言设置自动切换
944
+ - **位置固定** - 固定在页面右上角,不遮挡操作区域
945
+
946
+ ### 消息示例
947
+
948
+ ```typescript
949
+ // 成功提示
950
+ showToast('success', '任务已成功保存');
951
+
952
+ // 错误提示
953
+ showToast('error', '保存失败:网络连接错误');
954
+
955
+ // 警告提示
956
+ showToast('warning', '删除任务将同时删除所有子任务');
957
+ ```
958
+
959
+ ## 删除确认对话框
960
+
961
+ 为了防止误操作,组件在删除任务时会弹出确认对话框。
962
+
963
+ ### 对话框功能
964
+
965
+ - **删除警告** - 清晰的警告信息
966
+ - **级联删除提示** - 如果删除父任务,会提示将同时删除所有子任务
967
+ - **确认/取消** - 用户可以选择确认或取消删除操作
968
+
969
+ ### 删除流程
970
+
971
+ ```
972
+ 用户点击删除按钮
973
+
974
+ 检查是否有子任务
975
+
976
+ 显示确认对话框
977
+
978
+ 用户确认删除
979
+
980
+ 执行删除操作
981
+
982
+ 显示删除结果提示
983
+ ```
984
+
985
+ ### 对话框内容
986
+
987
+ #### 删除普通任务
988
+
989
+ ```
990
+ ⚠️ 确认删除
991
+
992
+ 您确定要删除此任务吗?
993
+
994
+ 此操作不可撤销。
995
+ ```
996
+
997
+ #### 删除父任务(包含子任务)
998
+
999
+ ```
1000
+ ⚠️ 确认删除
1001
+
1002
+ 您确定要删除此任务吗?
1003
+
1004
+ 注意:删除此任务将同时删除其所有子任务(共 3 个)。
1005
+
1006
+ 此操作不可撤销。
1007
+ ```
1008
+
1009
+ ### 事件处理
1010
+
1011
+ ```typescript
1012
+ const eventConfig = ref<EventConfig>({
1013
+ removeTask: async (task) => {
1014
+ // 检查是否有子任务
1015
+ const hasChildren = dataConfig.value.dataSource.some(
1016
+ t => t.pid === task.id
1017
+ );
1018
+
1019
+ // 显示确认对话框
1020
+ const confirmed = await showDeleteConfirm(task, hasChildren);
1021
+
1022
+ if (confirmed) {
1023
+ // 执行删除
1024
+ await api.deleteTask(task.id);
1025
+ // 更新数据源
1026
+ dataConfig.value.dataSource = dataConfig.value.dataSource.filter(
1027
+ t => t.id !== task.id
1028
+ );
1029
+ // 显示成功提示
1030
+ showToast('success', '任务已删除');
1031
+ }
1032
+ }
1033
+ });
1034
+ ```
1035
+
1036
+ ### 安全特性
1037
+
1038
+ - **二次确认** - 所有删除操作都需要用户确认
1039
+ - **级联提示** - 明确告知用户删除的影响范围
1040
+ - **不可撤销警告** - 提醒用户操作的不可逆性
1041
+ - **子任务统计** - 显示将要删除的子任务数量
1042
+
1043
+ ## 树形任务结构
1044
+
1045
+ 组件支持完整的树形任务结构,可以清晰地展示任务的层级关系。
1046
+
1047
+ ### 核心特性
1048
+
1049
+ - **层级展示** - 通过缩进和连接线清晰展示父子关系
1050
+ - **折叠展开** - 支持折叠/展开子任务,简化复杂项目视图
1051
+ - **视觉连接** - 树形连接线直观展示任务层级
1052
+ - **快速操作** - 行内按钮快速添加/删除子任务
1053
+ - **悬停高亮** - 鼠标悬停时高亮显示当前任务行
1054
+
1055
+ ### 任务层级结构
1056
+
1057
+ ```typescript
1058
+ // 根任务(pid = '0')
1059
+ {
1060
+ id: '1',
1061
+ pid: '0', // '0' 表示根任务
1062
+ taskNo: '项目开发',
1063
+ start_date: '2024-12-01',
1064
+ end_date: '2024-12-31'
1065
+ }
1066
+
1067
+ // 子任务
1068
+ {
1069
+ id: '1-1',
1070
+ pid: '1', // 父任务ID
1071
+ taskNo: '前端开发',
1072
+ start_date: '2024-12-01',
1073
+ end_date: '2024-12-15'
1074
+ }
1075
+
1076
+ // 孙任务
1077
+ {
1078
+ id: '1-1-1',
1079
+ pid: '1-1', // 父任务ID
1080
+ taskNo: 'UI设计',
1081
+ start_date: '2024-12-01',
1082
+ end_date: '2024-12-05'
1083
+ }
1084
+ ```
1085
+
1086
+ ### 视觉元素
1087
+
1088
+ #### 1. 缩进显示
1089
+
1090
+ 子任务会根据层级自动缩进,每层缩进固定距离:
1091
+
1092
+ ```
1093
+ ├─ 项目开发
1094
+ │ ├─ 前端开发
1095
+ │ │ ├─ UI设计
1096
+ │ │ └─ 功能开发
1097
+ │ └─ 后端开发
1098
+ │ ├─ API设计
1099
+ │ └─ 数据库设计
1100
+ ```
1101
+
1102
+ #### 2. 连接线
1103
+
1104
+ 树形连接线清晰地展示父子关系:
1105
+
1106
+ - **垂直线** - 连接父任务到子任务
1107
+ - **水平线** - 标记任务的层级位置
1108
+ - **分支线** - 展示任务的分支结构
1109
+
1110
+ #### 3. 折叠/展开按钮
1111
+
1112
+ 每个有子任务的任务左侧都有折叠/展开按钮:
1113
+
1114
+ - **展开状态** (▶) - 显示所有子任务
1115
+ - **折叠状态** (▼) - 隐藏所有子任务
1116
+
1117
+ ### 交互操作
1118
+
1119
+ #### 添加子任务
1120
+
1121
+ 在任务行点击"添加子任务"按钮,会自动:
1122
+
1123
+ 1. 创建新的子任务
1124
+ 2. 设置正确的父任务ID
1125
+ 3. 打开任务编辑对话框
1126
+ 4. 保存后自动刷新树形结构
1127
+
1128
+ ```typescript
1129
+ const addSubTask = (parentTask) => {
1130
+ const newTask = {
1131
+ id: generateId(),
1132
+ pid: parentTask.id, // 设置父任务ID
1133
+ taskNo: '新子任务',
1134
+ start_date: parentTask.start_date,
1135
+ end_date: parentTask.end_date,
1136
+ job_progress: '0'
1137
+ };
1138
+ eventConfig.value.addSubTask?.(newTask);
1139
+ };
1140
+ ```
1141
+
1142
+ #### 删除任务
1143
+
1144
+ 删除任务时会:
1145
+
1146
+ 1. 检查是否有子任务
1147
+ 2. 显示确认对话框(包含级联删除提示)
1148
+ 3. 删除任务及其所有子任务
1149
+ 4. 自动更新树形结构
1150
+
1151
+ ```typescript
1152
+ const deleteTask = (task) => {
1153
+ // 级联删除所有子任务
1154
+ const deleteRecursive = (taskId) => {
1155
+ const children = dataConfig.value.dataSource.filter(
1156
+ t => t.pid === taskId
1157
+ );
1158
+ children.forEach(child => deleteRecursive(child.id));
1159
+ dataConfig.value.dataSource = dataConfig.value.dataSource.filter(
1160
+ t => t.id !== taskId
1161
+ );
1162
+ };
1163
+ deleteRecursive(task.id);
1164
+ };
1165
+ ```
1166
+
1167
+ #### 折叠/展开
1168
+
1169
+ 点击折叠/展开按钮可以:
1170
+
1171
+ - **展开** - 显示所有子任务和孙任务
1172
+ - **折叠** - 隐藏所有后代任务
1173
+ - **状态记忆** - 折叠状态会保存到 localStorage
1174
+
1175
+ ### 父子任务联动
1176
+
1177
+ 父任务移动时,子任务会自动跟随移动,保持相对时间关系:
1178
+
1179
+ ```typescript
1180
+ // 父任务移动 5 天
1181
+ const moveParentTask = (task, days) => {
1182
+ const oldStart = dayjs(task.start_date);
1183
+ const oldEnd = dayjs(task.end_date);
1184
+
1185
+ // 更新父任务
1186
+ task.start_date = oldStart.add(days, 'day').format('YYYY-MM-DD');
1187
+ task.end_date = oldEnd.add(days, 'day').format('YYYY-MM-DD');
1188
+
1189
+ // 子任务跟随移动
1190
+ const children = getChildren(task.id);
1191
+ children.forEach(child => {
1192
+ const childOldStart = dayjs(child.start_date);
1193
+ const childOldEnd = dayjs(child.end_date);
1194
+ child.start_date = childOldStart.add(days, 'day').format('YYYY-MM-DD');
1195
+ child.end_date = childOldEnd.add(days, 'day').format('YYYY-MM-DD');
1196
+ });
1197
+ };
1198
+ ```
1199
+
1200
+ ### 样式自定义
1201
+
1202
+ 可以通过 CSS 自定义树形结构的样式:
1203
+
1204
+ ```css
1205
+ /* 连接线颜色 */
1206
+ .gantt-tree-line {
1207
+ border-color: #d0d0d0;
1208
+ }
1209
+
1210
+ /* 折叠/展开按钮 */
1211
+ .gantt-collapse-btn {
1212
+ color: #666;
1213
+ cursor: pointer;
1214
+ }
1215
+
1216
+ .gantt-collapse-btn:hover {
1217
+ color: #333;
1218
+ }
1219
+
1220
+ /* 行悬停效果 */
1221
+ .gantt-row:hover {
1222
+ background-color: #f5f5f5;
1223
+ }
1224
+ ```
1225
+
1226
+ ### 最佳实践
1227
+
1228
+ 1. **合理层级** - 建议层级不超过 5 层,过深的层级会影响可读性
1229
+ 2. **任务命名** - 使用清晰的命名规范,便于理解层级关系
1230
+ 3. **折叠管理** - 对于大型项目,合理使用折叠功能简化视图
1231
+ 4. **批量操作** - 父任务移动时子任务自动跟随,避免逐个调整
1232
+ 5. **性能优化** - 深层嵌套时注意性能,考虑使用折叠减少渲染数量
1233
+
1234
+ ## 国际化支持
511
1235
 
512
1236
  ### 支持的语言
513
1237
 
@@ -739,47 +1463,96 @@ interface LinkConfig {
739
1463
  ```
740
1464
  src/
741
1465
  ├── components/
1466
+ │ ├── CustomFieldsDialog.vue # 自定义字段对话框
1467
+ │ ├── DeleteConfirmDialog.vue # 删除确认对话框
1468
+ │ ├── MessageToast.vue # 消息提示组件
1469
+ │ ├── TaskDialog.vue # 任务编辑对话框
742
1470
  │ └── gantt/
743
- │ ├── Gantt.vue # 主组件
744
- │ ├── Bar.vue # 任务条组件
745
- │ ├── BarRecursionRow.vue # 递归行组件
746
- │ ├── TaskLinks.vue # 连线组件
747
- ├── TimelineHeader.vue # 时间轴表头
748
- │ ├── TableContent.vue # 表格内容
749
- │ ├── RightTable.vue # 右侧甘特图区域
750
- │ ├── SplitPane.vue # 分割面板
751
- │ ├── DatePicker.vue # 日期选择器
752
- │ ├── GanttConfigPanel.vue # 配置面板
753
- │ ├── GanttThemeSelector.vue # 主题选择器
754
- │ ├── LanguageSelector.vue # 语言选择器
755
- │ ├── LinkConfigPanel.vue # 连线配置面板
756
- │ ├── Types.ts # 类型定义
757
- │ ├── Store.ts # 状态管理
758
- │ ├── ShareState.ts # 共享状态
759
- │ ├── LinkConfig.ts # 连线配置
760
- │ ├── Symbols.ts # 注入符号
761
- ├── ZodSchema.ts # 数据验证
762
- │ ├── i18n/ # 国际化系统
763
- │ │ ├── index.ts # i18n 核心
764
- │ │ └── locales/ # 语言包
765
- ├── zh-CN.ts # 中文语言包
766
- ├── en-US.ts # 英文语言包
767
- │ │ ├── ja-JP.ts # 日语语言包
768
- │ │ ├── ko-KR.ts # 韩语语言包
769
- │ │ ├── fr-FR.ts # 法语语言包
770
- │ │ ├── de-DE.ts # 德语语言包
771
- │ │ ├── es-ES.ts # 西班牙语语言包
772
- │ │ └── ru-RU.ts # 俄语语言包
773
- │ ├── task/ # 任务相关组件
774
- │ │ ├── TaskTable.vue
775
- │ │ ├── TaskHeader.vue
776
- │ │ ├── TaskContent.vue
777
- │ │ └── TaskRow.vue
778
- └── themes/ # 主题配置
779
- └── GanttThemes.ts
780
- ├── App.vue # 示例应用
781
- ├── main.ts # 入口文件
782
- └── style.css # 全局样式
1471
+ │ ├── composables/ # 甘特图组合式函数
1472
+ ├── LinkConfig.ts
1473
+ ├── PerformanceConfig.ts
1474
+ ├── useHorizontalVirtualScroll.ts
1475
+ │ └── useVirtualScroll.ts
1476
+ │ ├── config/ # 配置面板组件
1477
+ ├── CheckboxConfig.vue
1478
+ ├── ColorInput.vue
1479
+ ├── ColumnConfigPanel.vue
1480
+ ├── ConfigSection.vue
1481
+ ├── DatePicker.vue
1482
+ ├── GanttConfigPanel.vue
1483
+ ├── GanttThemeSelector.vue
1484
+ ├── LanguageSelector.vue
1485
+ ├── LinkConfigPanel.vue
1486
+ ├── LinkTypeColorConfig.vue
1487
+ ├── PathTypeSelector.vue
1488
+ ├── SliderInput.vue
1489
+ │ └── ThemeSelector.vue
1490
+ │ ├── core/ # 核心组件
1491
+ │ │ ├── Gantt.vue # 主组件
1492
+ │ │ └── SplitPane.vue # 分割面板
1493
+ │ ├── gantt.css # 甘特图样式
1494
+ │ ├── i18n/ # 国际化系统
1495
+ │ │ ├── index.ts # i18n 核心
1496
+ │ │ └── locales/ # 语言包
1497
+ │ │ ├── zh-CN.ts # 中文语言包
1498
+ │ │ ├── zh-TW.ts # 繁体中文语言包
1499
+ │ │ ├── en-US.ts # 英文语言包
1500
+ │ │ ├── ja-JP.ts # 日语语言包
1501
+ ├── ko-KR.ts # 韩语语言包
1502
+ │ │ ├── fr-FR.ts # 法语语言包
1503
+ │ │ ├── de-DE.ts # 德语语言包
1504
+ │ │ ├── es-ES.ts # 西班牙语语言包
1505
+ │ │ └── ru-RU.ts # 俄语语言包
1506
+ ├── links/ # 连线组件
1507
+ └── TaskLinks.vue # 任务连线
1508
+ ├── state/ # 状态管理
1509
+ │ │ ├── ShareState.ts # 共享状态
1510
+ │ │ ├── Store.ts # 状态存储
1511
+ │ │ └── Symbols.ts # 注入符号
1512
+ │ ├── task/ # 任务相关组件
1513
+ │ │ ├── TaskTable.vue # 任务表格
1514
+ │ │ ├── TaskHeader.vue # 任务表头
1515
+ │ │ ├── TaskContent.vue # 任务内容
1516
+ │ │ ├── TaskRow.vue # 任务行
1517
+ │ │ └── TaskRecursionRow.vue # 递归任务行
1518
+ │ ├── themes/ # 主题配置
1519
+ │ │ ├── GanttThemes.ts # 主题定义
1520
+ │ │ └── LiquidGlass.css # 液态玻璃主题
1521
+ │ ├── timeline/ # 时间轴组件
1522
+ │ │ ├── Bar.vue # 任务条
1523
+ │ │ ├── BarRecursionRow.vue # 递归任务条
1524
+ │ │ ├── Milestone.vue # 里程碑
1525
+ │ │ ├── RightTable.vue # 右侧甘特图区域
1526
+ │ │ ├── TableContent.vue # 表格内容
1527
+ │ │ ├── TimelineHeader.vue # 时间轴表头
1528
+ │ │ ├── composables/ # 时间轴组合式函数
1529
+ │ │ │ ├── useBarGeometry.ts
1530
+ │ │ │ ├── useBarTheme.ts
1531
+ │ │ │ ├── useHover.ts
1532
+ │ │ │ ├── useInteractions.ts
1533
+ │ │ │ └── useProgress.ts
1534
+ │ │ └── utils/ # 工具函数
1535
+ │ │ └── dateCalc.ts
1536
+ │ └── types/ # 类型定义
1537
+ │ ├── Types.ts # 甘特图类型
1538
+ │ └── ZodSchema.ts # 数据验证
1539
+ ├── composables/ # 全局组合式函数
1540
+ │ ├── useCustomFields.ts # 自定义字段
1541
+ │ ├── useMessage.ts # 消息提示
1542
+ │ └── useTaskManagement.ts # 任务管理
1543
+ ├── mock/ # 模拟数据
1544
+ │ └── mockData.ts # 示例数据
1545
+ ├── services/ # 服务层
1546
+ │ └── taskApi.ts # 任务 API
1547
+ ├── styles/ # 全局样式
1548
+ │ └── dialog-common.css # 对话框通用样式
1549
+ ├── types/ # 类型定义
1550
+ │ └── task.ts # 任务类型
1551
+ ├── App.vue # 示例应用
1552
+ ├── index.ts # 导出入口
1553
+ ├── main.ts # 应用入口
1554
+ ├── style.css # 全局样式
1555
+ └── vite-env.d.ts # Vite 环境类型
783
1556
  ```
784
1557
 
785
1558
  ## 完整示例
@@ -809,7 +1582,7 @@ MIT
809
1582
 
810
1583
  <div id="english-documentation"></div>
811
1584
 
812
- <details>
1585
+ <details open>
813
1586
  <summary><h2>🇺🇸 English Documentation</h2></summary>
814
1587
 
815
1588
  A feature-rich, highly customizable Vue 3 Gantt chart component that supports task management, dependency relationships, multiple view modes, and theme switching.
@@ -820,10 +1593,16 @@ A feature-rich, highly customizable Vue 3 Gantt chart component that supports ta
820
1593
  <img src="https://img.shields.io/badge/Vite-6.2.0-646CFF?style=for-the-badge&logo=vite&logoColor=white" alt="Vite">
821
1594
  </div>
822
1595
 
823
- **Note**: For better reading experience, you can also view the [separate English README file](README.en-US.md).
824
-
825
1596
  ## Interface Preview
826
1597
 
1598
+ <div align="center">
1599
+ <img src="https://github.com/user-attachments/assets/34562bf8-0709-44aa-a05d-6e970ea8b57f" alt="Vue3 Gantt Chart - Light Theme" />
1600
+ <p><em>Light Theme - Complete Task Management Interface</em></p>
1601
+
1602
+ <img src="https://github.com/user-attachments/assets/d6a60ba1-9f5b-479a-b402-68014ec7c935" alt="Vue3 Gantt Chart - Dark Theme" />
1603
+ <p><em>Dark Theme - Eye-friendly Mode</em></p>
1604
+ </div>
1605
+
827
1606
  ```
828
1607
  ┌─────────────────────────────────────────────────────────────────────────────┐
829
1608
  │ Vue3 Gantt Professional Component │
@@ -839,39 +1618,1780 @@ A feature-rich, highly customizable Vue 3 Gantt chart component that supports ta
839
1618
  └─────────────────┴───────────────────────────────────────────────────────────┘
840
1619
  ```
841
1620
 
842
- **Key Features:**
843
- - 🎯 Left task list + Right Gantt chart timeline
844
- - 📊 Visual progress bars showing task completion
845
- - 🔗 Task dependency relationship lines
846
- - 🎨 Multi-theme support (Light/Dark/Colorful, etc.)
847
- - 🖱️ Drag to adjust task time and progress
848
- - 🌍 Multi-language support (Chinese/English/Japanese/Korean/French/German/Spanish/Russian)
849
-
850
- ## Features
851
-
852
- - **Multiple View Modes** - Month, Day, Week, and Hour time granularity views
853
- - **Task Dependencies** - Support for FS, SS, FF, SF dependency types
854
- - **Milestone Support** - Diamond markers for key project milestones with dependency support
855
- - **Theme System** - 5 built-in themes with custom theme support
856
- - **Internationalization** - Built-in 8 languages, easily extensible
857
- - **Progress Management** - Visual progress bars with drag-to-adjust
858
- - **Interactive Operations** - Task dragging, resizing, parent-child linkage
859
- - **Responsive Design** - Adjustable split panel ratio
860
- - **High Performance** - Virtual scrolling optimization for large datasets
861
-
862
- ### For complete English documentation including:
863
- - Detailed configuration guide
864
- - Task data format
865
- - Dependency relationships
866
- - View modes
867
- - ✅ Theme system
868
- - Internationalization
869
- - Interactive features
870
- - Link configuration
871
- - Performance optimization
872
- - ✅ Project structure
873
-
874
- **Please visit**: [README.en-US.md](README.en-US.md) for the full English documentation.
1621
+ **Key Highlights:**
1622
+ - 🎯 **Dual-Column Layout** - Left task list + Right Gantt timeline, clear information at a glance
1623
+ - 📊 **Visual Progress** - Real-time progress bars with drag-to-adjust completion
1624
+ - 🔗 **Smart Dependencies** - Four dependency types (FS/SS/FF/SF) with auto-drawn links
1625
+ - 🎨 **Multi-Theme** - 5 built-in themes, dark mode and custom theme support
1626
+ - 🖱️ **Rich Interactions** - Drag move, resize, parent-child task linkage
1627
+ - 🌍 **Internationalization** - Built-in 8 languages, easily extensible
1628
+ - ⚡ **High Performance** - Virtual scrolling, handles massive task data effortlessly
1629
+ - 💎 **Milestones** - Diamond markers for key nodes with dependency support
1630
+
1631
+ ## Core Features
1632
+
1633
+ ### 📅 Multiple View Modes
1634
+ Five time granularities for different scenarios:
1635
+ - **Quarter View** - Ultra-long-term project planning, displayed by month
1636
+ - **Month View** - Long-term project planning, displayed by day
1637
+ - **Week View** - Medium-term project tracking, displayed by week
1638
+ - **Day View** - Short-term task management, supports full day/half day sub-modes
1639
+ - **Hour View** - Fine task scheduling, supports hour/30min/15min sub-modes
1640
+
1641
+ ### 🔗 Task Dependency Management
1642
+ - **Finish-to-Start (FS)** - Successor task starts after predecessor finishes
1643
+ - **Start-to-Start (SS)** - Both tasks start simultaneously
1644
+ - **Finish-to-Finish (FF)** - Both tasks finish simultaneously
1645
+ - **Start-to-Finish (SF)** - Predecessor finishes after successor starts
1646
+
1647
+ ### 💎 Milestone Features
1648
+ - Diamond icon markers for project key nodes
1649
+ - Support as dependency source and target
1650
+ - Auto-detect (start time = end time) or manual marking
1651
+
1652
+ ### 🎨 Theme System
1653
+ - 5 beautiful built-in themes (Metro/Dark/Modern/Classic/Colorful)
1654
+ - Dark mode support, eye-friendly
1655
+ - Complete CSS variable support, easy customization
1656
+ - Theme settings auto-saved to browser
1657
+
1658
+ ### 🌍 Internationalization
1659
+ - Built-in 8 languages (CN/EN/JP/KR/FR/DE/ES/RU)
1660
+ - Instant switching, no page refresh needed
1661
+ - All UI elements fully translated
1662
+ - Timeline headers auto-localized
1663
+ - Easy to extend new languages
1664
+
1665
+ ### 🖱️ Interactive Operations
1666
+ - **Drag Move** - Modify task start and end dates
1667
+ - **Resize** - Drag edges to adjust task duration
1668
+ - **Progress Adjust** - Drag triangle slider to adjust completion
1669
+ - **Parent-Child Linkage** - Child tasks follow when parent moves
1670
+ - **Split Panel** - Adjustable left-right area ratio
1671
+
1672
+ ### ⚡ Performance Optimization
1673
+ - Virtual scroll rendering, supports massive task data
1674
+ - Throttled updates, avoids frequent redraws
1675
+ - Cached computations, improves response speed
1676
+ - On-demand link rendering, optimized drawing performance
1677
+
1678
+ ### 📝 Custom Fields
1679
+ - **Multiple Field Types** - Supports text, number, date, dropdown selection field types
1680
+ - **Flexible Configuration** - Add any number of custom fields to tasks
1681
+ - **Form Validation** - Built-in field validation rules ensure data validity
1682
+ - **Local Storage** - Field configuration automatically saved to browser, persists after refresh
1683
+ - **Dynamic Management** - Add, edit, delete custom fields at runtime
1684
+
1685
+ ### 💬 Message Toast
1686
+ - **Three Alert Types** - Success, error, warning for different scenarios
1687
+ - **Auto Dismiss** - Messages automatically disappear without manual closing
1688
+ - **Elegant Animation** - Smooth enter and exit animation effects
1689
+ - **Multi-language Support** - Alert text automatically switches with language settings
1690
+
1691
+ ### 🗑️ Delete Confirmation
1692
+ - **Safe Deletion** - Confirmation dialog before task deletion prevents accidental operations
1693
+ - **Cascade Delete** - When deleting parent task, automatically prompts that all subtasks will be deleted
1694
+ - **Friendly Prompts** - Clear warning messages inform users about deletion impact scope
1695
+
1696
+ ### 🎛️ Configuration Panels
1697
+ - **Link Style Configuration** - Customize task link path type, color, width, dashed style, arrow settings
1698
+ - **Parent-Child Relationship Style** - Configure parent-child task connection line styles
1699
+ - **Column Display Settings** - Flexibly control task list column show/hide
1700
+ - **One-click Reset** - Quickly restore default configuration
1701
+
1702
+ ### 🌲 Tree Task Structure
1703
+ - **Hierarchy Display** - Clear tree structure showing task parent-child relationships
1704
+ - **Collapse/Expand** - Support collapsing/expanding subtasks to simplify view
1705
+ - **Connection Lines** - Visual connection lines showing hierarchy relationships
1706
+ - **Quick Operations** - Inline buttons for quickly adding/deleting subtasks
1707
+ - **Hover Highlight** - Mouse hover highlights current task row
1708
+
1709
+ ## 🚀 Installation
1710
+
1711
+ ### Option 1: Install via npm (Recommended)
1712
+
1713
+ ```bash
1714
+ # Using npm
1715
+ npm install @lee576/vue3-gantt
1716
+
1717
+ # Or using yarn
1718
+ yarn add @lee576/vue3-gantt
1719
+
1720
+ # Or using pnpm
1721
+ pnpm add @lee576/vue3-gantt
1722
+ ```
1723
+
1724
+ ### Option 2: Build from Source
1725
+
1726
+ ```bash
1727
+ # Clone repository
1728
+ git clone https://github.com/lee576/vue3-gantt.git
1729
+ cd vue3-gantt
1730
+
1731
+ # Install dependencies
1732
+ npm install
1733
+
1734
+ # Start development server
1735
+ npm run dev
1736
+ ```
1737
+
1738
+ ## 📚 Quick Start
1739
+
1740
+ ### 1️⃣ Import Component
1741
+
1742
+ ```typescript
1743
+ import { createApp } from 'vue';
1744
+ import Gantt from '@lee576/vue3-gantt';
1745
+ import '@lee576/vue3-gantt/style.css';
1746
+
1747
+ const app = createApp(App);
1748
+ app.use(Gantt); // Global registration
1749
+ ```
1750
+
1751
+ Or import in component:
1752
+
1753
+ ```vue
1754
+ <script setup lang="ts">
1755
+ import { ref } from 'vue';
1756
+ import Gantt, {
1757
+ type DataConfig,
1758
+ type StyleConfig,
1759
+ type EventConfig,
1760
+ LinkType
1761
+ } from '@lee576/vue3-gantt';
1762
+ import '@lee576/vue3-gantt/style.css';
1763
+ </script>
1764
+ ```
1765
+
1766
+ ### 2️⃣ Configure Container Height (Important!)
1767
+
1768
+ > ⚠️ **Important**: The component **must have an explicit container height** to display properly.
1769
+
1770
+ **Recommended methods (choose one):**
1771
+
1772
+ ```vue
1773
+ <!-- Method 1: Use viewport height (Easiest) -->
1774
+ <template>
1775
+ <div style="height: 100vh;">
1776
+ <gantt :dataConfig="dataConfig" :styleConfig="styleConfig" />
1777
+ </div>
1778
+ </template>
1779
+
1780
+ <!-- Method 2: Use fixed height -->
1781
+ <template>
1782
+ <div style="height: 800px;">
1783
+ <gantt :dataConfig="dataConfig" :styleConfig="styleConfig" />
1784
+ </div>
1785
+ </template>
1786
+
1787
+ <!-- Method 3: Flex layout -->
1788
+ <template>
1789
+ <div style="display: flex; flex-direction: column; height: 100vh;">
1790
+ <div>Header</div>
1791
+ <div style="flex: 1;"> <!-- Auto-fill remaining space -->
1792
+ <gantt :dataConfig="dataConfig" :styleConfig="styleConfig" />
1793
+ </div>
1794
+ </div>
1795
+ </template>
1796
+ ```
1797
+
1798
+ <details>
1799
+ <summary>💡 Why set height?</summary>
1800
+
1801
+ The component uses `height: 100%` internally. According to CSS specifications, percentage height requires the parent element to have an explicit height to calculate. Without a height on the parent container, the component will collapse.
1802
+
1803
+ **Solutions:**
1804
+ - Use `100vh` (viewport height)
1805
+ - Use fixed pixel value (e.g., `800px`)
1806
+ - Use Flex layout's `flex: 1`
1807
+ - Configure `html, body { height: 100%; }` then use `100%`
1808
+
1809
+ </details>
1810
+
1811
+ ### 3️⃣ Basic Configuration
1812
+
1813
+ ```vue
1814
+ <template>
1815
+ <div style="height: 100vh;">
1816
+ <gantt
1817
+ :dataConfig="dataConfig"
1818
+ :styleConfig="styleConfig"
1819
+ :eventConfig="eventConfig"
1820
+ />
1821
+ </div>
1822
+ </template>
1823
+
1824
+ <script setup lang="ts">
1825
+ import { ref, onMounted } from 'vue';
1826
+ import dayjs from 'dayjs';
1827
+ import Gantt, {
1828
+ type DataConfig,
1829
+ type StyleConfig,
1830
+ type EventConfig,
1831
+ LinkType
1832
+ } from '@lee576/vue3-gantt';
1833
+ import '@lee576/vue3-gantt/style.css';
1834
+
1835
+ // 🎨 Style Configuration
1836
+ const styleConfig = ref<StyleConfig>({
1837
+ headersHeight: 100, // Header height
1838
+ rowHeight: 60, // Row height
1839
+ setBarColor: (row) => {
1840
+ // Custom task bar colors
1841
+ const colorMap = { 'urgent': '#ef4444', 'important': '#3b82f6', 'normal': '#6b7280' };
1842
+ return colorMap[row.level] ?? '#000';
1843
+ }
1844
+ });
1845
+
1846
+ // 📊 Data Configuration
1847
+ const dataConfig = ref<DataConfig>({
1848
+ queryStartDate: dayjs().startOf('month').format('YYYY-MM-DD'),
1849
+ queryEndDate: dayjs().endOf('month').format('YYYY-MM-DD'),
1850
+ dataSource: [],
1851
+ dependencies: [],
1852
+ mapFields: {
1853
+ id: 'id',
1854
+ parentId: 'pid',
1855
+ task: 'taskNo',
1856
+ priority: 'level',
1857
+ startdate: 'start_date',
1858
+ enddate: 'end_date',
1859
+ takestime: 'spend_time',
1860
+ progress: 'job_progress'
1861
+ },
1862
+ taskHeaders: [
1863
+ { title: 'No.', width: 80, property: 'no', show: true },
1864
+ { title: 'Task Name', width: 200, property: 'task', show: true },
1865
+ { title: 'Priority', width: 90, property: 'priority', show: true },
1866
+ { title: 'Start Date', width: 150, property: 'startdate', show: true },
1867
+ { title: 'End Date', width: 150, property: 'enddate', show: true },
1868
+ ]
1869
+ });
1870
+
1871
+ // ⚡ Event Configuration
1872
+ const eventConfig = ref<EventConfig>({
1873
+ queryTask: async (startDate, endDate, mode) => {
1874
+ // Query task data
1875
+ const tasks = await fetchTasks(startDate, endDate);
1876
+ dataConfig.value.dataSource = tasks;
1877
+ },
1878
+ barDate: (id, startDate, endDate) => {
1879
+ console.log('Task date changed', { id, startDate, endDate });
1880
+ },
1881
+ updateProgress: (detail) => {
1882
+ console.log('Progress updated', detail);
1883
+ }
1884
+ });
1885
+
1886
+ // Initialize and load data
1887
+ onMounted(() => {
1888
+ const start = dayjs().startOf('month').format('YYYY-MM-DD');
1889
+ const end = dayjs().endOf('month').format('YYYY-MM-DD');
1890
+ eventConfig.value.queryTask?.(start, end, 'month');
1891
+ });
1892
+ </script>
1893
+ ```
1894
+
1895
+ ## 📖 Configuration Guide
1896
+
1897
+ ## Configuration Details
1898
+
1899
+ ### StyleConfig
1900
+
1901
+ | Property | Type | Default | Description |
1902
+ |----------|------|---------|-------------|
1903
+ | headersHeight | number | 100 | Header area height (pixels) |
1904
+ | rowHeight | number | 60 | Row height (pixels) |
1905
+ | setBarColor | function | - | Callback function for custom task bar colors |
1906
+
1907
+ ### DataConfig
1908
+
1909
+ | Property | Type | Description |
1910
+ |----------|------|-------------|
1911
+ | queryStartDate | string | Query start date (YYYY-MM-DD) |
1912
+ | queryEndDate | string | Query end date (YYYY-MM-DD) |
1913
+ | dataSource | array | Task data source |
1914
+ | dependencies | array | Task dependencies |
1915
+ | mapFields | object | Field mapping configuration |
1916
+ | taskHeaders | array | Left task table column configuration |
1917
+
1918
+ #### mapFields Field Mapping
1919
+
1920
+ ```typescript
1921
+ {
1922
+ id: 'id', // Task ID field
1923
+ parentId: 'pid', // Parent task ID field (for hierarchy)
1924
+ task: 'taskNo', // Task name field
1925
+ priority: 'level', // Priority field
1926
+ startdate: 'start_date', // Start date field
1927
+ enddate: 'end_date', // End date field
1928
+ takestime: 'spend_time', // Duration field
1929
+ progress: 'job_progress' // Progress field (0-1)
1930
+ }
1931
+ ```
1932
+
1933
+ #### taskHeaders Header Configuration
1934
+
1935
+ ```typescript
1936
+ {
1937
+ title: string; // Column title
1938
+ width: number; // Column width
1939
+ property: string; // Corresponds to property name in mapFields
1940
+ show: boolean; // Whether to display
1941
+ }
1942
+ ```
1943
+
1944
+
1945
+ ### EventConfig
1946
+
1947
+ | Event | Parameters | Description |
1948
+ |-------|------------|-------------|
1949
+ | addRootTask | (row) | Triggered when adding a root task |
1950
+ | addSubTask | (task) | Triggered when adding a subtask |
1951
+ | removeTask | (task) | Triggered when removing a task |
1952
+ | editTask | (task) | Triggered when editing a task |
1953
+ | queryTask | (startDate, endDate, mode) | Triggered when querying tasks |
1954
+ | barDate | (id, startDate, endDate) | Triggered when task date changes |
1955
+ | allowChangeTaskDate | (allow) | Whether task date modification is allowed |
1956
+ | updateProgress | (detail) | Triggered when progress is updated |
1957
+
1958
+ #### updateProgress Event Details
1959
+
1960
+ ```typescript
1961
+ interface ProgressUpdateDetail {
1962
+ taskId: any; // Task ID
1963
+ oldProgress: number; // Old progress value (0-1)
1964
+ newProgress: number; // New progress value (0-1)
1965
+ task: object; // Complete task object
1966
+ }
1967
+ ```
1968
+
1969
+ ## Task Data Format
1970
+
1971
+ ### Regular Task
1972
+
1973
+ ```typescript
1974
+ {
1975
+ id: '1', // Task ID
1976
+ pid: '0', // Parent task ID, '0' means root task
1977
+ taskNo: 'Project Planning Phase', // Task name
1978
+ level: 'Important', // Priority
1979
+ start_date: '2024-12-01 08:00:00', // Start time
1980
+ end_date: '2024-12-06 18:00:00', // End time
1981
+ job_progress: '0.85', // Progress (0-1)
1982
+ spend_time: null // Duration (auto-calculated)
1983
+ }
1984
+ ```
1985
+
1986
+ ### Milestone Task
1987
+
1988
+ Milestones are key project checkpoints, displayed with diamond icons. The key characteristic is **start date equals end date**:
1989
+
1990
+ ```typescript
1991
+ {
1992
+ id: 'milestone-1', // Milestone ID
1993
+ pid: '0', // Parent task ID
1994
+ taskNo: '🎯 Requirements Complete', // Milestone name
1995
+ level: 'Urgent', // Priority
1996
+ start_date: '2024-12-02 18:00:00', // Start time
1997
+ end_date: '2024-12-02 18:00:00', // End time (same as start)
1998
+ job_progress: '1.0', // Milestones are usually 100%
1999
+ spend_time: null,
2000
+ type: 'milestone' // Optional: explicitly mark as milestone
2001
+ }
2002
+ ```
2003
+
2004
+ **Milestone Recognition Rules**:
2005
+ 1. **Auto-detection**: Automatically displayed as diamond when `start_date === end_date`
2006
+ 2. **Explicit marking**: Set `type: 'milestone'` field
2007
+ 3. **Custom function**: Custom logic via `styleConfig.setTaskType`
2008
+
2009
+ ## Task Dependencies
2010
+
2011
+ ```
2012
+ Finish-Start (FS) Start-Start (SS) Finish-Finish (FF) Start-Finish (SF)
2013
+ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐
2014
+ │ Task A │──┐ │ Task A │──┐ │ Task A │──┐ │ Task A │◄─┐
2015
+ └─────────┘ │ └─────────┘ │ └─────────┘ │ └─────────┘ │
2016
+ ▼ ▼ ▼ │
2017
+ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐
2018
+ │ Task B │ │ Task B │ │ Task B │ │ Task B │
2019
+ └─────────┘ └─────────┘ └─────────┘ └─────────┘
2020
+ B starts after A and B start A and B finish B starts
2021
+ A finishes together together before A ends
2022
+ ```
2023
+
2024
+ ### Dependency Types
2025
+
2026
+ | Type | Enum | Description |
2027
+ |------|------|-------------|
2028
+ | Finish-Start (FS) | FINISH_TO_START | Successor task starts after predecessor finishes |
2029
+ | Start-Start (SS) | START_TO_START | Tasks start simultaneously |
2030
+ | Finish-Finish (FF) | FINISH_TO_FINISH | Tasks finish simultaneously |
2031
+ | Start-Finish (SF) | START_TO_FINISH | Predecessor finishes after successor starts |
2032
+
2033
+ ### Configuration Example
2034
+
2035
+ #### Regular Task Dependencies
2036
+
2037
+ ```typescript
2038
+ import { LinkType } from './components/gantt/Types';
2039
+
2040
+ dependencies: [
2041
+ // Task 2 starts after Task 1 finishes
2042
+ { sourceTaskId: '1', targetTaskId: '2', type: LinkType.FINISH_TO_START },
2043
+
2044
+ // Task 3 and Task 4 start together
2045
+ { sourceTaskId: '3', targetTaskId: '4', type: LinkType.START_TO_START },
2046
+
2047
+ // Task 5 and Task 6 must finish together
2048
+ { sourceTaskId: '5', targetTaskId: '6', type: LinkType.FINISH_TO_FINISH },
2049
+ ]
2050
+ ```
2051
+
2052
+ #### Milestone Dependencies
2053
+
2054
+ Milestones support being **source** or **target** in dependency relationships:
2055
+
2056
+ ```typescript
2057
+ dependencies: [
2058
+ // Task completion → Milestone
2059
+ { sourceTaskId: 'task-5', targetTaskId: 'milestone-1', type: LinkType.FINISH_TO_START },
2060
+
2061
+ // Milestone → Task starts
2062
+ { sourceTaskId: 'milestone-1', targetTaskId: 'task-6', type: LinkType.FINISH_TO_START },
2063
+
2064
+ // Multiple tasks → Same milestone
2065
+ { sourceTaskId: 'frontend-dev', targetTaskId: 'milestone-2', type: LinkType.FINISH_TO_START },
2066
+ { sourceTaskId: 'backend-dev', targetTaskId: 'milestone-2', type: LinkType.FINISH_TO_START },
2067
+ ]
2068
+ ```
2069
+
2070
+ ## View Modes
2071
+
2072
+ | Mode | Time Unit | Header Example | Use Case |
2073
+ |------|-----------|----------------|----------|
2074
+ | 📆 **Quarter** | Month | `2024-Q1 2024-Q2 2024-Q3 ...` | Ultra long-term project planning |
2075
+ | 🗓️ **Month** | Day | `01 02 03 04 05 ...` | Long-term project planning |
2076
+ | 📅 **Day** | Day | `Mon Tue Wed ...` | Short-term task management |
2077
+ | 📊 **Week** | Week | `W50 W51 W52 ...` | Mid-term project tracking |
2078
+ | ⏰ **Hour** | Hour | `08 09 10 11 12 ...` | Precise task scheduling |
2079
+
2080
+ The component supports five time granularity views:
2081
+
2082
+ | Mode | Description | Sub-modes | Use Case |
2083
+ |------|-------------|-----------|----------|
2084
+ | Quarter | Display by month, quarter unit | - | Ultra long-term project planning |
2085
+ | Month | Display by day, month unit | - | Long-term project planning |
2086
+ | Day | Display by day, precise to day | Full day / Half day | Short-term task management |
2087
+ | Week | Display by week | - | Mid-term project tracking |
2088
+ | Hour | Display by hour | Hour / 30min / 15min | Precise task scheduling |
2089
+
2090
+ ### View Mode Switching
2091
+
2092
+ The component provides view mode switching buttons at the top. Click to switch between different view modes.
2093
+
2094
+ ### Sub-mode Details
2095
+
2096
+ **Day View Sub-modes:**
2097
+ - **Full day** - Each day displays as a complete time segment
2098
+ - **Half day** - Each day is divided into morning and afternoon time segments
2099
+
2100
+ **Hour View Sub-modes:**
2101
+ - **Hour** - Each hour displays as a time segment
2102
+ - **30min** - Each hour is divided into two 30-minute segments
2103
+ - **15min** - Each hour is divided into four 15-minute segments
2104
+
2105
+ ## Theme System
2106
+
2107
+ | Theme | Primary Color | Style Features |
2108
+ |-------|---------------|----------------|
2109
+ | 🔷 **Metro** | `#0078d4` | Microsoft Metro design language, professional metallic texture |
2110
+ | 🌙 **Dark** | `#00d4ff` | Eye-friendly dark theme, suitable for extended use |
2111
+ | ✨ **Modern** | `#6366f1` | Clean modern design, refreshing and comfortable |
2112
+ | 💼 **Classic** | `#2563eb` | Traditional business style, stable and dignified |
2113
+ | 🎨 **Colorful** | `#f59e0b` | Vibrant colorful theme, full of vitality |
2114
+ | 🍎 **Apple** | `#007aff` | Minimalist elegant macOS style, smooth and natural |
2115
+ | 💧 **Liquid Glass** | `#007aff` | iOS 26 liquid glass effect, translucent flowing texture |
2116
+
2117
+ ### Built-in Themes
2118
+
2119
+ | Theme ID | Name | Description |
2120
+ |----------|------|-------------|
2121
+ | metro | Metro | Microsoft Metro design language |
2122
+ | dark | Dark Mode | Eye-friendly dark theme |
2123
+ | modern | Modern | Clean modern design |
2124
+ | classic | Classic | Traditional business style |
2125
+ | colorful | Colorful | Vibrant colorful theme |
2126
+ | apple | Apple | Minimalist elegant macOS style |
2127
+ | liquidGlass | Liquid Glass | iOS 26 liquid glass effect |
2128
+
2129
+ ### Switching Themes
2130
+
2131
+ A theme selector is provided in the top right corner of the component. Click to switch themes. Theme settings are automatically saved to localStorage.
2132
+
2133
+ ### Custom Theme CSS Variables
2134
+
2135
+ ```css
2136
+ :root {
2137
+ --primary: #0078d4; /* Primary color */
2138
+ --primary-dark: #106ebe; /* Primary color dark */
2139
+ --primary-light: #1084d8; /* Primary color light */
2140
+ --bg-content: #ffffff; /* Content background color */
2141
+ --bg-metal-light: linear-gradient(145deg, #ffffff, #f5f5f5);
2142
+ --bg-metal-normal: linear-gradient(145deg, #f5f5f5, #e8e8e8);
2143
+ --border: #d0d0d0; /* Border color */
2144
+ --text-primary: #333333; /* Primary text color */
2145
+ --text-secondary: #666666; /* Secondary text color */
2146
+ --row-hover: #FFF3A1; /* Row hover color */
2147
+ --font-family: 'Segoe UI', sans-serif;
2148
+ }
2149
+ ```
2150
+
2151
+ ## Custom Fields
2152
+
2153
+ The component supports powerful custom field functionality, allowing you to add any number of custom fields to tasks to meet different project personalization needs.
2154
+
2155
+ ### Features
2156
+
2157
+ - **Multiple Field Types** - Text, number, date, dropdown selection
2158
+ - **Dynamic Management** - Add, edit, delete fields at runtime
2159
+ - **Form Validation** - Built-in validation rules ensure data validity
2160
+ - **Local Storage** - Field configuration automatically saved to browser
2161
+ - **Task Binding** - Custom field values associated with task data
2162
+
2163
+ ### Field Types
2164
+
2165
+ | Type | Description | Example Value |
2166
+ |------|-------------|---------------|
2167
+ | Text | Single-line text input | "Project ID: PRJ-001" |
2168
+ | Number | Numeric input, supports decimals | 100.5 |
2169
+ | Date | Date picker | "2024-12-01" |
2170
+ | Dropdown | Predefined option list | "High Priority" |
2171
+
2172
+ ### Usage
2173
+
2174
+ #### 1. Open Custom Field Management
2175
+
2176
+ Click the "Custom Fields" button in the Gantt chart toolbar to open the field management dialog.
2177
+
2178
+ #### 2. Add Custom Field
2179
+
2180
+ ```typescript
2181
+ // Example: Add an "Owner" field
2182
+ const customField = {
2183
+ id: 'field-1',
2184
+ name: 'Owner',
2185
+ type: 'text', // text | number | date | select
2186
+ required: false, // Whether required
2187
+ options: [] // Options for dropdown selection
2188
+ };
2189
+ ```
2190
+
2191
+ #### 3. Use Custom Fields in Tasks
2192
+
2193
+ Custom field values are stored in the task's `customFieldValues` field:
2194
+
2195
+ ```typescript
2196
+ {
2197
+ id: '1',
2198
+ taskNo: 'Project Planning',
2199
+ start_date: '2024-12-01',
2200
+ end_date: '2024-12-06',
2201
+ job_progress: '0.85',
2202
+ customFieldValues: {
2203
+ 'field-1': 'John Doe', // Owner
2204
+ 'field-2': '100', // Budget
2205
+ 'field-3': '2024-11-30', // Approval Date
2206
+ 'field-4': 'High Priority' // Priority
2207
+ }
2208
+ }
2209
+ ```
2210
+
2211
+ #### 4. Dropdown Field Configuration
2212
+
2213
+ ```typescript
2214
+ const priorityField = {
2215
+ id: 'field-priority',
2216
+ name: 'Priority',
2217
+ type: 'select',
2218
+ required: true,
2219
+ options: [
2220
+ { label: 'Urgent', value: 'urgent' },
2221
+ { label: 'Important', value: 'important' },
2222
+ { label: 'Normal', value: 'normal' }
2223
+ ]
2224
+ };
2225
+ ```
2226
+
2227
+ ### Field Validation
2228
+
2229
+ The component includes basic field validation rules:
2230
+
2231
+ - **Required Fields** - If field is marked as `required: true`, a value must be provided
2232
+ - **Number Validation** - Number fields only accept valid numeric values
2233
+ - **Date Validation** - Date fields only accept valid date formats
2234
+ - **Option Validation** - Dropdown fields only accept predefined option values
2235
+
2236
+ ### API Integration
2237
+
2238
+ #### Backend Storage Format
2239
+
2240
+ Custom field values need to be stored in the backend in a specific format:
2241
+
2242
+ ```typescript
2243
+ // Recommended format: JSON string
2244
+ customFieldValues: JSON.stringify({
2245
+ 'field-1': 'John Doe',
2246
+ 'field-2': '100'
2247
+ })
2248
+
2249
+ // Or array format (requires backend support)
2250
+ customFieldValues: [
2251
+ { fieldId: 'field-1', value: 'John Doe' },
2252
+ { fieldId: 'field-2', value: '100' }
2253
+ ]
2254
+ ```
2255
+
2256
+ #### Data Processing Example
2257
+
2258
+ ```typescript
2259
+ // When saving task
2260
+ const saveTask = async (task) => {
2261
+ const payload = {
2262
+ ...task,
2263
+ customFieldValues: JSON.stringify(task.customFieldValues)
2264
+ };
2265
+ await api.saveTask(payload);
2266
+ };
2267
+
2268
+ // When loading task
2269
+ const loadTask = async (taskId) => {
2270
+ const data = await api.getTask(taskId);
2271
+ return {
2272
+ ...data,
2273
+ customFieldValues: JSON.parse(data.customFieldValues || '{}')
2274
+ };
2275
+ };
2276
+ ```
2277
+
2278
+ ### Best Practices
2279
+
2280
+ 1. **Field Naming** - Use clear, concise field names for easy understanding
2281
+ 2. **Required Settings** - Reasonably set required fields to avoid over-restriction
2282
+ 3. **Option Management** - Provide complete option lists for dropdown fields
2283
+ 4. **Data Validation** - Also validate fields in backend to ensure data integrity
2284
+ 5. **Performance Optimization** - Avoid adding too many custom fields that affect performance
2285
+
2286
+ ## Configuration Panels
2287
+
2288
+ The component provides two powerful configuration panels for customizing Gantt chart display and behavior.
2289
+
2290
+ ### Gantt Configuration Panel
2291
+
2292
+ Access via the "Gantt Config" button in the toolbar.
2293
+
2294
+ #### Language Settings
2295
+
2296
+ - **Language Selection** - Switch between Chinese (zh-CN) and English (en-US)
2297
+ - **Auto-detection** - Automatically detects browser language on first load
2298
+
2299
+ #### Theme Settings
2300
+
2301
+ - **Light/Dark Mode** - Switch between light and dark themes
2302
+ - **Theme Persistence** - Theme preference saved to local storage
2303
+
2304
+ #### Dependency Line Styles
2305
+
2306
+ Configure task dependency line appearance:
2307
+
2308
+ ```typescript
2309
+ {
2310
+ pathType: 'straight', // Connection path type: straight | curved
2311
+ color: '#409EFF', // Line color
2312
+ width: 2, // Line width (px)
2313
+ dashed: false, // Whether to use dashed line
2314
+ showArrow: true, // Whether to show arrow
2315
+ arrowSize: 6 // Arrow size (px)
2316
+ }
2317
+ ```
2318
+
2319
+ **Path Types:**
2320
+ - **Straight** - Direct straight line connection
2321
+ - **Curved** - Smooth curved line connection
2322
+
2323
+ **Style Options:**
2324
+ - **Color** - Supports any valid CSS color value
2325
+ - **Width** - 1-5px recommended
2326
+ - **Dashed** - Creates dashed line effect
2327
+ - **Arrow** - Shows direction indicator at end point
2328
+
2329
+ ### Column Configuration Panel
2330
+
2331
+ Access via the "Column Config" button in the toolbar.
2332
+
2333
+ #### Column Display Settings
2334
+
2335
+ Control which columns are visible in the task list:
2336
+
2337
+ ```typescript
2338
+ const columns = [
2339
+ { key: 'taskNo', label: 'Task Name', visible: true },
2340
+ { key: 'start_date', label: 'Start Date', visible: true },
2341
+ { key: 'end_date', label: 'End Date', visible: true },
2342
+ { key: 'job_progress', label: 'Progress', visible: true },
2343
+ { key: 'duration', label: 'Duration', visible: false }
2344
+ ];
2345
+ ```
2346
+
2347
+ #### Column Operations
2348
+
2349
+ - **Toggle Visibility** - Click checkbox to show/hide column
2350
+ - **Show All** - Display all columns at once
2351
+ - **Hide All** - Hide all columns at once
2352
+ - **Reset Default** - Restore to default column configuration
2353
+
2354
+ #### Column Types
2355
+
2356
+ | Column Key | Description | Format |
2357
+ |------------|-------------|--------|
2358
+ | taskNo | Task name | Text |
2359
+ | start_date | Start date | YYYY-MM-DD |
2360
+ | end_date | End date | YYYY-MM-DD |
2361
+ | job_progress | Progress percentage | 0-100% |
2362
+ | duration | Task duration | Number (days) |
2363
+
2364
+ ### Configuration Persistence
2365
+
2366
+ All configuration settings are automatically saved to browser local storage:
2367
+
2368
+ ```typescript
2369
+ // Storage keys
2370
+ const CONFIG_KEYS = {
2371
+ ganttConfig: 'vue3-gantt-config', // Gantt chart settings
2372
+ columnConfig: 'vue3-gantt-columns', // Column display settings
2373
+ customFields: 'vue3-gantt-fields' // Custom field definitions
2374
+ };
2375
+ ```
2376
+
2377
+ **Benefits:**
2378
+ - Settings persist across page refreshes
2379
+ - Configuration shared across browser sessions
2380
+ - Easy to reset to defaults if needed
2381
+
2382
+ ### Best Practices
2383
+
2384
+ 1. **Line Visibility** - Use contrasting colors for dependency lines
2385
+ 2. **Column Balance** - Don't show too many columns at once
2386
+ 3. **Theme Consistency** - Match Gantt chart theme with application theme
2387
+ 4. **Performance** - Complex line styles may impact performance with many tasks
2388
+
2389
+ ## Task Dialog
2390
+
2391
+ The task dialog provides a comprehensive interface for creating and editing tasks with rich features.
2392
+
2393
+ ### Dialog Features
2394
+
2395
+ - **Dual Mode** - Create new task or edit existing task
2396
+ - **Form Validation** - Real-time validation with error messages
2397
+ - **Custom Fields** - Support for dynamic custom field inputs
2398
+ - **Date Constraints** - Automatic date validation and adjustment
2399
+ - **Progress Control** - Visual progress slider with percentage display
2400
+
2401
+ ### Basic Fields
2402
+
2403
+ #### Task Name
2404
+
2405
+ ```typescript
2406
+ {
2407
+ taskNo: 'Project Planning', // Required, max length 200
2408
+ name: 'Project Planning' // Display name (optional)
2409
+ }
2410
+ ```
2411
+
2412
+ - **Required** - Yes
2413
+ - **Max Length** - 200 characters
2414
+ - **Validation** - Cannot be empty
2415
+
2416
+ #### Date Range
2417
+
2418
+ ```typescript
2419
+ {
2420
+ start_date: '2024-12-01', // Start date
2421
+ end_date: '2024-12-06' // End date
2422
+ }
2423
+ ```
2424
+
2425
+ **Features:**
2426
+ - **Date Picker** - Built-in date picker for easy selection
2427
+ - **Auto-adjustment** - End date automatically adjusted if before start date
2428
+ - **Format** - YYYY-MM-DD
2429
+ - **Validation** - End date must be >= start date
2430
+
2431
+ #### Progress
2432
+
2433
+ ```typescript
2434
+ {
2435
+ job_progress: '0.85' // Progress value (0-1)
2436
+ }
2437
+ ```
2438
+
2439
+ **Features:**
2440
+ - **Slider Control** - Visual slider for easy adjustment
2441
+ - **Percentage Display** - Shows progress as percentage (0-100%)
2442
+ - **Decimal Support** - Supports decimal values (e.g., 0.5 = 50%)
2443
+ - **Validation** - Must be between 0 and 1
2444
+
2445
+ ### Custom Fields Section
2446
+
2447
+ The dialog dynamically renders custom fields based on configuration:
2448
+
2449
+ ```typescript
2450
+ // Example custom fields in dialog
2451
+ const customFields = [
2452
+ {
2453
+ id: 'field-1',
2454
+ name: 'Owner',
2455
+ type: 'text',
2456
+ value: 'John Doe'
2457
+ },
2458
+ {
2459
+ id: 'field-2',
2460
+ name: 'Budget',
2461
+ type: 'number',
2462
+ value: '10000'
2463
+ },
2464
+ {
2465
+ id: 'field-3',
2466
+ name: 'Priority',
2467
+ type: 'select',
2468
+ options: [
2469
+ { label: 'High', value: 'high' },
2470
+ { label: 'Medium', value: 'medium' },
2471
+ { label: 'Low', value: 'low' }
2472
+ ],
2473
+ value: 'high'
2474
+ }
2475
+ ];
2476
+ ```
2477
+
2478
+ **Field Types:**
2479
+ - **Text Input** - Single-line text field
2480
+ - **Number Input** - Numeric field with validation
2481
+ - **Date Picker** - Date selection field
2482
+ - **Dropdown** - Select from predefined options
2483
+
2484
+ ### Form Validation
2485
+
2486
+ The dialog implements comprehensive validation:
2487
+
2488
+ ```typescript
2489
+ // Validation rules
2490
+ const rules = {
2491
+ taskNo: [
2492
+ { required: true, message: 'Task name is required' },
2493
+ { max: 200, message: 'Task name cannot exceed 200 characters' }
2494
+ ],
2495
+ start_date: [
2496
+ { required: true, message: 'Start date is required' }
2497
+ ],
2498
+ end_date: [
2499
+ { required: true, message: 'End date is required' },
2500
+ {
2501
+ validator: (rule, value, callback) => {
2502
+ if (value < start_date) {
2503
+ callback(new Error('End date must be after start date'));
2504
+ } else {
2505
+ callback();
2506
+ }
2507
+ }
2508
+ }
2509
+ ]
2510
+ };
2511
+ ```
2512
+
2513
+ **Validation Types:**
2514
+ - **Required Fields** - Ensures mandatory fields are filled
2515
+ - **Format Validation** - Validates date and number formats
2516
+ - **Business Rules** - Enforces logical constraints (e.g., end >= start)
2517
+ - **Custom Field Validation** - Validates based on field type and requirements
2518
+
2519
+ ### Dialog Actions
2520
+
2521
+ #### Save Button
2522
+
2523
+ - Validates all fields before saving
2524
+ - Shows error messages if validation fails
2525
+ - Emits save event with task data
2526
+ - Closes dialog on successful save
2527
+
2528
+ #### Cancel Button
2529
+
2530
+ - Closes dialog without saving
2531
+ - Discards any unsaved changes
2532
+ - No confirmation required
2533
+
2534
+ ### Best Practices
2535
+
2536
+ 1. **Clear Naming** - Use descriptive task names
2537
+ 2. **Date Planning** - Set realistic date ranges
2538
+ 3. **Progress Updates** - Regularly update progress values
2539
+ 4. **Custom Fields** - Use custom fields for project-specific data
2540
+ 5. **Validation** - Pay attention to validation messages
2541
+
2542
+ ## Message Toast
2543
+
2544
+ The component includes a built-in message toast system for providing user feedback.
2545
+
2546
+ ### Message Types
2547
+
2548
+ Three types of messages are supported:
2549
+
2550
+ | Type | Icon | Color | Usage |
2551
+ |------|------|-------|-------|
2552
+ | Success | ✓ | Green | Successful operations (save, delete, etc.) |
2553
+ | Error | ✗ | Red | Failed operations (validation errors, API errors) |
2554
+ | Warning | ⚠ | Orange | Warnings (unsaved changes, potential issues) |
2555
+
2556
+ ### Usage
2557
+
2558
+ #### Display Success Message
2559
+
2560
+ ```typescript
2561
+ // In component
2562
+ import { useMessage } from '@/composables/useMessage';
2563
+
2564
+ const { showMessage } = useMessage();
2565
+
2566
+ // Show success message
2567
+ showMessage('Task saved successfully', 'success');
2568
+ ```
2569
+
2570
+ #### Display Error Message
2571
+
2572
+ ```typescript
2573
+ // Show error message
2574
+ showMessage('Failed to save task: Invalid data', 'error');
2575
+ ```
2576
+
2577
+ #### Display Warning Message
2578
+
2579
+ ```typescript
2580
+ // Show warning message
2581
+ showMessage('Unsaved changes will be lost', 'warning');
2582
+ ```
2583
+
2584
+ ### Message Behavior
2585
+
2586
+ **Auto-dismissal:**
2587
+ - Success messages: 3 seconds
2588
+ - Error messages: 5 seconds
2589
+ - Warning messages: 4 seconds
2590
+
2591
+ **Manual Dismissal:**
2592
+ - Click message to dismiss immediately
2593
+ - Hover to pause auto-dismissal timer
2594
+
2595
+ **Positioning:**
2596
+ - Top-right corner of screen
2597
+ - Stacked vertically for multiple messages
2598
+ - Maximum 3 messages displayed simultaneously
2599
+
2600
+ ### Message Queue
2601
+
2602
+ The toast system manages a message queue:
2603
+
2604
+ ```typescript
2605
+ // Message queue properties
2606
+ interface Message {
2607
+ id: string; // Unique message ID
2608
+ type: 'success' | 'error' | 'warning';
2609
+ content: string; // Message text
2610
+ duration: number; // Display duration (ms)
2611
+ timestamp: number; // Creation timestamp
2612
+ }
2613
+ ```
2614
+
2615
+ **Queue Management:**
2616
+ - New messages added to end of queue
2617
+ - Oldest messages dismissed first
2618
+ - Prevents duplicate messages
2619
+
2620
+ ### Styling
2621
+
2622
+ Messages are styled according to type:
2623
+
2624
+ ```css
2625
+ /* Success message */
2626
+ .message-success {
2627
+ background: #f0f9ff;
2628
+ border-left: 4px solid #67c23a;
2629
+ color: #67c23a;
2630
+ }
2631
+
2632
+ /* Error message */
2633
+ .message-error {
2634
+ background: #fef0f0;
2635
+ border-left: 4px solid #f56c6c;
2636
+ color: #f56c6c;
2637
+ }
2638
+
2639
+ /* Warning message */
2640
+ .message-warning {
2641
+ background: #fdf6ec;
2642
+ border-left: 4px solid #e6a23c;
2643
+ color: #e6a23c;
2644
+ }
2645
+ ```
2646
+
2647
+ ### Best Practices
2648
+
2649
+ 1. **Clear Messages** - Use clear, concise message text
2650
+ 2. **Appropriate Types** - Choose correct message type for situation
2651
+ 3. **User Feedback** - Provide feedback for all user actions
2652
+ 4. **Error Details** - Include helpful information in error messages
2653
+ 5. **Avoid Spam** - Don't show too many messages in short time
2654
+
2655
+ ## Delete Confirmation Dialog
2656
+
2657
+ The delete confirmation dialog ensures safe task deletion with clear warnings and options.
2658
+
2659
+ ### Dialog Features
2660
+
2661
+ - **Warning Display** - Shows clear warning about deletion consequences
2662
+ - **Cascade Warning** - Informs about child task deletion
2663
+ - **Confirmation Required** - Prevents accidental deletions
2664
+ - **Action Buttons** - Clear confirm and cancel options
2665
+
2666
+ ### Dialog Content
2667
+
2668
+ #### Warning Message
2669
+
2670
+ ```
2671
+ ⚠️ Warning: You are about to delete this task
2672
+ ```
2673
+
2674
+ #### Cascade Warning (for parent tasks)
2675
+
2676
+ ```
2677
+ Note: This will also delete all child tasks under this task.
2678
+ Are you sure you want to continue?
2679
+ ```
2680
+
2681
+ #### Confirmation Question
2682
+
2683
+ ```
2684
+ Are you sure you want to delete this task?
2685
+ ```
2686
+
2687
+ ### Dialog Actions
2688
+
2689
+ #### Confirm Button
2690
+
2691
+ - **Text** - "Confirm" or "Delete"
2692
+ - **Style** - Red/danger color to indicate destructive action
2693
+ - **Action** - Deletes task and all child tasks (if any)
2694
+ - **Feedback** - Shows success message after deletion
2695
+
2696
+ #### Cancel Button
2697
+
2698
+ - **Text** - "Cancel"
2699
+ - **Style** - Gray/neutral color
2700
+ - **Action** - Closes dialog without deleting
2701
+ - **Feedback** - No action taken
2702
+
2703
+ ### Deletion Behavior
2704
+
2705
+ #### Simple Task Deletion
2706
+
2707
+ When deleting a task without children:
2708
+
2709
+ ```typescript
2710
+ // Single task deletion
2711
+ const deleteTask = (taskId: string) => {
2712
+ // 1. Show confirmation dialog
2713
+ // 2. User confirms
2714
+ // 3. Delete task from data
2715
+ // 4. Show success message
2716
+ // 5. Update UI
2717
+ };
2718
+ ```
2719
+
2720
+ #### Parent Task Deletion
2721
+
2722
+ When deleting a task with children:
2723
+
2724
+ ```typescript
2725
+ // Parent task with children
2726
+ const deleteTaskWithChildren = (taskId: string) => {
2727
+ // 1. Show confirmation dialog with cascade warning
2728
+ // 2. User confirms
2729
+ // 3. Delete all child tasks recursively
2730
+ // 4. Delete parent task
2731
+ // 5. Show success message
2732
+ // 6. Update UI
2733
+ };
2734
+ ```
2735
+
2736
+ **Cascade Deletion:**
2737
+ - All child tasks are deleted
2738
+ - Child tasks' children are also deleted
2739
+ - Entire subtree is removed from data
2740
+
2741
+ ### Safety Features
2742
+
2743
+ #### Double Confirmation
2744
+
2745
+ For critical deletions, the dialog may require additional confirmation:
2746
+
2747
+ ```typescript
2748
+ // Example: Delete task with many children
2749
+ if (childCount > 10) {
2750
+ // Show additional confirmation step
2751
+ const confirmed = await showDoubleConfirmation();
2752
+ if (!confirmed) return;
2753
+ }
2754
+ ```
2755
+
2756
+ #### Undo Support (Optional)
2757
+
2758
+ The component can be extended to support undo:
2759
+
2760
+ ```typescript
2761
+ // Store deleted tasks for potential undo
2762
+ const deletedTasks = [];
2763
+
2764
+ const deleteTask = (task) => {
2765
+ // Save task before deletion
2766
+ deletedTasks.push({
2767
+ task: task,
2768
+ timestamp: Date.now()
2769
+ });
2770
+
2771
+ // Perform deletion
2772
+ performDeletion(task.id);
2773
+ };
2774
+
2775
+ const undoDelete = () => {
2776
+ const lastDeleted = deletedTasks.pop();
2777
+ if (lastDeleted) {
2778
+ restoreTask(lastDeleted.task);
2779
+ }
2780
+ };
2781
+ ```
2782
+
2783
+ ### Best Practices
2784
+
2785
+ 1. **Clear Warnings** - Always show clear warnings before deletion
2786
+ 2. **Cascade Info** - Inform users about child task deletion
2787
+ 3. **Confirmation** - Always require confirmation for deletion
2788
+ 4. **Feedback** - Show success message after deletion
2789
+ 5. **Recovery** - Consider implementing undo functionality
2790
+
2791
+ ## Tree Task Structure
2792
+
2793
+ The component supports hierarchical task tree structure with rich visualization and interaction features.
2794
+
2795
+ ### Core Features
2796
+
2797
+ - **Multi-level Hierarchy** - Support unlimited task nesting levels
2798
+ - **Visual Indentation** - Clear visual representation of task hierarchy
2799
+ - **Connection Lines** - Tree-style connection lines between parent and child tasks
2800
+ - **Expand/Collapse** - Interactive expand/collapse for parent tasks
2801
+ - **Task Numbering** - Hierarchical task numbering (1, 1.1, 1.1.1, etc.)
2802
+ - **Inline Operations** - Add/delete child tasks directly from task row
2803
+
2804
+ ### Task Hierarchy Structure
2805
+
2806
+ Tasks can be organized in a tree structure:
2807
+
2808
+ ```typescript
2809
+ // Example task hierarchy
2810
+ const tasks = [
2811
+ {
2812
+ id: '1',
2813
+ taskNo: 'Project Phase 1',
2814
+ level: 0, // Root level
2815
+ children: [
2816
+ {
2817
+ id: '1-1',
2818
+ taskNo: 'Task 1.1',
2819
+ level: 1, // First level child
2820
+ children: [
2821
+ {
2822
+ id: '1-1-1',
2823
+ taskNo: 'Task 1.1.1',
2824
+ level: 2 // Second level child
2825
+ }
2826
+ ]
2827
+ },
2828
+ {
2829
+ id: '1-2',
2830
+ taskNo: 'Task 1.2',
2831
+ level: 1
2832
+ }
2833
+ ]
2834
+ }
2835
+ ];
2836
+ ```
2837
+
2838
+ **Level Properties:**
2839
+ - `level: 0` - Root task (no parent)
2840
+ - `level: 1` - First level child
2841
+ - `level: 2` - Second level child
2842
+ - And so on...
2843
+
2844
+ ### Visual Elements
2845
+
2846
+ #### Indentation
2847
+
2848
+ Each level of hierarchy is indented by a fixed amount:
2849
+
2850
+ ```css
2851
+ /* Indentation per level */
2852
+ .task-row {
2853
+ padding-left: calc(level * 24px);
2854
+ }
2855
+ ```
2856
+
2857
+ **Visual Effect:**
2858
+ - Level 0: No indentation
2859
+ - Level 1: 24px indentation
2860
+ - Level 2: 48px indentation
2861
+ - Level 3: 72px indentation
2862
+
2863
+ #### Connection Lines
2864
+
2865
+ Tree-style connection lines show parent-child relationships:
2866
+
2867
+ ```
2868
+ ├─ Task 1.0 (parent)
2869
+ │ ├─ Task 1.1 (child)
2870
+ │ │ ├─ Task 1.1.1 (grandchild)
2871
+ │ │ └─ Task 1.1.2 (grandchild)
2872
+ │ └─ Task 1.2 (child)
2873
+ └─ Task 2.0 (parent)
2874
+ ```
2875
+
2876
+ **Line Types:**
2877
+ - **Vertical Line** - Connects parent to children
2878
+ - **Horizontal Line** - Connects to task name
2879
+ - **Corner** - Smooth corner at connection point
2880
+
2881
+ #### Expand/Collapse Icons
2882
+
2883
+ Parent tasks display expand/collapse indicators:
2884
+
2885
+ - **Expanded (▾)** - Shows children, click to collapse
2886
+ - **Collapsed (▸)** - Hides children, click to expand
2887
+ - **Leaf Task** - No icon (no children)
2888
+
2889
+ ### Interaction Operations
2890
+
2891
+ #### Expand/Collapse Tasks
2892
+
2893
+ Click the expand/collapse icon to toggle visibility:
2894
+
2895
+ ```typescript
2896
+ // Expand task
2897
+ const expandTask = (taskId: string) => {
2898
+ const task = findTask(taskId);
2899
+ if (task) {
2900
+ task.expanded = true;
2901
+ // Show all child tasks
2902
+ }
2903
+ };
2904
+
2905
+ // Collapse task
2906
+ const collapseTask = (taskId: string) => {
2907
+ const task = findTask(taskId);
2908
+ if (task) {
2909
+ task.expanded = false;
2910
+ // Hide all child tasks
2911
+ }
2912
+ };
2913
+ ```
2914
+
2915
+ **Keyboard Support:**
2916
+ - `Right Arrow` - Expand task
2917
+ - `Left Arrow` - Collapse task
2918
+
2919
+ #### Add Child Task
2920
+
2921
+ Click the "+" button on a task row to add a child:
2922
+
2923
+ ```typescript
2924
+ const addChildTask = (parentTaskId: string) => {
2925
+ const parentTask = findTask(parentTaskId);
2926
+ if (parentTask) {
2927
+ const newTask = {
2928
+ id: generateId(),
2929
+ taskNo: 'New Task',
2930
+ level: parentTask.level + 1,
2931
+ parentId: parentTaskId
2932
+ };
2933
+ parentTask.children.push(newTask);
2934
+ // Auto-expand parent to show new child
2935
+ parentTask.expanded = true;
2936
+ }
2937
+ };
2938
+ ```
2939
+
2940
+ #### Delete Task
2941
+
2942
+ Click the "×" button to delete a task:
2943
+
2944
+ ```typescript
2945
+ const deleteTask = (taskId: string) => {
2946
+ // Show confirmation dialog
2947
+ const confirmed = showDeleteConfirmation(taskId);
2948
+ if (confirmed) {
2949
+ // Delete task and all children
2950
+ removeTaskAndChildren(taskId);
2951
+ }
2952
+ };
2953
+ ```
2954
+
2955
+ **Cascade Deletion:**
2956
+ - Deleting a parent task deletes all its children
2957
+ - Deleting a child task only deletes that child
2958
+ - Confirmation dialog warns about cascade deletion
2959
+
2960
+ ### Parent-Child Task Linkage
2961
+
2962
+ #### Date Constraints
2963
+
2964
+ Child task dates are constrained by parent task dates:
2965
+
2966
+ ```typescript
2967
+ // Child task cannot extend beyond parent
2968
+ const validateChildDates = (child: Task, parent: Task) => {
2969
+ if (child.start_date < parent.start_date) {
2970
+ child.start_date = parent.start_date;
2971
+ }
2972
+ if (child.end_date > parent.end_date) {
2973
+ child.end_date = parent.end_date;
2974
+ }
2975
+ };
2976
+ ```
2977
+
2978
+ **Rules:**
2979
+ - Child start date >= Parent start date
2980
+ - Child end date <= Parent end date
2981
+ - Parent dates automatically adjust if needed
2982
+
2983
+ #### Progress Calculation
2984
+
2985
+ Parent task progress is calculated from children:
2986
+
2987
+ ```typescript
2988
+ // Calculate parent progress from children
2989
+ const calculateParentProgress = (parent: Task) => {
2990
+ if (!parent.children || parent.children.length === 0) {
2991
+ return parent.job_progress;
2992
+ }
2993
+
2994
+ const totalProgress = parent.children.reduce((sum, child) => {
2995
+ return sum + parseFloat(child.job_progress);
2996
+ }, 0);
2997
+
2998
+ return (totalProgress / parent.children.length).toFixed(2);
2999
+ };
3000
+ ```
3001
+
3002
+ **Calculation Method:**
3003
+ - Average of all child task progress
3004
+ - Automatically updates when child progress changes
3005
+ - Can be overridden manually
3006
+
3007
+ ### Style Customization
3008
+
3009
+ #### Indentation Width
3010
+
3011
+ Customize indentation per level:
3012
+
3013
+ ```typescript
3014
+ const config = {
3015
+ indentationWidth: 24 // px per level
3016
+ };
3017
+ ```
3018
+
3019
+ #### Line Styles
3020
+
3021
+ Customize connection line appearance:
3022
+
3023
+ ```css
3024
+ .tree-line {
3025
+ color: #dcdfe6; /* Line color */
3026
+ width: 1px; /* Line width */
3027
+ style: solid; /* Line style */
3028
+ }
3029
+ ```
3030
+
3031
+ #### Icon Styles
3032
+
3033
+ Customize expand/collapse icons:
3034
+
3035
+ ```css
3036
+ .expand-icon {
3037
+ color: #909399; /* Icon color */
3038
+ font-size: 14px; /* Icon size */
3039
+ cursor: pointer; /* Pointer cursor */
3040
+ }
3041
+
3042
+ .expand-icon:hover {
3043
+ color: #409EFF; /* Hover color */
3044
+ }
3045
+ ```
3046
+
3047
+ ### Best Practices
3048
+
3049
+ 1. **Shallow Hierarchy** - Keep hierarchy depth reasonable (3-5 levels max)
3050
+ 2. **Clear Naming** - Use descriptive names at each level
3051
+ 3. **Logical Grouping** - Group related tasks under same parent
3052
+ 4. **Regular Review** - Periodically review and reorganize structure
3053
+ 5. **Consistent Indentation** - Maintain consistent indentation for clarity
3054
+
3055
+ ## Internationalization Support
3056
+
3057
+ ### Supported Languages
3058
+
3059
+ | Language | Code | Status |
3060
+ |----------|------|--------|
3061
+ | 🇨🇳 Simplified Chinese | zh-CN | ✅ Full support |
3062
+ | 🇺🇸 English | en-US | ✅ Full support |
3063
+ | 🇯🇵 Japanese | ja-JP | ✅ Full support |
3064
+ | 🇰🇷 Korean | ko-KR | ✅ Full support |
3065
+ | 🇫🇷 French | fr-FR | ✅ Full support |
3066
+ | 🇩🇪 German | de-DE | ✅ Full support |
3067
+ | 🇪🇸 Spanish | es-ES | ✅ Full support |
3068
+ | 🇷🇺 Russian | ru-RU | ✅ Full support |
3069
+
3070
+ ### Usage
3071
+
3072
+ #### 1. Switch Language
3073
+
3074
+ In the top right corner of the Gantt chart toolbar, click the language selector to switch the interface language:
3075
+
3076
+ ```typescript
3077
+ import { setLocale } from './components/gantt/i18n';
3078
+
3079
+ // Switch to English
3080
+ setLocale('en-US');
3081
+
3082
+ // Switch to Chinese
3083
+ setLocale('zh-CN');
3084
+ ```
3085
+
3086
+ #### 2. Get Current Language
3087
+
3088
+ ```typescript
3089
+ import { getLocale } from './components/gantt/i18n';
3090
+
3091
+ const currentLang = getLocale(); // 'zh-CN' or 'en-US'
3092
+ ```
3093
+
3094
+ #### 3. Use Translation in Components
3095
+
3096
+ ```vue
3097
+ <script setup lang="ts">
3098
+ import { useI18n } from './components/gantt/i18n';
3099
+
3100
+ const { t, locale } = useI18n();
3101
+ </script>
3102
+
3103
+ <template>
3104
+ <div>
3105
+ <h1>{{ t('common.title') }}</h1>
3106
+ <button>{{ t('common.confirm') }}</button>
3107
+ <p>{{ t('task.name') }}</p>
3108
+ </div>
3109
+ </template>
3110
+ ```
3111
+
3112
+ ### i18n Features
3113
+
3114
+ - ✅ **Instant Switching** - No page refresh required to switch languages
3115
+ - ✅ **Auto Save** - Language selection automatically saved to browser localStorage
3116
+ - ✅ **Complete Coverage** - All interface text has been translated
3117
+ - ✅ **Dynamic Headers** - Timeline headers (months, weekdays, etc.) automatically formatted based on language
3118
+ - ✅ **Type Safe** - TypeScript provides complete type support
3119
+ - ✅ **Easy Extension** - Can easily add new language support
3120
+
3121
+ ### Translated Interface Elements
3122
+
3123
+ #### Toolbar
3124
+ - Date picker separator ("to" / "至")
3125
+ - View mode buttons (Month/Week/Day/Hour)
3126
+ - Link legend title and all link types
3127
+
3128
+ #### Task Headers
3129
+ - No. (序号)
3130
+ - Task Name (任务名称)
3131
+ - Priority (优先级)
3132
+ - Start Date (开始时间)
3133
+ - End Date (结束时间)
3134
+ - Duration (耗时)
3135
+ - Progress (进度)
3136
+
3137
+ #### Timeline Headers
3138
+ - Month names (January/一月, February/二月...)
3139
+ - Weekday names (Monday/星期一, Tuesday/星期二...)
3140
+ - Date format (01/01日, 02/02日...)
3141
+ - Hour format (0:00/0点, 1:00/1点...)
3142
+ - Week title (Week 1/第1周)
3143
+
3144
+ #### Configuration Panel
3145
+ - Gantt configuration title
3146
+ - Theme settings options
3147
+ - All link configuration options
3148
+ - All buttons and labels
3149
+
3150
+ ### Adding New Languages
3151
+
3152
+ To add new language support, follow these steps:
3153
+
3154
+ 1. Create a new language file in the `src/components/gantt/i18n/locales/` directory (e.g., `ja-JP.ts`)
3155
+ 2. Copy the structure from `zh-CN.ts` or `en-US.ts`
3156
+ 3. Translate all text
3157
+ 4. Import and register the new language in `src/components/gantt/i18n/index.ts`:
3158
+
3159
+ ```typescript
3160
+ import jaJP from './locales/ja-JP';
3161
+ import koKR from './locales/ko-KR';
3162
+ import frFR from './locales/fr-FR';
3163
+ import deDE from './locales/de-DE';
3164
+ import esES from './locales/es-ES';
3165
+ import ruRU from './locales/ru-RU';
3166
+
3167
+ const messages: Record<Locale, Messages> = {
3168
+ 'zh-CN': zhCN,
3169
+ 'en-US': enUS,
3170
+ 'ja-JP': jaJP, // Added Japanese
3171
+ 'ko-KR': koKR, // Added Korean
3172
+ 'fr-FR': frFR, // Added French
3173
+ 'de-DE': deDE, // Added German
3174
+ 'es-ES': esES, // Added Spanish
3175
+ 'ru-RU': ruRU // Added Russian
3176
+ };
3177
+ ```
3178
+
3179
+ 5. Update the `getLocales()` function to add new language options
3180
+
3181
+ ### Language Pack Structure
3182
+
3183
+ ```typescript
3184
+ export default {
3185
+ common: { // Common text
3186
+ confirm: 'Confirm',
3187
+ cancel: 'Cancel',
3188
+ // ...
3189
+ },
3190
+ date: { // Date and time
3191
+ year: 'Year',
3192
+ month: 'Month',
3193
+ // ...
3194
+ },
3195
+ viewMode: { // View mode
3196
+ month: 'Month',
3197
+ week: 'Week',
3198
+ // ...
3199
+ },
3200
+ task: { // Task related
3201
+ name: 'Task Name',
3202
+ priority: 'Priority',
3203
+ // ...
3204
+ },
3205
+ // More categories...
3206
+ }
3207
+ ```
3208
+
3209
+
3210
+ ## Interactive Features
3211
+
3212
+ | Operation | Description | Effect |
3213
+ |-----------|-------------|--------|
3214
+ | 🖱️ **Drag & Move** | Drag entire task bar | Modify task start and end dates |
3215
+ | 📏 **Resize** | Drag task bar left/right edges | Adjust task duration |
3216
+ | 📊 **Progress Adjust** | Drag triangle slider at bottom of task bar | Adjust task completion progress |
3217
+
3218
+ ### Task Bar Operations
3219
+
3220
+ - **Drag & Move** - Drag task bar to modify start and end dates
3221
+ - **Resize** - Drag task bar left/right edges to adjust duration
3222
+ - **Progress Adjust** - Drag triangle slider at bottom to adjust progress
3223
+
3224
+ ### Parent-Child Task Linkage
3225
+
3226
+ - Moving parent tasks causes child tasks to move along
3227
+ - Resizing parent tasks checks child task constraints
3228
+ - Child tasks cannot start before parent tasks
3229
+
3230
+ ### Quick Operations
3231
+
3232
+ - Click the **+** button in the top left to add root tasks
3233
+ - Click the calendar icon to jump to today
3234
+ - Right-click task rows to add subtasks, edit, or delete
3235
+
3236
+ ## Link Configuration
3237
+
3238
+ ### Link Styles
3239
+
3240
+ ```typescript
3241
+ interface LinkConfig {
3242
+ color: string; // Link color
3243
+ width: number; // Link width
3244
+ dashArray?: string; // Dash style
3245
+ showArrow: boolean; // Show arrow
3246
+ arrowSize: number; // Arrow size
3247
+ showLabels: boolean; // Show labels
3248
+ pathType: LinkPathType; // Path type
3249
+ cornerRadius: number; // Corner radius
3250
+ smoothCorners: boolean; // Smooth corners
3251
+ }
3252
+ ```
3253
+
3254
+ ### Path Types
3255
+
3256
+ ```
3257
+ Straight Bezier Curve Right Angle
3258
+ ┌─────┐ ┌─────┐ ┌─────┐
3259
+ │Task A│ ────────▶│Task A│ ╭───────▶ │Task A│ ┐
3260
+ └─────┘ └─────┘ ╰─┐ └─────┘ │
3261
+ │ │
3262
+ ┌─────┐ ┌─────┐
3263
+ │Task B│ │Task B│
3264
+ └─────┘ └─────┘
3265
+ ```
3266
+
3267
+ | Type | Enum | Description |
3268
+ |------|------|-------------|
3269
+ | Straight | STRAIGHT | Direct connection |
3270
+ | Bezier Curve | BEZIER | Smooth curve |
3271
+ | Right Angle | RIGHT_ANGLE | Right-angle connection |
3272
+
3273
+ ## Performance Optimization
3274
+
3275
+ The component includes multiple performance optimizations:
3276
+
3277
+ - **Virtual Scrolling** - Only render tasks in the visible area
3278
+ - **Throttled Updates** - Use throttling to avoid frequent re-renders when data changes
3279
+ - **Cached Calculations** - Use computed to cache complex calculation results
3280
+ - **On-Demand Rendering** - Calculate and render elements like links on demand
3281
+
3282
+ ## Project Structure
3283
+
3284
+ ```
3285
+ src/
3286
+ ├── components/
3287
+ │ ├── CustomFieldsDialog.vue # Custom fields dialog
3288
+ │ ├── DeleteConfirmDialog.vue # Delete confirmation dialog
3289
+ │ ├── MessageToast.vue # Message toast component
3290
+ │ ├── TaskDialog.vue # Task editing dialog
3291
+ │ └── gantt/
3292
+ │ ├── composables/ # Gantt composables
3293
+ │ │ ├── LinkConfig.ts
3294
+ │ │ ├── PerformanceConfig.ts
3295
+ │ │ ├── useHorizontalVirtualScroll.ts
3296
+ │ │ └── useVirtualScroll.ts
3297
+ │ ├── config/ # Configuration panel components
3298
+ │ │ ├── CheckboxConfig.vue
3299
+ │ │ ├── ColorInput.vue
3300
+ │ │ ├── ColumnConfigPanel.vue
3301
+ │ │ ├── ConfigSection.vue
3302
+ │ │ ├── DatePicker.vue
3303
+ │ │ ├── GanttConfigPanel.vue
3304
+ │ │ ├── GanttThemeSelector.vue
3305
+ │ │ ├── LanguageSelector.vue
3306
+ │ │ ├── LinkConfigPanel.vue
3307
+ │ │ ├── LinkTypeColorConfig.vue
3308
+ │ │ ├── PathTypeSelector.vue
3309
+ │ │ ├── SliderInput.vue
3310
+ │ │ └── ThemeSelector.vue
3311
+ │ ├── core/ # Core components
3312
+ │ │ ├── Gantt.vue # Main component
3313
+ │ │ └── SplitPane.vue # Split panel
3314
+ │ ├── gantt.css # Gantt styles
3315
+ │ ├── i18n/ # Internationalization system
3316
+ │ │ ├── index.ts # i18n core
3317
+ │ │ └── locales/ # Language packs
3318
+ │ │ ├── zh-CN.ts # Chinese language pack
3319
+ │ │ ├── zh-TW.ts # Traditional Chinese language pack
3320
+ │ │ ├── en-US.ts # English language pack
3321
+ │ │ ├── ja-JP.ts # Japanese language pack
3322
+ │ │ ├── ko-KR.ts # Korean language pack
3323
+ │ │ ├── fr-FR.ts # French language pack
3324
+ │ │ ├── de-DE.ts # German language pack
3325
+ │ │ ├── es-ES.ts # Spanish language pack
3326
+ │ │ └── ru-RU.ts # Russian language pack
3327
+ │ ├── links/ # Link components
3328
+ │ │ └── TaskLinks.vue # Task links
3329
+ │ ├── state/ # State management
3330
+ │ │ ├── ShareState.ts # Shared state
3331
+ │ │ ├── Store.ts # State store
3332
+ │ │ └── Symbols.ts # Injection symbols
3333
+ │ ├── task/ # Task-related components
3334
+ │ │ ├── TaskTable.vue # Task table
3335
+ │ │ ├── TaskHeader.vue # Task header
3336
+ │ │ ├── TaskContent.vue # Task content
3337
+ │ │ ├── TaskRow.vue # Task row
3338
+ │ │ └── TaskRecursionRow.vue # Recursive task row
3339
+ │ ├── themes/ # Theme configuration
3340
+ │ │ ├── GanttThemes.ts # Theme definitions
3341
+ │ │ └── LiquidGlass.css # Liquid glass theme
3342
+ │ ├── timeline/ # Timeline components
3343
+ │ │ ├── Bar.vue # Task bar
3344
+ │ │ ├── BarRecursionRow.vue # Recursive task bar
3345
+ │ │ ├── Milestone.vue # Milestone
3346
+ │ │ ├── RightTable.vue # Right Gantt chart area
3347
+ │ │ ├── TableContent.vue # Table content
3348
+ │ │ ├── TimelineHeader.vue # Timeline header
3349
+ │ │ ├── composables/ # Timeline composables
3350
+ │ │ │ ├── useBarGeometry.ts
3351
+ │ │ │ ├── useBarTheme.ts
3352
+ │ │ │ ├── useHover.ts
3353
+ │ │ │ ├── useInteractions.ts
3354
+ │ │ │ └── useProgress.ts
3355
+ │ │ └── utils/ # Utility functions
3356
+ │ │ └── dateCalc.ts
3357
+ │ └── types/ # Type definitions
3358
+ │ ├── Types.ts # Gantt types
3359
+ │ └── ZodSchema.ts # Data validation
3360
+ ├── composables/ # Global composables
3361
+ │ ├── useCustomFields.ts # Custom fields
3362
+ │ ├── useMessage.ts # Message toast
3363
+ │ └── useTaskManagement.ts # Task management
3364
+ ├── mock/ # Mock data
3365
+ │ └── mockData.ts # Sample data
3366
+ ├── services/ # Service layer
3367
+ │ └── taskApi.ts # Task API
3368
+ ├── styles/ # Global styles
3369
+ │ └── dialog-common.css # Dialog common styles
3370
+ ├── types/ # Type definitions
3371
+ │ └── task.ts # Task types
3372
+ ├── App.vue # Example application
3373
+ ├── index.ts # Export entry
3374
+ ├── main.ts # Application entry
3375
+ ├── style.css # Global styles
3376
+ └── vite-env.d.ts # Vite environment types
3377
+ ```
3378
+
3379
+ ## Complete Example
3380
+
3381
+ Refer to `src/App.vue` for a complete usage example, including:
3382
+
3383
+ - Multi-level task structure
3384
+ - Various dependency configurations
3385
+ - Custom color mapping
3386
+ - Event handling
3387
+ - Internationalization integration
3388
+
3389
+ ## Browser Support
3390
+
3391
+ - Chrome (Recommended)
3392
+ - Firefox
3393
+ - Safari
3394
+ - Edge
875
3395
 
876
3396
  ## License
877
3397