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