@cimom/ci-web-plugins-commom 1.0.12 → 1.0.15
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 +171 -158
- package/dist/CI.Web.Plugins.Commom.css +2 -2
- package/dist/DhtmlxGanttPro/README.md +360 -0
- package/dist/DhtmlxGanttPro/index.js +1 -0
- package/dist/SearchPro/SearchPro.bundle.js +2 -2
- package/dist/VxeGridPro/README.md +91 -91
- package/dist/VxeModalPro/README.md +122 -122
- package/dist/VxeTablePro/README.md +86 -86
- package/dist/components/DhtmlxGanttPro/index.vue/index.js +1 -0
- package/dist/components/DhtmlxGanttPro/index.vue/index2.js +1 -0
- package/dist/components/DhtmlxGanttPro/index.vue/index3.js +1 -0
- package/dist/components/SearchPro/index.vue/index2.js +1 -1
- package/dist/components/SearchPro/innerComponents/reportSelectTable.vue/index2.js +1 -1
- package/dist/components/SearchPro/tableTemplate/index.vue/index2.js +1 -1
- package/dist/components/SearchPro/tableTemplate/second.vue/index2.js +1 -1
- package/dist/components/VxeGridPro/index.vue/index2.js +1 -1
- package/dist/components/VxeTablePro/index.vue/index2.js +1 -1
- package/dist/config/index/index.js +1 -1
- package/dist/index/index.js +1 -1
- package/package.json +11 -6
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
# DhtmlxGanttPro 插件
|
|
2
|
+
|
|
3
|
+
基于 DHTMLX-Gantt 的 Vue3 封装组件,提供开箱即用的甘特图功能。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- ✅ **Vue3 Composition API** - 使用最新的 Vue3 语法
|
|
8
|
+
- ✅ **TypeScript 支持** - 完整的类型定义
|
|
9
|
+
- ✅ **响应式数据** - 支持数据动态更新
|
|
10
|
+
- ✅ **事件系统** - 完整的事件回调机制
|
|
11
|
+
- ✅ **配置灵活** - 支持自定义配置和主题
|
|
12
|
+
- ✅ **中文本地化** - 内置中文界面支持
|
|
13
|
+
- ✅ **只读模式** - 支持只读和编辑模式切换
|
|
14
|
+
- ✅ **生命周期管理** - 自动处理组件初始化和销毁
|
|
15
|
+
- ✅ **错误处理** - 完善的错误处理和恢复机制
|
|
16
|
+
|
|
17
|
+
## 安装
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @cimom/ci-web-plugins-commom dhtmlx-gantt
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 基础用法
|
|
24
|
+
|
|
25
|
+
```vue
|
|
26
|
+
<template>
|
|
27
|
+
<div>
|
|
28
|
+
<DhtmlxGanttPro
|
|
29
|
+
:data="ganttData"
|
|
30
|
+
:links="ganttLinks"
|
|
31
|
+
:height="'500px'"
|
|
32
|
+
@task-click="onTaskClick"
|
|
33
|
+
@task-change="onTaskChange"
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
</template>
|
|
37
|
+
|
|
38
|
+
<script>
|
|
39
|
+
import { ref } from 'vue'
|
|
40
|
+
import { DhtmlxGanttPro } from '@cimom/ci-web-plugins-commom'
|
|
41
|
+
|
|
42
|
+
export default {
|
|
43
|
+
components: {
|
|
44
|
+
DhtmlxGanttPro
|
|
45
|
+
},
|
|
46
|
+
setup() {
|
|
47
|
+
const ganttData = ref([
|
|
48
|
+
{ id: 1, text: '任务1', start_date: '2024-01-01', duration: 5, progress: 0.6 },
|
|
49
|
+
{ id: 2, text: '任务2', start_date: '2024-01-08', duration: 3, progress: 0.3 }
|
|
50
|
+
])
|
|
51
|
+
|
|
52
|
+
const ganttLinks = ref([
|
|
53
|
+
{ id: 1, source: 1, target: 2, type: '0' }
|
|
54
|
+
])
|
|
55
|
+
|
|
56
|
+
const onTaskClick = ({ task }) => {
|
|
57
|
+
console.log('点击任务:', task)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const onTaskChange = ({ id, task }) => {
|
|
61
|
+
console.log('任务变更:', id, task)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
ganttData,
|
|
66
|
+
ganttLinks,
|
|
67
|
+
onTaskClick,
|
|
68
|
+
onTaskChange
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
</script>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 按需引入
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
import { DhtmlxGanttPro } from '@cimom/ci-web-plugins-commom/DhtmlxGanttPro'
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## 全局注册
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
import { createApp } from 'vue'
|
|
85
|
+
import CIWebPlugins from '@cimom/ci-web-plugins-commom'
|
|
86
|
+
import 'dhtmlx-gantt/codebase/dhtmlxgantt.css'
|
|
87
|
+
|
|
88
|
+
const app = createApp(App)
|
|
89
|
+
app.use(CIWebPlugins)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Props
|
|
93
|
+
|
|
94
|
+
| 参数 | 类型 | 默认值 | 说明 |
|
|
95
|
+
|------|------|--------|------|
|
|
96
|
+
| width | String/Number | '100%' | 甘特图宽度 |
|
|
97
|
+
| height | String/Number | '500px' | 甘特图高度 |
|
|
98
|
+
| data | Array | [] | 任务数据 |
|
|
99
|
+
| links | Array | [] | 任务依赖关系数据 |
|
|
100
|
+
| config | Object | {} | 甘特图配置 |
|
|
101
|
+
| readonly | Boolean | false | 是否只读模式 |
|
|
102
|
+
| locale | String | 'cn' | 本地化语言 |
|
|
103
|
+
| theme | String | 'default' | 主题样式 |
|
|
104
|
+
|
|
105
|
+
## 数据格式
|
|
106
|
+
|
|
107
|
+
### 任务数据 (data)
|
|
108
|
+
|
|
109
|
+
```javascript
|
|
110
|
+
[
|
|
111
|
+
{
|
|
112
|
+
id: 1, // 任务ID (必需)
|
|
113
|
+
text: '任务名称', // 任务名称 (必需)
|
|
114
|
+
start_date: '2024-01-01', // 开始日期 (必需)
|
|
115
|
+
duration: 5, // 工期 (必需)
|
|
116
|
+
progress: 0.6, // 进度 0-1
|
|
117
|
+
parent: 0, // 父任务ID
|
|
118
|
+
type: 'task', // 任务类型
|
|
119
|
+
color: '#3498db', // 颜色
|
|
120
|
+
priority: 1, // 优先级
|
|
121
|
+
// ... 其他自定义字段
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 依赖关系数据 (links)
|
|
127
|
+
|
|
128
|
+
```javascript
|
|
129
|
+
[
|
|
130
|
+
{
|
|
131
|
+
id: 1, // 链接ID (必需)
|
|
132
|
+
source: 1, // 源任务ID (必需)
|
|
133
|
+
target: 2, // 目标任务ID (必需)
|
|
134
|
+
type: '0' // 链接类型: '0'-'结束到开始', '1'-'开始到开始', '2'-'结束到结束', '3'-'开始到结束'
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## 事件
|
|
140
|
+
|
|
141
|
+
| 事件名 | 参数 | 说明 |
|
|
142
|
+
|--------|------|------|
|
|
143
|
+
| task-click | { task, event } | 任务点击 |
|
|
144
|
+
| task-dblclick | { task, event } | 任务双击 |
|
|
145
|
+
| task-change | { id, task } | 任务变更 |
|
|
146
|
+
| task-add | { id, task } | 任务添加 |
|
|
147
|
+
| task-delete | { id } | 任务删除 |
|
|
148
|
+
| data-loaded | { data, links } | 数据加载完成 |
|
|
149
|
+
| data-error | error | 数据加载错误 |
|
|
150
|
+
| view-change | { mode } | 视图变更 |
|
|
151
|
+
| scale-change | - | 时间尺度变更 |
|
|
152
|
+
|
|
153
|
+
## 配置选项
|
|
154
|
+
|
|
155
|
+
```javascript
|
|
156
|
+
const config = {
|
|
157
|
+
// 日期格式
|
|
158
|
+
date_format: '%Y-%m-%d',
|
|
159
|
+
|
|
160
|
+
// 时间尺度
|
|
161
|
+
scale_unit: 'day', // 'minute', 'hour', 'day', 'week', 'month', 'year'
|
|
162
|
+
date_scale: '%m/%d',
|
|
163
|
+
step: 1,
|
|
164
|
+
|
|
165
|
+
// 子尺度
|
|
166
|
+
subscales: [
|
|
167
|
+
{ unit: 'month', step: 1, date: '%Y年%m月' }
|
|
168
|
+
],
|
|
169
|
+
|
|
170
|
+
// 列配置
|
|
171
|
+
columns: [
|
|
172
|
+
{ name: 'text', label: '任务名称', width: 150, tree: true },
|
|
173
|
+
{ name: 'start_date', label: '开始时间', width: 80 },
|
|
174
|
+
{ name: 'duration', label: '工期', width: 60 },
|
|
175
|
+
{ name: 'progress', label: '进度', width: 60 }
|
|
176
|
+
],
|
|
177
|
+
|
|
178
|
+
// 其他配置...
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## 方法
|
|
183
|
+
|
|
184
|
+
通过 ref 可以调用以下方法:
|
|
185
|
+
|
|
186
|
+
```javascript
|
|
187
|
+
const ganttRef = ref(null)
|
|
188
|
+
|
|
189
|
+
// 获取甘特图实例
|
|
190
|
+
const ganttInstance = ganttRef.value.getGanttInstance()
|
|
191
|
+
|
|
192
|
+
// 刷新甘特图 - 重新应用配置
|
|
193
|
+
ganttRef.value.refresh()
|
|
194
|
+
|
|
195
|
+
// 获取选中的任务
|
|
196
|
+
const selectedTask = ganttRef.value.getSelectedTask()
|
|
197
|
+
|
|
198
|
+
// 添加任务
|
|
199
|
+
ganttRef.value.addTask({
|
|
200
|
+
text: '新任务',
|
|
201
|
+
start_date: '2024-01-01',
|
|
202
|
+
duration: 3
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
// 更新任务
|
|
206
|
+
ganttRef.value.updateTask(1, {
|
|
207
|
+
text: '更新的任务',
|
|
208
|
+
progress: 0.8
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
// 删除任务
|
|
212
|
+
ganttRef.value.deleteTask(1)
|
|
213
|
+
|
|
214
|
+
// 缩放到适应所有任务
|
|
215
|
+
ganttRef.value.fitToTask()
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### 配置更新
|
|
219
|
+
|
|
220
|
+
为了避免递归更新问题,配置变更不会自动应用到甘特图。如需更新配置,请调用 `refresh()` 方法:
|
|
221
|
+
|
|
222
|
+
```javascript
|
|
223
|
+
const ganttRef = ref(null)
|
|
224
|
+
const ganttConfig = ref({
|
|
225
|
+
scale_unit: 'day',
|
|
226
|
+
date_scale: '%m/%d'
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
// 更新配置后刷新
|
|
230
|
+
const updateConfig = () => {
|
|
231
|
+
ganttConfig.value.scale_unit = 'week'
|
|
232
|
+
ganttConfig.value.date_scale = '%W周'
|
|
233
|
+
|
|
234
|
+
// 手动刷新以应用新配置
|
|
235
|
+
nextTick(() => {
|
|
236
|
+
ganttRef.value?.refresh()
|
|
237
|
+
})
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## 高级用法
|
|
242
|
+
|
|
243
|
+
### 自定义主题
|
|
244
|
+
|
|
245
|
+
```vue
|
|
246
|
+
<template>
|
|
247
|
+
<DhtmlxGanttPro
|
|
248
|
+
:data="ganttData"
|
|
249
|
+
:theme="'dark'"
|
|
250
|
+
:config="customConfig"
|
|
251
|
+
/>
|
|
252
|
+
</template>
|
|
253
|
+
|
|
254
|
+
<script>
|
|
255
|
+
const customConfig = {
|
|
256
|
+
// 自定义样式配置
|
|
257
|
+
grid_width: 350,
|
|
258
|
+
add_column: false,
|
|
259
|
+
autosize: 'y',
|
|
260
|
+
details_on_create: true,
|
|
261
|
+
// 更多配置...
|
|
262
|
+
}
|
|
263
|
+
</script>
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### 动态数据加载
|
|
267
|
+
|
|
268
|
+
```javascript
|
|
269
|
+
const loadProjectData = async (projectId) => {
|
|
270
|
+
try {
|
|
271
|
+
const response = await fetch(`/api/projects/${projectId}`)
|
|
272
|
+
const { data, links } = await response.json()
|
|
273
|
+
|
|
274
|
+
ganttData.value = data
|
|
275
|
+
ganttLinks.value = links
|
|
276
|
+
} catch (error) {
|
|
277
|
+
console.error('数据加载失败:', error)
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### 只读模式
|
|
283
|
+
|
|
284
|
+
```vue
|
|
285
|
+
<template>
|
|
286
|
+
<div>
|
|
287
|
+
<button @click="toggleReadonly">
|
|
288
|
+
{{ readonly ? '编辑模式' : '只读模式' }}
|
|
289
|
+
</button>
|
|
290
|
+
|
|
291
|
+
<DhtmlxGanttPro
|
|
292
|
+
:data="ganttData"
|
|
293
|
+
:readonly="readonly"
|
|
294
|
+
/>
|
|
295
|
+
</div>
|
|
296
|
+
</template>
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## 样式定制
|
|
300
|
+
|
|
301
|
+
```css
|
|
302
|
+
/* 容器样式 */
|
|
303
|
+
.dhtmlx-gantt-pro {
|
|
304
|
+
border-radius: 8px;
|
|
305
|
+
overflow: hidden;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/* 任务条样式 */
|
|
309
|
+
:deep(.gantt_task_line) {
|
|
310
|
+
border-radius: 4px;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/* 进度条样式 */
|
|
314
|
+
:deep(.gantt_task_progress) {
|
|
315
|
+
border-radius: 4px;
|
|
316
|
+
background: linear-gradient(90deg, #4CAF50, #45a049);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/* 网格头部样式 */
|
|
320
|
+
:deep(.gantt_grid_scale) {
|
|
321
|
+
background: #f8f9fa;
|
|
322
|
+
border-bottom: 2px solid #e9ecef;
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
## 注意事项
|
|
327
|
+
|
|
328
|
+
1. **依赖版本**: 确保安装了正确版本的 `dhtmlx-gantt`
|
|
329
|
+
2. **CSS 样式**: 需要导入 `dhtmlx-gantt/codebase/dhtmlxgantt.css`
|
|
330
|
+
3. **数据格式**: 严格按照文档格式提供数据
|
|
331
|
+
4. **性能优化**: 大量数据时建议使用分页或虚拟滚动
|
|
332
|
+
5. **浏览器兼容**: 支持现代浏览器,IE 需要额外 polyfill
|
|
333
|
+
|
|
334
|
+
## 常见问题
|
|
335
|
+
|
|
336
|
+
### Q: 甘特图不显示?
|
|
337
|
+
A: 检查是否正确导入了 CSS 文件,确保容器有正确的宽高。
|
|
338
|
+
|
|
339
|
+
### Q: 数据更新后视图不刷新?
|
|
340
|
+
A: 确保使用响应式数据,或者调用 `refresh()` 方法。
|
|
341
|
+
|
|
342
|
+
### Q: 如何自定义列?
|
|
343
|
+
A: 在 `config.columns` 中配置列定义。
|
|
344
|
+
|
|
345
|
+
### Q: 如何处理大量数据?
|
|
346
|
+
A: 建议使用分页加载,或者启用虚拟滚动。
|
|
347
|
+
|
|
348
|
+
## 更新日志
|
|
349
|
+
|
|
350
|
+
### v1.0.0
|
|
351
|
+
- 🎉 初始版本发布
|
|
352
|
+
- ✨ 支持 Vue3 Composition API
|
|
353
|
+
- ✨ 完整的事件系统
|
|
354
|
+
- ✨ 中文本地化支持
|
|
355
|
+
- ✨ 只读模式
|
|
356
|
+
- ✨ TypeScript 类型定义
|
|
357
|
+
|
|
358
|
+
## 许可证
|
|
359
|
+
|
|
360
|
+
MIT License
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../components/DhtmlxGanttPro/index.vue/index.js";export{default}from"../components/DhtmlxGanttPro/index.vue/index2.js";
|