@lee576/vue3-gantt 1.0.7 → 1.0.9

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.en-US.md CHANGED
@@ -48,11 +48,12 @@ A feature-rich, highly customizable Vue 3 Gantt chart component that supports ta
48
48
  ## ✨ Core Features
49
49
 
50
50
  ### 📅 Multiple View Modes
51
- Four time granularities for different scenarios:
51
+ Five time granularities for different scenarios:
52
+ - **Quarter View** - Ultra-long-term project planning, displayed by month
52
53
  - **Month View** - Long-term project planning, displayed by day
53
54
  - **Week View** - Medium-term project tracking, displayed by week
54
- - **Day View** - Short-term task management, precise to day
55
- - **Hour View** - Fine task scheduling, displayed by hour
55
+ - **Day View** - Short-term task management, supports full day/half day sub-modes
56
+ - **Hour View** - Fine task scheduling, supports hour/30min/15min sub-modes
56
57
 
57
58
  ### 🔗 Task Dependency Management
58
59
  - **Finish-to-Start (FS)** - Successor task starts after predecessor finishes
@@ -91,6 +92,37 @@ Four time granularities for different scenarios:
91
92
  - Cached computations, improves response speed
92
93
  - On-demand link rendering, optimized drawing performance
93
94
 
95
+ ### 📝 Custom Fields
96
+ - **Multiple Field Types** - Supports text, number, date, dropdown selection field types
97
+ - **Flexible Configuration** - Add any number of custom fields to tasks
98
+ - **Form Validation** - Built-in field validation rules ensure data validity
99
+ - **Local Storage** - Field configuration automatically saved to browser, persists after refresh
100
+ - **Dynamic Management** - Add, edit, delete custom fields at runtime
101
+
102
+ ### 💬 Message Toast
103
+ - **Three Alert Types** - Success, error, warning for different scenarios
104
+ - **Auto Dismiss** - Messages automatically disappear without manual closing
105
+ - **Elegant Animation** - Smooth enter and exit animation effects
106
+ - **Multi-language Support** - Alert text automatically switches with language settings
107
+
108
+ ### 🗑️ Delete Confirmation
109
+ - **Safe Deletion** - Confirmation dialog before task deletion prevents accidental operations
110
+ - **Cascade Delete** - When deleting parent task, automatically prompts that all subtasks will be deleted
111
+ - **Friendly Prompts** - Clear warning messages inform users about deletion impact scope
112
+
113
+ ### 🎛️ Configuration Panels
114
+ - **Link Style Configuration** - Customize task link path type, color, width, dashed style, arrow settings
115
+ - **Parent-Child Relationship Style** - Configure parent-child task connection line styles
116
+ - **Column Display Settings** - Flexibly control task list column show/hide
117
+ - **One-click Reset** - Quickly restore default configuration
118
+
119
+ ### 🌲 Tree Task Structure
120
+ - **Hierarchy Display** - Clear tree structure showing task parent-child relationships
121
+ - **Collapse/Expand** - Support collapsing/expanding subtasks to simplify view
122
+ - **Connection Lines** - Visual connection lines showing hierarchy relationships
123
+ - **Quick Operations** - Inline buttons for quickly adding/deleting subtasks
124
+ - **Hover Highlight** - Mouse hover highlights current task row
125
+
94
126
  ## 🚀 Installation
95
127
 
96
128
  ### Option 1: Install via npm (Recommended)
@@ -458,19 +490,36 @@ dependencies: [
458
490
 
459
491
  | Mode | Time Unit | Header Example | Use Case |
460
492
  |------|-----------|----------------|----------|
493
+ | 📆 **Quarter** | Month | `2024-Q1 2024-Q2 2024-Q3 ...` | Ultra long-term project planning |
461
494
  | 🗓️ **Month** | Day | `01 02 03 04 05 ...` | Long-term project planning |
462
495
  | 📅 **Day** | Day | `Mon Tue Wed ...` | Short-term task management |
463
496
  | 📊 **Week** | Week | `W50 W51 W52 ...` | Mid-term project tracking |
464
497
  | ⏰ **Hour** | Hour | `08 09 10 11 12 ...` | Precise task scheduling |
465
498
 
466
- The component supports four time granularity views:
499
+ The component supports five time granularity views:
500
+
501
+ | Mode | Description | Sub-modes | Use Case |
502
+ |------|-------------|-----------|----------|
503
+ | Quarter | Display by month, quarter unit | - | Ultra long-term project planning |
504
+ | Month | Display by day, month unit | - | Long-term project planning |
505
+ | Day | Display by day, precise to day | Full day / Half day | Short-term task management |
506
+ | Week | Display by week | - | Mid-term project tracking |
507
+ | Hour | Display by hour | Hour / 30min / 15min | Precise task scheduling |
508
+
509
+ ### View Mode Switching
510
+
511
+ The component provides view mode switching buttons at the top. Click to switch between different view modes.
512
+
513
+ ### Sub-mode Details
514
+
515
+ **Day View Sub-modes:**
516
+ - **Full day** - Each day displays as a complete time segment
517
+ - **Half day** - Each day is divided into morning and afternoon time segments
467
518
 
468
- | Mode | Description | Use Case |
469
- |------|-------------|----------|
470
- | Month | Display by day, month unit | Long-term project planning |
471
- | Day | Display by day, precise to day | Short-term task management |
472
- | Week | Display by week | Mid-term project tracking |
473
- | Hour | Display by hour | Precise task scheduling |
519
+ **Hour View Sub-modes:**
520
+ - **Hour** - Each hour displays as a time segment
521
+ - **30min** - Each hour is divided into two 30-minute segments
522
+ - **15min** - Each hour is divided into four 15-minute segments
474
523
 
475
524
  ## Theme System
476
525
 
@@ -481,6 +530,8 @@ The component supports four time granularity views:
481
530
  | ✨ **Modern** | `#6366f1` | Clean modern design, refreshing and comfortable |
482
531
  | 💼 **Classic** | `#2563eb` | Traditional business style, stable and dignified |
483
532
  | 🎨 **Colorful** | `#f59e0b` | Vibrant colorful theme, full of vitality |
533
+ | 🍎 **Apple** | `#007aff` | Minimalist elegant macOS style, smooth and natural |
534
+ | 💧 **Liquid Glass** | `#007aff` | iOS 26 liquid glass effect, translucent flowing texture |
484
535
 
485
536
  ### Built-in Themes
486
537
 
@@ -491,6 +542,8 @@ The component supports four time granularity views:
491
542
  | modern | Modern | Clean modern design |
492
543
  | classic | Classic | Traditional business style |
493
544
  | colorful | Colorful | Vibrant colorful theme |
545
+ | apple | Apple | Minimalist elegant macOS style |
546
+ | liquidGlass | Liquid Glass | iOS 26 liquid glass effect |
494
547
 
495
548
  ### Switching Themes
496
549
 
@@ -514,9 +567,911 @@ A theme selector is provided in the top right corner of the component. Click to
514
567
  }
