chbim-time-axis-v2 0.0.12 → 0.0.14
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 +53 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,6 +29,10 @@
|
|
|
29
29
|
npm install chbim-time-axis-v2
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
## 📺 示例项目
|
|
33
|
+
|
|
34
|
+
查看完整的测试项目代码:[TimelineDemoV2](https://github.com/zg95/TimelineDemoV2)
|
|
35
|
+
|
|
32
36
|
## 🚀 快速开始
|
|
33
37
|
|
|
34
38
|
### 1. 引入样式
|
|
@@ -142,10 +146,19 @@ interface GanttTask {
|
|
|
142
146
|
parentId?: string;
|
|
143
147
|
warning?: string; // 内部计算的警告信息
|
|
144
148
|
allowInstant?: boolean; // 是否允许在此任务行上右键添加瞬时点
|
|
149
|
+
attr?: Record<string, any>; // 自定义属性
|
|
150
|
+
class?: string; // 自定义类名
|
|
145
151
|
}
|
|
146
152
|
```
|
|
147
153
|
|
|
148
|
-
### 2.
|
|
154
|
+
### 2. 普通任务 (Task)
|
|
155
|
+
|
|
156
|
+
最基础的任务类型,由开始时间和结束时间定义。
|
|
157
|
+
|
|
158
|
+
- **行为**: 在甘特图上显示为连续的条形,支持拖拽移动和拖拽边缘调整大小。
|
|
159
|
+
- **数据**: 直接使用通用接口中的 `startTime` 和 `endTime`。
|
|
160
|
+
|
|
161
|
+
### 3. 任务组 (Group)
|
|
149
162
|
|
|
150
163
|
用于组织子任务。时间范围通常由子任务决定,但也可以设置限制范围。
|
|
151
164
|
|
|
@@ -161,7 +174,7 @@ interface GanttGroup extends GanttTask {
|
|
|
161
174
|
}
|
|
162
175
|
```
|
|
163
176
|
|
|
164
|
-
###
|
|
177
|
+
### 4. 块状任务 (Block)
|
|
165
178
|
|
|
166
179
|
适用于同一行展示多个不连续的时间段。
|
|
167
180
|
|
|
@@ -171,6 +184,8 @@ interface TaskBlock {
|
|
|
171
184
|
endTime: string;
|
|
172
185
|
name?: string;
|
|
173
186
|
color?: string; // 支持 HEX, RGB 等 CSS 颜色值
|
|
187
|
+
attr?: Record<string, any>; // 自定义属性
|
|
188
|
+
class?: string; // 自定义类名
|
|
174
189
|
}
|
|
175
190
|
|
|
176
191
|
// 在 GanttTask 中使用
|
|
@@ -180,7 +195,7 @@ interface BlockTask extends GanttTask {
|
|
|
180
195
|
}
|
|
181
196
|
```
|
|
182
197
|
|
|
183
|
-
###
|
|
198
|
+
### 5. 瞬时任务 (Instant)
|
|
184
199
|
|
|
185
200
|
适用于展示时间点事件。
|
|
186
201
|
|
|
@@ -190,6 +205,8 @@ interface TaskInstant {
|
|
|
190
205
|
time: string;
|
|
191
206
|
name?: string;
|
|
192
207
|
color?: string;
|
|
208
|
+
attr?: Record<string, any>; // 自定义属性
|
|
209
|
+
class?: string; // 自定义类名
|
|
193
210
|
}
|
|
194
211
|
|
|
195
212
|
// 在 GanttTask 中使用
|
|
@@ -220,6 +237,15 @@ interface InstantTask extends GanttTask {
|
|
|
220
237
|
| `add` | `parentId: string` | 点击分组行的 "+" 按钮时触发。 |
|
|
221
238
|
| `delete` | `taskId: string` | 点击删除按钮时触发。 |
|
|
222
239
|
|
|
240
|
+
### Methods (暴露方法)
|
|
241
|
+
|
|
242
|
+
通过 `ref` 获取组件实例后可调用的方法:
|
|
243
|
+
|
|
244
|
+
| 方法名 | 参数 | 描述 |
|
|
245
|
+
| :--------------- | :--- | :------------- |
|
|
246
|
+
| `toggleMaximize` | - | 切换最大化模式 |
|
|
247
|
+
| `toggleMinimize` | - | 切换最小化模式 |
|
|
248
|
+
|
|
223
249
|
### Slots (插槽)
|
|
224
250
|
|
|
225
251
|
组件提供了丰富的插槽用于自定义 UI。
|
|
@@ -278,6 +304,24 @@ interface InstantTask extends GanttTask {
|
|
|
278
304
|
</template>
|
|
279
305
|
```
|
|
280
306
|
|
|
307
|
+
#### 4. 内容定制插槽
|
|
308
|
+
|
|
309
|
+
支持自定义任务条、时间块和瞬时点的内容渲染。
|
|
310
|
+
|
|
311
|
+
- `barContent`: 自定义普通任务条的内容。参数: `{ bar: GanttTask }`
|
|
312
|
+
- `blockContent`: 自定义时间块的内容。参数: `{ block: TaskBlock, task: GanttTask }`
|
|
313
|
+
- `instantContent`: 自定义瞬时点的内容。参数: `{ instant: TaskInstant, task: GanttTask }`
|
|
314
|
+
|
|
315
|
+
```vue
|
|
316
|
+
<template #barContent="{ bar }">
|
|
317
|
+
<div class="my-bar-content">{{ bar.name }}</div>
|
|
318
|
+
</template>
|
|
319
|
+
|
|
320
|
+
<template #blockContent="{ block }">
|
|
321
|
+
<span>{{ block.name }}</span>
|
|
322
|
+
</template>
|
|
323
|
+
```
|
|
324
|
+
|
|
281
325
|
## 🧩 Cesium 联动机制
|
|
282
326
|
|
|
283
327
|
组件通过 `Cesium.Clock.onTick` 事件与 Cesium 保持高频同步:
|
|
@@ -293,7 +337,12 @@ A:
|
|
|
293
337
|
|
|
294
338
|
- 对于 `block` 类型,在 `blocks` 数组中指定 `color` 属性。
|
|
295
339
|
- 对于 `instant` 类型,在 `instants` 数组中指定 `color` 属性。
|
|
296
|
-
- 对于普通 `task
|
|
340
|
+
- 对于普通 `task`,建议在任务对象中设置 `class` 属性,并通过自定义 CSS 类来控制颜色。例如:
|
|
341
|
+
```css
|
|
342
|
+
.my-red-task {
|
|
343
|
+
background-color: red !important;
|
|
344
|
+
}
|
|
345
|
+
```
|
|
297
346
|
|
|
298
347
|
**Q: 添加瞬时点(Instant)的功能在哪里?**
|
|
299
348
|
A: 在设置了 `allowInstant: true` 的任务行(非分组)对应的空白时间轴区域**右键点击**,会弹出内置菜单 "添加瞬时任务"。
|