bm-admin-ui 1.0.63-alpha → 1.0.65-alpha

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.
Files changed (41) hide show
  1. package/es/components/flow-designer/index.d.ts +45 -4
  2. package/es/components/flow-designer/index.js +1284 -11
  3. package/es/components/flow-designer/src/bm-nodes/BmConditionNode.vue.d.ts +0 -1
  4. package/es/components/flow-designer/src/bm-nodes/BmHtmlNode.vue.d.ts +1 -1
  5. package/es/components/flow-designer/src/config.d.ts +1 -0
  6. package/es/components/flow-designer/src/flow-designer.vue.d.ts +47 -4
  7. package/es/components/flow-designer/src/utils.d.ts +1 -0
  8. package/es/components/form-create/index.js +17563 -213
  9. package/es/components/form-designer/index.js +83 -9
  10. package/es/components/staffs-selector/index.d.ts +0 -1
  11. package/es/components/staffs-selector/index.js +19 -16
  12. package/es/components/staffs-selector/src/multipleCmp.vue.d.ts +0 -1
  13. package/es/components/staffs-selector/src/staffs-selector.vue.d.ts +0 -1
  14. package/lib/components/flow-designer/index.d.ts +45 -4
  15. package/lib/components/flow-designer/index.js +1285 -9
  16. package/lib/components/flow-designer/src/bm-nodes/BmConditionNode.vue.d.ts +0 -1
  17. package/lib/components/flow-designer/src/bm-nodes/BmHtmlNode.vue.d.ts +1 -1
  18. package/lib/components/flow-designer/src/config.d.ts +1 -0
  19. package/lib/components/flow-designer/src/flow-designer.vue.d.ts +47 -4
  20. package/lib/components/flow-designer/src/utils.d.ts +1 -0
  21. package/lib/components/form-create/index.js +17562 -212
  22. package/lib/components/form-designer/index.js +83 -9
  23. package/lib/components/staffs-selector/index.d.ts +0 -1
  24. package/lib/components/staffs-selector/index.js +19 -16
  25. package/lib/components/staffs-selector/src/multipleCmp.vue.d.ts +0 -1
  26. package/lib/components/staffs-selector/src/staffs-selector.vue.d.ts +0 -1
  27. package/package.json +1 -1
  28. package/theme-chalk/flow-designer.css +1 -1
  29. package/theme-chalk/index.css +1 -1
  30. package/types/components/flow-designer/index.d.ts +45 -4
  31. package/types/components/flow-designer/src/bm-nodes/BmConditionNode.vue.d.ts +0 -1
  32. package/types/components/flow-designer/src/bm-nodes/BmHtmlNode.vue.d.ts +1 -1
  33. package/types/components/flow-designer/src/config.d.ts +1 -0
  34. package/types/components/flow-designer/src/flow-designer.vue.d.ts +47 -4
  35. package/types/components/flow-designer/src/utils.d.ts +1 -0
  36. package/types/components/staffs-selector/index.d.ts +0 -1
  37. package/types/components/staffs-selector/src/multipleCmp.vue.d.ts +0 -1
  38. package/types/components/staffs-selector/src/staffs-selector.vue.d.ts +0 -1
  39. package/es/components/flow-designer/src/flow-designer-test.d.ts +0 -20
  40. package/lib/components/flow-designer/src/flow-designer-test.d.ts +0 -20
  41. package/types/components/flow-designer/src/flow-designer-test.d.ts +0 -20
@@ -1,6 +1,74 @@
1
1
  import { withInstall } from 'bm-admin-ui/es/utils/with-install';
2
- import { defineComponent, ref, onMounted, openBlock, createElementBlock } from 'vue';
3
- import LogicFlow from '@logicflow/core';
2
+ import { defineComponent, ref, resolveComponent, openBlock, createElementBlock, createElementVNode, normalizeStyle, withModifiers, toDisplayString, createBlock, withKeys, createVNode, createCommentVNode, createTextVNode, nextTick, normalizeClass, unref, withCtx, render, onMounted } from 'vue';
3
+ import '@logicflow/core/dist/style/index.css';
4
+ import '@logicflow/extension/lib/style/index.css';
5
+ import LogicFlow, { HtmlNodeModel, HtmlNode, RectNodeModel, RectNode, PolylineEdgeModel, PolylineEdge } from '@logicflow/core';
6
+ import { Menu, BpmnAdapter } from '@logicflow/extension';
7
+ import { RightOutlined, CloseOutlined, ContactsFilled } from '@ant-design/icons-vue';
8
+ import AInput from 'ant-design-vue/lib/input';
9
+ import Tag from 'ant-design-vue/lib/tag';
10
+ import { message } from 'ant-design-vue';
11
+ import Modal from 'ant-design-vue/lib/modal';
12
+
13
+ /******************************************************************************
14
+ Copyright (c) Microsoft Corporation.
15
+
16
+ Permission to use, copy, modify, and/or distribute this software for any
17
+ purpose with or without fee is hereby granted.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
20
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
21
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
22
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
23
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
24
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
25
+ PERFORMANCE OF THIS SOFTWARE.
26
+ ***************************************************************************** */
27
+
28
+ function __rest(s, e) {
29
+ var t = {};
30
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
31
+ t[p] = s[p];
32
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
33
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
34
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
35
+ t[p[i]] = s[p[i]];
36
+ }
37
+ return t;
38
+ }
39
+
40
+ class EndCircleModel extends HtmlNodeModel {
41
+ initNodeData(data) {
42
+ super.initNodeData(data);
43
+ this.isHovered = false;
44
+ }
45
+ setAttributes() {
46
+ super.setAttributes();
47
+ this.isSelected = false;
48
+ this.isHovered = false;
49
+ }
50
+ getDefaultAnchor() {
51
+ const { width, height, x, y, id } = this;
52
+ return [
53
+ {
54
+ x,
55
+ y: y - height / 2,
56
+ id: `${id}_0`,
57
+ },
58
+ ];
59
+ }
60
+ }
61
+ class EndCircleView extends HtmlNode {
62
+ setHtml(roolEl) {
63
+ const html = `<div class="bm-flow-end-circle">结束</div>`;
64
+ roolEl.innerHTML = html;
65
+ }
66
+ }
67
+ var EndCircle = {
68
+ type: 'bmEndNode',
69
+ view: EndCircleView,
70
+ model: EndCircleModel,
71
+ };
4
72
 
