CustomPalette.js
6.74 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
import {
changeElementSize,
} from "@/components/VueBpmn/custom/util";
export default class CustomPalette {
constructor(bpmnFactory, create, elementFactory, palette, translate) {
this.bpmnFactory = bpmnFactory;
this.create = create;
this.elementFactory = elementFactory;
this.translate = translate;
palette.registerProvider(this);
}
getPaletteEntries(element) {
const {
bpmnFactory,
create,
elementFactory,
translate
} = this;
function createTask() {
return function (event) {
const businessObject = bpmnFactory.create('bpmn:UserTask');
businessObject['custom'] = 1
businessObject.name = "用户任务";
const shape = elementFactory.createShape({
type: 'bpmn:UserTask',
businessObject
});
changeElementSize(shape);
create.start(event, shape);
}
}
function createSignTask(isSequential) {
return function (event) {
let loopCharacteristics = bpmnFactory.create('bpmn:MultiInstanceLoopCharacteristics');
if (isSequential) {
loopCharacteristics.isSequential = true;
}
const businessObject = bpmnFactory.create('bpmn:UserTask', { loopCharacteristics: loopCharacteristics });
businessObject['custom'] = 1
businessObject.name = "会签任务";
const shape = elementFactory.createShape({
type: 'bpmn:UserTask',
businessObject
});
changeElementSize(shape);
create.start(event, shape);
}
}
function createServiceTask() {
return function (event) {
const businessObject = bpmnFactory.create('bpmn:ServiceTask');
businessObject['custom'] = 1
businessObject.name = "服务任务";
const shape = elementFactory.createShape({
type: 'bpmn:ServiceTask',
businessObject
});
changeElementSize(shape);
create.start(event, shape);
}
}
function createStartEvent() {
return function (event) {
const businessObject = bpmnFactory.create('bpmn:StartEvent');
businessObject['custom'] = 1
businessObject.name = "开始";
const shape = elementFactory.createShape({
type: 'bpmn:StartEvent',
businessObject
});
changeElementSize(shape);
create.start(event, shape);
}
}
function createEndEvent() {
return function (event) {
const businessObject = bpmnFactory.create('bpmn:EndEvent');
businessObject['custom'] = 1
businessObject.name = "结束";
const shape = elementFactory.createShape({
type: 'bpmn:EndEvent',
businessObject
});
changeElementSize(shape);
create.start(event, shape);
}
}
function createSubprocessCollapsed() {
return function (event) {
const businessObject = bpmnFactory.create('bpmn:CallActivity');
businessObject['custom'] = 1
businessObject.name = "外部子流程";
const shape = elementFactory.createShape({
type: 'bpmn:CallActivity',
businessObject
});
changeElementSize(shape);
create.start(event, shape);
}
}
function createParallelGateway() {
return function (event) {
const businessObject = bpmnFactory.create('bpmn:ParallelGateway');
businessObject['custom'] = 1
businessObject.name = "同步网关";
const shape = elementFactory.createShape({
type: 'bpmn:ParallelGateway',
businessObject
});
changeElementSize(shape);
create.start(event, shape);
}
}
function createInclusiveGateway() {
return function (event) {
const businessObject = bpmnFactory.create('bpmn:InclusiveGateway');
businessObject['custom'] = 1
businessObject.name = "条件同步网关";
const shape = elementFactory.createShape({
type: 'bpmn:InclusiveGateway',
businessObject
});
changeElementSize(shape);
create.start(event, shape);
}
}
return {
'create.start-event': {
group: 'model',
className: 'bpmn-icon-start-event-none',
title: translate('开始'),
action: {
dragstart: createStartEvent(),
click: createStartEvent()
}
},
'create.end-event': {
group: 'model',
className: 'bpmn-icon-end-event-none',
title: translate('结束'),
action: {
dragstart: createEndEvent(),
click: createEndEvent()
}
},
'create.user-task': {
group: 'model',
// className: 'icon-custom lindaidai-task',
className: 'bpmn-icon-user-task',
title: translate('用户任务'),
action: {
dragstart: createTask(),
click: createTask()
}
},
'create.sign-task': {
group: 'model',
// className: 'icon-custom lindaidai-task', bpmn-icon-business-rule
className: 'bpmn-icon-parallel-mi-marker',
title: translate('会签并行'),
action: {
dragstart: createSignTask(),
click: createSignTask()
}
},
'create.sign-task-sequential': {
group: 'model',
// className: 'icon-custom lindaidai-task',
className: 'bpmn-icon-sequential-mi-marker',
title: translate('会签串行'),
action: {
dragstart: createSignTask(true),
click: createSignTask(true)
}
},
'create.service-task': {
group: 'model',
// className: 'icon-custom lindaidai-task',
className: 'bpmn-icon-service-task',
title: translate('服务任务'),
action: {
dragstart: createServiceTask(),
click: createServiceTask()
}
},
'create.subprocess-collapsed': {
group: 'model',
className: 'bpmn-icon-subprocess-collapsed',
title: translate('外部子流程'),
action: {
dragstart: createSubprocessCollapsed(),
click: createSubprocessCollapsed()
}
},
'create.parallel-gateway': {
group: 'gateway',
className: 'bpmn-icon-gateway-xor',
title: translate('同步网关'),
action: {
dragstart: createParallelGateway(),
click: createParallelGateway()
}
},
'create.inclusive-gateway': {
group: 'gateway',
className: 'bpmn-icon-gateway-or',
title: translate('条件同步网关'),
action: {
dragstart: createInclusiveGateway(),
click: createInclusiveGateway()
}
}
}
}
}
CustomPalette.$inject = [
'bpmnFactory',
'create',
'elementFactory',
'palette',
'translate'
]