jordium-gantt-vue3 1.0.9 → 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,35 +1,229 @@
1
- # jordium-gantt-vue3
1
+ # <img src="public/assets/jordium-gantt-vue3-logo.svg" alt="jordium-gantt-vue3 logo" width="32" style="vertical-align:middle;margin-right:8px;" /> jordium-gantt-vue3
2
+
3
+ <!-- For English documentation, see README-EN.md -->
4
+ **🌐 Languages**: [📖 English Documentation](./README-EN.md) | [📖 中文文档](./README.md)
2
5
 
3
6
  [![npm version](https://img.shields.io/npm/v/jordium-gantt-vue3.svg?cacheBust=1)](https://www.npmjs.com/package/jordium-gantt-vue3)
4
7
  [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
8
  [![Vue 3](https://img.shields.io/badge/vue-3.x-green.svg)](https://vuejs.org/)
6
9
  [![TypeScript](https://img.shields.io/badge/typescript-5.x-blue.svg)](https://www.typescriptlang.org/)
7
10
 
8
- A modern, flexible, and feature-rich Gantt chart component library for Vue 3. Built with TypeScript, supporting drag-and-drop, milestone management, task relationships, theme switching, and internationalization.
11
+ > 现代化的 Vue 3 甘特图组件库,为项目管理和任务调度提供完整解决方案
12
+
13
+ ## 🌐 在线体验
14
+
15
+ 🎯 **[立即体验 Github在线Demo →](https://nelson820125.github.io/jordium-gantt-vue3/)**
16
+
17
+ *在线 Demo 包含完整功能展示:任务管理、里程碑、主题切换、国际化等*
18
+
19
+ ## 🎨 主题支持
20
+
21
+ ### 亮色主题
22
+
23
+ ![亮色主题](design/screenshots/light-theme.png)
24
+
25
+ ### 暗色主题
9
26
 
10
- ## ✨ Features
27
+ ![暗色主题](design/screenshots/dark-theme.png)
11
28
 
12
- - 🎯 **Task Management**: Create, edit, delete tasks with full CRUD support
13
- - 📅 **Timeline View**: Interactive timeline with drag-and-drop functionality
14
- - 🎯 **Milestone Support**: Add and manage project milestones
15
- - 🔗 **Task Dependencies**: Support for predecessor relationships
16
- - 🎨 **Dual Themes**: Light and dark mode with smooth transitions
17
- - 🌍 **Internationalization**: Built-in Chinese and English support
18
- - 📱 **Responsive Design**: Works seamlessly on desktop and mobile
19
- - 🔧 **Highly Customizable**: Rich API and event system
20
- - 💎 **TypeScript Support**: Full type safety for better development experience
29
+ ## 🚀 插件特点
21
30
 
22
- ## 📦 Installation
31
+ - 📊 **完整功能**: 任务管理、里程碑追踪、依赖关系、进度可视化
32
+ - 🎨 **主题切换**: 内置亮色/暗色主题,支持自定义主题变量
33
+ - 🖱️ **交互丰富**: 拖拽调整、大小缩放、双击编辑、右键菜单
34
+ - 🌍 **国际化**: 内置中英文,支持自定义语言包
35
+ - 📱 **响应式**: 适配桌面和移动端,流畅的触控体验
36
+ - ⚡ **高性能**: 虚拟滚动、懒加载、优化渲染
37
+ - 🔧 **可扩展**: 丰富的 API 接口,支持自定义组件和事件
38
+ - 💎 **类型安全**: 完整 TypeScript 支持,开发体验更佳
39
+
40
+ ## 📦 安装
23
41
 
24
42
  ```bash
43
+ # npm
25
44
  npm install jordium-gantt-vue3
26
- # or
45
+
46
+ # yarn
27
47
  yarn add jordium-gantt-vue3
28
- # or
48
+
49
+ # pnpm
29
50
  pnpm add jordium-gantt-vue3
30
51
  ```
31
52
 
32
- ## 🚀 Quick Start
53
+ ## 📄 许可证
54
+
55
+ [MIT License](./LICENSE) © 2025 JORDIUM.COM
56
+
57
+ ---
58
+
59
+ > 💡 **徽章下载**:
60
+ > - npm 版本徽章:https://img.shields.io/npm/v/jordium-gantt-vue3.svg
61
+ > - MIT 许可证徽章:https://img.shields.io/badge/license-MIT-blue.svg
62
+ > - Vue 版本徽章:https://img.shields.io/badge/vue-3.x-green.svg
63
+ > - TypeScript 徽章:https://img.shields.io/badge/typescript-5.x-blue.svg
64
+
65
+ ## 📁 项目结构
66
+
67
+ ```
68
+ jordium-gantt-vue3/
69
+ ├── src/ # 源码目录
70
+ │ ├── components/ # 核心组件
71
+ │ │ ├── GanttChart.vue # 主入口组件
72
+ │ │ ├── TaskList.vue # 任务列表
73
+ │ │ ├── Timeline.vue # 时间轴
74
+ │ │ ├── TaskBar.vue # 任务条
75
+ │ │ ├── MilestonePoint.vue # 里程碑
76
+ │ │ └── ... # 其他组件
77
+ │ ├── models/ # 数据模型
78
+ │ │ ├── classes/ # 类定义
79
+ │ │ └── configs/ # 配置接口
80
+ │ ├── composables/ # 组合式函数
81
+ │ ├── styles/ # 样式文件
82
+ │ └── index.ts # 导出入口
83
+ ├── demo/ # 开发演示
84
+ ├── dist/ # 构建产物
85
+ ├── docs/ # 文档
86
+ └── package.json
87
+ ```
88
+
89
+ ## 🔧 API 参考
90
+
91
+ ### GanttChart 属性
92
+
93
+ | 属性名 | 类型 | 默认值 | 说明 |
94
+ |--------|------|--------|------|
95
+ | `tasks` | `Task[]` | `[]` | 任务数据数组 |
96
+ | `milestones` | `Task[]` | `[]` | 里程碑数据数组 |
97
+ | `editComponent` | `any` | - | 自定义编辑组件 |
98
+ | `useDefaultDrawer` | `boolean` | `true` | 是否使用默认编辑抽屉 |
99
+ | `showToolbar` | `boolean` | `true` | 是否显示工具栏 |
100
+ | `toolbarConfig` | `ToolbarConfig` | `{}` | 工具栏配置 |
101
+ | `localeMessages` | `Partial<Messages['zh-CN']>` | - | 自定义多语言配置 |
102
+ | `onTaskDoubleClick` | `(task: Task) => void` | - | 任务双击事件回调 |
103
+ | `onTaskDelete` | `(task: Task) => void` | - | 任务删除事件回调 |
104
+ | `onTaskUpdate` | `(task: Task) => void` | - | 任务更新事件回调 |
105
+ | `onTaskAdd` | `(task: Task) => void` | - | 任务添加事件回调 |
106
+ | `onMilestoneSave` | `(milestone: Task) => void` | - | 里程碑保存事件回调 |
107
+ | `onMilestoneDelete` | `(milestoneId: number) => void` | - | 里程碑删除事件回调 |
108
+ | `onMilestoneIconChange` | `(milestoneId: number, icon: string) => void` | - | 里程碑图标变更事件回调 |
109
+ | `onAddTask` | `() => void` | - | 新增任务工具栏事件回调 |
110
+ | `onAddMilestone` | `() => void` | - | 新增里程碑工具栏事件回调 |
111
+ | `onTodayLocate` | `() => void` | - | 定位今天工具栏事件回调 |
112
+ | `onExportCsv` | `() => boolean \| void` | - | 导出CSV工具栏事件回调 |
113
+ | `onExportPdf` | `() => void` | - | 导出PDF工具栏事件回调 |
114
+ | `onLanguageChange` | `(lang: 'zh-CN' \| 'en-US') => void` | - | 语言切换工具栏事件回调 |
115
+ | `onThemeChange` | `(isDark: boolean) => void` | - | 主题切换工具栏事件回调 |
116
+ | `onFullscreenChange` | `(isFullscreen: boolean) => void` | - | 全屏切换工具栏事件回调 |
117
+
118
+ ### GanttChart 事件
119
+
120
+ | 事件名 | 参数 | 说明 |
121
+ |--------|------|------|
122
+ | `taskbar-drag-end` | `task: Task` | 任务条拖拽结束 |
123
+ | `taskbar-resize-end` | `task: Task` | 任务条大小调整结束 |
124
+ | `milestone-drag-end` | `milestone: Task` | 里程碑拖拽结束 |
125
+
126
+ ### 数据类型
127
+
128
+ #### 核心类型 (src/models/classes)
129
+
130
+ **Task 任务类型**
131
+ ```typescript
132
+ interface Task {
133
+ id: number // 任务唯一标识
134
+ name: string // 任务名称
135
+ predecessor?: string // 前置任务ID
136
+ assignee?: string // 负责人
137
+ startDate?: string // 开始日期 (YYYY-MM-DD格式)
138
+ endDate?: string // 结束日期 (YYYY-MM-DD格式)
139
+ progress?: number // 完成进度 (0-100)
140
+ estimatedHours?: number // 预估工时
141
+ actualHours?: number // 实际工时
142
+ parentId?: number // 上级任务ID
143
+ children?: Task[] // 子任务数组(支持嵌套结构)
144
+ collapsed?: boolean // 是否折叠子任务
145
+ isParent?: boolean // 是否为父级任务
146
+ type?: string // 任务类型 (task/story/bug/milestone)
147
+ description?: string // 任务描述
148
+ icon?: string // 任务图标
149
+ level?: number // 任务层级
150
+ }
151
+ ```
152
+
153
+ **Milestone 里程碑类型**
154
+ ```typescript
155
+ // 里程碑实际上是 Task 类型的特殊用法
156
+ // 具有 type: 'milestone' 属性的 Task 对象
157
+ interface Milestone extends Task {
158
+ type: 'milestone' // 必须为 'milestone'
159
+ startDate: string // 里程碑日期 (必填)
160
+ endDate?: string // 结束日期 (可选,通常与startDate相同)
161
+ }
162
+ ```
163
+
164
+ **Language 语言类型**
165
+ ```typescript
166
+ type Language = 'zh' | 'en' // 支持的语言类型
167
+ type Locale = 'zh-CN' | 'en-US' // 完整的语言区域标识
168
+ ```
169
+
170
+ #### 配置类型 (src/models/configs)
171
+
172
+ **TimelineConfig 时间轴配置**
173
+ ```typescript
174
+ interface TimelineConfig {
175
+ startDate: Date // 时间轴开始日期
176
+ endDate: Date // 时间轴结束日期
177
+ zoomLevel: number // 缩放级别
178
+ }
179
+ ```
180
+
181
+ **ToolbarConfig 工具栏配置**
182
+ ```typescript
183
+ interface ToolbarConfig {
184
+ showAddTask?: boolean // 是否显示新增任务按钮
185
+ showAddMilestone?: boolean // 是否显示新增里程碑按钮
186
+ showTodayLocate?: boolean // 是否显示定位今天按钮
187
+ showExportCsv?: boolean // 是否显示导出CSV按钮
188
+ showExportPdf?: boolean // 是否显示导出PDF按钮
189
+ showLanguage?: boolean // 是否显示语言切换按钮
190
+ showTheme?: boolean // 是否显示主题切换按钮
191
+ showFullscreen?: boolean // 是否显示全屏切换按钮
192
+ showTimeScale?: boolean // 是否显示时间刻度切换按钮组(日|周|月)
193
+ }
194
+ ```
195
+
196
+ #### 组合式函数 (src/composables)
197
+
198
+ **useI18n 国际化工具**
199
+ ```typescript
200
+ // 提供多语言支持
201
+ const {
202
+ locale, // 当前语言
203
+ setLocale, // 切换语言
204
+ t, // 翻译函数
205
+ formatYearMonth // 年月格式化
206
+ } = useI18n()
207
+
208
+ // 支持的语言
209
+ type Locale = 'zh-CN' | 'en-US'
210
+ ```
211
+
212
+ **useMessage 消息提示工具**
213
+ ```typescript
214
+ // 提供全局消息提示
215
+ const { showMessage } = useMessage()
216
+
217
+ // 消息类型
218
+ type MessageType = 'success' | 'error' | 'warning' | 'info'
219
+
220
+ // 使用示例
221
+ showMessage('操作成功', 'success')
222
+ ```
223
+
224
+ ## 💻 基本使用
225
+
226
+ ### 简单示例
33
227
 
34
228
  ```vue
35
229
  <script setup lang="ts">
@@ -40,19 +234,19 @@ import 'jordium-gantt-vue3/dist/style.css'
40
234
  const tasks = ref([
41
235
  {
42
236
  id: 1,
43
- name: 'Project Kickoff',
237
+ name: '项目启动',
44
238
  startDate: '2025-01-01',
45
239
  endDate: '2025-01-15',
46
240
  progress: 80,
47
- assignee: 'John Doe'
241
+ assignee: '张三'
48
242
  },
49
243
  {
50
244
  id: 2,
51
- name: 'Requirements Analysis',
245
+ name: '需求分析',
52
246
  startDate: '2025-01-16',
53
247
  endDate: '2025-01-30',
54
248
  progress: 60,
55
- assignee: 'Jane Smith',
249
+ assignee: '李四',
56
250
  predecessor: '1'
57
251
  }
58
252
  ])
@@ -60,7 +254,7 @@ const tasks = ref([
60
254
  const milestones = ref([
61
255
  {
62
256
  id: 1,
63
- name: 'Project Milestone',
257
+ name: '项目里程碑',
64
258
  startDate: '2025-01-31',
65
259
  type: 'milestone'
66
260
  }
@@ -77,163 +271,149 @@ const milestones = ref([
77
271
  </template>
78
272
  ```
79
273
 
80
- ## 🔧 API Reference
81
-
82
- ### Core Properties
83
-
84
- | Property | Type | Default | Description |
85
- |----------|------|---------|-------------|
86
- | `tasks` | `Task[]` | `[]` | Task data array |
87
- | `milestones` | `Task[]` | `[]` | Milestone data array |
88
- | `useDefaultDrawer` | `boolean` | `true` | Use default edit drawer |
89
- | `showToolbar` | `boolean` | `true` | Show toolbar |
90
- | `toolbarConfig` | `ToolbarConfig` | `{}` | Toolbar configuration |
91
- | `localeMessages` | `object` | - | Custom locale messages |
92
-
93
- ### Event Callbacks
94
-
95
- | Property | Type | Description |
96
- |----------|------|-------------|
97
- | `onTaskDoubleClick` | `(task: Task) => void` | Task double-click callback |
98
- | `onTaskDelete` | `(task: Task) => void` | Task delete callback |
99
- | `onTaskUpdate` | `(task: Task) => void` | Task update callback |
100
- | `onTaskAdd` | `(task: Task) => void` | Task add callback |
101
- | `onMilestoneSave` | `(milestone: Task) => void` | Milestone save callback |
102
- | `onMilestoneDelete` | `(id: number) => void` | Milestone delete callback |
103
- | `onLanguageChange` | `(lang: string) => void` | Language change callback |
104
- | `onThemeChange` | `(isDark: boolean) => void` | Theme change callback |
105
-
106
- ### Events
107
-
108
- | Event | Parameters | Description |
109
- |-------|------------|-------------|
110
- | `@taskbar-drag-end` | `task: Task` | Task drag ended |
111
- | `@taskbar-resize-end` | `task: Task` | Task resize ended |
112
- | `@milestone-drag-end` | `milestone: Task` | Milestone drag ended |
113
-
114
- ### Task Data Structure
115
-
116
- ```typescript
117
- interface Task {
118
- id: number // Unique task identifier
119
- name: string // Task name
120
- predecessor?: string // Predecessor task ID
121
- assignee?: string // Assignee
122
- startDate?: string // Start date (YYYY-MM-DD format)
123
- endDate?: string // End date (YYYY-MM-DD format)
124
- progress?: number // Completion progress (0-100)
125
- estimatedHours?: number // Estimated hours
126
- actualHours?: number // Actual hours
127
- parentId?: number // Parent task ID
128
- children?: Task[] // Child tasks array (supports nested structure)
129
- collapsed?: boolean // Whether child tasks are collapsed
130
- isParent?: boolean // Whether it's a parent task
131
- type?: string // Task type (task/story/bug/milestone)
132
- description?: string // Task description
133
- icon?: string // Task icon
134
- level?: number // Task level
135
- }
136
- ```
137
- ### TimelineConfig Data Structure
138
-
139
- ```typescript
140
- interface TimelineConfig {
141
- startDate: Date // Timeline start date
142
- endDate: Date // Timeline end date
143
- zoomLevel: number // Zoom level
144
- }
145
- ```
146
-
147
- ### ToolbarConfig Data Structure
148
-
149
- ```typescript
150
- interface ToolbarConfig {
151
- showAddTask?: boolean // Show add task button
152
- showAddMilestone?: boolean // Show add milestone button
153
- showTodayLocate?: boolean // Show locate today button
154
- showExportCsv?: boolean // Show export CSV button
155
- showExportPdf?: boolean // Show export PDF button
156
- showLanguage?: boolean // Show language switch button
157
- showTheme?: boolean // Show theme switch button
158
- showFullscreen?: boolean // Show fullscreen toggle button
159
- }
160
- ```
161
-
162
- ## 🎨 Advanced Usage
163
-
164
- ### Custom Event Handling
274
+ ### 自定义事件处理
165
275
 
166
276
  ```vue
167
277
  <script setup lang="ts">
168
278
  import { GanttChart } from 'jordium-gantt-vue3'
169
279
 
280
+ // 自定义双击处理
170
281
  const handleTaskDoubleClick = (task) => {
171
- console.log('Task clicked:', task)
172
- // Open custom edit dialog
282
+ console.log('双击任务:', task)
283
+ // 打开自定义编辑界面
284
+ router.push(`/task/${task.id}/edit`)
173
285
  }
174
286
 
175
- const handleTaskDragEnd = (task) => {
176
- console.log('Task moved:', task)
177
- // Save changes to backend
287
+ // 自定义删除处理
288
+ const handleTaskDelete = async (task) => {
289
+ const confirmed = await showConfirm(`确定删除任务 "${task.name}" 吗?`)
290
+ if (confirmed) {
291
+ await api.deleteTask(task.id)
292
+ // 刷新任务列表
293
+ refreshTasks()
294
+ }
178
295
  }
179
296
 
180
- const toolbarConfig = {
181
- showAddTask: true,
182
- showTheme: true,
183
- showLanguage: true,
184
- showExportCsv: true
297
+ // 监听拖拽事件
298
+ const handleTaskDragEnd = (task) => {
299
+ console.log('任务拖拽结束:', task)
300
+ // 保存任务时间变更
301
+ api.updateTask(task)
185
302
  }
186
303
  </script>
187
304
 
188
305
  <template>
189
306
  <GanttChart
190
307
  :tasks="tasks"
191
- :milestones="milestones"
192
- :toolbar-config="toolbarConfig"
193
308
  :on-task-double-click="handleTaskDoubleClick"
309
+ :on-task-delete="handleTaskDelete"
310
+ :use-default-drawer="false"
194
311
  @taskbar-drag-end="handleTaskDragEnd"
195
312
  />
196
313
  </template>
197
314
  ```
198
315
 
199
- ### Internationalization
316
+ ### 主题和国际化
200
317
 
201
318
  ```vue
202
- <script setup>
319
+ <script setup lang="ts">
320
+ import { ref } from 'vue'
321
+ import { GanttChart } from 'jordium-gantt-vue3'
322
+
323
+ // 工具栏配置
324
+ const toolbarConfig = {
325
+ showLanguage: true,
326
+ showTheme: true,
327
+ showAddTask: true,
328
+ showAddMilestone: true,
329
+ showTodayLocate: true,
330
+ showExportCsv: true,
331
+ showExportPdf: true,
332
+ showFullscreen: true,
333
+ showTimeScale: true // 控制日|周|月时间刻度按钮组的可见性
334
+ }
335
+
336
+ // 自定义多语言配置
203
337
  const customLocaleMessages = {
204
- taskName: 'Custom Task Name',
205
- addTask: 'Custom Add Task'
338
+ taskName: '自定义任务名称',
339
+ addTask: '自定义新增任务'
340
+ }
341
+
342
+ // 处理工具栏事件
343
+ const handleLanguageChange = (lang) => {
344
+ console.log('语言切换到:', lang)
345
+ }
346
+
347
+ const handleThemeChange = (isDark) => {
348
+ console.log('主题切换到:', isDark ? '暗色' : '亮色')
206
349
  }
207
350
  </script>
208
351
 
209
352
  <template>
210
353
  <GanttChart
354
+ :tasks="tasks"
355
+ :milestones="milestones"
356
+ :toolbar-config="toolbarConfig"
211
357
  :locale-messages="customLocaleMessages"
212
- :on-language-change="(lang) => console.log('Language:', lang)"
358
+ :on-language-change="handleLanguageChange"
359
+ :on-theme-change="handleThemeChange"
213
360
  />
214
361
  </template>
215
362
  ```
216
363
 
217
- ## 📚 Documentation & Resources
364
+ ## 🤝 贡献与合作
365
+
366
+ ### 参与贡献
367
+
368
+ 我们欢迎社区贡献!如果你想参与项目开发:
369
+
370
+ 1. **Fork** 本仓库
371
+ 2. **创建** 你的特性分支 (`git checkout -b feature/AmazingFeature`)
372
+ 3. **提交** 你的修改 (`git commit -m 'Add some AmazingFeature'`)
373
+ 4. **推送** 到分支 (`git push origin feature/AmazingFeature`)
374
+ 5. **打开** Pull Request
375
+
376
+ ### 报告问题
377
+
378
+ 如果你发现了 bug 或有功能建议:
218
379
 
219
- - 📖 **Full Documentation**: [GitHub Repository](https://github.com/nelson820125/jordium-gantt-vue3)
220
- - 📋 **Changelog**: [CHANGELOG.md](https://github.com/nelson820125/jordium-gantt-vue3/blob/main/CHANGELOG.md)
221
- - 🐛 **Issues**: [GitHub Issues](https://github.com/nelson820125/jordium-gantt-vue3/issues)
380
+ - 📬 [提交 Github Issue](https://github.com/nelson820125/jordium-gantt-vue3/issues)
381
+ - 📬 [提交 Gitee Issue](https://gitee.com/jordium/jordium-gantt-vue3/issues)
382
+ - 📧 发送邮件至:ning.li@jordium.com / nelson820125@gmail.com / lining820125@163.com
222
383
 
223
- ## 🤝 Contributing
384
+ ### 商业合作
224
385
 
225
- We welcome contributions! Please see our [Contributing Guide](https://github.com/nelson820125/jordium-gantt-vue3/blob/main/CONTRIBUTING.md) for details.
386
+ 我们提供专业的技术支持和定制开发服务:
226
387
 
227
- ## 📄 License
388
+ - 🏢 **企业定制**: 根据业务需求定制系统开发
389
+ - 💼 **技术咨询**: 业务及架构设计解决方案咨询
228
390
 
229
- [MIT License](https://opensource.org/licenses/MIT) © 2025 Jordium.com
391
+ **联系方式**:
392
+ - 📧 商务邮箱:ning.li@jordium.com / nelson820125@gmail.com
230
393
 
231
- ## 📧 Support
394
+ ### 开发环境
232
395
 
233
- - 📬 **GitHub Issues**: [Report bugs or request features](https://github.com/nelson820125/jordium-gantt-vue3/issues)
234
- - 📧 **Email**: ning.li@jordium.com / nelson820125@gmail.com
235
- - 💼 **Business**: For enterprise support and custom development
396
+ ```bash
397
+ # 克隆项目
398
+ git clone https://github.com/nelson820125/jordium-gantt-vue3.git
399
+
400
+ # 安装依赖
401
+ npm install
402
+
403
+ # 启动开发服务器
404
+ npm run dev
405
+
406
+ # 构建库文件
407
+ npm run build:lib
408
+
409
+ # 运行测试
410
+ npm run test
411
+ ```
236
412
 
237
413
  ---
238
414
 
239
- > 💡 If this project helps you, please give it a ⭐ Star on GitHub!
415
+ **🔗 相关链接**
416
+ - [GitHub 仓库](https://github.com/nelson820125/jordium-gantt-vue3)
417
+ - [更新日志](./CHANGELOG.md)
418
+
419
+ > 💡 **提示**: 如果这个项目对你有帮助,请给我们一个 ⭐ Star!