jordium-gantt-vue3 1.7.0 → 1.7.1
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 +239 -1
- package/dist/assets/jordium-gantt-vue3.css +1 -1
- package/dist/jordium-gantt-vue3-styles.js +1 -1
- package/dist/jordium-gantt-vue3.cjs.js +64 -64
- package/dist/jordium-gantt-vue3.es.js +11107 -10865
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
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
2
|
|
|
3
|
+
<style>
|
|
4
|
+
.version-badge {
|
|
5
|
+
display: inline-block;
|
|
6
|
+
padding: 1px 6px;
|
|
7
|
+
font-size: 11px;
|
|
8
|
+
font-weight: 600;
|
|
9
|
+
line-height: 1.2;
|
|
10
|
+
color: #409eff;
|
|
11
|
+
background-color: #ecf5ff;
|
|
12
|
+
border: 1px solid #d9ecff;
|
|
13
|
+
border-radius: 3px;
|
|
14
|
+
margin-left: 4px;
|
|
15
|
+
vertical-align: middle;
|
|
16
|
+
}
|
|
17
|
+
</style>
|
|
18
|
+
|
|
3
19
|
<p align="center">
|
|
4
20
|
<a href="https://www.npmjs.com/package/jordium-gantt-vue3">
|
|
5
21
|
<img src="https://img.shields.io/npm/v/jordium-gantt-vue3?style=flat-square" alt="npm version">
|
|
@@ -197,7 +213,12 @@ npm run dev
|
|
|
197
213
|
| `enableTaskRowMove` | `boolean` | `false` | 是否允许拖拽和摆放TaskRow |
|
|
198
214
|
| `enableTaskListContextMenu` | `boolean` | `true` | 是否启用 TaskList(TaskRow)右键菜单功能。为 `true` 时:未声明 `task-list-context-menu` 插槽则使用内置菜单,声明了插槽则使用自定义菜单;为 `false` 时右键菜单完全禁用 |
|
|
199
215
|
| `enableTaskBarContextMenu` | `boolean` | `true` | 是否启用 TaskBar 右键菜单功能。为 `true` 时:未声明 `task-bar-context-menu` 插槽则使用内置菜单,声明了插槽则使用自定义菜单;为 `false` 时右键菜单完全禁用 |
|
|
200
|
-
| `assigneeOptions` | `Array<{ key?: string \| number; value: string \| number; label: string }>` | `[]` | 任务编辑抽屉中负责人下拉菜单的选项列表 |
|
|
216
|
+
| `assigneeOptions` | `Array<{ key?: string \| number; value: string \| number; label: string }>` | `[]` | 任务编辑抽屉中负责人下拉菜单的选项列表 |
|
|
217
|
+
| `locale` <sup class="version-badge">1.7.1</sup> | `'zh-CN' \| 'en-US'` | `'zh-CN'` | 语言设置(响应式)。设置后组件内部语言将跟随变化 |
|
|
218
|
+
| `theme` <sup class="version-badge">1.7.1</sup> | `'light' \| 'dark'` | `'light'` | 主题模式(响应式)。设置后组件主题将跟随变化 |
|
|
219
|
+
| `timeScale` <sup class="version-badge">1.7.1</sup> | `'hour' \| 'day' \| 'week' \| 'month' \| 'quarter' \| 'year'` | `'week'` | 时间刻度(响应式)。设置后时间线刻度将跟随变化 |
|
|
220
|
+
| `fullscreen` <sup class="version-badge">1.7.1</sup> | `boolean` | `false` | 全屏状态控制(响应式)。设置后组件全屏状态将跟随变化 |
|
|
221
|
+
| `expandAll` <sup class="version-badge">1.7.1</sup> | `boolean` | `true` | 展开/收起所有任务(响应式)。设置后所有任务的展开状态将跟随变化 |
|
|
201
222
|
|
|
202
223
|
#### TaskListColumn 属性
|
|
203
224
|
|
|
@@ -535,6 +556,61 @@ const handleMilestoneSaved = milestone => {
|
|
|
535
556
|
</script>
|
|
536
557
|
```
|
|
537
558
|
|
|
559
|
+
#### 示例4:外部组件控制状态(TimeScale、Fullscreen、Expand/Collapse、Locale、Theme)
|
|
560
|
+
|
|
561
|
+
通过响应式Props绑定来控制组件状态,组件状态会自动跟随Props变化。
|
|
562
|
+
|
|
563
|
+
```vue
|
|
564
|
+
<template>
|
|
565
|
+
<div>
|
|
566
|
+
<!-- 外部控制面板 -->
|
|
567
|
+
<div class="control-panel">
|
|
568
|
+
<button @click="propsFullscreen = !propsFullscreen">切换全屏</button>
|
|
569
|
+
<button @click="propsExpandAll = !propsExpandAll">展开/收起所有</button>
|
|
570
|
+
<button @click="propsLocale = 'zh-CN'">中文</button>
|
|
571
|
+
<button @click="propsLocale = 'en-US'">English</button>
|
|
572
|
+
<button @click="propsTimeScale = 'day'">日视图</button>
|
|
573
|
+
<button @click="propsTimeScale = 'week'">周视图</button>
|
|
574
|
+
<button @click="propsTimeScale = 'month'">月视图</button>
|
|
575
|
+
<button @click="propsTheme = 'light'">亮色主题</button>
|
|
576
|
+
<button @click="propsTheme = 'dark'">暗色主题</button>
|
|
577
|
+
</div>
|
|
578
|
+
|
|
579
|
+
<!-- 甘特图组件 -->
|
|
580
|
+
<div style="height: 600px;">
|
|
581
|
+
<GanttChart
|
|
582
|
+
:tasks="tasks"
|
|
583
|
+
:milestones="milestones"
|
|
584
|
+
:locale="propsLocale"
|
|
585
|
+
:theme="propsTheme"
|
|
586
|
+
:time-scale="propsTimeScale"
|
|
587
|
+
:fullscreen="propsFullscreen"
|
|
588
|
+
:expand-all="propsExpandAll"
|
|
589
|
+
/>
|
|
590
|
+
</div>
|
|
591
|
+
</div>
|
|
592
|
+
</template>
|
|
593
|
+
|
|
594
|
+
<script setup lang="ts">
|
|
595
|
+
import { ref } from 'vue'
|
|
596
|
+
import { GanttChart } from 'jordium-gantt-vue3'
|
|
597
|
+
import 'jordium-gantt-vue3/dist/assets/jordium-gantt-vue3.css'
|
|
598
|
+
|
|
599
|
+
const tasks = ref([
|
|
600
|
+
{ id: 1, name: '任务1', startDate: '2025-01-01', endDate: '2025-01-10', progress: 50 },
|
|
601
|
+
{ id: 2, name: '任务2', startDate: '2025-01-05', endDate: '2025-01-15', progress: 30 },
|
|
602
|
+
])
|
|
603
|
+
const milestones = ref([])
|
|
604
|
+
|
|
605
|
+
// Props控制变量
|
|
606
|
+
const propsLocale = ref<'zh-CN' | 'en-US'>('zh-CN')
|
|
607
|
+
const propsTheme = ref<'light' | 'dark'>('light')
|
|
608
|
+
const propsTimeScale = ref<'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year'>('week')
|
|
609
|
+
const propsFullscreen = ref(false)
|
|
610
|
+
const propsExpandAll = ref(false)
|
|
611
|
+
</script>
|
|
612
|
+
```
|
|
613
|
+
|
|
538
614
|
---
|
|
539
615
|
|
|
540
616
|
### 任务管理
|
|
@@ -2032,6 +2108,168 @@ const taskBarConfig = computed<TaskBarConfig>(() => ({
|
|
|
2032
2108
|
> - 避免出现时间线过窄或留白过多的问题
|
|
2033
2109
|
> - 适用不同分辨率展示
|
|
2034
2110
|
|
|
2111
|
+
### Expose 方法
|
|
2112
|
+
|
|
2113
|
+
GanttChart 组件通过 `defineExpose` 暴露了一系列方法,允许父组件通过模板引用 (`ref`) 直接调用这些方法来控制组件行为。这种命令式的控制方式适合需要精确控制时机的场景。
|
|
2114
|
+
|
|
2115
|
+
#### 可用的 Expose 方法
|
|
2116
|
+
|
|
2117
|
+
| 方法名 | 参数 | 返回值 | 说明 |
|
|
2118
|
+
| --- | --- | --- | --- |
|
|
2119
|
+
| `setLocale` <sup class="version-badge">1.7.1</sup> | `locale: 'zh-CN' \| 'en-US'` | `void` | 设置组件语言 |
|
|
2120
|
+
| `currentLocale` <sup class="version-badge">1.7.1</sup> | - | `'zh-CN' \| 'en-US'` | 获取当前语言设置 |
|
|
2121
|
+
| `setTheme` <sup class="version-badge">1.7.1</sup> | `mode: 'light' \| 'dark'` | `void` | 设置主题模式 |
|
|
2122
|
+
| `currentTheme` <sup class="version-badge">1.7.1</sup> | - | `'light' \| 'dark'` | 获取当前主题模式 |
|
|
2123
|
+
| `setTimeScale` <sup class="version-badge">1.7.1</sup> | `scale: TimelineScale` | `void` | 设置时间刻度(`'hour' \| 'day' \| 'week' \| 'month' \| 'quarter' \| 'year'`) |
|
|
2124
|
+
| `currentScale` <sup class="version-badge">1.7.1</sup> | - | `TimelineScale` | 获取当前时间刻度 |
|
|
2125
|
+
| `toggleFullscreen` <sup class="version-badge">1.7.1</sup> | - | `void` | 切换全屏状态 |
|
|
2126
|
+
| `enterFullscreen` <sup class="version-badge">1.7.1</sup> | - | `void` | 进入全屏模式 |
|
|
2127
|
+
| `exitFullscreen` <sup class="version-badge">1.7.1</sup> | - | `void` | 退出全屏模式 |
|
|
2128
|
+
| `isFullscreen` <sup class="version-badge">1.7.1</sup> | - | `boolean` | 获取当前是否处于全屏状态 |
|
|
2129
|
+
| `toggleExpandAll` <sup class="version-badge">1.7.1</sup> | - | `void` | 切换展开/收起所有任务 |
|
|
2130
|
+
| `expandAll` <sup class="version-badge">1.7.1</sup> | - | `void` | 展开所有任务 |
|
|
2131
|
+
| `collapseAll` <sup class="version-badge">1.7.1</sup> | - | `void` | 收起所有任务 |
|
|
2132
|
+
| `isExpandAll` <sup class="version-badge">1.7.1</sup> | - | `boolean` | 获取当前是否全部展开 |
|
|
2133
|
+
| `scrollToToday` <sup class="version-badge">1.7.1</sup> | - | `void` | 滚动到今天的位置 |
|
|
2134
|
+
| `scrollToTask` <sup class="version-badge">1.7.1</sup> | `taskId: number \| string` | `void` | 滚动到指定任务(任务会自动展开到可见状态) |
|
|
2135
|
+
| `scrollToDate` <sup class="version-badge">1.7.1</sup> | `date: string \| Date` | `void` | 滚动到指定日期位置(格式:`'YYYY-MM-DD'` 或 Date 对象) |
|
|
2136
|
+
|
|
2137
|
+
#### 使用示例
|
|
2138
|
+
|
|
2139
|
+
**基础用法:命令式控制**
|
|
2140
|
+
|
|
2141
|
+
```vue
|
|
2142
|
+
<template>
|
|
2143
|
+
<div>
|
|
2144
|
+
<!-- 外部控制按钮 -->
|
|
2145
|
+
<div class="control-panel">
|
|
2146
|
+
<button @click="handleSetLocale('zh-CN')">中文</button>
|
|
2147
|
+
<button @click="handleSetLocale('en-US')">English</button>
|
|
2148
|
+
<button @click="handleSetTheme('light')">亮色主题</button>
|
|
2149
|
+
<button @click="handleSetTheme('dark')">暗色主题</button>
|
|
2150
|
+
<button @click="handleSetTimeScale('day')">日视图</button>
|
|
2151
|
+
<button @click="handleSetTimeScale('week')">周视图</button>
|
|
2152
|
+
<button @click="handleSetTimeScale('month')">月视图</button>
|
|
2153
|
+
<button @click="ganttRef?.toggleFullscreen()">切换全屏</button>
|
|
2154
|
+
<button @click="ganttRef?.toggleExpandAll()">展开/收起所有</button>
|
|
2155
|
+
<button @click="ganttRef?.scrollToToday()">定位到今天</button>
|
|
2156
|
+
<button @click="handleScrollToTask">滚动到任务2</button>
|
|
2157
|
+
<button @click="handleScrollToDate">滚动到2025-06-01</button>
|
|
2158
|
+
</div>
|
|
2159
|
+
|
|
2160
|
+
<!-- 状态显示 -->
|
|
2161
|
+
<div class="status-panel">
|
|
2162
|
+
<p>当前语言: {{ currentLang }}</p>
|
|
2163
|
+
<p>当前主题: {{ currentThemeMode }}</p>
|
|
2164
|
+
<p>当前刻度: {{ currentTimeScale }}</p>
|
|
2165
|
+
<p>全屏状态: {{ isFullscreenMode ? '是' : '否' }}</p>
|
|
2166
|
+
<p>展开状态: {{ isAllExpanded ? '全部展开' : '部分收起' }}</p>
|
|
2167
|
+
</div>
|
|
2168
|
+
|
|
2169
|
+
<!-- 甘特图组件 -->
|
|
2170
|
+
<div style="height: 600px;">
|
|
2171
|
+
<GanttChart
|
|
2172
|
+
ref="ganttRef"
|
|
2173
|
+
:tasks="tasks"
|
|
2174
|
+
:milestones="milestones"
|
|
2175
|
+
/>
|
|
2176
|
+
</div>
|
|
2177
|
+
</div>
|
|
2178
|
+
</template>
|
|
2179
|
+
|
|
2180
|
+
<script setup lang="ts">
|
|
2181
|
+
import { ref } from 'vue'
|
|
2182
|
+
import { GanttChart } from 'jordium-gantt-vue3'
|
|
2183
|
+
import type { TimelineScale } from 'jordium-gantt-vue3'
|
|
2184
|
+
import 'jordium-gantt-vue3/dist/assets/jordium-gantt-vue3.css'
|
|
2185
|
+
|
|
2186
|
+
// 组件引用
|
|
2187
|
+
const ganttRef = ref<InstanceType<typeof GanttChart>>()
|
|
2188
|
+
|
|
2189
|
+
// 状态变量
|
|
2190
|
+
const currentLang = ref<'zh-CN' | 'en-US'>('zh-CN')
|
|
2191
|
+
const currentThemeMode = ref<'light' | 'dark'>('light')
|
|
2192
|
+
const currentTimeScale = ref<TimelineScale>('week')
|
|
2193
|
+
const isFullscreenMode = ref(false)
|
|
2194
|
+
const isAllExpanded = ref(true)
|
|
2195
|
+
|
|
2196
|
+
// 任务数据
|
|
2197
|
+
const tasks = ref([
|
|
2198
|
+
{ id: 1, name: '任务1', startDate: '2025-01-01', endDate: '2025-01-10', progress: 50 },
|
|
2199
|
+
{ id: 2, name: '任务2', startDate: '2025-01-05', endDate: '2025-01-15', progress: 30 },
|
|
2200
|
+
])
|
|
2201
|
+
const milestones = ref([])
|
|
2202
|
+
|
|
2203
|
+
// 语言控制
|
|
2204
|
+
const handleSetLocale = (locale: 'zh-CN' | 'en-US') => {
|
|
2205
|
+
ganttRef.value?.setLocale(locale)
|
|
2206
|
+
currentLang.value = ganttRef.value?.currentLocale() || locale
|
|
2207
|
+
}
|
|
2208
|
+
|
|
2209
|
+
// 主题控制
|
|
2210
|
+
const handleSetTheme = (mode: 'light' | 'dark') => {
|
|
2211
|
+
ganttRef.value?.setTheme(mode)
|
|
2212
|
+
currentThemeMode.value = ganttRef.value?.currentTheme() || mode
|
|
2213
|
+
}
|
|
2214
|
+
|
|
2215
|
+
// 时间刻度控制
|
|
2216
|
+
const handleSetTimeScale = (scale: TimelineScale) => {
|
|
2217
|
+
ganttRef.value?.setTimeScale(scale)
|
|
2218
|
+
currentTimeScale.value = ganttRef.value?.currentScale() || scale
|
|
2219
|
+
}
|
|
2220
|
+
|
|
2221
|
+
// 滚动到指定任务
|
|
2222
|
+
const handleScrollToTask = () => {
|
|
2223
|
+
ganttRef.value?.scrollToTask(2)
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
// 滚动到指定日期
|
|
2227
|
+
const handleScrollToDate = () => {
|
|
2228
|
+
ganttRef.value?.scrollToDate('2025-06-01')
|
|
2229
|
+
}
|
|
2230
|
+
</script>
|
|
2231
|
+
|
|
2232
|
+
<style scoped>
|
|
2233
|
+
.control-panel {
|
|
2234
|
+
display: flex;
|
|
2235
|
+
gap: 10px;
|
|
2236
|
+
margin-bottom: 20px;
|
|
2237
|
+
flex-wrap: wrap;
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
.status-panel {
|
|
2241
|
+
padding: 10px;
|
|
2242
|
+
background-color: #f5f5f5;
|
|
2243
|
+
border-radius: 4px;
|
|
2244
|
+
margin-bottom: 20px;
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2247
|
+
.status-panel p {
|
|
2248
|
+
margin: 5px 0;
|
|
2249
|
+
}
|
|
2250
|
+
</style>
|
|
2251
|
+
```
|
|
2252
|
+
|
|
2253
|
+
#### 最佳实践
|
|
2254
|
+
|
|
2255
|
+
1. **命令式 vs 响应式**
|
|
2256
|
+
- 使用 **Expose 方法**:需要精确控制调用时机,如按钮点击、特定事件触发
|
|
2257
|
+
- 使用 **Props 绑定**:状态需要跟随数据源自动更新,如与 URL 参数同步
|
|
2258
|
+
|
|
2259
|
+
2. **获取状态**
|
|
2260
|
+
- 提供了成对的 getter 方法(如 `currentLocale()`、`currentTheme()`)
|
|
2261
|
+
- 可在调用 setter 后立即获取最新状态进行验证
|
|
2262
|
+
|
|
2263
|
+
3. **错误处理**
|
|
2264
|
+
- 调用前检查 `ref` 是否已挂载:`ganttRef.value?.methodName()`
|
|
2265
|
+
- 在 `onMounted` 生命周期之后调用更安全
|
|
2266
|
+
|
|
2267
|
+
**完整示例可参考:**
|
|
2268
|
+
- npm-demo 项目:`npm-demo/src/components/GanttTest.vue`
|
|
2269
|
+
- npm-webpack-demo 项目:`npm-webpack-demo/src/App.vue`
|
|
2270
|
+
|
|
2271
|
+
---
|
|
2272
|
+
|
|
2035
2273
|
### 主题与国际化
|
|
2036
2274
|
|
|
2037
2275
|
#### 主题切换
|