-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathindex.ts
More file actions
75 lines (68 loc) · 2.13 KB
/
index.ts
File metadata and controls
75 lines (68 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import IntentNodeVue from './index.vue'
import { AppNode, AppNodeModel } from '@/workflow/common/app-node'
class IntentNode extends AppNode {
constructor(props: any) {
super(props, IntentNodeVue)
}
}
const get_up_index_height = (branch_list: Array<any>, index: number) => {
return branch_list
.filter((item, i) => i < index)
.map((item) => item.height + 8)
.reduce((x,y) => x+y, 0)
}
class IntentModel extends AppNodeModel {
refreshBranch() {
// 更新节点连接边的path
this.incoming.edges.forEach((edge: any) => {
// 调用自定义的更新方案
edge.updatePathByAnchor()
})
this.outgoing.edges.forEach((edge: any) => {
edge.updatePathByAnchor()
})
}
getDefaultAnchor() {
const {
id,
x,
y,
width,
height,
properties: { branch_condition_list }
} = this
if (this.height === undefined) {
this.height = 200
}
const showNode = this.properties.showNode === undefined ? true : this.properties.showNode
const anchors: any = []
anchors.push({
x: x - width / 2 + 10,
y: showNode ? y : y - 15,
id: `${id}_left`,
edgeAddable: false,
type: 'left'
})
if (branch_condition_list) {
const FORM_ITEMS_HEIGHT = 382 // 上方表单占用高度
for (let index = 0; index < branch_condition_list.length; index++) {
const element = branch_condition_list[index]
const h = get_up_index_height(branch_condition_list, index)
anchors.push({
x: x + width / 2 - 10,
y: showNode
? y - height / 2 + FORM_ITEMS_HEIGHT + h + element.height / 2
: y - 15,
id: `${id}_${element.id}_right`,
type: 'right'
})
}
}
return anchors
}
}
export default {
type: 'intent-node',
model: IntentModel,
view: IntentNode
}