gantt-planing-vue 0.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/LICENSE +21 -0
- package/README.md +199 -0
- package/dist/gantt-planing-vue.js +2507 -0
- package/dist/gantt-planing-vue.umd.cjs +8 -0
- package/dist/index.d.ts +1080 -0
- package/dist/style.css +1 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 GOaroundT-T
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# gantt-planing-vue
|
|
2
|
+
|
|
3
|
+
现代化 Vue 3 工程项目进度管理与 4 合 1 网络图引擎组件库(甘特图 + 时标网络图 + 双代号 ADM + 单代号 PERT/PDM 前导图),原生支持 CAD 级平移缩放视口与关键路径法(CPM)算法。
|
|
4
|
+
|
|
5
|
+
[](https://vuejs.org/)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
[](https://vitejs.dev/)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 🌟 核心特性
|
|
13
|
+
|
|
14
|
+
### 1. 4 合 1 进度图表引擎(统一底层数据驱动)
|
|
15
|
+
- **甘特图(Gantt Chart)**:
|
|
16
|
+
- 无限级任务树与表格(WBS、工期、进度、起止日期)。
|
|
17
|
+
- 大数据高性能**手动虚拟滚动**(Phantom 容器 + translateY 视口裁剪)。
|
|
18
|
+
- **指针式响应式拖拽**:支持任务条整体平移、左右端工期拉伸、进度拖动。
|
|
19
|
+
- **依赖连线绘制**:拖动任务条右侧连线锚点直接拉线连接紧后任务。
|
|
20
|
+
- **丰富快捷键操作**:`Tab`(任务降级为子节点)、`Shift + Tab`(任务升级)、`Delete`(删除任务)、`Ctrl + D`(快捷复制下行新建)、`Ctrl + X / C / V`(任务剪切/复制/粘贴)。
|
|
21
|
+
- **时标网络图(Time-Scaled Network Diagram)**:
|
|
22
|
+
- 水平实箭线表示工作持续时间 $DU$。
|
|
23
|
+
- 工程标准**自由时差波形线(Wave Line / Free Float FF)**自动生成。
|
|
24
|
+
- 紧后工作折线/垂直逻辑转移线。
|
|
25
|
+
- **双代号网络图(ADM - Arrow Diagramming Method)**:
|
|
26
|
+
- 节点为事件编号圆圈 $(i) \to (j)$,满足拓扑编号 $i < j$。
|
|
27
|
+
- 箭线上方标注工作名称,下方标注持续时间。
|
|
28
|
+
- 逻辑断路与虚工作自动生成**虚箭线(Dashed Arrow)**。
|
|
29
|
+
- **单代号 / PERT 前导图(PDM - Precedence Diagramming Method)**:
|
|
30
|
+
- 工程级**标准六参数活动卡片**:
|
|
31
|
+
$$\begin{array}{|c|c|c|} \hline \text{最早开始 (ES)} & \text{工期 (DU)} & \text{最早完成 (EF)} \\ \hline \multicolumn{3}{|c|}{\text{工作名称 / 关键路径徽标}} \\ \hline \text{最迟开始 (LS)} & \text{总时差 (TF)} & \text{最迟完成 (LF)} \\ \hline \end{array}$$
|
|
32
|
+
- 基于拓扑分层的 Sugiyama 正交避让连线布局。
|
|
33
|
+
|
|
34
|
+
### 2. 关键路径法(CPM)引擎
|
|
35
|
+
- 内置标准 CPM 前向正推算法(Forward Pass,求 $ES, EF$)与逆向逆推算法(Backward Pass,求 $LS, LF$)。
|
|
36
|
+
- 自动计算**总时差(Total Float $TF$)**与**自由时差(Free Float $FF$)**。
|
|
37
|
+
- 自动识别关键工作($TF = 0$)并在图表中以醒目红色标注**关键线路(Critical Path)**。
|
|
38
|
+
|
|
39
|
+
### 3. CAD 级交互视口(useCadViewport)
|
|
40
|
+
- **无级缩放**:滚轮以鼠标当前光标坐标为中心无级放大/缩小(20% ~ 350%)。
|
|
41
|
+
- **画布平移**:鼠标左键/中键拖拽画布无限平移。
|
|
42
|
+
- **CAD 控制台**:放大、缩小、1:1 原始比例还原、**一键全图自适应居中(Fit to Screen)**。
|
|
43
|
+
- 点阵背景底纹与图例系统。
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 📦 安装
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install gantt-planing-vue
|
|
51
|
+
# 或者
|
|
52
|
+
pnpm add gantt-planing-vue
|
|
53
|
+
# 或者
|
|
54
|
+
yarn add gantt-planing-vue
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 🚀 快速上手
|
|
60
|
+
|
|
61
|
+
### 1. 全局注册插件
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
// main.ts
|
|
65
|
+
import { createApp } from 'vue'
|
|
66
|
+
import App from './App.vue'
|
|
67
|
+
import GanttPlaningVue from 'gantt-planing-vue'
|
|
68
|
+
import 'gantt-planing-vue/style.css'
|
|
69
|
+
|
|
70
|
+
const app = createApp(App)
|
|
71
|
+
app.use(GanttPlaningVue)
|
|
72
|
+
app.mount('#app')
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 2. 在组件中使用
|
|
76
|
+
|
|
77
|
+
```vue
|
|
78
|
+
<script setup lang="ts">
|
|
79
|
+
import { ref } from 'vue'
|
|
80
|
+
import { GanttChart, ScaleMode, ViewMode, type Task, type TreeColumn } from 'gantt-planing-vue'
|
|
81
|
+
|
|
82
|
+
const tasks = ref<Task[]>([
|
|
83
|
+
{
|
|
84
|
+
id: 1,
|
|
85
|
+
parent_id: 0,
|
|
86
|
+
name: '基础工程',
|
|
87
|
+
duration: 5,
|
|
88
|
+
progress: 40,
|
|
89
|
+
start: new Date(2026, 8, 1),
|
|
90
|
+
end: new Date(2026, 8, 6),
|
|
91
|
+
children: [],
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: 2,
|
|
95
|
+
parent_id: 0,
|
|
96
|
+
name: '主体结构施工',
|
|
97
|
+
duration: 10,
|
|
98
|
+
progress: 10,
|
|
99
|
+
dependencies: ['1'], // 紧前任务为基础工程
|
|
100
|
+
start: new Date(2026, 8, 6),
|
|
101
|
+
end: new Date(2026, 8, 16),
|
|
102
|
+
children: [],
|
|
103
|
+
},
|
|
104
|
+
])
|
|
105
|
+
|
|
106
|
+
const columns = ref<TreeColumn[]>([
|
|
107
|
+
{ type: 'selection', title: '任务名称', field: 'name', width: 260, align: 'left' },
|
|
108
|
+
{ title: '工期', field: 'duration', width: 80, align: 'center' },
|
|
109
|
+
{ title: '进度', field: 'progress', width: 80, align: 'center' },
|
|
110
|
+
])
|
|
111
|
+
|
|
112
|
+
const viewMode = ref<ViewMode>(ViewMode.GanttViewer)
|
|
113
|
+
const scaleMode = ref<ScaleMode>(ScaleMode.Day)
|
|
114
|
+
</script>
|
|
115
|
+
|
|
116
|
+
<template>
|
|
117
|
+
<div style="width: 100vw; height: 100vh;">
|
|
118
|
+
<!-- 切换模式:ViewMode.GanttViewer | ViewMode.TimeViewer | ViewMode.AdmViewer | ViewMode.PdmViewer -->
|
|
119
|
+
<GanttChart
|
|
120
|
+
v-model:tasks="tasks"
|
|
121
|
+
:task-data="tasks"
|
|
122
|
+
:column-data="columns"
|
|
123
|
+
:scale-mode="scaleMode"
|
|
124
|
+
:view-mode="viewMode"
|
|
125
|
+
/>
|
|
126
|
+
</div>
|
|
127
|
+
</template>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## 🛠️ 单独使用 CAD 网络图查看器
|
|
133
|
+
|
|
134
|
+
如果只需要使用独立的 CAD 网络图查看器,可以直接使用 `DiagramViewer`:
|
|
135
|
+
|
|
136
|
+
```vue
|
|
137
|
+
<script setup lang="ts">
|
|
138
|
+
import { ref } from 'vue'
|
|
139
|
+
import { DiagramViewer, type Task } from 'gantt-planing-vue'
|
|
140
|
+
|
|
141
|
+
const tasks = ref<Task[]>([/* 任务数据 */])
|
|
142
|
+
const mode = ref<'time' | 'adm' | 'pert'>('pert')
|
|
143
|
+
</script>
|
|
144
|
+
|
|
145
|
+
<template>
|
|
146
|
+
<div style="width: 1000px; height: 600px;">
|
|
147
|
+
<DiagramViewer
|
|
148
|
+
:tasks="tasks"
|
|
149
|
+
:mode="mode"
|
|
150
|
+
:show-toolbar="true"
|
|
151
|
+
:show-legend="true"
|
|
152
|
+
/>
|
|
153
|
+
</div>
|
|
154
|
+
</template>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## 🧮 独立调用 CPM 关键路径算法
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
import { calculateCpm } from 'gantt-planing-vue'
|
|
163
|
+
|
|
164
|
+
const result = calculateCpm(tasks)
|
|
165
|
+
console.log('总工期:', result.totalDuration)
|
|
166
|
+
console.log('关键线路任务 ID 列表:', result.criticalPath)
|
|
167
|
+
|
|
168
|
+
// 每个活动的六参数:
|
|
169
|
+
result.activityList.forEach(act => {
|
|
170
|
+
console.log(`${act.name}: ES=${act.es}, EF=${act.ef}, LS=${act.ls}, LF=${act.lf}, 总时差TF=${act.tf}, 自由时差FF=${act.ff}, 关键工作=${act.isCritical}`)
|
|
171
|
+
})
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## 💻 本地运行 Demo
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# 进入项目根目录
|
|
180
|
+
cd gantt-planing-vue
|
|
181
|
+
|
|
182
|
+
# 安装依赖
|
|
183
|
+
npm install
|
|
184
|
+
|
|
185
|
+
# 启动 Vite 开发服务器预览 Demo
|
|
186
|
+
npm run dev
|
|
187
|
+
|
|
188
|
+
# 运行类型检查
|
|
189
|
+
npm run typecheck
|
|
190
|
+
|
|
191
|
+
# 构建生产产物
|
|
192
|
+
npm run build
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## 📄 开源许可证
|
|
198
|
+
|
|
199
|
+
[MIT License](LICENSE) © 2026
|