515
568
  ```
516
569
 
517
- ## Internationalization Support
570
+ ## Custom Fields
571
+
572
+ The component supports powerful custom field functionality, allowing you to add any number of custom fields to tasks to meet different project personalization needs.
573
+
574
+ ### Features
575
+
576
+ - **Multiple Field Types** - Text, number, date, dropdown selection
577
+ - **Dynamic Management** - Add, edit, delete fields at runtime
578
+ - **Form Validation** - Built-in validation rules ensure data validity
579
+ - **Local Storage** - Field configuration automatically saved to browser
580
+ - **Task Binding** - Custom field values associated with task data
581
+
582
+ ### Field Types
583
+
584
+ | Type | Description | Example Value |
585
+ |------|-------------|---------------|
586
+ | Text | Single-line text input | "Project ID: PRJ-001" |
587
+ | Number | Numeric input, supports decimals | 100.5 |
588
+ | Date | Date picker | "2024-12-01" |
589
+ | Dropdown | Predefined option list | "High Priority" |
590
+
591
+ ### Usage
592
+
593
+ #### 1. Open Custom Field Management
594
+
595
+ Click the "Custom Fields" button in the Gantt chart toolbar to open the field management dialog.
596
+
597
+ #### 2. Add Custom Field
598
+
599
+ ```typescript
600
+ // Example: Add an "Owner" field
601
+ const customField = {
602
+ id: 'field-1',
603
+ name: 'Owner',
604
+ type: 'text', // text | number | date | select
605
+ required: false, // Whether required
606
+ options: [] // Options for dropdown selection
607
+ };
608
+ ```
609
+
610
+ #### 3. Use Custom Fields in Tasks
611
+
612
+ Custom field values are stored in the task's `customFieldValues` field:
613
+
614
+ ```typescript
615
+ {
616
+ id: '1',
617
+ taskNo: 'Project Planning',
618
+ start_date: '2024-12-01',
619
+ end_date: '2024-12-06',
620
+ job_progress: '0.85',
621
+ customFieldValues: {
622
+ 'field-1': 'John Doe', // Owner
623
+ 'field-2': '100', // Budget
624
+ 'field-3': '2024-11-30', // Approval Date
625
+ 'field-4': 'High Priority' // Priority
626
+ }
627
+ }
628
+ ```
629
+
630
+ #### 4. Dropdown Field Configuration
631
+
632
+ ```typescript
633
+ const priorityField = {
634
+ id: 'field-priority',
635
+ name: 'Priority',
636
+ type: 'select',
637
+ required: true,
638
+ options: [
639
+ { label: 'Urgent', value: 'urgent' },
640
+ { label: 'Important', value: 'important' },
641
+ { label: 'Normal', value: 'normal' }
642
+ ]
643
+ };
644
+ ```
645
+
646
+ ### Field Validation
647
+
648
+ The component includes basic field validation rules:
649
+
650
+ - **Required Fields** - If field is marked as `required: true`, a value must be provided
651
+ - **Number Validation** - Number fields only accept valid numeric values
652
+ - **Date Validation** - Date fields only accept valid date formats
653
+ - **Option Validation** - Dropdown fields only accept predefined option values
654
+
655
+ ### API Integration
656
+
657
+ #### Backend Storage Format
658
+
659
+ Custom field values need to be stored in the backend in a specific format:
660
+
661
+ ```typescript
662
+ // Recommended format: JSON string
663
+ customFieldValues: JSON.stringify({
664
+ 'field-1': 'John Doe',
665
+ 'field-2': '100'
666
+ })
667
+
668
+ // Or array format (requires backend support)
669
+ customFieldValues: [
670
+ { fieldId: 'field-1', value: 'John Doe' },
671
+ { fieldId: 'field-2', value: '100' }
672
+ ]
673
+ ```
674
+
675
+ #### Data Processing Example
676
+
677
+ ```typescript
678
+ // When saving task
679
+ const saveTask = async (task) => {
680
+ const payload = {
681
+ ...task,
682
+ customFieldValues: JSON.stringify(task.customFieldValues)
683
+ };
684
+ await api.saveTask(payload);
685
+ };
686
+
687
+ // When loading task
688
+ const loadTask = async (taskId) => {
689
+ const data = await api.getTask(taskId);
690
+ return {
691
+ ...data,
692
+ customFieldValues: JSON.parse(data.customFieldValues || '{}')
693
+ };
694
+ };
695
+ ```
696
+
697
+ ### Best Practices
698
+
699
+ 1. **Field Naming** - Use clear, concise field names for easy understanding
700
+ 2. **Required Settings** - Reasonably set required fields to avoid over-restriction
701
+ 3. **Option Management** - Provide complete option lists for dropdown fields
702
+ 4. **Data Validation** - Also validate fields in backend to ensure data integrity
703
+ 5. **Performance Optimization** - Avoid adding too many custom fields that affect performance
704
+
705
+ ## Configuration Panels
706
+
707
+ The component provides two powerful configuration panels for customizing Gantt chart display and behavior.
708
+
709
+ ### Gantt Configuration Panel
710
+
711
+ Access via the "Gantt Config" button in the toolbar.
712
+
713
+ #### Language Settings
714
+
715
+ - **Language Selection** - Switch between Chinese (zh-CN) and English (en-US)
716
+ - **Auto-detection** - Automatically detects browser language on first load
717
+
718
+ #### Theme Settings
719
+
720
+ - **Light/Dark Mode** - Switch between light and dark themes
721
+ - **Theme Persistence** - Theme preference saved to local storage
722
+
723
+ #### Dependency Line Styles
724
+
725
+ Configure task dependency line appearance:
726
+
727
+ ```typescript
728
+ {
729
+ pathType: 'straight', // Connection path type: straight | curved
730
+ color: '#409EFF', // Line color
731
+ width: 2, // Line width (px)
732
+ dashed: false, // Whether to use dashed line
733
+ showArrow: true, // Whether to show arrow
734
+ arrowSize: 6 // Arrow size (px)
735
+ }
736
+ ```
737
+
738
+ **Path Types:**
739
+ - **Straight** - Direct straight line connection
740
+ - **Curved** - Smooth curved line connection
741
+
742
+ **Style Options:**
743
+ - **Color** - Supports any valid CSS color value
744
+ - **Width** - 1-5px recommended
745
+ - **Dashed** - Creates dashed line effect
746
+ - **Arrow** - Shows direction indicator at end point
747
+
748
+ ### Column Configuration Panel
749
+
750
+ Access via the "Column Config" button in the toolbar.
751
+
752
+ #### Column Display Settings
753
+
754
+ Control which columns are visible in the task list:
755
+
756
+ ```typescript
757
+ const columns = [
758
+ { key: 'taskNo', label: 'Task Name', visible: true },
759
+ { key: 'start_date', label: 'Start Date', visible: true },
760
+ { key: 'end_date', label: 'End Date', visible: true },
761
+ { key: 'job_progress', label: 'Progress', visible: true },
762
+ { key: 'duration', label: 'Duration', visible: false }
763
+ ];
764
+ ```
765
+
766
+ #### Column Operations
767
+
768
+ - **Toggle Visibility** - Click checkbox to show/hide column
769
+ - **Show All** - Display all columns at once
770
+ - **Hide All** - Hide all columns at once
771
+ - **Reset Default** - Restore to default column configuration
772
+
773
+ #### Column Types
774
+
775
+ | Column Key | Description | Format |
776
+ |------------|-------------|--------|
777
+ | taskNo | Task name | Text |
778
+ | start_date | Start date | YYYY-MM-DD |
779
+ | end_date | End date | YYYY-MM-DD |
780
+ | job_progress | Progress percentage | 0-100% |
781
+ | duration | Task duration | Number (days) |
782
+
783
+ ### Configuration Persistence
784
+
785
+ All configuration settings are automatically saved to browser local storage:
786
+
787
+ ```typescript
788
+ // Storage keys
789
+ const CONFIG_KEYS = {
790
+ ganttConfig: 'vue3-gantt-config', // Gantt chart settings
791
+ columnConfig: 'vue3-gantt-columns', // Column display settings
792
+ customFields: 'vue3-gantt-fields' // Custom field definitions
793
+ };
794
+ ```
795
+
796
+ **Benefits:**
797
+ - Settings persist across page refreshes
798
+ - Configuration shared across browser sessions
799
+ - Easy to reset to defaults if needed
800
+
801
+ ### Best Practices
802
+
803
+ 1. **Line Visibility** - Use contrasting colors for dependency lines
804
+ 2. **Column Balance** - Don't show too many columns at once
805
+ 3. **Theme Consistency** - Match Gantt chart theme with application theme
806
+ 4. **Performance** - Complex line styles may impact performance with many tasks
807
+
808
+ ## Task Dialog
809
+
810
+ The task dialog provides a comprehensive interface for creating and editing tasks with rich features.
811
+
812
+ ### Dialog Features
813
+
814
+ - **Dual Mode** - Create new task or edit existing task
815
+ - **Form Validation** - Real-time validation with error messages
816
+ - **Custom Fields** - Support for dynamic custom field inputs
817
+ - **Date Constraints** - Automatic date validation and adjustment
818
+ - **Progress Control** - Visual progress slider with percentage display
819
+
820
+ ### Basic Fields
821
+
822
+ #### Task Name
823
+
824
+ ```typescript
825
+ {
826
+ taskNo: 'Project Planning', // Required, max length 200
827
+ name: 'Project Planning' // Display name (optional)
828
+ }
829
+ ```
830
+
831
+ - **Required** - Yes
832
+ - **Max Length** - 200 characters
833
+ - **Validation** - Cannot be empty
834
+
835
+ #### Date Range
836
+
837
+ ```typescript
838
+ {
839
+ start_date: '2024-12-01', // Start date
840
+ end_date: '2024-12-06' // End date
841
+ }
842
+ ```
843
+
844
+ **Features:**
845
+ - **Date Picker** - Built-in date picker for easy selection
846
+ - **Auto-adjustment** - End date automatically adjusted if before start date
847
+ - **Format** - YYYY-MM-DD
848
+ - **Validation** - End date must be >= start date
849
+
850
+ #### Progress
851
+
852
+ ```typescript
853
+ {
854
+ job_progress: '0.85' // Progress value (0-1)
855
+ }
856
+ ```
857
+
858
+ **Features:**
859
+ - **Slider Control** - Visual slider for easy adjustment
860
+ - **Percentage Display** - Shows progress as percentage (0-100%)
861
+ - **Decimal Support** - Supports decimal values (e.g., 0.5 = 50%)
862
+ - **Validation** - Must be between 0 and 1
863
+
864
+ ### Custom Fields Section
865
+
866
+ The dialog dynamically renders custom fields based on configuration:
867
+
868
+ ```typescript
869
+ // Example custom fields in dialog
870
+ const customFields = [
871
+ {
872
+ id: 'field-1',
873
+ name: 'Owner',
874
+ type: 'text',
875
+ value: 'John Doe'
876
+ },
877
+ {
878
+ id: 'field-2',
879
+ name: 'Budget',
880
+ type: 'number',
881
+ value: '10000'
882
+ },
883
+ {
884
+ id: 'field-3',
885
+ name: 'Priority',
886
+ type: 'select',
887
+ options: [
888
+ { label: 'High', value: 'high' },
889
+ { label: 'Medium', value: 'medium' },
890
+ { label: 'Low', value: 'low' }
891
+ ],
892
+ value: 'high'
893
+ }
894
+ ];
895
+ ```
896
+
897
+ **Field Types:**
898
+ - **Text Input** - Single-line text field
899
+ - **Number Input** - Numeric field with validation
900
+ - **Date Picker** - Date selection field
901
+ - **Dropdown** - Select from predefined options
902
+
903
+ ### Form Validation
904
+
905
+ The dialog implements comprehensive validation:
906
+
907
+ ```typescript
908
+ // Validation rules
909
+ const rules = {
910
+ taskNo: [
911
+ { required: true, message: 'Task name is required' },
912
+ { max: 200, message: 'Task name cannot exceed 200 characters' }
913
+ ],
914
+ start_date: [
915
+ { required: true, message: 'Start date is required' }
916
+ ],
917
+ end_date: [
918
+ { required: true, message: 'End date is required' },
919
+ {
920
+ validator: (rule, value, callback) => {
921
+ if (value < start_date) {
922
+ callback(new Error('End date must be after start date'));
923
+ } else {
924
+ callback();
925
+ }
926
+ }
927
+ }
928
+ ]
929
+ };
930
+ ```
931
+
932
+ **Validation Types:**
933
+ - **Required Fields** - Ensures mandatory fields are filled
934
+ - **Format Validation** - Validates date and number formats
935
+ - **Business Rules** - Enforces logical constraints (e.g., end >= start)
936
+ - **Custom Field Validation** - Validates based on field type and requirements
937
+
938
+ ### Dialog Actions
939
+
940
+ #### Save Button
941
+
942
+ - Validates all fields before saving
943
+ - Shows error messages if validation fails
944
+ - Emits save event with task data
945
+ - Closes dialog on successful save
946
+
947
+ #### Cancel Button
948
+
949
+ - Closes dialog without saving
950
+ - Discards any unsaved changes
951
+ - No confirmation required
952
+
953
+ ### Best Practices
954
+
955
+ 1. **Clear Naming** - Use descriptive task names
956
+ 2. **Date Planning** - Set realistic date ranges
957
+ 3. **Progress Updates** - Regularly update progress values
958
+ 4. **Custom Fields** - Use custom fields for project-specific data
959
+ 5. **Validation** - Pay attention to validation messages
960
+
961
+ ## Message Toast
962
+
963
+ The component includes a built-in message toast system for providing user feedback.
964
+
965
+ ### Message Types
966
+
967
+ Three types of messages are supported:
968
+
969
+ | Type | Icon | Color | Usage |
970
+ |------|------|-------|-------|
971
+ | Success | ✓ | Green | Successful operations (save, delete, etc.) |
972
+ | Error | ✗ | Red | Failed operations (validation errors, API errors) |
973
+ | Warning | ⚠ | Orange | Warnings (unsaved changes, potential issues) |
974
+
975
+ ### Usage
976
+
977
+ #### Display Success Message
978
+
979
+ ```typescript
980
+ // In component
981
+ import { useMessage } from '@/composables/useMessage';
982
+
983
+ const { showMessage } = useMessage();
984
+
985
+ // Show success message
986
+ showMessage('Task saved successfully', 'success');
987
+ ```
988
+
989
+ #### Display Error Message
990
+
991
+ ```typescript
992
+ // Show error message
993
+ showMessage('Failed to save task: Invalid data', 'error');
994
+ ```
995
+
996
+ #### Display Warning Message
997
+
998
+ ```typescript
999
+ // Show warning message
1000
+ showMessage('Unsaved changes will be lost', 'warning');
1001
+ ```
1002
+
1003
+ ### Message Behavior
1004
+
1005
+ **Auto-dismissal:**
1006
+ - Success messages: 3 seconds
1007
+ - Error messages: 5 seconds
1008
+ - Warning messages: 4 seconds
1009
+
1010
+ **Manual Dismissal:**
1011
+ - Click message to dismiss immediately
1012
+ - Hover to pause auto-dismissal timer
1013
+
1014
+ **Positioning:**
1015
+ - Top-right corner of screen
1016
+ - Stacked vertically for multiple messages
1017
+ - Maximum 3 messages displayed simultaneously
1018
+
1019
+ ### Message Queue
1020
+
1021
+ The toast system manages a message queue:
1022
+
1023
+ ```typescript
1024
+ // Message queue properties
1025
+ interface Message {
1026
+ id: string; // Unique message ID
1027
+ type: 'success' | 'error' | 'warning';
1028
+ content: string; // Message text
1029
+ duration: number; // Display duration (ms)
1030
+ timestamp: number; // Creation timestamp
1031
+ }
1032
+ ```
1033
+
1034
+ **Queue Management:**
1035
+ - New messages added to end of queue
1036
+ - Oldest messages dismissed first
1037
+ - Prevents duplicate messages
1038
+
1039
+ ### Styling
1040
+
1041
+ Messages are styled according to type:
1042
+
1043
+ ```css
1044
+ /* Success message */
1045
+ .message-success {
1046
+ background: #f0f9ff;
1047
+ border-left: 4px solid #67c23a;
1048
+ color: #67c23a;
1049
+ }
1050
+
1051
+ /* Error message */
1052
+ .message-error {
1053
+ background: #fef0f0;
1054
+ border-left: 4px solid #f56c6c;
1055
+ color: #f56c6c;
1056
+ }
1057
+
1058
+ /* Warning message */
1059
+ .message-warning {
1060
+ background: #fdf6ec;
1061
+ border-left: 4px solid #e6a23c;
1062
+ color: #e6a23c;
1063
+ }
1064
+ ```
1065
+
1066
+ ### Best Practices
1067
+
1068
+ 1. **Clear Messages** - Use clear, concise message text
1069
+ 2. **Appropriate Types** - Choose correct message type for situation
1070
+ 3. **User Feedback** - Provide feedback for all user actions
1071
+ 4. **Error Details** - Include helpful information in error messages
1072
+ 5. **Avoid Spam** - Don't show too many messages in short time
1073
+
1074
+ ## Delete Confirmation Dialog
1075
+
1076
+ The delete confirmation dialog ensures safe task deletion with clear warnings and options.
1077
+
1078
+ ### Dialog Features
1079
+
1080
+ - **Warning Display** - Shows clear warning about deletion consequences
1081
+ - **Cascade Warning** - Informs about child task deletion
1082
+ - **Confirmation Required** - Prevents accidental deletions
1083
+ - **Action Buttons** - Clear confirm and cancel options
1084
+
1085
+ ### Dialog Content
1086
+
1087
+ #### Warning Message
1088
+
1089
+ ```
1090
+ ⚠️ Warning: You are about to delete this task
1091
+ ```
1092
+
1093
+ #### Cascade Warning (for parent tasks)
1094
+
1095
+ ```
1096
+ Note: This will also delete all child tasks under this task.
1097
+ Are you sure you want to continue?
1098
+ ```
1099
+
1100
+ #### Confirmation Question
1101
+
1102
+ ```
1103
+ Are you sure you want to delete this task?
1104
+ ```
1105
+
1106
+ ### Dialog Actions
1107
+
1108
+ #### Confirm Button
1109
+
1110
+ - **Text** - "Confirm" or "Delete"
1111
+ - **Style** - Red/danger color to indicate destructive action
1112
+ - **Action** - Deletes task and all child tasks (if any)
1113
+ - **Feedback** - Shows success message after deletion
1114
+
1115
+ #### Cancel Button
1116
+
1117
+ - **Text** - "Cancel"
1118
+ - **Style** - Gray/neutral color
1119
+ - **Action** - Closes dialog without deleting
1120
+ - **Feedback** - No action taken
1121
+
1122
+ ### Deletion Behavior
1123
+
1124
+ #### Simple Task Deletion
1125
+
1126
+ When deleting a task without children:
1127
+
1128
+ ```typescript
1129
+ // Single task deletion
1130
+ const deleteTask = (taskId: string) => {
1131
+ // 1. Show confirmation dialog
1132
+ // 2. User confirms
1133
+ // 3. Delete task from data
1134
+ // 4. Show success message
1135
+ // 5. Update UI
1136
+ };
1137
+ ```
1138
+
1139
+ #### Parent Task Deletion
1140
+
1141
+ When deleting a task with children:
1142
+
1143
+ ```typescript
1144
+ // Parent task with children
1145
+ const deleteTaskWithChildren = (taskId: string) => {
1146
+ // 1. Show confirmation dialog with cascade warning
1147
+ // 2. User confirms
1148
+ // 3. Delete all child tasks recursively
1149
+ // 4. Delete parent task
1150
+ // 5. Show success message
1151
+ // 6. Update UI
1152
+ };
1153
+ ```
1154
+
1155
+ **Cascade Deletion:**
1156
+ - All child tasks are deleted
1157
+ - Child tasks' children are also deleted
1158
+ - Entire subtree is removed from data
1159
+
1160
+ ### Safety Features
1161
+
1162
+ #### Double Confirmation
1163
+
1164
+ For critical deletions, the dialog may require additional confirmation:
1165
+
1166
+ ```typescript
1167
+ // Example: Delete task with many children
1168
+ if (childCount > 10) {
1169
+ // Show additional confirmation step
1170
+ const confirmed = await showDoubleConfirmation();
1171
+ if (!confirmed) return;
1172
+ }
1173
+ ```
1174
+
1175
+ #### Undo Support (Optional)
1176
+
1177
+ The component can be extended to support undo:
1178
+
1179
+ ```typescript
1180
+ // Store deleted tasks for potential undo
1181
+ const deletedTasks = [];
1182
+
1183
+ const deleteTask = (task) => {
1184
+ // Save task before deletion
1185
+ deletedTasks.push({
1186
+ task: task,
1187
+ timestamp: Date.now()
1188
+ });
1189
+
1190
+ // Perform deletion
1191
+ performDeletion(task.id);
1192
+ };
1193
+
1194
+ const undoDelete = () => {
1195
+ const lastDeleted = deletedTasks.pop();
1196
+ if (lastDeleted) {
1197
+ restoreTask(lastDeleted.task);
1198
+ }
1199
+ };
1200
+ ```
1201
+
1202
+ ### Best Practices
1203
+
1204
+ 1. **Clear Warnings** - Always show clear warnings before deletion
1205
+ 2. **Cascade Info** - Inform users about child task deletion
1206
+ 3. **Confirmation** - Always require confirmation for deletion
1207
+ 4. **Feedback** - Show success message after deletion
1208
+ 5. **Recovery** - Consider implementing undo functionality
1209
+
1210
+ ## Tree Task Structure
1211
+
1212
+ The component supports hierarchical task tree structure with rich visualization and interaction features.
1213
+
1214
+ ### Core Features
1215
+
1216
+ - **Multi-level Hierarchy** - Support unlimited task nesting levels
1217
+ - **Visual Indentation** - Clear visual representation of task hierarchy
1218
+ - **Connection Lines** - Tree-style connection lines between parent and child tasks
1219
+ - **Expand/Collapse** - Interactive expand/collapse for parent tasks
1220
+ - **Task Numbering** - Hierarchical task numbering (1, 1.1, 1.1.1, etc.)
1221
+ - **Inline Operations** - Add/delete child tasks directly from task row
1222
+
1223
+ ### Task Hierarchy Structure
1224
+
1225
+ Tasks can be organized in a tree structure:
1226
+
1227
+ ```typescript
1228
+ // Example task hierarchy
1229
+ const tasks = [
1230
+ {
1231
+ id: '1',
1232
+ taskNo: 'Project Phase 1',
1233
+ level: 0, // Root level
1234
+ children: [
1235
+ {
1236
+ id: '1-1',
1237
+ taskNo: 'Task 1.1',
1238
+ level: 1, // First level child
1239
+ children: [
1240
+ {
1241
+ id: '1-1-1',
1242
+ taskNo: 'Task 1.1.1',
1243
+ level: 2 // Second level child
1244
+ }
1245
+ ]
1246
+ },
1247
+ {
1248
+ id: '1-2',
1249
+ taskNo: 'Task 1.2',
1250
+ level: 1
1251
+ }
1252
+ ]
1253
+ }
1254
+ ];
1255
+ ```
1256
+
1257
+ **Level Properties:**
1258
+ - `level: 0` - Root task (no parent)
1259
+ - `level: 1` - First level child
1260
+ - `level: 2` - Second level child
1261
+ - And so on...
1262
+
1263
+ ### Visual Elements
1264
+
1265
+ #### Indentation
1266
+
1267
+ Each level of hierarchy is indented by a fixed amount:
1268
+
1269
+ ```css
1270
+ /* Indentation per level */
1271
+ .task-row {
1272
+ padding-left: calc(level * 24px);
1273
+ }
1274
+ ```
1275
+
1276
+ **Visual Effect:**
1277
+ - Level 0: No indentation
1278
+ - Level 1: 24px indentation
1279
+ - Level 2: 48px indentation
1280
+ - Level 3: 72px indentation
1281
+
1282
+ #### Connection Lines
1283
+
1284
+ Tree-style connection lines show parent-child relationships:
1285
+
1286
+ ```
1287
+ ├─ Task 1.0 (parent)
1288
+ │ ├─ Task 1.1 (child)
1289
+ │ │ ├─ Task 1.1.1 (grandchild)
1290
+ │ │ └─ Task 1.1.2 (grandchild)
1291
+ │ └─ Task 1.2 (child)
1292
+ └─ Task 2.0 (parent)
1293
+ ```
1294
+
1295
+ **Line Types:**
1296
+ - **Vertical Line** - Connects parent to children
1297
+ - **Horizontal Line** - Connects to task name
1298
+ - **Corner** - Smooth corner at connection point
1299
+
1300
+ #### Expand/Collapse Icons
1301
+
1302
+ Parent tasks display expand/collapse indicators:
1303
+
1304
+ - **Expanded (▾)** - Shows children, click to collapse
1305
+ - **Collapsed (▸)** - Hides children, click to expand
1306
+ - **Leaf Task** - No icon (no children)
1307
+
1308
+ ### Interaction Operations
1309
+
1310
+ #### Expand/Collapse Tasks
1311
+
1312
+ Click the expand/collapse icon to toggle visibility:
1313
+
1314
+ ```typescript
1315
+ // Expand task
1316
+ const expandTask = (taskId: string) => {
1317
+ const task = findTask(taskId);
1318
+ if (task) {
1319
+ task.expanded = true;
1320
+ // Show all child tasks
1321
+ }
1322
+ };
1323
+
1324
+ // Collapse task
1325
+ const collapseTask = (taskId: string) => {
1326
+ const task = findTask(taskId);
1327
+ if (task) {
1328
+ task.expanded = false;
1329
+ // Hide all child tasks
1330
+ }
1331
+ };
1332
+ ```
1333
+
1334
+ **Keyboard Support:**
1335
+ - `Right Arrow` - Expand task
1336
+ - `Left Arrow` - Collapse task
1337
+
1338
+ #### Add Child Task
1339
+
1340
+ Click the "+" button on a task row to add a child:
1341
+
1342
+ ```typescript
1343
+ const addChildTask = (parentTaskId: string) => {
1344
+ const parentTask = findTask(parentTaskId);
1345
+ if (parentTask) {
1346
+ const newTask = {
1347
+ id: generateId(),
1348
+ taskNo: 'New Task',
1349
+ level: parentTask.level + 1,
1350
+ parentId: parentTaskId
1351
+ };
1352
+ parentTask.children.push(newTask);
1353
+ // Auto-expand parent to show new child
1354
+ parentTask.expanded = true;
1355
+ }
1356
+ };
1357
+ ```
1358
+
1359
+ #### Delete Task
1360
+
1361
+ Click the "×" button to delete a task:
1362
+
1363
+ ```typescript
1364
+ const deleteTask = (taskId: string) => {
1365
+ // Show confirmation dialog
1366
+ const confirmed = showDeleteConfirmation(taskId);
1367
+ if (confirmed) {
1368
+ // Delete task and all children
1369
+ removeTaskAndChildren(taskId);
1370
+ }
1371
+ };
1372
+ ```
1373
+
1374
+ **Cascade Deletion:**
1375
+ - Deleting a parent task deletes all its children
1376
+ - Deleting a child task only deletes that child
1377
+ - Confirmation dialog warns about cascade deletion
1378
+
1379
+ ### Parent-Child Task Linkage
1380
+
1381
+ #### Date Constraints
518
1382
 
519
- The component has a built-in complete internationalization (i18n) system, supporting bilingual switching between Chinese and English, and can easily extend more languages.
1383
+ Child task dates are constrained by parent task dates:
1384
+
1385
+ ```typescript
1386
+ // Child task cannot extend beyond parent
1387
+ const validateChildDates = (child: Task, parent: Task) => {
1388
+ if (child.start_date < parent.start_date) {
1389
+ child.start_date = parent.start_date;
1390
+ }
1391
+ if (child.end_date > parent.end_date) {
1392
+ child.end_date = parent.end_date;
1393
+ }
1394
+ };
1395
+ ```
1396
+
1397
+ **Rules:**
1398
+ - Child start date >= Parent start date
1399
+ - Child end date <= Parent end date
1400
+ - Parent dates automatically adjust if needed
1401
+
1402
+ #### Progress Calculation
1403
+
1404
+ Parent task progress is calculated from children:
1405
+
1406
+ ```typescript
1407
+ // Calculate parent progress from children
1408
+ const calculateParentProgress = (parent: Task) => {
1409
+ if (!parent.children || parent.children.length === 0) {
1410
+ return parent.job_progress;
1411
+ }
1412
+
1413
+ const totalProgress = parent.children.reduce((sum, child) => {
1414
+ return sum + parseFloat(child.job_progress);
1415
+ }, 0);
1416
+
1417
+ return (totalProgress / parent.children.length).toFixed(2);
1418
+ };
1419
+ ```
1420
+
1421
+ **Calculation Method:**
1422
+ - Average of all child task progress
1423
+ - Automatically updates when child progress changes
1424
+ - Can be overridden manually
1425
+
1426
+ ### Style Customization
1427
+
1428
+ #### Indentation Width
1429
+
1430
+ Customize indentation per level:
1431
+
1432
+ ```typescript
1433
+ const config = {
1434
+ indentationWidth: 24 // px per level
1435
+ };
1436
+ ```
1437
+
1438
+ #### Line Styles
1439
+
1440
+ Customize connection line appearance:
1441
+
1442
+ ```css
1443
+ .tree-line {
1444
+ color: #dcdfe6; /* Line color */
1445
+ width: 1px; /* Line width */
1446
+ style: solid; /* Line style */
1447
+ }
1448
+ ```
1449
+
1450
+ #### Icon Styles
1451
+
1452
+ Customize expand/collapse icons:
1453
+
1454
+ ```css
1455
+ .expand-icon {
1456
+ color: #909399; /* Icon color */
1457
+ font-size: 14px; /* Icon size */
1458
+ cursor: pointer; /* Pointer cursor */
1459
+ }
1460
+
1461
+ .expand-icon:hover {
1462
+ color: #409EFF; /* Hover color */
1463
+ }
1464
+ ```
1465
+
1466
+ ### Best Practices
1467
+
1468
+ 1. **Shallow Hierarchy** - Keep hierarchy depth reasonable (3-5 levels max)
1469
+ 2. **Clear Naming** - Use descriptive names at each level
1470
+ 3. **Logical Grouping** - Group related tasks under same parent
1471
+ 4. **Regular Review** - Periodically review and reorganize structure
1472
+ 5. **Consistent Indentation** - Maintain consistent indentation for clarity
1473
+
1474
+ ## Internationalization Support
520
1475
 
521
1476
  ### Supported Languages
522
1477
 
@@ -748,47 +1703,96 @@ The component includes multiple performance optimizations:
748
1703
  ```