5
73
  var _export_sfc = (sfc, props) => {
6
74
  const target = sfc.__vccOpts || sfc;
@@ -10,23 +78,1228 @@ var _export_sfc = (sfc, props) => {
10
78
  return target;
11
79
  };
12
80
 
81
+ const _sfc_main$2 = defineComponent({
82
+ components: { RightOutlined, CloseOutlined, AInput },
83
+ props: {
84
+ type: {
85
+ type: String,
86
+ default: "begin"
87
+ },
88
+ label: {
89
+ type: String,
90
+ default: "\u53D1\u8D77\u4EBA"
91
+ },
92
+ desc: {
93
+ type: String,
94
+ default: ""
95
+ },
96
+ contentClick: {
97
+ type: Function,
98
+ default: (e) => {
99
+ }
100
+ },
101
+ deleteClick: {
102
+ type: Function,
103
+ default: (e) => {
104
+ }
105
+ },
106
+ icon: {
107
+ type: Function || null,
108
+ default: null
109
+ },
110
+ style: {
111
+ type: Object,
112
+ default: () => ({})
113
+ }
114
+ },
115
+ emits: ["update:label"],
116
+ setup(props, { emit }) {
117
+ const isEditLabel = ref(false);
118
+ const tempLabel = ref("");
119
+ tempLabel.value = "";
120
+ const methods = {
121
+ toEditLabel() {
122
+ tempLabel.value = props["label"];
123
+ isEditLabel.value = true;
124
+ },
125
+ updateLabel(_) {
126
+ nextTick(() => {
127
+ isEditLabel.value = false;
128
+ });
129
+ if (tempLabel.value)
130
+ emit("update:label", tempLabel.value);
131
+ else {
132
+ emit("update:label", props["label"]);
133
+ }
134
+ }
135
+ };
136
+ return {
137
+ isEditLabel,
138
+ tempLabel,
139
+ ...methods
140
+ };
141
+ }
142
+ });
143
+ const _hoisted_1$1 = { class: "bm-html-box" };
144
+ const _hoisted_2$1 = { class: "default-box" };
145
+ const _hoisted_3$1 = { class: "iconfont box-icon" };
146
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
147
+ const _component_AInput = resolveComponent("AInput");
148
+ const _component_CloseOutlined = resolveComponent("CloseOutlined");
149
+ const _component_RightOutlined = resolveComponent("RightOutlined");
150
+ return openBlock(), createElementBlock("div", _hoisted_1$1, [
151
+ createElementVNode("div", _hoisted_2$1, [
152
+ createElementVNode("div", {
153
+ class: "box-head",
154
+ style: normalizeStyle(_ctx.style)
155
+ }, [
156
+ !_ctx.isEditLabel ? (openBlock(), createElementBlock("p", {
157
+ key: 0,
158
+ onClick: _cache[0] || (_cache[0] = withModifiers((...args) => _ctx.toEditLabel && _ctx.toEditLabel(...args), ["stop"]))
159
+ }, toDisplayString(_ctx.label), 1)) : (openBlock(), createBlock(_component_AInput, {
160
+ key: 1,
161
+ value: _ctx.tempLabel,
162
+ "onUpdate:value": _cache[1] || (_cache[1] = ($event) => _ctx.tempLabel = $event),
163
+ size: "small",
164
+ onBlur: _ctx.updateLabel,
165
+ onKeydown: withKeys(_ctx.updateLabel, ["enter"])
166
+ }, null, 8, ["value", "onBlur", "onKeydown"])),
167
+ _ctx.type !== "begin" ? (openBlock(), createElementBlock("i", {
168
+ key: 2,
169
+ class: "delete-icon",
170
+ onClick: _cache[2] || (_cache[2] = withModifiers(
171
+ () => {
172
+ _ctx.deleteClick();
173
+ },
174
+ ["stop"]
175
+ ))
176
+ }, [
177
+ createVNode(_component_CloseOutlined)
178
+ ])) : createCommentVNode("v-if", true)
179
+ ], 4),
180
+ createElementVNode("div", {
181
+ class: "box-body",
182
+ onClick: _cache[3] || (_cache[3] = withModifiers(
183
+ () => {
184
+ _ctx.contentClick();
185
+ },
186
+ ["stop"]
187
+ ))
188
+ }, [
189
+ createTextVNode(toDisplayString(_ctx.desc), 1),
190
+ createElementVNode("span", _hoisted_3$1, [
191
+ createVNode(_component_RightOutlined)
192
+ ])
193
+ ])
194
+ ])
195
+ ]);
196
+ }
197
+ var BmHtmlNode = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render], ["__file", "BmHtmlNode.vue"]]);
198
+
199
+ const _hoisted_1 = { class: "bm-condition-node" };
200
+ const _hoisted_2 = { class: "bm-condition-node-box" };
201
+ const _hoisted_3 = { class: "condition-header" };
202
+ const _hoisted_4 = { key: 0 };
203
+ const _hoisted_5 = { class: "condition-desc" };
204
+ const _hoisted_6 = { class: "desc" };
205
+ const _hoisted_7 = { key: 0 };
13
206
  const __default__ = {
14
- name: "BmFlowDesigner"
207
+ name: "BmConditionNode"
15
208
  };
