lw-cdp-ui 1.1.57 → 1.1.59
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/dist/components/lwFlow/index.vue +108 -3
- package/dist/lw-cdp-ui.esm.js +1447 -1373
- package/dist/lw-cdp-ui.umd.js +9 -9
- package/dist/style.css +1 -1
- package/package.json +55 -53
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
import LogicFlow from '@logicflow/core'
|
|
32
32
|
import '@logicflow/core/dist/index.css';
|
|
33
33
|
import { Menu, MiniMap } from "@logicflow/extension";
|
|
34
|
+
import { dagre } from '@logicflow/layout';
|
|
34
35
|
import '@logicflow/extension/lib/style/index.css';
|
|
35
36
|
|
|
36
37
|
// 注册组件
|
|
@@ -82,6 +83,33 @@ export default {
|
|
|
82
83
|
return {}
|
|
83
84
|
}
|
|
84
85
|
},
|
|
86
|
+
/**
|
|
87
|
+
* 节点数据 在没有完整modelValue 用以自动创建节点
|
|
88
|
+
*/
|
|
89
|
+
nodes: {
|
|
90
|
+
type: Array,
|
|
91
|
+
default: () => {
|
|
92
|
+
return []
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
/**
|
|
96
|
+
* 节点配置初始化数据
|
|
97
|
+
*/
|
|
98
|
+
nodeDatas: {
|
|
99
|
+
type: Object,
|
|
100
|
+
default: () => {
|
|
101
|
+
return nodeDatas
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
/**
|
|
105
|
+
* 节点配置
|
|
106
|
+
*/
|
|
107
|
+
configNodesList: {
|
|
108
|
+
type: Object,
|
|
109
|
+
default: () => {
|
|
110
|
+
return configNodesList
|
|
111
|
+
}
|
|
112
|
+
},
|
|
85
113
|
/**
|
|
86
114
|
* 是否显示默认节点
|
|
87
115
|
*/
|
|
@@ -246,7 +274,7 @@ export default {
|
|
|
246
274
|
this.logicFlow = new LogicFlow({
|
|
247
275
|
container: this.$refs.container,
|
|
248
276
|
// 注册组件
|
|
249
|
-
plugins: [Menu, MiniMap],
|
|
277
|
+
plugins: [Menu, MiniMap, dagre],
|
|
250
278
|
// 不可编辑
|
|
251
279
|
isSilentMode: this.isView,
|
|
252
280
|
hoverOutline: !this.isView,
|
|
@@ -256,11 +284,75 @@ export default {
|
|
|
256
284
|
})
|
|
257
285
|
this.initMenu()
|
|
258
286
|
await this.initNode()
|
|
259
|
-
|
|
287
|
+
if (!this.modelValue) {
|
|
288
|
+
this.logicFlow.render(this.modelValue)
|
|
289
|
+
} else {
|
|
290
|
+
// 根据节点数据初始化节点
|
|
291
|
+
this.initNodeData()
|
|
292
|
+
}
|
|
293
|
+
|
|
260
294
|
this.bindEvent()
|
|
261
295
|
// 内容移动到中心
|
|
262
296
|
this.logicFlow.translateCenter()
|
|
263
297
|
},
|
|
298
|
+
/**
|
|
299
|
+
* 根据node 初始化数据
|
|
300
|
+
*/
|
|
301
|
+
async initNodeData() {
|
|
302
|
+
function getUUID() {
|
|
303
|
+
return 'xxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
304
|
+
const r = (Math.random() * 16) | 0; // 生成 0-15 的随机数
|
|
305
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8; // 如果是 'x' 使用随机数,否则按规则生成
|
|
306
|
+
return v.toString(16); // 转换为16进制字符串
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
function generateNode(data) {
|
|
310
|
+
return {
|
|
311
|
+
id: getUUID(),
|
|
312
|
+
type: data.type || "",
|
|
313
|
+
x: 0, // 可根据实际需要动态调整
|
|
314
|
+
y: 0, // 可根据实际需要动态调整
|
|
315
|
+
properties: {
|
|
316
|
+
data
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function generateEdge(sourceNode, targetNode) {
|
|
322
|
+
return {
|
|
323
|
+
id: getUUID(),
|
|
324
|
+
type: "polyline",
|
|
325
|
+
sourceNodeId: sourceNode.id,
|
|
326
|
+
targetNodeId: targetNode.id,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
const nodes = [];
|
|
330
|
+
const edges = [];
|
|
331
|
+
const nodeMap = {};
|
|
332
|
+
|
|
333
|
+
// 创建节点
|
|
334
|
+
this.nodes.forEach(item => {
|
|
335
|
+
const node = generateNode(item);
|
|
336
|
+
nodes.push(node);
|
|
337
|
+
nodeMap[item.into] = node;
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
// 创建边
|
|
341
|
+
this.nodes.forEach(item => {
|
|
342
|
+
const sourceKey = item.from;
|
|
343
|
+
const targetKey = item.into;
|
|
344
|
+
if (nodeMap[sourceKey] && nodeMap[targetKey]) {
|
|
345
|
+
edges.push(generateEdge(nodeMap[sourceKey], nodeMap[targetKey]));
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
this.logicFlow.renderRawData({
|
|
350
|
+
nodes,
|
|
351
|
+
edges
|
|
352
|
+
})
|
|
353
|
+
this.logicFlow.extension.dagre.layout()
|
|
354
|
+
|
|
355
|
+
},
|
|
264
356
|
/**
|
|
265
357
|
* 初始化右键菜单
|
|
266
358
|
*/
|
|
@@ -375,6 +467,16 @@ export default {
|
|
|
375
467
|
}
|
|
376
468
|
}
|
|
377
469
|
},
|
|
470
|
+
/**
|
|
471
|
+
* 处理流程图数据 返回纯节点
|
|
472
|
+
*/
|
|
473
|
+
getNodes(nodes) {
|
|
474
|
+
let list = []
|
|
475
|
+
nodes.forEach((node) => {
|
|
476
|
+
list.push({ ...node.properties.data, type: node.type })
|
|
477
|
+
})
|
|
478
|
+
return list
|
|
479
|
+
},
|
|
378
480
|
/**
|
|
379
481
|
* 节点绑定事件
|
|
380
482
|
*/
|
|
@@ -394,8 +496,11 @@ export default {
|
|
|
394
496
|
let { undos } = data
|
|
395
497
|
// 返回所有历史数据
|
|
396
498
|
this.$emit('change', undos)
|
|
397
|
-
// 同步最后数据
|
|
499
|
+
// 同步最后数据 原始流程数据
|
|
398
500
|
this.$emit('update:modelValue', undos[undos.length - 1])
|
|
501
|
+
|
|
502
|
+
// 处理后的nodes 数据
|
|
503
|
+
this.$emit("update:nodes", this.getNodes(undos[undos.length - 1].nodes, undos[undos.length - 1].edges))
|
|
399
504
|
})
|
|
400
505
|
|
|
401
506
|
// 错误提示
|