749
1704
  src/
750
1705
  ├── components/
1706
+ │ ├── CustomFieldsDialog.vue # Custom fields dialog
1707
+ │ ├── DeleteConfirmDialog.vue # Delete confirmation dialog
1708
+ │ ├── MessageToast.vue # Message toast component
1709
+ │ ├── TaskDialog.vue # Task editing dialog
751
1710
  │ └── gantt/
752
- │ ├── Gantt.vue # Main component
753
- │ ├── Bar.vue # Task bar component
754
- │ ├── BarRecursionRow.vue # Recursive row component
755
- │ ├── TaskLinks.vue # Link component
756
- ├── TimelineHeader.vue # Timeline header
757
- │ ├── TableContent.vue # Table content
758
- │ ├── RightTable.vue # Right Gantt chart area
759
- │ ├── SplitPane.vue # Split panel
760
- │ ├── DatePicker.vue # Date picker
761
- │ ├── GanttConfigPanel.vue # Configuration panel
762
- │ ├── GanttThemeSelector.vue # Theme selector
763
- │ ├── LanguageSelector.vue # Language selector
764
- │ ├── LinkConfigPanel.vue # Link configuration panel
765
- │ ├── Types.ts # Type definitions
766
- │ ├── Store.ts # State management
767
- │ ├── ShareState.ts # Shared state
768
- │ ├── LinkConfig.ts # Link configuration
769
- │ ├── Symbols.ts # Injection symbols
770
- ├── ZodSchema.ts # Data validation
771
- │ ├── i18n/ # Internationalization system
772
- │ │ ├── index.ts # i18n core
773
- │ │ └── locales/ # Language packs
774
- ├── zh-CN.ts # Chinese language pack
775
- ├── en-US.ts # English language pack
776
- │ │ ├── ja-JP.ts # Japanese language pack
777
- │ │ ├── ko-KR.ts # Korean language pack
778
- │ │ ├── fr-FR.ts # French language pack
779
- │ │ ├── de-DE.ts # German language pack
780
- │ │ ├── es-ES.ts # Spanish language pack
781
- │ │ └── ru-RU.ts # Russian language pack
782
- │ ├── task/ # Task-related components
783
- │ │ ├── TaskTable.vue
784
- │ │ ├── TaskHeader.vue
785
- │ │ ├── TaskContent.vue
786
- │ │ └── TaskRow.vue
787
- └── themes/ # Theme configuration
788
- └── GanttThemes.ts
789
- ├── App.vue # Example application
790
- ├── main.ts # Entry file
791
- └── style.css # Global styles
1711
+ │ ├── composables/ # Gantt composables
1712
+ ├── LinkConfig.ts
1713
+ ├── PerformanceConfig.ts
1714
+ ├── useHorizontalVirtualScroll.ts
1715
+ │ └── useVirtualScroll.ts
1716
+ │ ├── config/ # Configuration panel components
1717
+ ├── CheckboxConfig.vue
1718
+ ├── ColorInput.vue
1719
+ ├── ColumnConfigPanel.vue
1720
+ ├── ConfigSection.vue
1721
+ ├── DatePicker.vue
1722
+ ├── GanttConfigPanel.vue
1723
+ ├── GanttThemeSelector.vue
1724
+ ├── LanguageSelector.vue
1725
+ ├── LinkConfigPanel.vue
1726
+ ├── LinkTypeColorConfig.vue
1727
+ ├── PathTypeSelector.vue
1728
+ ├── SliderInput.vue
1729
+ │ └── ThemeSelector.vue
1730
+ │ ├── core/ # Core components
1731
+ │ │ ├── Gantt.vue # Main component
1732
+ │ │ └── SplitPane.vue # Split panel
1733
+ │ ├── gantt.css # Gantt styles
1734
+ │ ├── i18n/ # Internationalization system
1735
+ │ │ ├── index.ts # i18n core
1736
+ │ │ └── locales/ # Language packs
1737
+ │ │ ├── zh-CN.ts # Chinese language pack
1738
+ │ │ ├── zh-TW.ts # Traditional Chinese language pack
1739
+ │ │ ├── en-US.ts # English language pack
1740
+ │ │ ├── ja-JP.ts # Japanese language pack
1741
+ ├── ko-KR.ts # Korean language pack
1742
+ │ │ ├── fr-FR.ts # French language pack
1743
+ │ │ ├── de-DE.ts # German language pack
1744
+ │ │ ├── es-ES.ts # Spanish language pack
1745
+ │ │ └── ru-RU.ts # Russian language pack
1746
+ ├── links/ # Link components
1747
+ └── TaskLinks.vue # Task links
1748
+ ├── state/ # State management
1749
+ │ │ ├── ShareState.ts # Shared state
1750
+ │ │ ├── Store.ts # State store
1751
+ │ │ └── Symbols.ts # Injection symbols
1752
+ │ ├── task/ # Task-related components
1753
+ │ │ ├── TaskTable.vue # Task table
1754
+ │ │ ├── TaskHeader.vue # Task header
1755
+ │ │ ├── TaskContent.vue # Task content
1756
+ │ │ ├── TaskRow.vue # Task row
1757
+ │ │ └── TaskRecursionRow.vue # Recursive task row
1758
+ │ ├── themes/ # Theme configuration
1759
+ │ │ ├── GanttThemes.ts # Theme definitions
1760
+ │ │ └── LiquidGlass.css # Liquid glass theme
1761
+ │ ├── timeline/ # Timeline components
1762
+ │ │ ├── Bar.vue # Task bar
1763
+ │ │ ├── BarRecursionRow.vue # Recursive task bar
1764
+ │ │ ├── Milestone.vue # Milestone
1765
+ │ │ ├── RightTable.vue # Right Gantt chart area
1766
+ │ │ ├── TableContent.vue # Table content
1767
+ │ │ ├── TimelineHeader.vue # Timeline header
1768
+ │ │ ├── composables/ # Timeline composables
1769
+ │ │ │ ├── useBarGeometry.ts
1770
+ │ │ │ ├── useBarTheme.ts
1771
+ │ │ │ ├── useHover.ts
1772
+ │ │ │ ├── useInteractions.ts
1773
+ │ │ │ └── useProgress.ts
1774
+ │ │ └── utils/ # Utility functions
1775
+ │ │ └── dateCalc.ts
1776
+ │ └── types/ # Type definitions
1777
+ │ ├── Types.ts # Gantt types
1778
+ │ └── ZodSchema.ts # Data validation
1779
+ ├── composables/ # Global composables
1780
+ │ ├── useCustomFields.ts # Custom fields
1781
+ │ ├── useMessage.ts # Message toast
1782
+ │ └── useTaskManagement.ts # Task management
1783
+ ├── mock/ # Mock data
1784
+ │ └── mockData.ts # Sample data
1785
+ ├── services/ # Service layer
1786
+ │ └── taskApi.ts # Task API
1787
+ ├── styles/ # Global styles
1788
+ │ └── dialog-common.css # Dialog common styles
1789
+ ├── types/ # Type definitions
1790
+ │ └── task.ts # Task types
1791
+ ├── App.vue # Example application
1792
+ ├── index.ts # Export entry
1793
+ ├── main.ts # Application entry
1794
+ ├── style.css # Global styles
1795
+ └── vite-env.d.ts # Vite environment types
792
1796
  ```
793
1797
 
794
1798
  ## Complete Example