16
- const _sfc_main = /* @__PURE__ */ defineComponent({
209
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17
210
  ...__default__,
211
+ props: {
212
+ isCustom: {
213
+ type: Boolean,
214
+ default: false
215
+ },
216
+ title: {
217
+ type: String,
218
+ default: " "
219
+ },
220
+ priority: {
221
+ type: Number || String,
222
+ default: 1
223
+ },
224
+ desc: {
225
+ type: String,
226
+ default: " "
227
+ },
228
+ copyCallback: {
229
+ type: Function,
230
+ default: () => {
231
+ console.info("\u8BF7\u8BBE\u7F6E\u590D\u5236\u51FD\u6570");
232
+ }
233
+ },
234
+ deleteCallback: {
235
+ type: Function,
236
+ default: () => {
237
+ console.info("\u8BF7\u8BBE\u7F6E\u5220\u9664\u51FD\u6570");
238
+ }
239
+ }
240
+ },
18
241
  setup(__props) {
19
- const container = ref();
20
- let lf;
21
- function init() {
22
- lf = new LogicFlow({
242
+ return (_ctx, _cache) => {
243
+ return openBlock(), createElementBlock("div", _hoisted_1, [
244
+ createElementVNode("div", _hoisted_2, [
245
+ createElementVNode("div", _hoisted_3, [
246
+ createElementVNode("span", {
247
+ class: normalizeClass(["condition-title", { custom: __props.isCustom }])
248
+ }, toDisplayString(__props.isCustom ? __props.title : "\u9ED8\u8BA4\u6761\u4EF6"), 3),
249
+ __props.isCustom ? (openBlock(), createElementBlock("span", _hoisted_4, [
250
+ createVNode(unref(Tag), null, {
251
+ default: withCtx(() => [
252
+ createTextVNode(toDisplayString(`\u4F18\u5148\u7EA7${__props.priority}`), 1)
253
+ ]),
254
+ _: 1
255
+ })
256
+ ])) : createCommentVNode("v-if", true),
257
+ createElementVNode("span", {
258
+ class: normalizeClass(["opeator", { active: __props.isCustom }])
259
+ }, [
260
+ createCommentVNode(' <CopyOutlined\n @click.stop="\n () => {\n copyCallback()\n }\n " />&nbsp;\u6682\u65F6\u5173\u95ED\u590D\u5236\u8282\u70B9 '),
261
+ createVNode(unref(CloseOutlined), {
262
+ onClick: _cache[0] || (_cache[0] = () => {
263
+ __props.deleteCallback();
264
+ })
265
+ })
266
+ ], 2)
267
+ ]),
268
+ createElementVNode("div", _hoisted_5, [
269
+ createElementVNode("span", _hoisted_6, toDisplayString(__props.desc), 1),
270
+ __props.isCustom ? (openBlock(), createElementBlock("span", _hoisted_7, [
271
+ createVNode(unref(RightOutlined))
272
+ ])) : createCommentVNode("v-if", true)
273
+ ])
274
+ ])
275
+ ]);
276
+ };
277
+ }
278
+ });
279
+ var BmConditionNode = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__file", "BmConditionNode.vue"]]);
280
+
281
+ const BM_NODE_CONFIG = {
282
+ WIDTH: 250,
283
+ HEIGHT: 110,
284
+ DEFAULTBG: '#9393a3',
285
+ DEFAULTCOLOR: '#fff',
286
+ LINELENGTH: 100,
287
+ ADDNODEOFFSET: 100,
288
+ ENDRADIUS: 16,
289
+ HALFNODEHEIGHT: 55,
290
+ NEXTOFFSET_Y: 210,
291
+ OFFSETDISTANCE: 210,
292
+ PLUSRADIUS: 15,
293
+ ACWIDTH: 90,
294
+ ACHEIGHT: 32,
295
+ CONDIWIDTH: 250,
296
+ CONDIHEIGHT: 100,
297
+ CONDIOFFSET: 60 + 250 / 2,
298
+ PLUSOFFSET: 55 + 50,
299
+ CONDITIONNAME: 'condition',
300
+ PLUSCONDINAME: 'bmAddCondiNode',
301
+ ENDNODENAME: 'bmEndNode',
302
+ ACOFFSETDISTANCE: 210 - (100 - 32),
303
+ CONDITIONPADDING: 60,
304
+ DELETEDEFAULTOFFSET: 32 + 100 + 200,
305
+ };
306
+
307
+ class FlowItemModel extends HtmlNodeModel {
308
+ setAttributes() {
309
+ this.text.editable = false;
310
+ this.width = BM_NODE_CONFIG.WIDTH;
311
+ this.height = BM_NODE_CONFIG.HEIGHT;
312
+ this.isSelected = false;
313
+ this.isHitable = false;
314
+ }
315
+ getDefaultAnchor() {
316
+ const { width, height, x, y, id, properties } = this;
317
+ return [
318
+ {
319
+ x: properties['horizontal'] ? x - width / 2 : x,
320
+ y: properties['horizontal'] ? y : y + height / 2,
321
+ id: `${id}_0`,
322
+ },
323
+ {
324
+ x: properties['horizontal'] ? x + width / 2 : x,
325
+ y: properties['horizontal'] ? y : y - height / 2,
326
+ id: `${id}_1`,
327
+ },
328
+ ];
329
+ }
330
+ }
331
+ class FlowItemNode extends HtmlNode {
332
+ constructor() {
333
+ super(...arguments);
334
+ this.vueNode = null;
335
+ }
336
+ setHtml(rootEl) {
337
+ const { properties, id } = this.props.model;
338
+ const { eventCenter } = this.props.graphModel;
339
+ if (!properties.type)
340
+ throw new Error('节点type未传递');
341
+ if (properties.type === 'condition') {
342
+ if (!this.vueNode) {
343
+ let desc = this.props.model.properties.desc;
344
+ if (!desc) {
345
+ desc = properties.isCustom ? '条件字段' : '默认条件,无需设置';
346
+ }
347
+ const node = createVNode(BmConditionNode, {
348
+ isCustom: properties.isCustom,
349
+ title: this.props.model.properties.title ||
350
+ properties.priority.title ||
351
+ '默认条件',
352
+ priority: this.props.model.properties.priority ||
353
+ properties.priority ||
354
+ 99,
355
+ desc,
356
+ nodeClick: () => {
357
+ eventCenter.emit('content:click', this.props.model);
358
+ },
359
+ copyCallback: () => {
360
+ eventCenter.emit('flownode:copynode', this.props.model);
361
+ },
362
+ deleteCallback: () => {
363
+ eventCenter.emit('condition:delete', this.props.model);
364
+ },
365
+ }, []);
366
+ this.vueNode = render(node, rootEl);
367
+ }
368
+ }
369
+ else {
370
+ if (!properties.label) {
371
+ properties.label = '未命名';
372
+ }
373
+ if (!properties.desc) {
374
+ properties.desc = '未指定数据';
375
+ }
376
+ if (!this.vueNode) {
377
+ const node = createVNode(BmHtmlNode, {
378
+ type: properties.type,
379
+ label: this.props.model.properties.label,
380
+ desc: this.props.model.properties.desc,
381
+ icon: properties.icon || null,
382
+ style: properties.style || {
383
+ backgroundColor: BM_NODE_CONFIG.DEFAULTBG,
384
+ color: BM_NODE_CONFIG.DEFAULTCOLOR,
385
+ },
386
+ 'onUpdate:label': (value) => {
387
+ this.props.model.properties.label = value;
388
+ },
389
+ contentClick: () => {
390
+ const { eventCenter } = this.props.graphModel;
391
+ eventCenter.emit('content:click', this.props.model);
392
+ },
393
+ deleteClick: () => {
394
+ eventCenter.emit('flownode:delete', { id });
395
+ },
396
+ }, []);
397
+ this.vueNode = render(node, rootEl);
398
+ }
399
+ }
400
+ }
401
+ }
402
+ const bmFlowItem = {
403
+ type: 'bmFlowNode',
404
+ view: FlowItemNode,
405
+ model: FlowItemModel,
406
+ };
407
+ var BmFlowHtmlNode = bmFlowItem;
408
+
409
+ const ACTYPE = 'addCondi';
410
+ class AddFlowNodeModel extends RectNodeModel {
411
+ constructor() {
412
+ super(...arguments);
413
+ this.__flowChildren = [];
414
+ this.__ACChildren = [];
415
+ this.FLOWTYPE = {
416
+ auditing: {
417
+ type: 'auditing',
418
+ label: '审批人',
419
+ desc: '指定人员',
420
+ style: {
421
+ backgroundColor: '#ff9019',
422
+ color: '#ffffff',
423
+ },
424
+ nodeWidth: 250,
425
+ nodeHeight: 110,
426
+ icon: ContactsFilled,
427
+ },
428
+ deal: {
429
+ type: 'deal',
430
+ label: '办理人',
431
+ desc: '指定人员',
432
+ style: {
433
+ backgroundColor: '#e64c2e',
434
+ color: '#ffffff',
435
+ },
436
+ nodeWidth: 250,
437
+ nodeHeight: 110,
438
+ },
439
+ addflow: {
440
+ type: 'addCondi',
441
+ nodeHeight: 32,
442
+ nodeWidth: 90,
443
+ },
444
+ };
445
+ }
446
+ updateChild(node) {
447
+ this.__flowChildren.push(node.id);
448
+ if (node.type === ACTYPE)
449
+ this.__ACChildren.push(node.id);
450
+ }
451
+ addConditionItem(node) {
452
+ const [nextNode] = this.graphModel.getNodeOutgoingNode(node.id);
453
+ if (nextNode.type === 'addCondi') {
454
+ message.warning('已添加条件分支');
455
+ return;
456
+ }
457
+ const { eventCenter } = this.graphModel;
458
+ eventCenter.emit('node:add-condi', { node });
459
+ return;
460
+ }
461
+ setAttributes() {
462
+ const addMenu = [
463
+ {
464
+ className: 'lf-menu-lock custom-menu',
465
+ text: '审批人',
466
+ icon: true,
467
+ callback: (node) => {
468
+ const { eventCenter } = this.graphModel;
469
+ eventCenter.emit('node:add-item', {
470
+ nodetype: 'bmFlowNode',
471
+ node,
472
+ data: this.FLOWTYPE['auditing'],
473
+ });
474
+ },
475
+ },
476
+ {
477
+ className: 'lf-menu-lock custom-menu',
478
+ text: '办理人',
479
+ icon: true,
480
+ callback: (node) => {
481
+ const { eventCenter } = this.graphModel;
482
+ eventCenter.emit('node:add-item', {
483
+ nodetype: 'bmFlowNode',
484
+ node,
485
+ data: this.FLOWTYPE['deal'],
486
+ });
487
+ },
488
+ },
489
+ {
490
+ className: 'lf-menu-lock custom-menu',
491
+ text: '条件分支',
492
+ icon: true,
493
+ callback: (node) => {
494
+ this.addConditionItem(node);
495
+ },
496
+ },
497
+ ];
498
+ this.menu = addMenu;
499
+ }
500
+ initNodeData(data) {
501
+ data.text = {
502
+ value: '+',
503
+ x: data.x,
504
+ y: data.y,
505
+ };
506
+ const { properties } = data;
507
+ const { nodeWidth, nodeHeight } = properties;
508
+ this.width = nodeWidth;
509
+ this.height = nodeHeight;
510
+ this.radius = 50;
511
+ super.initNodeData(data);
512
+ }
513
+ getTextStyle() {
514
+ const style = super.getTextStyle();
515
+ style.color = '#fff';
516
+ style.fontSize = 26;
517
+ return style;
518
+ }
519
+ getNodeStyle() {
520
+ const style = super.getNodeStyle();
521
+ style.stroke = '';
522
+ style.fill = '#2F4EED';
523
+ return style;
524
+ }
525
+ }
526
+ class AddFlowNode extends RectNode {
527
+ }
528
+ var AddFlowNode$1 = {
529
+ type: 'bmAddNode',
530
+ view: AddFlowNode,
531
+ model: AddFlowNodeModel,
532
+ };
533
+
534
+ class AddCondition extends RectNode {
535
+ }
536
+ class AddConditionModel extends RectNodeModel {
537
+ constructor() {
538
+ super(...arguments);
539
+ this.__branchs = [];
540
+ this.__branchLengths = new Map();
541
+ this.__outNode = null;
542
+ }
543
+ initNodeData(data) {
544
+ if (!data.text || typeof data.text === 'string') {
545
+ data.text = {
546
+ value: data.text || '添加条件',
547
+ x: data.x,
548
+ y: data.y,
549
+ };
550
+ }
551
+ this.width = BM_NODE_CONFIG.ACWIDTH;
552
+ this.height = BM_NODE_CONFIG.ACHEIGHT;
553
+ this.radius = 16;
554
+ super.initNodeData(data);
555
+ }
556
+ getNodeStyle() {
557
+ const style = super.getNodeStyle();
558
+ style.stroke = '#D9D9D9';
559
+ style.strokeWidth = 1;
560
+ return style;
561
+ }
562
+ getTextStyle() {
563
+ const style = super.getTextStyle();
564
+ style.fontSize = 14;
565
+ style.color = '#2F4EED';
566
+ return style;
567
+ }
568
+ }
569
+ var AddCondi = {
570
+ type: 'bmAddCondiNode',
571
+ view: AddCondition,
572
+ model: AddConditionModel,
573
+ };
574
+
575
+ class BmPolyLineModel extends PolylineEdgeModel {
576
+ constructor() {
577
+ super(...arguments);
578
+ this.FLOWTYPE = {
579
+ auditing: {
580
+ type: 'auditing',
581
+ label: '审批人',
582
+ desc: '指定人员',
583
+ style: {
584
+ backgroundColor: '#ff9019',
585
+ color: '#ffffff',
586
+ },
587
+ nodeWidth: 250,
588
+ nodeHeight: 110,
589
+ },
590
+ deal: {
591
+ type: 'deal',
592
+ label: '办理人',
593
+ desc: '指定人员',
594
+ style: {
595
+ backgroundColor: '#e64c2e',
596
+ color: '#ffffff',
597
+ },
598
+ nodeWidth: 250,
599
+ nodeHeight: 110,
600
+ },
601
+ addflow: {
602
+ type: 'addCondi',
603
+ nodeHeight: 32,
604
+ nodeWidth: 90,
605
+ },
606
+ };
607
+ }
608
+ addConditionItem(model) {
609
+ const nextNode = this.graphModel.getNodeModelById(model.targetNodeId);
610
+ if (nextNode.type === 'addCondi') {
611
+ message.warning('已添加条件分支');
612
+ return;
613
+ }
614
+ const { eventCenter } = this.graphModel;
615
+ eventCenter.emit('node:add-condi', { model });
616
+ return;
617
+ }
618
+ initEdgeData(data) {
619
+ super.initEdgeData(data);
620
+ this.isSelected = false;
621
+ this.isHovered = false;
622
+ const model = this.graphModel.getNodeModelById(this.sourceNodeId);
623
+ this.isHitable = model.type !== BM_NODE_CONFIG.PLUSCONDINAME;
624
+ }
625
+ getEdgeStyle() {
626
+ const style = super.getEdgeStyle();
627
+ return style;
628
+ }
629
+ setAttributes() {
630
+ const addMenu = [
631
+ {
632
+ className: 'custom-menu-icon-1',
633
+ text: '审批人',
634
+ icon: true,
635
+ callback: (model) => {
636
+ const { eventCenter } = this.graphModel;
637
+ eventCenter.emit('node:add-item', {
638
+ nodetype: 'bmFlowNode',
639
+ model,
640
+ data: this.FLOWTYPE['auditing'],
641
+ });
642
+ },
643
+ },
644
+ {
645
+ className: 'custom-menu-icon-2',
646
+ text: '办理人',
647
+ icon: true,
648
+ callback: (model) => {
649
+ const { eventCenter } = this.graphModel;
650
+ eventCenter.emit('node:add-item', {
651
+ nodetype: 'bmFlowNode',
652
+ model,
653
+ data: this.FLOWTYPE['deal'],
654
+ });
655
+ },
656
+ },
657
+ {
658
+ className: 'custom-menu-icon-3',
659
+ text: '条件分支',
660
+ icon: true,
661
+ callback: (model) => {
662
+ this.addConditionItem(model);
663
+ },
664
+ },
665
+ ];
666
+ this.menu = addMenu;
667
+ }
668
+ }
669
+ class BmPolyLine extends PolylineEdge {
670
+ }
671
+ var BmPolyLine$1 = {
672
+ type: 'bmpolyline',
673
+ view: BmPolyLine,
674
+ model: BmPolyLineModel,
675
+ };
676
+
677
+ const idGeneratorFunc = (function () {
678
+ let id = 0;
679
+ return function () {
680
+ return `bm${(Math.random().toString(36) + Number(`${Date.now()}${++id}`).toString(36)).slice(2)}`;
681
+ };
682
+ })();
683
+ function initBasicFlow(_a) {
684
+ var { container } = _a, config = __rest(_a, ["container"]);
685
+ const lf = new LogicFlow(Object.assign({ container, background: {
686
+ backgroundColor: '#f8f8f8',
687
+ }, grid: {
688
+ size: 10,
689
+ visible: false,
690
+ type: 'mesh',
691
+ config: {
692
+ color: '#fff',
693
+ thickness: 10,
694
+ },
695
+ }, partial: false, stopScrollGraph: false, adjustEdge: false, edgeSelectedOutline: false, adjustEdgeStartAndEnd: false, nodeSelectedOutline: false, textEdit: false, snapline: true, hoverOutline: false, plugins: [Menu, BpmnAdapter], isSilentMode: true, idGenerator: idGeneratorFunc, edgeGenerator: idGeneratorFunc }, config));
696
+ lf.batchRegister([
697
+ EndCircle,
698
+ AddFlowNode$1,
699
+ AddCondi,
700
+ BmPolyLine$1,
701
+ BmFlowHtmlNode,
702
+ ]);
703
+ lf.extension.menu.setMenuConfig({
704
+ nodeMenu: false,
705
+ graphMenu: [],
706
+ });
707
+ lf.setTheme({
708
+ polyline: {
709
+ strokeWidth: 2,
710
+ stroke: '#D9D9D9',
711
+ },
712
+ arrow: {
713
+ offset: 0,
714
+ verticalLength: 0,
715
+ },
716
+ edgeText: {
717
+ textWidth: 50,
718
+ fontSize: 23,
719
+ color: '#fff',
720
+ background: {
721
+ fill: '#2F4EED',
722
+ },
723
+ },
724
+ rect: {
725
+ fill: '#FFFFFF',
726
+ stroke: '#000000',
727
+ strokeWidth: 2,
728
+ },
729
+ });
730
+ lf.render();
731
+ return lf;
732
+ }
733
+ function is(val, type) {
734
+ return toString.call(val) === `[object ${type}]`;
735
+ }
736
+ function isString(val) {
737
+ return is(val, 'String');
738
+ }
739
+
740
+ const _sfc_main = /* @__PURE__ */ defineComponent({
741
+ __name: "flow-designer",
742
+ props: {
743
+ lineLength: {
744
+ type: Number,
745
+ default: 100
746
+ }
747
+ },
748
+ emits: ["nodeCallback", "loadFinish"],
749
+ setup(__props, { expose, emit }) {
750
+ const props = __props;
751
+ const container = ref(null);
752
+ let lf = null;
753
+ let graphModel = null;
754
+ let eventCenter;
755
+ function getFlowRawData() {
756
+ const json = lf.getGraphRawData();
757
+ const xml = lf.getGraphData();
758
+ return { json, xml };
759
+ }
760
+ function loadFlowData(json) {
761
+ lf.renderRawData(json);
762
+ lf.graphModel.nodes.forEach((item) => {
763
+ if (item.properties.type === "begin")
764
+ state.startId = item.id;
765
+ if (item.type === BM_NODE_CONFIG.ENDNODENAME)
766
+ state.endId = item.id;
767
+ });
768
+ emit("loadFinish", lf.graphModel.nodes);
769
+ }
770
+ const state = {
771
+ startId: "",
772
+ endId: ""
773
+ };
774
+ const flowMethods = {
775
+ addFlowNodeByEdge(edge, type, data) {
776
+ const { id, sourceNodeId, targetNodeId } = edge;
777
+ const outNode = graphModel.getNodeModelById(targetNodeId);
778
+ const inputNode = graphModel.getNodeModelById(sourceNodeId);
779
+ graphModel.deleteEdgeById(id);
780
+ const newNode = flowMethods.addNodeFunc(type, inputNode.x, 0, data);
781
+ flowMethods.addEdgeFunc(sourceNodeId, newNode.id, "+");
782
+ flowMethods.addEdgeFunc(newNode.id, outNode.id, "+");
783
+ flowMethods.rezoomConditionFlowsFunc();
784
+ return newNode;
785
+ },
786
+ createCondiFlowsByEdge(edge) {
787
+ const { id, sourceNodeId, targetNodeId } = edge;
788
+ const outNode = graphModel.getNodeModelById(targetNodeId);
789
+ const inputNode = graphModel.getNodeModelById(sourceNodeId);
790
+ if (outNode && outNode.type === BM_NODE_CONFIG.PLUSCONDINAME) {
791
+ message.error("\u540E\u7F6E\u8282\u70B9\u5DF2\u662F\u6761\u4EF6\u8282\u70B9");
792
+ return;
793
+ }
794
+ if (inputNode.properties && inputNode.properties.type && inputNode.properties.type === BM_NODE_CONFIG.CONDITIONNAME) {
795
+ message.error("\u524D\u7F6E\u8282\u70B9\u5DF2\u4E3A\u6761\u4EF6\u8282\u70B9");
796
+ return;
797
+ }
798
+ graphModel.deleteEdgeById(id);
799
+ const addCondi = flowMethods.addNodeFunc("bmAddCondiNode", inputNode.x, 0);
800
+ flowMethods.addEdgeFunc(sourceNodeId, addCondi.id, "+");
801
+ flowMethods.addCondiFlowFunc(
802
+ addCondi,
803
+ "bmFlowNode",
804
+ {
805
+ type: "condition",
806
+ isCustom: false,
807
+ priority: 99
808
+ },
809
+ 0,
810
+ graphModel.getNodeModelById(state.endId)
811
+ );
812
+ flowMethods.addCondiFlowFunc(
813
+ addCondi,
814
+ "bmFlowNode",
815
+ {
816
+ type: "condition",
817
+ isCustom: true,
818
+ title: `\u6761\u4EF61`,
819
+ desc: "\u6761\u4EF6\u5B57\u6BB5",
820
+ priority: 1
821
+ },
822
+ 0,
823
+ outNode
824
+ );
825
+ addCondi.properties.outId = outNode.id;
826
+ flowMethods.rezoomConditionFlowsFunc(addCondi);
827
+ },
828
+ deleteFlowNode(id) {
829
+ const [preNode] = graphModel.getNodeIncomingNode(id);
830
+ const [nextNode] = graphModel.getNodeOutgoingNode(id);
831
+ if (nextNode.type === BM_NODE_CONFIG.PLUSCONDINAME && preNode?.properties?.type === "condition") {
832
+ let queue = [nextNode.id];
833
+ let deleteIds = [nextNode.id];
834
+ while (queue.length) {
835
+ let id2 = queue.shift();
836
+ let node = graphModel.getNodeModelById(String(id2));
837
+ if (["auditing", "deal"].includes(String(node?.properties?.type))) {
838
+ message.error("\u8BF7\u5148\u5220\u9664\u5F53\u524D\u8282\u70B9\u4E0B\u7684\u6761\u4EF6\u8282\u70B9");
839
+ return;
840
+ }
841
+ let outgoings = graphModel.getNodeOutgoingNode(id2);
842
+ let ids = outgoings.map((n) => n.id);
843
+ deleteIds.push(...ids);
844
+ queue.push(...ids);
845
+ }
846
+ deleteIds.forEach((id2) => id2 !== state.endId && graphModel.deleteNode(id2));
847
+ graphModel.deleteNode(id);
848
+ flowMethods.addEdgeFunc(preNode.id, state.endId, "+");
849
+ flowMethods.rezoomConditionFlowsFunc();
850
+ return;
851
+ }
852
+ graphModel.deleteNode(id);
853
+ flowMethods.addEdgeFunc(preNode.id, nextNode.id, "+");
854
+ flowMethods.rezoomConditionFlowsFunc();
855
+ },
856
+ addNewCondiFlowFunc(node, nodeProperties = {}) {
857
+ const branchs = graphModel.getNodeOutgoingEdge(node.id).length;
858
+ const condition = flowMethods.addCondiFlowFunc(
859
+ graphModel.getNodeModelById(node.id),
860
+ "bmFlowNode",
861
+ {
862
+ ...nodeProperties,
863
+ type: "condition",
864
+ isCustom: true,
865
+ title: `\u6761\u4EF6${branchs}`,
866
+ desc: "\u6761\u4EF6\u5B57\u6BB5",
867
+ priority: branchs
868
+ },
869
+ 0,
870
+ graphModel.getNodeModelById(state.endId)
871
+ );
872
+ flowMethods.rezoomConditionFlowsFunc();
873
+ return condition;
874
+ },
875
+ rezoomConditionFlowsFunc() {
876
+ const queue = [];
877
+ queue.push(state.startId);
878
+ const nodeMap = { [state.startId]: 1 };
879
+ const deltaMap = {
880
+ [state.startId]: { x: 0, y: 0 }
881
+ };
882
+ while (queue.length) {
883
+ const id = queue.shift();
884
+ const node = graphModel.getNodeModelById(id);
885
+ if (node?.properties?.type === "begin") {
886
+ const [outgoing] = graphModel.getNodeOutgoingNode(id);
887
+ queue.push(outgoing.id);
888
+ continue;
889
+ }
890
+ if (node.type === BM_NODE_CONFIG.ENDNODENAME) {
891
+ deltaMap[id] = { x: 0, y: 0 };
892
+ continue;
893
+ }
894
+ const incomings2 = graphModel.getNodeIncomingNode(id);
895
+ const incoming = incomings2[0];
896
+ let weight = nodeMap[incoming.id] || nodeMap[id];
897
+ if (node.type === BM_NODE_CONFIG.PLUSCONDINAME) {
898
+ const conditions = graphModel.getNodeOutgoingNode(id);
899
+ const length = conditions.length;
900
+ conditions.sort((a, b) => {
901
+ if (+a.properties.priority === 99)
902
+ return false;
903
+ if (+b.properties.priority === 99)
904
+ return true;
905
+ return a.properties.priority - b.properties.priority;
906
+ });
907
+ delete nodeMap[incoming.id];
908
+ for (const key in nodeMap) {
909
+ if (nodeMap[key] > weight)
910
+ nodeMap[key] = nodeMap[key] + length - 1;
911
+ }
912
+ conditions.forEach((item) => {
913
+ nodeMap[item.id] = function(w) {
914
+ return w;
915
+ }(weight);
916
+ weight++;
917
+ });
918
+ queue.push(...conditions.map((item) => item.id));
919
+ deltaMap[id] = {
920
+ x: 0,
921
+ y: incoming.y + deltaMap[incoming.id]?.y + incoming.height / 2 + node.height / 2 + BM_NODE_CONFIG.LINELENGTH - node.y
922
+ };
923
+ } else {
924
+ const [outgoing] = graphModel.getNodeOutgoingNode(id);
925
+ delete nodeMap[incoming.id];
926
+ nodeMap[node.id] = weight;
927
+ deltaMap[id] = {
928
+ x: 0,
929
+ y: incoming.y + deltaMap[incoming.id]?.y + incoming.height / 2 + node.height / 2 + BM_NODE_CONFIG.LINELENGTH - node.y
930
+ };
931
+ queue.push(outgoing.id);
932
+ }
933
+ }
934
+ queue.push(state.endId);
935
+ while (queue.length) {
936
+ const id = queue.shift();
937
+ const node = graphModel.getNodeModelById(id);
938
+ if (node?.properties?.type === "begin") {
939
+ continue;
940
+ }
941
+ const incomings2 = graphModel.getNodeIncomingNode(id);
942
+ if (node.type === BM_NODE_CONFIG.ENDNODENAME) {
943
+ const mid = Math.ceil(incomings2.length / 2);
944
+ const double = incomings2.length % 2 === 0;
945
+ incomings2.forEach((n) => {
946
+ const weight = nodeMap[n.id];
947
+ if (deltaMap[n.id]) {
948
+ if (double) {
949
+ deltaMap[n.id]["x"] = ((incomings2.length + 1) / 2 - weight) * 2 * BM_NODE_CONFIG.CONDIOFFSET - n.x;
950
+ } else {
951
+ deltaMap[n.id]["x"] = (mid - weight) * 2 * BM_NODE_CONFIG.CONDIOFFSET - n.x;
952
+ }
953
+ } else {
954
+ deltaMap[n.id] = {
955
+ x: (mid - weight) * BM_NODE_CONFIG.CONDIOFFSET,
956
+ y: node.y
957
+ };
958
+ }
959
+ });
960
+ queue.push(...incomings2.map((n) => n?.id));
961
+ continue;
962
+ }
963
+ const incoming = incomings2[0];
964
+ if (node.type === BM_NODE_CONFIG.PLUSCONDINAME) {
965
+ const outgoings = graphModel.getNodeOutgoingNode(id);
966
+ const weight = nodeMap[id];
967
+ for (const key in nodeMap) {
968
+ if (nodeMap[key] > weight) {
969
+ nodeMap[key] = nodeMap[key] - outgoings.length;
970
+ }
971
+ }
972
+ let left = Number.MAX_SAFE_INTEGER;
973
+ let right = Number.MIN_SAFE_INTEGER;
974
+ outgoings.forEach((n) => {
975
+ left = Math.min(left, n.x + deltaMap[n.id]?.x);
976
+ right = Math.max(right, n.x + deltaMap[n.id]?.x);
977
+ });
978
+ if (incoming?.properties.type === "begin") {
979
+ deltaMap[node.id].x = node.x - incoming.y;
980
+ } else {
981
+ deltaMap[id].x = left + (right - left) / 2 - node.x;
982
+ }
983
+ queue.push(incoming.id);
984
+ delete nodeMap[id];
985
+ nodeMap[incoming.id] = weight;
986
+ } else {
987
+ const [outgoing] = graphModel.getNodeOutgoingNode(id);
988
+ const [incoming2] = graphModel.getNodeIncomingNode(id);
989
+ if (outgoing?.type !== BM_NODE_CONFIG.ENDNODENAME) {
990
+ deltaMap[id].x = deltaMap[outgoing.id].x + outgoing.x - node.x;
991
+ nodeMap[id] = nodeMap[outgoing.id];
992
+ delete nodeMap[outgoing.id];
993
+ queue.push(incoming2.id);
994
+ } else {
995
+ nodeMap[incoming2.id] = nodeMap[incoming2.id] ? Math.min(nodeMap[incoming2.id], nodeMap[id]) : nodeMap[id];
996
+ deltaMap[incoming2.id].x = node.x + deltaMap[id].x;
997
+ queue.push(incoming2.id);
998
+ delete nodeMap[id];
999
+ }
1000
+ }
1001
+ }
1002
+ const incomings = graphModel.getNodeIncomingNode(
1003
+ state.endId
1004
+ );
1005
+ const end = graphModel.getNodeModelById(state.endId);
1006
+ let max = Number.MIN_SAFE_INTEGER;
1007
+ incomings.forEach((n) => {
1008
+ max = Math.max(
1009
+ max,
1010
+ n.y + deltaMap[n.id]?.y + n.height / 2 + end.height / 2 + BM_NODE_CONFIG.LINELENGTH
1011
+ );
1012
+ });
1013
+ deltaMap[state.endId]["y"] = max - end.y;
1014
+ for (const id in deltaMap) {
1015
+ const { x, y } = deltaMap[id];
1016
+ graphModel.moveNode(id, x, y);
1017
+ }
1018
+ flowMethods.checkEdgePoints(state.startId);
1019
+ },
1020
+ addCondiFlowFunc(node, nodetype, data, offsetMain = 0, outNode = null) {
1021
+ const { id, x, y } = node;
1022
+ const newNode = flowMethods.addNodeFunc(
1023
+ nodetype,
1024
+ x + offsetMain,
1025
+ y + BM_NODE_CONFIG.LINELENGTH + node.height,
1026
+ data
1027
+ );
1028
+ flowMethods.addEdgeFunc(id, newNode.id, void 0);
1029
+ if (outNode) {
1030
+ const node2 = outNode;
1031
+ const shouldDistance = newNode.height + BM_NODE_CONFIG.LINELENGTH + newNode.y;
1032
+ if (shouldDistance > outNode.y)
1033
+ graphModel.moveNodes(
1034
+ [node2.id, ...flowMethods.nodeIdsBFC(node2.id)],
1035
+ 0,
1036
+ shouldDistance - node2.y
1037
+ );
1038
+ flowMethods.addEdgeFunc(newNode.id, node2.id, "+");
1039
+ }
1040
+ return newNode;
1041
+ },
1042
+ deleteConditionFlowFunc(node) {
1043
+ const [addCondi] = graphModel.getNodeIncomingNode(node.id);
1044
+ let queue = [node.id];
1045
+ let deleteIds = [node.id];
1046
+ const priority = node?.properties?.priority;
1047
+ while (queue.length) {
1048
+ let id = queue.shift();
1049
+ if (id === state.endId) {
1050
+ continue;
1051
+ }
1052
+ let outgoings2 = graphModel.getNodeOutgoingNode(id);
1053
+ let ids = outgoings2.map((n) => n.id);
1054
+ deleteIds.push(...ids);
1055
+ console.log(deleteIds, ids, outgoings2);
1056
+ queue.push(...ids);
1057
+ }
1058
+ deleteIds.forEach((id) => id !== state.endId && graphModel.deleteNode(id));
1059
+ let outgoings = graphModel.getNodeOutgoingNode(addCondi.id);
1060
+ if (outgoings.length <= 1) {
1061
+ let [pre] = graphModel.getNodeIncomingNode(addCondi.id);
1062
+ outgoings.some((n) => {
1063
+ if (!n?.properties?.isCustom) {
1064
+ let [next] = graphModel.getNodeOutgoingNode(n.id);
1065
+ flowMethods.addEdgeFunc(pre.id, next.id, "+");
1066
+ graphModel.deleteNode(addCondi.id);
1067
+ graphModel.deleteNode(n.id);
1068
+ return true;
1069
+ }
1070
+ });
1071
+ } else {
1072
+ outgoings.forEach((node2) => {
1073
+ if (node2?.properties?.isCustom && +node2?.properties?.priority > +priority) {
1074
+ node2.properties.priority = node2.properties.priority - 1;
1075
+ }
1076
+ });
1077
+ }
1078
+ flowMethods.rezoomConditionFlowsFunc();
1079
+ },
1080
+ addNodeFunc(type, x = 0, y = 0, properties = {}, ...args) {
1081
+ return graphModel.addNode({ type, x, y, properties, ...args });
1082
+ },
1083
+ addEdgeFunc(sourceNodeId, targetNodeId, text, pointsList = [], type, properties) {
1084
+ const params = {
1085
+ sourceNodeId,
1086
+ targetNodeId,
1087
+ type: type || "bmpolyline",
1088
+ pointsList,
1089
+ properties
1090
+ };
1091
+ if (text && isString(text)) {
1092
+ const sourceNode = graphModel.getNodeModelById(sourceNodeId);
1093
+ params["text"] = { value: text, x: sourceNode.x, y: sourceNode.y + 85 };
1094
+ }
1095
+ return graphModel.addEdge({
1096
+ ...params
1097
+ });
1098
+ },
1099
+ nodeIdsBFC(id, out = [], end = "") {
1100
+ if (!id || id === "")
1101
+ return [];
1102
+ const ids = /* @__PURE__ */ new Set();
1103
+ const queue = [id];
1104
+ while (queue.length) {
1105
+ const id2 = queue.shift();
1106
+ const nodes = graphModel.getNodeOutgoingNode(id2);
1107
+ for (const node of nodes) {
1108
+ if (!ids.has(node.id) && node.id !== end) {
1109
+ queue.unshift(node.id);
1110
+ ids.add(node.id);
1111
+ }
1112
+ }
1113
+ }
1114
+ out.forEach((item) => ids.has(item) && ids.delete(item));
1115
+ return Array.from(ids);
1116
+ },
1117
+ checkEdgePoints(startId) {
1118
+ flowMethods.resetEdgePoint(startId, true);
1119
+ flowMethods.resetEdgePoint(startId, false);
1120
+ const nodes = graphModel.getNodeOutgoingNode(startId);
1121
+ if (nodes && nodes.length) {
1122
+ nodes.forEach((node) => {
1123
+ flowMethods.checkEdgePoints(node.id);
1124
+ });
1125
+ }
1126
+ },
1127
+ resetEdgePoint(nodeId, isIncoming = false) {
1128
+ const edges = isIncoming ? graphModel.getNodeIncomingEdge(nodeId) : graphModel.getNodeOutgoingEdge(nodeId);
1129
+ edges.forEach((edge) => {
1130
+ const targetNode = graphModel.getNodeModelById(edge.targetNodeId);
1131
+ const pointsList = flowMethods.getEdgesPoints(
1132
+ graphModel.getNodeModelById(edge.sourceNodeId),
1133
+ targetNode,
1134
+ isIncoming ? "ed" : "bd"
1135
+ );
1136
+ if (pointsList.length) {
1137
+ flowMethods.addEdgeFunc(
1138
+ edge.sourceNodeId,
1139
+ edge.targetNodeId,
1140
+ targetNode?.properties?.type === BM_NODE_CONFIG.CONDITIONNAME ? void 0 : "+",
1141
+ pointsList
1142
+ );
1143
+ graphModel.deleteEdgeById(edge.id);
1144
+ }
1145
+ });
1146
+ },
1147
+ getEdgesPoints(sourceNode, targetNode, direction = "") {
1148
+ let list = [];
1149
+ if (sourceNode.x === targetNode.x || sourceNode.y === targetNode.y)
1150
+ return [
1151
+ { x: sourceNode.x, y: sourceNode.y + sourceNode.height / 2 },
1152
+ { x: targetNode.x, y: targetNode.y - targetNode.height / 2 }
1153
+ ];
1154
+ switch (direction) {
1155
+ case "bd":
1156
+ list = [
1157
+ { x: sourceNode.x + sourceNode.width / 2, y: sourceNode.y },
1158
+ { x: targetNode.x, y: sourceNode.y },
1159
+ { x: targetNode.x, y: targetNode.y - targetNode.height / 2 }
1160
+ ];
1161
+ break;
1162
+ case "ed":
1163
+ list = [
1164
+ { x: sourceNode.x, y: sourceNode.y + sourceNode.height / 2 },
1165
+ {
1166
+ x: sourceNode.x,
1167
+ y: targetNode.y - (targetNode.height + props.lineLength) / 2
1168
+ },
1169
+ {
1170
+ x: targetNode.x,
1171
+ y: targetNode.y - (targetNode.height + props.lineLength) / 2
1172
+ },
1173
+ { x: targetNode.x, y: targetNode.y - targetNode.height / 2 }
1174
+ ];
1175
+ break;
1176
+ }
1177
+ return list;
1178
+ }
1179
+ };
1180
+ function initFlowInstance() {
1181
+ const parent = document.querySelector(
1182
+ ".bm-flow-designer-container"
1183
+ )?.parentElement;
1184
+ const { clientWidth, clientHeight } = parent;
1185
+ const width = clientWidth;
1186
+ const height = clientHeight;
1187
+ const config = {
23
1188
  container: container.value,
24
- grid: true
1189
+ width,
1190
+ height
1191
+ };
1192
+ lf = initBasicFlow(config);
1193
+ graphModel = lf.graphModel;
1194
+ eventCenter = graphModel.eventCenter;
1195
+ }
1196
+ function initFlowEvent() {
1197
+ eventCenter.on("flownode:delete", ({ id }) => {
1198
+ Modal.confirm({
1199
+ content: "\u662F\u5426\u786E\u5B9A\u5220\u9664\u8282\u70B9\uFF1F",
1200
+ cancelText: "\u53D6\u6D88",
1201
+ okText: "\u5220\u9664",
1202
+ centered: true,
1203
+ onOk: () => {
1204
+ flowMethods.deleteFlowNode(id);
1205
+ }
1206
+ });
1207
+ });
1208
+ eventCenter.on("condition:delete", (data) => {
1209
+ Modal.confirm({
1210
+ content: "\u5220\u9664\u6761\u4EF6\u540E\uFF0C\u8BE5\u6761\u4EF6\u4E0B\u6240\u6709\u76F8\u5173\u7684\u8282\u70B9\u8BBE\u7F6E\u5C06\u4E00\u5E76\u60C5\u51B5\uFF0C\u662F\u5426\u786E\u8BA4\u5220\u9664\uFF1F",
1211
+ cancelText: "\u53D6\u6D88",
1212
+ okText: "\u5220\u9664",
1213
+ centered: true,
1214
+ onOk: () => {
1215
+ flowMethods.deleteConditionFlowFunc(data);
1216
+ }
1217
+ });
1218
+ });
1219
+ eventCenter.on("flownode:copynode", (data) => {
1220
+ flowMethods.copyConditionLine(data);
1221
+ });
1222
+ eventCenter.on("flownode:info", () => {
1223
+ console.log("\u8282\u70B9\u4FE1\u606F\u56DE\u8C03");
1224
+ });
1225
+ eventCenter.on("edge:click", ({ data, e, position }) => {
1226
+ eventCenter.emit("edge:contextmenu", { data, e, position });
1227
+ });
1228
+ eventCenter.on("node:click", ({ data }) => {
1229
+ const { type } = data;
1230
+ if (type === "bmAddCondiNode") {
1231
+ flowMethods.addNewCondiFlowFunc(data);
1232
+ }
1233
+ });
1234
+ eventCenter.on("node:add-condi", ({ model }) => {
1235
+ flowMethods.createCondiFlowsByEdge(model);
1236
+ });
1237
+ eventCenter.on("node:add-item", ({ model, nodetype, data }) => {
1238
+ flowMethods.addFlowNodeByEdge(model, nodetype, data);
1239
+ });
1240
+ eventCenter.on("content:click", (model) => {
1241
+ let branchs = void 0;
1242
+ if (model.properties?.type === BM_NODE_CONFIG.CONDITIONNAME) {
1243
+ let [parent] = graphModel.getNodeIncomingNode(model.id);
1244
+ branchs = graphModel.getNodeOutgoingEdge(parent.id).length - 1;
1245
+ }
1246
+ emit("nodeCallback", {
1247
+ id: model.id,
1248
+ properties: model.properties,
1249
+ branchs
1250
+ });
1251
+ });
1252
+ eventCenter.on("edge:add", () => {
1253
+ });
1254
+ }
1255
+ function focusOnZoom(y = void 0) {
1256
+ y = y || BM_NODE_CONFIG.HALFNODEHEIGHT + BM_NODE_CONFIG.LINELENGTH + BM_NODE_CONFIG.ENDRADIUS;
1257
+ lf.focusOn({
1258
+ coordinate: {
1259
+ x: 0,
1260
+ y
1261
+ }
1262
+ });
1263
+ }
1264
+ function initFlowNodes() {
1265
+ const start = flowMethods.addNodeFunc("bmFlowNode", 0, 0, {
1266
+ label: "\u53D1\u8D77\u4EBA",
1267
+ desc: "\u6587\u6848\u63CF\u8FF0",
1268
+ type: "begin"
1269
+ });
1270
+ const end = flowMethods.addNodeFunc(
1271
+ "bmEndNode",
1272
+ 0,
1273
+ BM_NODE_CONFIG.HALFNODEHEIGHT + BM_NODE_CONFIG.LINELENGTH + BM_NODE_CONFIG.ENDRADIUS * 2
1274
+ );
1275
+ flowMethods.addEdgeFunc(start.id, end.id, "+");
1276
+ focusOnZoom();
1277
+ state.endId = end.id;
1278
+ state.startId = start.id;
1279
+ emit("loadFinish", lf.graphModel.nodes);
1280
+ }
1281
+ function changePriority(id, priority) {
1282
+ let node = graphModel.getNodeModelById(id);
1283
+ let [parent] = graphModel.getNodeIncomingNode(id);
1284
+ let children = graphModel.getNodeOutgoingNode(parent.id);
1285
+ children.some((item) => {
1286
+ if (+item.properties.priority === +priority) {
1287
+ item.properties.priority = +node.properties.priority || 1;
1288
+ node.properties.priority = +priority;
1289
+ return true;
1290
+ }
25
1291
  });
26
- lf.render();
27
1292
  }
28
1293
  onMounted(() => {
29
- init();
1294
+ initFlowInstance();
1295
+ initFlowEvent();
1296
+ });
1297
+ expose({
1298
+ loadFlowData,
1299
+ getFlowRawData,
1300
+ initFlowNodes,
1301
+ focusOnZoom,
1302
+ changePriority
30
1303
  });
31
1304
  return (_ctx, _cache) => {
32
1305
  return openBlock(), createElementBlock("div", {