@logicflow/extension 2.2.0-alpha.7 → 2.2.1
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 +16 -0
- package/package.json +10 -7
- package/.turbo/turbo-build.log +0 -38
- package/CHANGELOG.md +0 -1829
- package/__test__/bpmn-adapter.test.js +0 -227
- package/es/materials/curved-edge/__test__/curved-edge.test.d.ts +0 -1
- package/es/materials/curved-edge/__test__/curved-edge.test.js +0 -18
- package/jest.config.js +0 -198
- package/lib/materials/curved-edge/__test__/curved-edge.test.d.ts +0 -1
- package/lib/materials/curved-edge/__test__/curved-edge.test.js +0 -20
- package/rollup.config.js +0 -52
- package/src/NodeResize/BasicShape/Ellipse.tsx +0 -22
- package/src/NodeResize/BasicShape/Polygon.tsx +0 -24
- package/src/NodeResize/BasicShape/Rect.tsx +0 -44
- package/src/NodeResize/control/Control.tsx +0 -537
- package/src/NodeResize/control/ControlGroup.tsx +0 -76
- package/src/NodeResize/control/Util.ts +0 -206
- package/src/NodeResize/index.ts +0 -26
- package/src/NodeResize/node/DiamondResize.tsx +0 -149
- package/src/NodeResize/node/EllipseResize.tsx +0 -140
- package/src/NodeResize/node/HtmlResize.tsx +0 -125
- package/src/NodeResize/node/RectResize.tsx +0 -126
- package/src/NodeResize/node/index.ts +0 -4
- package/src/bpmn/constant.ts +0 -56
- package/src/bpmn/events/EndEvent.ts +0 -73
- package/src/bpmn/events/StartEvent.ts +0 -52
- package/src/bpmn/events/index.ts +0 -2
- package/src/bpmn/flow/SequenceFlow.ts +0 -25
- package/src/bpmn/flow/index.ts +0 -1
- package/src/bpmn/gateways/ExclusiveGateway.ts +0 -71
- package/src/bpmn/gateways/index.ts +0 -1
- package/src/bpmn/getBpmnId.ts +0 -31
- package/src/bpmn/index.ts +0 -60
- package/src/bpmn/tasks/ServiceTask.ts +0 -63
- package/src/bpmn/tasks/UserTask.ts +0 -64
- package/src/bpmn/tasks/index.ts +0 -2
- package/src/bpmn-adapter/bpmnIds.ts +0 -31
- package/src/bpmn-adapter/index.ts +0 -835
- package/src/bpmn-adapter/json2xml.ts +0 -127
- package/src/bpmn-adapter/xml2json.ts +0 -544
- package/src/bpmn-elements/README.md +0 -223
- package/src/bpmn-elements/__tests__/definition.test.js +0 -72
- package/src/bpmn-elements/index.d.ts +0 -26
- package/src/bpmn-elements/index.ts +0 -107
- package/src/bpmn-elements/presets/Event/EndEventFactory.ts +0 -114
- package/src/bpmn-elements/presets/Event/IntermediateCatchEvent.ts +0 -108
- package/src/bpmn-elements/presets/Event/IntermediateThrowEvent.ts +0 -109
- package/src/bpmn-elements/presets/Event/StartEventFactory.ts +0 -114
- package/src/bpmn-elements/presets/Event/boundaryEventFactory.ts +0 -117
- package/src/bpmn-elements/presets/Event/index.ts +0 -14
- package/src/bpmn-elements/presets/Flow/flow.d.ts +0 -6
- package/src/bpmn-elements/presets/Flow/index.ts +0 -8
- package/src/bpmn-elements/presets/Flow/manhattan.ts +0 -691
- package/src/bpmn-elements/presets/Flow/sequenceFlow.ts +0 -65
- package/src/bpmn-elements/presets/Gateway/gateway.ts +0 -107
- package/src/bpmn-elements/presets/Gateway/index.ts +0 -23
- package/src/bpmn-elements/presets/Pool/Lane.ts +0 -211
- package/src/bpmn-elements/presets/Pool/Pool.ts +0 -284
- package/src/bpmn-elements/presets/Pool/index.ts +0 -89
- package/src/bpmn-elements/presets/Task/index.ts +0 -122
- package/src/bpmn-elements/presets/Task/subProcess.ts +0 -189
- package/src/bpmn-elements/presets/Task/task.ts +0 -193
- package/src/bpmn-elements/presets/icons.ts +0 -155
- package/src/bpmn-elements/utils.ts +0 -52
- package/src/bpmn-elements-adapter/README.md +0 -293
- package/src/bpmn-elements-adapter/__tests__/adapter_in.test.js +0 -528
- package/src/bpmn-elements-adapter/__tests__/adapter_out.test.js +0 -569
- package/src/bpmn-elements-adapter/constant.ts +0 -76
- package/src/bpmn-elements-adapter/index.ts +0 -1134
- package/src/bpmn-elements-adapter/json2xml.ts +0 -105
- package/src/bpmn-elements-adapter/xml2json.ts +0 -542
- package/src/components/context-menu/index.ts +0 -253
- package/src/components/control/index.ts +0 -155
- package/src/components/dnd-panel/index.ts +0 -137
- package/src/components/highlight/index.ts +0 -227
- package/src/components/menu/index.ts +0 -748
- package/src/components/mini-map/index.ts +0 -686
- package/src/components/selection-select/index.ts +0 -387
- package/src/dynamic-group/index.ts +0 -774
- package/src/dynamic-group/model.ts +0 -580
- package/src/dynamic-group/node.ts +0 -288
- package/src/dynamic-group/utils.ts +0 -46
- package/src/index.less +0 -1
- package/src/index.ts +0 -47
- package/src/insert-node-in-polyline/edge.ts +0 -175
- package/src/insert-node-in-polyline/index.ts +0 -193
- package/src/materials/curved-edge/__test__/curved-edge.test.ts +0 -46
- package/src/materials/curved-edge/index.ts +0 -217
- package/src/materials/group/GroupNode.ts +0 -437
- package/src/materials/group/index.ts +0 -542
- package/src/materials/node-selection/index.ts +0 -380
- package/src/mindmap/fakerRoot.ts +0 -19
- package/src/mindmap/index.ts +0 -328
- package/src/mindmap/markContent.ts +0 -81
- package/src/mindmap/markContentOption.ts +0 -81
- package/src/mindmap/markEntity.ts +0 -82
- package/src/mindmap/markRoot.ts +0 -83
- package/src/mindmap/theme.ts +0 -11
- package/src/pool/LaneModel.ts +0 -226
- package/src/pool/LaneView.ts +0 -220
- package/src/pool/PoolModel.ts +0 -631
- package/src/pool/PoolView.ts +0 -75
- package/src/pool/constant.ts +0 -19
- package/src/pool/index.ts +0 -621
- package/src/pool/utils.ts +0 -46
- package/src/rect-label-node/RectLabelNodeView.ts +0 -33
- package/src/rect-label-node/index.ts +0 -15
- package/src/style/index.less +0 -381
- package/src/style/raw.ts +0 -328
- package/src/tools/auto-layout/index.ts +0 -282
- package/src/tools/flow-path/index.ts +0 -233
- package/src/tools/label/Label.tsx +0 -357
- package/src/tools/label/LabelModel.ts +0 -83
- package/src/tools/label/LabelOverlay.tsx +0 -162
- package/src/tools/label/algorithm.ts +0 -42
- package/src/tools/label/index.ts +0 -479
- package/src/tools/label/mediumEditor.ts +0 -121
- package/src/tools/label/utils.ts +0 -395
- package/src/tools/proximity-connect/index.ts +0 -435
- package/src/tools/snapshot/README.md +0 -145
- package/src/tools/snapshot/index.ts +0 -701
- package/src/tools/snapshot/utils.ts +0 -163
- package/src/turbo-adapter/index.ts +0 -212
- package/stats.html +0 -4842
- package/tsconfig.json +0 -18
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import LogicFlow from '@logicflow/core'
|
|
2
|
-
import PoolNode from './Pool'
|
|
3
|
-
import LaneNode from './Lane'
|
|
4
|
-
|
|
5
|
-
export function laneToJSON(data: any) {
|
|
6
|
-
return `<bpmn:participant id="${data.id}" name="${data.name}" processRef="${data.properties.processRef}"/>`
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function poolToJSON(data: any) {
|
|
10
|
-
return `<bpmn:collaboration id="${data.id}">
|
|
11
|
-
${data.children.map((child: any) => child.toJSON(child)).join('\t\n')}
|
|
12
|
-
</bpmn:collaboration>`
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function poolEvent(lf: any) {
|
|
16
|
-
const selectAll = () => {
|
|
17
|
-
const { nodes = [], edges = [] } = lf.getGraphData()
|
|
18
|
-
nodes.forEach((node: any) => {
|
|
19
|
-
const { id } = node
|
|
20
|
-
if (id) {
|
|
21
|
-
lf.selectElementById(id)
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
edges.forEach((edge: any) => {
|
|
25
|
-
const { id } = edge
|
|
26
|
-
if (id) {
|
|
27
|
-
lf.selectElementById(id)
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
return false
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
lf.keyboard.on('cmd + a', selectAll)
|
|
34
|
-
lf.keyboard.on('ctrl + a', selectAll)
|
|
35
|
-
lf.on('node:dnd-add, edge:add', ({ data }: any) => {
|
|
36
|
-
const { x, y, type, id } = data
|
|
37
|
-
if (type === 'pool') {
|
|
38
|
-
lf.setProperties(data.id, {})
|
|
39
|
-
const poolModel = lf.getNodeModelById(id)
|
|
40
|
-
const { width, height } = poolModel
|
|
41
|
-
const { id: laneId } = lf.addNode({
|
|
42
|
-
type: 'lane',
|
|
43
|
-
properties: {
|
|
44
|
-
nodeSize: {
|
|
45
|
-
width: width - 30,
|
|
46
|
-
height,
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
x: x + 15,
|
|
50
|
-
y,
|
|
51
|
-
})
|
|
52
|
-
poolModel.addChild(laneId)
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
lf.on('node:resize', ({ preData, data }: any) => {
|
|
56
|
-
const { id, type } = preData
|
|
57
|
-
const deltaHeight = data.height - preData.height
|
|
58
|
-
// const resizeDir = data.y - preData.y > 0 ? 'below': 'above'
|
|
59
|
-
// 节点高度变高,y下移, 方向为below
|
|
60
|
-
// 节点高度变高, y上移, 方向为above
|
|
61
|
-
// 节点高度变小, y下移, 方向为above
|
|
62
|
-
// 节点高度变小, y上移,方向为below
|
|
63
|
-
let resizeDir = 'below'
|
|
64
|
-
if (deltaHeight > 0 && data.y - preData.y < 0) {
|
|
65
|
-
resizeDir = 'above'
|
|
66
|
-
} else if (deltaHeight < 0 && data.y - preData.y > 0) {
|
|
67
|
-
resizeDir = 'above'
|
|
68
|
-
}
|
|
69
|
-
if (type === 'pool') {
|
|
70
|
-
// 泳池缩放,泳道一起调整
|
|
71
|
-
lf.getNodeModelById(id).resizeChildren({
|
|
72
|
-
resizeDir,
|
|
73
|
-
deltaHeight,
|
|
74
|
-
})
|
|
75
|
-
} else if (type === 'lane') {
|
|
76
|
-
// 泳道缩放, 调整泳池
|
|
77
|
-
const groupId = lf.extension.group.nodeGroupMap.get(id)
|
|
78
|
-
if (groupId) {
|
|
79
|
-
lf.getNodeModelById(groupId).resize(id, data)
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export const registerPoolNodes = (lf: LogicFlow) => {
|
|
86
|
-
lf.register(PoolNode)
|
|
87
|
-
lf.register(LaneNode)
|
|
88
|
-
poolEvent(lf)
|
|
89
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import LogicFlow from '@logicflow/core'
|
|
2
|
-
import { serviceTaskIcon, userTaskIcon } from '../icons'
|
|
3
|
-
import { TaskNodeFactory } from './task'
|
|
4
|
-
import { SubProcessFactory } from './subProcess'
|
|
5
|
-
|
|
6
|
-
function boundaryEvent(lf: any) {
|
|
7
|
-
lf.on('node:drag,node:dnd-drag', checkAppendBoundaryEvent)
|
|
8
|
-
lf.on('node:drop,node:dnd-add', appendBoundaryEvent)
|
|
9
|
-
lf.graphModel.addNodeMoveRules(
|
|
10
|
-
(
|
|
11
|
-
model: { isTaskNode: any; boundaryEvents: any },
|
|
12
|
-
deltaX: any,
|
|
13
|
-
deltaY: any,
|
|
14
|
-
) => {
|
|
15
|
-
if (model.isTaskNode) {
|
|
16
|
-
// 如果移动的是分组,那么分组的子节点也跟着移动。
|
|
17
|
-
const nodeIds = model.boundaryEvents
|
|
18
|
-
lf.graphModel.moveNodes(nodeIds, deltaX, deltaY, true)
|
|
19
|
-
return true
|
|
20
|
-
}
|
|
21
|
-
return true
|
|
22
|
-
},
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
function appendBoundaryEvent(this: any, { data }: any) {
|
|
26
|
-
const { type, id } = data
|
|
27
|
-
if (type !== 'bpmn:boundaryEvent') {
|
|
28
|
-
return
|
|
29
|
-
}
|
|
30
|
-
const { nodes } = lf.graphModel
|
|
31
|
-
for (const node of nodes) {
|
|
32
|
-
if (node.isTaskNode) {
|
|
33
|
-
let nodeId = null
|
|
34
|
-
if ((nodeId = isBoundaryEventCloseToTask(node, data)) !== null) {
|
|
35
|
-
const eventModel = lf.graphModel.getNodeModelById(id)
|
|
36
|
-
const nodeModel = lf.graphModel.getNodeModelById(nodeId)
|
|
37
|
-
const { attachedToRef } = eventModel.properties
|
|
38
|
-
if (attachedToRef && attachedToRef !== nodeId) {
|
|
39
|
-
lf.graphModel
|
|
40
|
-
.getNodeModelById(attachedToRef)
|
|
41
|
-
.deleteBoundaryEvent(id)
|
|
42
|
-
}
|
|
43
|
-
nodeModel.addBoundaryEvent(id)
|
|
44
|
-
return
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// 判断此节点是否在某个节点的边界上
|
|
51
|
-
// 如果在,且这个节点model存在属性isTaskNode,则调用这个方法
|
|
52
|
-
function checkAppendBoundaryEvent(this: any, { data }: any) {
|
|
53
|
-
const { type } = data
|
|
54
|
-
if (type !== 'bpmn:boundaryEvent') {
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
const { nodes } = lf.graphModel
|
|
58
|
-
for (const node of nodes) {
|
|
59
|
-
if (node.isTaskNode) {
|
|
60
|
-
if (isBoundaryEventCloseToTask(node, data)) {
|
|
61
|
-
// 同时只允许在一个节点的边界上
|
|
62
|
-
node.setTouching(true)
|
|
63
|
-
} else {
|
|
64
|
-
node.setTouching(false)
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function isBoundaryEventCloseToTask(task: any, event: any) {
|
|
71
|
-
const offset = 5
|
|
72
|
-
const { x: tx, y: ty, width: twidth, height: theight, id } = task
|
|
73
|
-
const bbox = {
|
|
74
|
-
minX: tx - twidth / 2,
|
|
75
|
-
maxX: tx + twidth / 2,
|
|
76
|
-
minY: ty - theight / 2,
|
|
77
|
-
maxY: ty + theight / 2,
|
|
78
|
-
}
|
|
79
|
-
const { x: bx, y: by } = event
|
|
80
|
-
const outerBBox = {
|
|
81
|
-
minX: bbox.minX - offset,
|
|
82
|
-
maxX: bbox.maxX + offset,
|
|
83
|
-
minY: bbox.minY - offset,
|
|
84
|
-
maxY: bbox.maxY + offset,
|
|
85
|
-
}
|
|
86
|
-
const innerBBox = {
|
|
87
|
-
minX: bbox.minX + offset,
|
|
88
|
-
maxX: bbox.maxX - offset,
|
|
89
|
-
minY: bbox.minY + offset,
|
|
90
|
-
maxY: bbox.maxY - offset,
|
|
91
|
-
}
|
|
92
|
-
if (
|
|
93
|
-
bx > outerBBox.minX &&
|
|
94
|
-
bx < outerBBox.maxX &&
|
|
95
|
-
by > outerBBox.minY &&
|
|
96
|
-
by < outerBBox.maxY
|
|
97
|
-
) {
|
|
98
|
-
if (
|
|
99
|
-
!(
|
|
100
|
-
bx > innerBBox.minX &&
|
|
101
|
-
bx < innerBBox.maxX &&
|
|
102
|
-
by > innerBBox.minY &&
|
|
103
|
-
by < innerBBox.maxY
|
|
104
|
-
)
|
|
105
|
-
) {
|
|
106
|
-
return id
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return null
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export function registerTaskNodes(lf: LogicFlow) {
|
|
114
|
-
const ServiceTask = TaskNodeFactory('bpmn:serviceTask', serviceTaskIcon)
|
|
115
|
-
const UserTask = TaskNodeFactory('bpmn:userTask', userTaskIcon)
|
|
116
|
-
|
|
117
|
-
lf.register(ServiceTask)
|
|
118
|
-
lf.register(UserTask)
|
|
119
|
-
lf.register(SubProcessFactory())
|
|
120
|
-
|
|
121
|
-
boundaryEvent(lf)
|
|
122
|
-
}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { h } from '@logicflow/core'
|
|
2
|
-
import { GroupNode, GroupNodeModel } from '../../../materials/group'
|
|
3
|
-
|
|
4
|
-
export function SubProcessFactory(): {
|
|
5
|
-
type: string
|
|
6
|
-
model: any
|
|
7
|
-
view: any
|
|
8
|
-
} {
|
|
9
|
-
class view extends GroupNode {
|
|
10
|
-
getFoldIcon() {
|
|
11
|
-
const { model } = this.props
|
|
12
|
-
const { x, y, width, height, properties, foldable } =
|
|
13
|
-
model as GroupNodeModel
|
|
14
|
-
const foldX = model.x - model.width / 2 + 5
|
|
15
|
-
const foldY = model.y - model.height / 2 + 5
|
|
16
|
-
if (!foldable) return null
|
|
17
|
-
const iconIcon = h('path', {
|
|
18
|
-
fill: 'none',
|
|
19
|
-
stroke: '#818281',
|
|
20
|
-
strokeWidth: 2,
|
|
21
|
-
'pointer-events': 'none',
|
|
22
|
-
d: properties.isFolded
|
|
23
|
-
? `M ${foldX + 3},${foldY + 6} ${foldX + 11},${foldY + 6} M${
|
|
24
|
-
foldX + 7
|
|
25
|
-
},${foldY + 2} ${foldX + 7},${foldY + 10}`
|
|
26
|
-
: `M ${foldX + 3},${foldY + 6} ${foldX + 11},${foldY + 6} `,
|
|
27
|
-
})
|
|
28
|
-
return h('g', {}, [
|
|
29
|
-
h('rect', {
|
|
30
|
-
height: 12,
|
|
31
|
-
width: 14,
|
|
32
|
-
rx: 2,
|
|
33
|
-
ry: 2,
|
|
34
|
-
strokeWidth: 1,
|
|
35
|
-
fill: '#F4F5F6',
|
|
36
|
-
stroke: '#CECECE',
|
|
37
|
-
cursor: 'pointer',
|
|
38
|
-
x: x - width / 2 + 5,
|
|
39
|
-
y: y - height / 2 + 5,
|
|
40
|
-
onClick: (e: any) => {
|
|
41
|
-
e.stopPropagation()
|
|
42
|
-
;(model as GroupNodeModel).foldGroup?.(!properties.isFolded)
|
|
43
|
-
},
|
|
44
|
-
}),
|
|
45
|
-
iconIcon,
|
|
46
|
-
])
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
getResizeShape() {
|
|
50
|
-
const { model } = this.props
|
|
51
|
-
const { x, y, width, height } = model
|
|
52
|
-
const style = model.getNodeStyle()
|
|
53
|
-
const foldRectAttrs = {
|
|
54
|
-
...style,
|
|
55
|
-
x: x - width / 2,
|
|
56
|
-
y: y - height / 2,
|
|
57
|
-
width,
|
|
58
|
-
height,
|
|
59
|
-
stroke: 'black',
|
|
60
|
-
strokeWidth: 2,
|
|
61
|
-
strokeDasharray: '0 0',
|
|
62
|
-
}
|
|
63
|
-
return h('g', {}, [
|
|
64
|
-
// this.getAddAbleShape(),
|
|
65
|
-
h('rect', { ...foldRectAttrs }),
|
|
66
|
-
this.getFoldIcon(),
|
|
67
|
-
])
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
class model extends GroupNodeModel {
|
|
72
|
-
boundaryEvents: any
|
|
73
|
-
|
|
74
|
-
initNodeData(data: {
|
|
75
|
-
width: number
|
|
76
|
-
height: number
|
|
77
|
-
properties: Record<string, any>
|
|
78
|
-
}) {
|
|
79
|
-
super.initNodeData(data)
|
|
80
|
-
this.foldable = true
|
|
81
|
-
// this.isFolded = true;
|
|
82
|
-
this.resizable = true
|
|
83
|
-
this.width = 400
|
|
84
|
-
this.height = 200
|
|
85
|
-
// 根据 properties中的配置重设 宽高
|
|
86
|
-
this.resetWidthHeight()
|
|
87
|
-
this.isTaskNode = true // 标识此节点是任务节点,可以被附件边界事件
|
|
88
|
-
this.boundaryEvents = [] // 记录自己附加的边界事件
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// 自定义根据properties.iniProp
|
|
92
|
-
resetWidthHeight() {
|
|
93
|
-
const width = (this.properties.iniProp as any)?.width
|
|
94
|
-
const height = (this.properties.iniProp as any)?.height
|
|
95
|
-
width && (this.width = width)
|
|
96
|
-
height && (this.height = height)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
getNodeStyle() {
|
|
100
|
-
const style = super.getNodeStyle()
|
|
101
|
-
style.stroke = '#989891'
|
|
102
|
-
style.strokeWidth = 1
|
|
103
|
-
style.strokeDasharray = '3 3'
|
|
104
|
-
if (this.isSelected) {
|
|
105
|
-
style.stroke = 'rgb(124, 15, 255)'
|
|
106
|
-
}
|
|
107
|
-
// isBoundaryEventTouchingTask属性用于标识拖动边界节点是否靠近此节点
|
|
108
|
-
// 如果靠近,则高亮提示
|
|
109
|
-
// style.fill = 'rgb(255, 230, 204)';
|
|
110
|
-
const { isBoundaryEventTouchingTask } = this.properties
|
|
111
|
-
if (isBoundaryEventTouchingTask) {
|
|
112
|
-
style.stroke = '#00acff'
|
|
113
|
-
style.strokeWidth = 2
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return style
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
addChild(id: string) {
|
|
120
|
-
const model = this.graphModel.getElement(id)
|
|
121
|
-
model?.setProperties({
|
|
122
|
-
parent: this.id,
|
|
123
|
-
})
|
|
124
|
-
super.addChild(id)
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// 隐藏锚点而不是设置锚点数为0
|
|
128
|
-
// 因为分组内部节点与外部节点相连时,
|
|
129
|
-
// 如果折叠分组,需要分组代替内部节点与外部节点相连。
|
|
130
|
-
getAnchorStyle() {
|
|
131
|
-
const style = super.getAnchorStyle()
|
|
132
|
-
style.stroke = '#000'
|
|
133
|
-
style.fill = '#fff'
|
|
134
|
-
if (!style.hover) {
|
|
135
|
-
style.hover = {}
|
|
136
|
-
}
|
|
137
|
-
style.hover.stroke = 'transparent'
|
|
138
|
-
return style
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
getOutlineStyle() {
|
|
142
|
-
const style = super.getOutlineStyle()
|
|
143
|
-
style.stroke = 'transparent'
|
|
144
|
-
if (!style.hover) {
|
|
145
|
-
style.hover = {}
|
|
146
|
-
}
|
|
147
|
-
style.hover.stroke = 'transparent'
|
|
148
|
-
return style
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* 提供方法给插件在判断此节点被拖动边界事件节点靠近时调用,从而触发高亮
|
|
153
|
-
*/
|
|
154
|
-
setTouching(flag: boolean) {
|
|
155
|
-
this.setProperty('isBoundaryEventTouchingTask', flag)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* 附加后记录被附加的边界事件节点Id
|
|
160
|
-
*/
|
|
161
|
-
addBoundaryEvent(nodeId: string) {
|
|
162
|
-
this.setTouching(false)
|
|
163
|
-
if (this.boundaryEvents.find((item: string) => item === nodeId)) {
|
|
164
|
-
return false
|
|
165
|
-
}
|
|
166
|
-
const boundaryEvent = this.graphModel.getNodeModelById(nodeId)
|
|
167
|
-
boundaryEvent?.setProperties({
|
|
168
|
-
attachedToRef: this.id,
|
|
169
|
-
})
|
|
170
|
-
this.boundaryEvents.push(nodeId)
|
|
171
|
-
return true
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* 被附加的边界事件节点被删除时,移除记录
|
|
176
|
-
*/
|
|
177
|
-
deleteBoundaryEvent(nodeId: string) {
|
|
178
|
-
this.boundaryEvents = this.boundaryEvents.filter(
|
|
179
|
-
(item: string) => item !== nodeId,
|
|
180
|
-
)
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return {
|
|
185
|
-
type: 'bpmn:subProcess',
|
|
186
|
-
view,
|
|
187
|
-
model,
|
|
188
|
-
}
|
|
189
|
-
}
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import LogicFlow, {
|
|
2
|
-
h,
|
|
3
|
-
GraphModel,
|
|
4
|
-
RectNode,
|
|
5
|
-
RectNodeModel,
|
|
6
|
-
} from '@logicflow/core'
|
|
7
|
-
import { parallelMarker, sequentialMarker, loopMarker } from '../icons'
|
|
8
|
-
import { genBpmnId, groupRule } from '../../utils'
|
|
9
|
-
|
|
10
|
-
import NodeConfig = LogicFlow.NodeConfig
|
|
11
|
-
|
|
12
|
-
export const multiInstanceIcon: any = {
|
|
13
|
-
parallel: parallelMarker,
|
|
14
|
-
sequential: sequentialMarker,
|
|
15
|
-
loop: loopMarker,
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
type TaskType = {
|
|
19
|
-
multiInstanceType: string
|
|
20
|
-
properties: Record<string, any>
|
|
21
|
-
[key: string]: any
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @param type 任务节点的type, 对应其XML定义中的节点名,如<bpmn:userTask /> 其type为bpmn:userTask
|
|
26
|
-
* @param icon 任务节点左上角的图标,可以是svg path,也可以是h函数生成的svg
|
|
27
|
-
* @param props (可选) 任务节点的属性
|
|
28
|
-
* @returns { type: string, model: any, view: any }
|
|
29
|
-
*/
|
|
30
|
-
export function TaskNodeFactory(
|
|
31
|
-
type: string,
|
|
32
|
-
icon: string | any[],
|
|
33
|
-
props?: any,
|
|
34
|
-
): {
|
|
35
|
-
type: string
|
|
36
|
-
model: any
|
|
37
|
-
view: any
|
|
38
|
-
} {
|
|
39
|
-
class view extends RectNode {
|
|
40
|
-
getLabelShape() {
|
|
41
|
-
// @ts-ignore
|
|
42
|
-
const { model } = this.props
|
|
43
|
-
const { x, y, width, height } = model
|
|
44
|
-
const style = model.getNodeStyle()
|
|
45
|
-
const i = Array.isArray(icon)
|
|
46
|
-
? h(
|
|
47
|
-
'g',
|
|
48
|
-
{
|
|
49
|
-
transform: `matrix(1 0 0 1 ${x - width / 2} ${y - height / 2})`,
|
|
50
|
-
},
|
|
51
|
-
...icon,
|
|
52
|
-
)
|
|
53
|
-
: h('path', {
|
|
54
|
-
fill: style.stroke,
|
|
55
|
-
d: icon,
|
|
56
|
-
})
|
|
57
|
-
return h(
|
|
58
|
-
'svg',
|
|
59
|
-
{
|
|
60
|
-
x: x - width / 2 + 5,
|
|
61
|
-
y: y - height / 2 + 5,
|
|
62
|
-
width: 25,
|
|
63
|
-
height: 25,
|
|
64
|
-
viewBox: '0 0 1274 1024',
|
|
65
|
-
},
|
|
66
|
-
i,
|
|
67
|
-
)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
getShape() {
|
|
71
|
-
// @ts-ignore
|
|
72
|
-
const { model } = this.props
|
|
73
|
-
const { x, y, width, height, radius, properties } = model
|
|
74
|
-
const style = model.getNodeStyle()
|
|
75
|
-
return h('g', {}, [
|
|
76
|
-
h('rect', {
|
|
77
|
-
...style,
|
|
78
|
-
x: x - width / 2,
|
|
79
|
-
y: y - height / 2,
|
|
80
|
-
rx: radius,
|
|
81
|
-
ry: radius,
|
|
82
|
-
width,
|
|
83
|
-
height,
|
|
84
|
-
opacity: 0.95,
|
|
85
|
-
}),
|
|
86
|
-
this.getLabelShape(),
|
|
87
|
-
h(
|
|
88
|
-
'g',
|
|
89
|
-
{
|
|
90
|
-
transform: `matrix(1 0 0 1 ${x - width / 2} ${y - height / 2})`,
|
|
91
|
-
},
|
|
92
|
-
h('path', {
|
|
93
|
-
fill: 'white',
|
|
94
|
-
strokeLinecap: 'round',
|
|
95
|
-
strokeLinejoin: 'round',
|
|
96
|
-
stroke: 'rgb(34, 36, 42)',
|
|
97
|
-
strokeWidth: '2',
|
|
98
|
-
d: multiInstanceIcon[properties.multiInstanceType as any] || '', // TODO: 确认 properties.multiInstanceType 的类型
|
|
99
|
-
}),
|
|
100
|
-
),
|
|
101
|
-
])
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
class model extends RectNodeModel {
|
|
106
|
-
boundaryEvents: any // TODO: 确认该属性类型,可移除查看其导致的问题
|
|
107
|
-
|
|
108
|
-
constructor(data: NodeConfig, graphModel: GraphModel) {
|
|
109
|
-
if (!data.id) {
|
|
110
|
-
data.id = `Activity_${genBpmnId()}`
|
|
111
|
-
}
|
|
112
|
-
const properties: TaskType = {
|
|
113
|
-
...(props || {}),
|
|
114
|
-
...data.properties,
|
|
115
|
-
// multiInstanceType: '',
|
|
116
|
-
// panels: ['multiInstance'],
|
|
117
|
-
}
|
|
118
|
-
data.properties = properties
|
|
119
|
-
super(data, graphModel)
|
|
120
|
-
properties?.boundaryEvents?.forEach((id: string) => {
|
|
121
|
-
this.addBoundaryEvent(id)
|
|
122
|
-
})
|
|
123
|
-
this.deleteProperty('boundaryEvents')
|
|
124
|
-
groupRule.call(this)
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
initNodeData(data: any) {
|
|
128
|
-
super.initNodeData(data)
|
|
129
|
-
this.isTaskNode = true // 标识此节点是任务节点,可以被附件边界事件
|
|
130
|
-
this.boundaryEvents = [] // 记录自己附加的边界事件
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
getNodeStyle() {
|
|
134
|
-
const style = super.getNodeStyle()
|
|
135
|
-
// isBoundaryEventTouchingTask属性用于标识拖动边界节点是否靠近此节点
|
|
136
|
-
// 如果靠近,则高亮提示
|
|
137
|
-
// style.fill = 'rgb(255, 230, 204)';
|
|
138
|
-
const { isBoundaryEventTouchingTask } = this.properties
|
|
139
|
-
if (isBoundaryEventTouchingTask) {
|
|
140
|
-
style.stroke = '#00acff'
|
|
141
|
-
style.strokeWidth = 2
|
|
142
|
-
}
|
|
143
|
-
return style
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
getOutlineStyle() {
|
|
147
|
-
const style = super.getOutlineStyle()
|
|
148
|
-
style.stroke = 'transparent'
|
|
149
|
-
!style.hover && (style.hover = {})
|
|
150
|
-
style.hover.stroke = 'transparent'
|
|
151
|
-
return style
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* 提供方法给插件在判断此节点被拖动边界事件节点靠近时调用,从而触发高亮
|
|
156
|
-
*/
|
|
157
|
-
setTouching(flag: boolean) {
|
|
158
|
-
this.setProperty('isBoundaryEventTouchingTask', flag)
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* 附加后记录被附加的边界事件节点Id
|
|
163
|
-
*/
|
|
164
|
-
addBoundaryEvent(nodeId: string) {
|
|
165
|
-
this.setTouching(false)
|
|
166
|
-
if (this.boundaryEvents.find((item: string) => item === nodeId)) {
|
|
167
|
-
return false
|
|
168
|
-
}
|
|
169
|
-
const boundaryEvent = this.graphModel.getNodeModelById(nodeId)
|
|
170
|
-
boundaryEvent?.setProperties({
|
|
171
|
-
attachedToRef: this.id,
|
|
172
|
-
})
|
|
173
|
-
this.boundaryEvents.push(nodeId)
|
|
174
|
-
return true
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* 被附加的边界事件节点被删除时,移除记录
|
|
179
|
-
*/
|
|
180
|
-
deleteBoundaryEvent(nodeId: string) {
|
|
181
|
-
this.boundaryEvents = this.boundaryEvents.filter(
|
|
182
|
-
(item: string) => item !== nodeId,
|
|
183
|
-
)
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// @ts-ignore
|
|
188
|
-
return {
|
|
189
|
-
type,
|
|
190
|
-
view,
|
|
191
|
-
model,
|
|
192
|
-
}
|
|
193
|
-
}
|