@tmagic/editor 1.3.0-alpha.13 → 1.3.0-alpha.14

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 (63) hide show
  1. package/dist/style.css +41 -113
  2. package/dist/tmagic-editor.js +1307 -1197
  3. package/dist/tmagic-editor.js.map +1 -1
  4. package/dist/tmagic-editor.umd.cjs +1318 -1204
  5. package/dist/tmagic-editor.umd.cjs.map +1 -1
  6. package/package.json +11 -11
  7. package/src/Editor.vue +0 -4
  8. package/src/components/CodeBlockEditor.vue +155 -0
  9. package/src/components/CodeParams.vue +59 -0
  10. package/src/fields/Code.vue +27 -19
  11. package/src/fields/CodeSelect.vue +7 -1
  12. package/src/fields/CodeSelectCol.vue +65 -74
  13. package/src/fields/DataSourceFields.vue +7 -9
  14. package/src/fields/DataSourceMethodSelect.vue +147 -0
  15. package/src/fields/DataSourceMethods.vue +103 -0
  16. package/src/fields/EventSelect.vue +33 -7
  17. package/src/icons/CodeIcon.vue +0 -2
  18. package/src/index.ts +8 -0
  19. package/src/layouts/CodeEditor.vue +32 -1
  20. package/src/layouts/Framework.vue +7 -3
  21. package/src/layouts/sidebar/Sidebar.vue +2 -10
  22. package/src/layouts/sidebar/code-block/CodeBlockList.vue +73 -124
  23. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +64 -0
  24. package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +23 -33
  25. package/src/layouts/sidebar/data-source/DataSourceList.vue +111 -0
  26. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +13 -81
  27. package/src/services/codeBlock.ts +17 -70
  28. package/src/services/dataSource.ts +2 -0
  29. package/src/theme/code-block.scss +0 -122
  30. package/src/theme/code-editor.scss +27 -2
  31. package/src/theme/data-source-methods.scss +13 -0
  32. package/src/theme/event.scss +15 -12
  33. package/src/theme/theme.scss +1 -0
  34. package/src/type.ts +21 -6
  35. package/src/utils/data-source/index.ts +11 -0
  36. package/src/utils/use-code-block-edit.ts +84 -0
  37. package/src/utils/use-data-source-method.ts +101 -0
  38. package/types/components/CodeBlockEditor.vue.d.ts +21 -0
  39. package/types/components/CodeParams.vue.d.ts +26 -0
  40. package/types/components/ContentMenu.vue.d.ts +2 -2
  41. package/types/fields/Code.vue.d.ts +26 -6
  42. package/types/fields/CodeSelectCol.vue.d.ts +16 -5
  43. package/types/fields/DataSourceFields.vue.d.ts +2 -0
  44. package/types/fields/DataSourceMethodSelect.vue.d.ts +44 -0
  45. package/types/fields/DataSourceMethods.vue.d.ts +45 -0
  46. package/types/index.d.ts +4 -0
  47. package/types/layouts/CodeEditor.vue.d.ts +2 -0
  48. package/types/layouts/PropsPanel.vue.d.ts +8 -8
  49. package/types/layouts/sidebar/Sidebar.vue.d.ts +0 -3
  50. package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +4 -9
  51. package/types/layouts/sidebar/code-block/{CodeBlockEditor.vue.d.ts → CodeBlockListPanel.vue.d.ts} +5 -6
  52. package/types/layouts/sidebar/data-source/DataSourceConfigPanel.vue.d.ts +3 -1
  53. package/types/layouts/sidebar/data-source/DataSourceList.vue.d.ts +14 -0
  54. package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +1 -11
  55. package/types/services/codeBlock.d.ts +5 -36
  56. package/types/services/dataSource.d.ts +1 -0
  57. package/types/type.d.ts +19 -6
  58. package/types/{components/FunctionEditor.vue.d.ts → utils/use-code-block-edit.d.ts} +26 -123
  59. package/types/utils/use-data-source-method.d.ts +116 -0
  60. package/src/components/CodeDraftEditor.vue +0 -148
  61. package/src/components/FunctionEditor.vue +0 -197
  62. package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +0 -100
  63. package/types/components/CodeDraftEditor.vue.d.ts +0 -61
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('lodash-es'), require('@tmagic/design'), require('@tmagic/schema'), require('@element-plus/icons-vue'), require('@tmagic/form'), require('@tmagic/table'), require('monaco-editor'), require('gesto'), require('@tmagic/utils'), require('@tmagic/stage'), require('events'), require('@tmagic/core'), require('keycon')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', 'lodash-es', '@tmagic/design', '@tmagic/schema', '@element-plus/icons-vue', '@tmagic/form', '@tmagic/table', 'monaco-editor', 'gesto', '@tmagic/utils', '@tmagic/stage', 'events', '@tmagic/core', 'keycon'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.serialize, global.lodashEs, global.design, global.schema, global.iconsVue, global.form, global.table, global.monaco, global.Gesto, global.utils, global.StageCore, global.events, global.core, global.KeyController));
5
- })(this, (function (exports, vue, serialize, lodashEs, design, schema, iconsVue, form, table, monaco, Gesto, utils, StageCore, events, core, KeyController) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('lodash-es'), require('monaco-editor'), require('serialize-javascript'), require('@tmagic/design'), require('@tmagic/schema'), require('@tmagic/form'), require('@tmagic/table'), require('gesto'), require('@tmagic/utils'), require('@tmagic/stage'), require('events'), require('@tmagic/core'), require('keycon')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', 'lodash-es', 'monaco-editor', 'serialize-javascript', '@tmagic/design', '@tmagic/schema', '@tmagic/form', '@tmagic/table', 'gesto', '@tmagic/utils', '@tmagic/stage', 'events', '@tmagic/core', 'keycon'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.iconsVue, global.lodashEs, global.monaco, global.serialize, global.design, global.schema, global.form, global.table, global.Gesto, global.utils, global.StageCore, global.events, global.core, global.KeyController));
5
+ })(this, (function (exports, vue, iconsVue, lodashEs, monaco, serialize, design, schema, form, table, Gesto, utils, StageCore, events, core, KeyController) { 'use strict';
6
6
 
7
7
  function _interopNamespaceDefault(e) {
8
8
  const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
@@ -23,35 +23,215 @@
23
23
 
24
24
  const monaco__namespace = /*#__PURE__*/_interopNamespaceDefault(monaco);
25
25
 
26
- const _sfc_main$H = /* @__PURE__ */ vue.defineComponent({
26
+ const _hoisted_1$r = {
27
+ class: /* @__PURE__ */ vue.normalizeClass(`magic-code-editor`)
28
+ };
29
+ const _sfc_main$K = /* @__PURE__ */ vue.defineComponent({
30
+ ...{
31
+ name: "MEditorCodeEditor"
32
+ },
33
+ __name: "CodeEditor",
34
+ props: {
35
+ initValues: {},
36
+ modifiedValues: {},
37
+ type: {},
38
+ language: { default: "javascript" },
39
+ options: { default: () => ({
40
+ tabSize: 2
41
+ }) },
42
+ height: {},
43
+ autoSave: { type: Boolean, default: true }
44
+ },
45
+ emits: ["initd", "save"],
46
+ setup(__props, { expose: __expose, emit }) {
47
+ const props = __props;
48
+ const toString = (v, language) => {
49
+ let value = "";
50
+ if (typeof v !== "string") {
51
+ if (props.language.toLocaleLowerCase() === "json") {
52
+ value = JSON.stringify(v, null, 2);
53
+ } else {
54
+ value = serialize(v, {
55
+ space: 2,
56
+ unsafe: true
57
+ }).replace(/"(\w+)":\s/g, "$1: ");
58
+ }
59
+ } else {
60
+ value = v;
61
+ }
62
+ if (language === "javascript" && value.startsWith("{") && value.endsWith("}")) {
63
+ value = `(${value})`;
64
+ }
65
+ return value;
66
+ };
67
+ let vsEditor = null;
68
+ let vsDiffEditor = null;
69
+ const values = vue.ref("");
70
+ const loading = vue.ref(false);
71
+ const codeEditor = vue.ref();
72
+ const resizeObserver = new globalThis.ResizeObserver(
73
+ lodashEs.throttle(() => {
74
+ vsEditor?.layout();
75
+ vsDiffEditor?.layout();
76
+ }, 300)
77
+ );
78
+ const setEditorValue = (v, m) => {
79
+ values.value = toString(v, props.language);
80
+ if (props.type === "diff") {
81
+ const originalModel = monaco__namespace.editor.createModel(values.value, "text/javascript");
82
+ const modifiedModel = monaco__namespace.editor.createModel(toString(m, props.language), "text/javascript");
83
+ return vsDiffEditor?.setModel({
84
+ original: originalModel,
85
+ modified: modifiedModel
86
+ });
87
+ }
88
+ return vsEditor?.setValue(values.value);
89
+ };
90
+ const getEditorValue = () => (props.type === "diff" ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue()) || "";
91
+ const init = async () => {
92
+ if (!codeEditor.value)
93
+ return;
94
+ const options = {
95
+ value: values.value,
96
+ language: props.language,
97
+ theme: "vs-dark",
98
+ ...props.options
99
+ };
100
+ if (props.type === "diff") {
101
+ vsDiffEditor = monaco__namespace.editor.createDiffEditor(codeEditor.value, options);
102
+ } else {
103
+ vsEditor = monaco__namespace.editor.create(codeEditor.value, options);
104
+ }
105
+ setEditorValue(props.initValues, props.modifiedValues);
106
+ loading.value = false;
107
+ emit("initd", vsEditor);
108
+ codeEditor.value.addEventListener("keydown", (e) => {
109
+ if (e.keyCode === 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
110
+ e.preventDefault();
111
+ e.stopPropagation();
112
+ const newValue = getEditorValue();
113
+ values.value = newValue;
114
+ emit("save", newValue);
115
+ }
116
+ });
117
+ if (props.type !== "diff" && props.autoSave) {
118
+ vsEditor?.onDidBlurEditorWidget(() => {
119
+ const newValue = getEditorValue();
120
+ if (values.value !== newValue) {
121
+ values.value = newValue;
122
+ emit("save", newValue);
123
+ }
124
+ });
125
+ }
126
+ resizeObserver.observe(codeEditor.value);
127
+ };
128
+ vue.watch(
129
+ () => props.initValues,
130
+ (v, preV) => {
131
+ if (v !== preV) {
132
+ setEditorValue(props.initValues, props.modifiedValues);
133
+ }
134
+ },
135
+ {
136
+ deep: true,
137
+ immediate: true
138
+ }
139
+ );
140
+ vue.onMounted(async () => {
141
+ loading.value = true;
142
+ init();
143
+ });
144
+ vue.onUnmounted(() => {
145
+ resizeObserver.disconnect();
146
+ });
147
+ const fullScreen = vue.ref(false);
148
+ const fullScreenHandler = () => {
149
+ fullScreen.value = !fullScreen.value;
150
+ setTimeout(() => {
151
+ vsEditor?.focus();
152
+ vsEditor?.layout();
153
+ vsDiffEditor?.focus();
154
+ vsDiffEditor?.layout();
155
+ });
156
+ };
157
+ __expose({
158
+ values,
159
+ getEditor() {
160
+ return vsEditor || vsDiffEditor;
161
+ },
162
+ getVsEditor() {
163
+ return vsEditor;
164
+ },
165
+ getVsDiffEditor() {
166
+ return vsDiffEditor;
167
+ },
168
+ setEditorValue,
169
+ focus() {
170
+ vsEditor?.focus();
171
+ vsDiffEditor?.focus();
172
+ }
173
+ });
174
+ return (_ctx, _cache) => {
175
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$r, [
176
+ (vue.openBlock(), vue.createBlock(vue.Teleport, {
177
+ to: "body",
178
+ disabled: !fullScreen.value
179
+ }, [
180
+ vue.createElementVNode("div", {
181
+ class: vue.normalizeClass(`magic-code-editor-wrapper${fullScreen.value ? " full-screen" : ""}`),
182
+ style: vue.normalizeStyle(!fullScreen.value && _ctx.height ? `height: ${_ctx.height}` : "100%")
183
+ }, [
184
+ vue.createVNode(vue.unref(design.TMagicButton), {
185
+ class: "magic-code-editor-full-screen-icon",
186
+ circle: "",
187
+ size: "small",
188
+ icon: vue.unref(iconsVue.FullScreen),
189
+ onClick: fullScreenHandler
190
+ }, null, 8, ["icon"]),
191
+ vue.createElementVNode("div", {
192
+ ref_key: "codeEditor",
193
+ ref: codeEditor,
194
+ class: "magic-code-editor-content"
195
+ }, null, 512)
196
+ ], 6)
197
+ ], 8, ["disabled"]))
198
+ ]);
199
+ };
200
+ }
201
+ });
202
+
203
+ const _sfc_main$J = /* @__PURE__ */ vue.defineComponent({
27
204
  ...{
28
205
  name: "MEditorCode"
29
206
  },
30
207
  __name: "Code",
31
208
  props: {
209
+ config: {},
32
210
  model: {},
33
211
  name: {},
34
- config: {},
35
- prop: {}
212
+ prop: {},
213
+ lastValues: {},
214
+ disabled: { type: Boolean, default: false },
215
+ size: {}
36
216
  },
37
217
  emits: ["change"],
38
218
  setup(__props, { emit }) {
39
219
  const props = __props;
40
- const language = vue.computed(() => props.config.language || "javascript");
41
- const height = vue.computed(() => props.config.height || `${document.body.clientHeight - 168}px`);
42
220
  const save = (v) => {
43
221
  props.model[props.name] = v;
44
222
  emit("change", v);
45
223
  };
46
224
  return (_ctx, _cache) => {
47
- const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
48
- return vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
49
- style: vue.normalizeStyle(`height: ${height.value}`),
225
+ return vue.openBlock(), vue.createBlock(_sfc_main$K, {
226
+ height: _ctx.config.height,
50
227
  "init-values": _ctx.model[_ctx.name],
51
- language: language.value,
52
- options: _ctx.config.options,
228
+ language: _ctx.config.language,
229
+ options: {
230
+ ..._ctx.config.options,
231
+ readOnly: _ctx.disabled
232
+ },
53
233
  onSave: save
54
- }, null, 8, ["style", "init-values", "language", "options"]);
234
+ }, null, 8, ["height", "init-values", "language", "options"]);
55
235
  };
56
236
  }
57
237
  });
@@ -62,7 +242,7 @@
62
242
  };
63
243
  const getConfig = (key) => $TMAGIC_EDITOR[key];
64
244
 
65
- const _sfc_main$G = /* @__PURE__ */ vue.defineComponent({
245
+ const _sfc_main$I = /* @__PURE__ */ vue.defineComponent({
66
246
  ...{
67
247
  name: "MEditorCodeLink"
68
248
  },
@@ -136,7 +316,7 @@
136
316
  }
137
317
  });
138
318
 
139
- const _sfc_main$F = /* @__PURE__ */ vue.defineComponent({
319
+ const _sfc_main$H = /* @__PURE__ */ vue.defineComponent({
140
320
  ...{
141
321
  name: "MEditorCodeSelect"
142
322
  },
@@ -151,6 +331,7 @@
151
331
  emits: ["change"],
152
332
  setup(__props, { emit }) {
153
333
  const props = __props;
334
+ const services = vue.inject("services");
154
335
  const codeConfig = vue.computed(() => ({
155
336
  type: "group-list",
156
337
  name: "hookData",
@@ -160,7 +341,9 @@
160
341
  items: [
161
342
  {
162
343
  type: "code-select-col",
163
- labelWidth: 0
344
+ name: "codeId",
345
+ labelWidth: 0,
346
+ disabled: () => !services?.codeBlockService.getEditStatus()
164
347
  }
165
348
  ]
166
349
  }));
@@ -201,6 +384,187 @@
201
384
  }
202
385
  });
203
386
 
387
+ const _sfc_main$G = /* @__PURE__ */ vue.defineComponent({
388
+ ...{
389
+ name: "MEditorCodeBlockEditor"
390
+ },
391
+ __name: "CodeBlockEditor",
392
+ props: {
393
+ content: {},
394
+ disabled: { type: Boolean }
395
+ },
396
+ emits: ["submit"],
397
+ setup(__props, { expose: __expose, emit }) {
398
+ const services = vue.inject("services");
399
+ const columnWidth = vue.computed(() => services?.uiService.get("columnWidth"));
400
+ const size = vue.computed(() => columnWidth.value ? columnWidth.value.center + columnWidth.value.right : 600);
401
+ const codeEditorHeight = vue.ref("600px");
402
+ const defaultParamColConfig = {
403
+ type: "row",
404
+ label: "参数类型",
405
+ items: [
406
+ {
407
+ text: "参数类型",
408
+ labelWidth: "70px",
409
+ type: "select",
410
+ name: "type",
411
+ options: [
412
+ {
413
+ text: "数字",
414
+ label: "数字",
415
+ value: "number"
416
+ },
417
+ {
418
+ text: "字符串",
419
+ label: "字符串",
420
+ value: "text"
421
+ },
422
+ {
423
+ text: "组件",
424
+ label: "组件",
425
+ value: "ui-select"
426
+ }
427
+ ]
428
+ }
429
+ ]
430
+ };
431
+ const functionConfig = vue.computed(() => [
432
+ {
433
+ text: "名称",
434
+ name: "name"
435
+ },
436
+ {
437
+ text: "注释",
438
+ name: "desc"
439
+ },
440
+ {
441
+ type: "table",
442
+ border: true,
443
+ text: "参数",
444
+ enableFullscreen: false,
445
+ name: "params",
446
+ maxHeight: "300px",
447
+ dropSort: false,
448
+ items: [
449
+ {
450
+ type: "text",
451
+ label: "参数名",
452
+ name: "name"
453
+ },
454
+ {
455
+ type: "text",
456
+ label: "注释",
457
+ name: "extra"
458
+ },
459
+ services?.codeBlockService.getParamsColConfig() || defaultParamColConfig
460
+ ]
461
+ },
462
+ {
463
+ name: "content",
464
+ type: "vs-code",
465
+ options: vue.inject("codeOptions", {}),
466
+ height: codeEditorHeight.value,
467
+ onChange: (formState, code) => {
468
+ try {
469
+ getConfig("parseDSL")(code);
470
+ return code;
471
+ } catch (error) {
472
+ design.tMagicMessage.error(error.message);
473
+ throw error;
474
+ }
475
+ }
476
+ }
477
+ ]);
478
+ const submitForm = async (values) => {
479
+ emit("submit", values);
480
+ };
481
+ const errorHandler = (error) => {
482
+ design.tMagicMessage.error(error.message);
483
+ };
484
+ const fomDrawer = vue.ref();
485
+ const openHandler = () => {
486
+ setTimeout(() => {
487
+ if (fomDrawer.value) {
488
+ const height = fomDrawer.value?.bodyHeight - 468;
489
+ codeEditorHeight.value = `${height > 100 ? height : 600}px`;
490
+ }
491
+ });
492
+ };
493
+ __expose({
494
+ show() {
495
+ fomDrawer.value?.show();
496
+ },
497
+ hide() {
498
+ fomDrawer.value?.hide();
499
+ }
500
+ });
501
+ return (_ctx, _cache) => {
502
+ return vue.openBlock(), vue.createBlock(vue.unref(form.MFormDrawer), {
503
+ ref_key: "fomDrawer",
504
+ ref: fomDrawer,
505
+ "label-width": "80px",
506
+ title: _ctx.content.name,
507
+ width: size.value,
508
+ config: functionConfig.value,
509
+ values: _ctx.content,
510
+ disabled: _ctx.disabled,
511
+ onSubmit: submitForm,
512
+ onError: errorHandler,
513
+ onOpen: openHandler
514
+ }, null, 8, ["title", "width", "config", "values", "disabled"]);
515
+ };
516
+ }
517
+ });
518
+
519
+ const _sfc_main$F = /* @__PURE__ */ vue.defineComponent({
520
+ ...{
521
+ name: "MEditorCodeParams"
522
+ },
523
+ __name: "CodeParams",
524
+ props: {
525
+ model: {},
526
+ size: {},
527
+ disabled: { type: Boolean },
528
+ name: {},
529
+ paramsConfig: {}
530
+ },
531
+ emits: ["change"],
532
+ setup(__props, { emit }) {
533
+ const props = __props;
534
+ const form$1 = vue.ref();
535
+ const getFormConfig = (items = []) => [
536
+ {
537
+ type: "fieldset",
538
+ items,
539
+ legend: "参数",
540
+ labelWidth: "70px",
541
+ name: props.name
542
+ }
543
+ ];
544
+ const codeParamsConfig = vue.computed(() => getFormConfig(props.paramsConfig));
545
+ const onParamsChangeHandler = async () => {
546
+ try {
547
+ const value = await form$1.value?.submitForm(true);
548
+ emit("change", value);
549
+ } catch (e) {
550
+ console.log(e);
551
+ }
552
+ };
553
+ return (_ctx, _cache) => {
554
+ return vue.openBlock(), vue.createBlock(vue.unref(form.MForm), {
555
+ ref_key: "form",
556
+ ref: form$1,
557
+ config: codeParamsConfig.value,
558
+ "init-values": _ctx.model,
559
+ disabled: _ctx.disabled,
560
+ size: _ctx.size,
561
+ "watch-props": false,
562
+ onChange: onParamsChangeHandler
563
+ }, null, 8, ["config", "init-values", "disabled", "size"]);
564
+ };
565
+ }
566
+ });
567
+
204
568
  const _hoisted_1$q = ["src"];
205
569
  const _sfc_main$E = /* @__PURE__ */ vue.defineComponent({
206
570
  ...{
@@ -244,6 +608,64 @@
244
608
  }
245
609
  });
246
610
 
611
+ const useCodeBlockEdit = (codeBlockService) => {
612
+ const codeConfig = vue.ref();
613
+ const codeId = vue.ref();
614
+ const codeBlockEditor = vue.ref();
615
+ const createCodeBlock = async () => {
616
+ if (!codeBlockService) {
617
+ design.tMagicMessage.error("新增代码块失败");
618
+ return;
619
+ }
620
+ codeConfig.value = {
621
+ name: "代码块",
622
+ content: `({app, params}) => {
623
+ // place your code here
624
+ }`,
625
+ params: []
626
+ };
627
+ codeId.value = await codeBlockService.getUniqueId();
628
+ await vue.nextTick();
629
+ codeBlockEditor.value?.show();
630
+ };
631
+ const editCode = async (id) => {
632
+ const codeBlock = await codeBlockService?.getCodeContentById(id);
633
+ if (!codeBlock) {
634
+ design.tMagicMessage.error("获取代码块内容失败");
635
+ return;
636
+ }
637
+ let codeContent = codeBlock.content;
638
+ if (typeof codeContent !== "string") {
639
+ codeContent = codeContent.toString();
640
+ }
641
+ codeConfig.value = {
642
+ ...lodashEs.cloneDeep(codeBlock),
643
+ content: codeContent
644
+ };
645
+ codeId.value = id;
646
+ await vue.nextTick();
647
+ codeBlockEditor.value?.show();
648
+ };
649
+ const deleteCode = async (key) => {
650
+ codeBlockService?.deleteCodeDslByIds([key]);
651
+ };
652
+ const submitCodeBlockHandler = async (values) => {
653
+ if (!codeId.value)
654
+ return;
655
+ await codeBlockService?.setCodeDslById(codeId.value, values);
656
+ codeBlockEditor.value?.hide();
657
+ };
658
+ return {
659
+ codeId,
660
+ codeConfig,
661
+ codeBlockEditor,
662
+ createCodeBlock,
663
+ editCode,
664
+ deleteCode,
665
+ submitCodeBlockHandler
666
+ };
667
+ };
668
+
247
669
  const _hoisted_1$p = { class: "m-fields-code-select-col" };
248
670
  const _hoisted_2$f = { class: "code-select-container" };
249
671
  const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
@@ -256,28 +678,33 @@
256
678
  model: {},
257
679
  prop: {},
258
680
  name: {},
681
+ lastValues: {},
682
+ disabled: { type: Boolean, default: false },
259
683
  size: {}
260
684
  },
261
685
  emits: ["change"],
262
686
  setup(__props, { emit }) {
263
687
  const props = __props;
264
688
  const services = vue.inject("services");
265
- const mForm = vue.inject("mForm");
689
+ const getParamItemsConfig = (codeId) => {
690
+ if (!codeDsl.value || !codeId)
691
+ return [];
692
+ const paramStatements = codeDsl.value[codeId]?.params;
693
+ if (lodashEs.isEmpty(paramStatements))
694
+ return [];
695
+ return paramStatements.map((paramState) => ({
696
+ labelWidth: "100px",
697
+ text: paramState.name,
698
+ ...paramState
699
+ }));
700
+ };
266
701
  const codeDsl = vue.computed(() => services?.codeBlockService.getCodeDsl());
267
- const editable = vue.computed(() => services?.codeBlockService.getEditStatus());
268
- const codeParamsConfig = vue.ref({
269
- type: "fieldset",
270
- items: [],
271
- legend: "参数",
272
- labelWidth: "70px",
273
- name: "params",
274
- display: false
275
- });
702
+ const paramsConfig = vue.ref(getParamItemsConfig(props.model[props.name]));
276
703
  const selectConfig = {
277
704
  type: "select",
278
705
  text: "代码块",
279
- name: "codeId",
280
- labelWidth: "70px",
706
+ name: props.name,
707
+ labelWidth: "80px",
281
708
  options: () => {
282
709
  if (codeDsl.value) {
283
710
  return lodashEs.map(codeDsl.value, (value, key) => ({
@@ -289,53 +716,20 @@
289
716
  return [];
290
717
  },
291
718
  onChange: (formState, codeId, { model }) => {
292
- model.params = {};
293
- }
294
- };
295
- const getParamItemsConfig = (codeId) => {
296
- if (!codeDsl.value)
297
- return [];
298
- const paramStatements = codeDsl.value[codeId]?.params;
299
- if (lodashEs.isEmpty(paramStatements))
300
- return [];
301
- return paramStatements.map((paramState) => ({
302
- labelWidth: "100px",
303
- text: paramState.name,
304
- ...paramState
305
- }));
306
- };
307
- const getCodeParamsConfig = (codeId) => {
308
- const paramsConfig = getParamItemsConfig(codeId);
309
- if (!props.model.params || lodashEs.isEmpty(props.model.params)) {
310
- props.model.params = {};
311
- form.createValues(mForm, paramsConfig, {}, props.model.params);
719
+ paramsConfig.value = getParamItemsConfig(codeId);
720
+ if (paramsConfig.value.length) {
721
+ model.params = form.createValues(formState, paramsConfig.value, {}, model.params);
722
+ } else {
723
+ model.params = {};
724
+ }
725
+ return codeId;
312
726
  }
313
- codeParamsConfig.value = {
314
- type: "fieldset",
315
- items: paramsConfig,
316
- legend: "参数",
317
- labelWidth: "70px",
318
- name: "params",
319
- display: !lodashEs.isEmpty(paramsConfig)
320
- };
321
727
  };
322
- const onParamsChangeHandler = () => {
728
+ const onParamsChangeHandler = (value) => {
729
+ props.model.params = value.params;
323
730
  emit("change", props.model);
324
731
  };
325
- vue.watch(
326
- () => props.model.codeId,
327
- (codeId) => {
328
- if (!codeId)
329
- return;
330
- getCodeParamsConfig(codeId);
331
- },
332
- {
333
- immediate: true
334
- }
335
- );
336
- const editCode = () => {
337
- services?.codeBlockService.setCodeEditorContent(true, props.model.codeId);
338
- };
732
+ const { codeBlockEditor, codeConfig, editCode, submitCodeBlockHandler } = useCodeBlockEdit(services?.codeBlockService);
339
733
  return (_ctx, _cache) => {
340
734
  const _component_m_form_container = vue.resolveComponent("m-form-container");
341
735
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$p, [
@@ -346,17 +740,29 @@
346
740
  model: _ctx.model,
347
741
  onChange: onParamsChangeHandler
348
742
  }, null, 8, ["model"]),
349
- vue.createVNode(_sfc_main$E, {
743
+ _ctx.model[_ctx.name] ? (vue.openBlock(), vue.createBlock(_sfc_main$E, {
744
+ key: 0,
350
745
  class: "icon",
351
- icon: editable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
352
- onClick: editCode
353
- }, null, 8, ["icon"])
746
+ icon: !_ctx.disabled ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
747
+ onClick: _cache[0] || (_cache[0] = ($event) => vue.unref(editCode)(_ctx.model[_ctx.name]))
748
+ }, null, 8, ["icon"])) : vue.createCommentVNode("", true)
354
749
  ]),
355
- vue.createVNode(_component_m_form_container, {
356
- config: codeParamsConfig.value,
750
+ paramsConfig.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$F, {
751
+ key: 0,
752
+ name: "params",
357
753
  model: _ctx.model,
754
+ size: _ctx.size,
755
+ "params-config": paramsConfig.value,
358
756
  onChange: onParamsChangeHandler
359
- }, null, 8, ["config", "model"])
757
+ }, null, 8, ["model", "size", "params-config"])) : vue.createCommentVNode("", true),
758
+ vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$G, {
759
+ key: 1,
760
+ ref_key: "codeBlockEditor",
761
+ ref: codeBlockEditor,
762
+ disabled: _ctx.disabled,
763
+ content: vue.unref(codeConfig),
764
+ onSubmit: vue.unref(submitCodeBlockHandler)
765
+ }, null, 8, ["disabled", "content", "onSubmit"])) : vue.createCommentVNode("", true)
360
766
  ]);
361
767
  };
362
768
  }
@@ -373,6 +779,7 @@
373
779
  config: {},
374
780
  model: {},
375
781
  prop: {},
782
+ lastValues: {},
376
783
  disabled: { type: Boolean, default: false },
377
784
  name: {}
378
785
  },
@@ -383,24 +790,20 @@
383
790
  const fieldValues = vue.ref({});
384
791
  const filedTitle = vue.ref("");
385
792
  const newHandler = () => {
386
- if (!addDialog.value)
387
- return;
388
793
  fieldValues.value = {};
389
794
  filedTitle.value = "新增属性";
390
- addDialog.value.dialogVisible = true;
795
+ addDialog.value?.show();
391
796
  };
392
797
  const fieldChange = ({ index, ...value }) => {
393
- if (!addDialog.value)
394
- return;
395
798
  if (index > -1) {
396
799
  props.model[props.name][index] = value;
397
800
  } else {
398
801
  props.model[props.name].push(value);
399
802
  }
400
- addDialog.value.dialogVisible = false;
803
+ addDialog.value?.hide();
401
804
  emit("change", props.model[props.name]);
402
805
  };
403
- const filedColumns = [
806
+ const fieldColumns = [
404
807
  {
405
808
  label: "属性名称",
406
809
  prop: "title"
@@ -420,14 +823,12 @@
420
823
  {
421
824
  text: "编辑",
422
825
  handler: (row, index) => {
423
- if (!addDialog.value)
424
- return;
425
826
  fieldValues.value = {
426
827
  ...row,
427
828
  index
428
829
  };
429
830
  filedTitle.value = `编辑${row.title}`;
430
- addDialog.value.dialogVisible = true;
831
+ addDialog.value?.show();
431
832
  }
432
833
  },
433
834
  {
@@ -513,7 +914,7 @@
513
914
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$o, [
514
915
  vue.createVNode(vue.unref(table.MagicTable), {
515
916
  data: _ctx.model[_ctx.name],
516
- columns: filedColumns
917
+ columns: fieldColumns
517
918
  }, null, 8, ["data"]),
518
919
  vue.createElementVNode("div", _hoisted_2$e, [
519
920
  vue.createVNode(vue.unref(design.TMagicButton), {
@@ -536,8 +937,9 @@
536
937
  config: dataSourceFieldsConfig,
537
938
  values: fieldValues.value,
538
939
  parentValues: _ctx.model[_ctx.name],
940
+ disabled: _ctx.disabled,
539
941
  onSubmit: fieldChange
540
- }, null, 8, ["title", "values", "parentValues"])
942
+ }, null, 8, ["title", "values", "parentValues", "disabled"])
541
943
  ]);
542
944
  };
543
945
  }
@@ -545,7 +947,7 @@
545
947
 
546
948
  const _hoisted_1$n = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
547
949
  const _hoisted_2$d = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
548
- const _hoisted_3$6 = { class: "el-input__inner" };
950
+ const _hoisted_3$5 = { class: "el-input__inner" };
549
951
  const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
550
952
  ...{
551
953
  name: "MEditorDataSourceInput"
@@ -743,75 +1145,358 @@
743
1145
  return _ctx.disabled || isFocused.value ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(design.getConfig)("components")?.autocomplete.component || "el-autocomplete"), vue.mergeProps(
744
1146
  {
745
1147
  key: 0,
746
- class: "tmagic-design-auto-complete",
747
- ref_key: "autocomplete",
748
- ref: autocomplete,
749
- modelValue: state.value,
750
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => state.value = $event)
751
- },
752
- vue.unref(design.getConfig)("components")?.autocomplete.props({
753
- disabled: _ctx.disabled,
1148
+ class: "tmagic-design-auto-complete",
1149
+ ref_key: "autocomplete",
1150
+ ref: autocomplete,
1151
+ modelValue: state.value,
1152
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => state.value = $event)
1153
+ },
1154
+ vue.unref(design.getConfig)("components")?.autocomplete.props({
1155
+ disabled: _ctx.disabled,
1156
+ size: _ctx.size,
1157
+ fetchSuggestions: querySearch,
1158
+ triggerOnFocus: false,
1159
+ clearable: true
1160
+ }) || {},
1161
+ {
1162
+ style: { "width": "100%" },
1163
+ onBlur: blurHandler,
1164
+ onChange: changeHandler,
1165
+ onInput: inputHandler,
1166
+ onSelect: selectHandler
1167
+ }
1168
+ ), {
1169
+ suffix: vue.withCtx(() => [
1170
+ vue.createVNode(_sfc_main$E, { icon: vue.unref(iconsVue.Coin) }, null, 8, ["icon"])
1171
+ ]),
1172
+ default: vue.withCtx(({ item }) => [
1173
+ vue.createElementVNode("div", _hoisted_1$n, [
1174
+ vue.createElementVNode("div", null, vue.toDisplayString(item.text), 1),
1175
+ vue.createElementVNode("span", _hoisted_2$d, vue.toDisplayString(item.value), 1)
1176
+ ])
1177
+ ]),
1178
+ _: 1
1179
+ }, 16, ["modelValue"])) : (vue.openBlock(), vue.createElementBlock("div", {
1180
+ key: 1,
1181
+ class: vue.normalizeClass(`tmagic-data-source-input-text el-input el-input--${_ctx.size}`),
1182
+ onMouseup: mouseupHandler
1183
+ }, [
1184
+ vue.createElementVNode("div", {
1185
+ class: vue.normalizeClass(`tmagic-data-source-input-text-wrapper el-input__wrapper ${isFocused.value ? " is-focus" : ""}`)
1186
+ }, [
1187
+ vue.createElementVNode("div", _hoisted_3$5, [
1188
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(displayState.value, (item, index) => {
1189
+ return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
1190
+ item.type === "text" ? (vue.openBlock(), vue.createElementBlock("span", {
1191
+ key: index,
1192
+ style: { "margin-right": "2px" }
1193
+ }, vue.toDisplayString(item.value), 1)) : vue.createCommentVNode("", true),
1194
+ item.type === "var" ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTag), {
1195
+ key: index,
1196
+ size: _ctx.size
1197
+ }, {
1198
+ default: vue.withCtx(() => [
1199
+ vue.createTextVNode(vue.toDisplayString(item.value), 1)
1200
+ ]),
1201
+ _: 2
1202
+ }, 1032, ["size"])) : vue.createCommentVNode("", true)
1203
+ ], 64);
1204
+ }), 256)),
1205
+ vue.createVNode(_sfc_main$E, {
1206
+ class: "tmagic-data-source-input-icon",
1207
+ icon: vue.unref(iconsVue.Coin)
1208
+ }, null, 8, ["icon"])
1209
+ ])
1210
+ ], 2)
1211
+ ], 34));
1212
+ };
1213
+ }
1214
+ });
1215
+
1216
+ const useDataSourceMethod = () => {
1217
+ const codeConfig = vue.ref();
1218
+ const codeBlockEditor = vue.ref();
1219
+ const dataSource = vue.ref();
1220
+ const dataSourceMethod = vue.ref("");
1221
+ return {
1222
+ codeConfig,
1223
+ codeBlockEditor,
1224
+ createCode: async (model) => {
1225
+ codeConfig.value = {
1226
+ name: "",
1227
+ content: `({ params, dataSource, app }) => {
1228
+ // place your code here
1229
+ }`,
1230
+ params: []
1231
+ };
1232
+ await vue.nextTick();
1233
+ dataSource.value = model;
1234
+ dataSourceMethod.value = "";
1235
+ codeBlockEditor.value?.show();
1236
+ },
1237
+ editCode: async (model, methodName) => {
1238
+ const method = model.methods?.find((method2) => method2.name === methodName);
1239
+ if (!method) {
1240
+ design.tMagicMessage.error("获取数据源方法失败");
1241
+ return;
1242
+ }
1243
+ let codeContent = method.content;
1244
+ if (typeof codeContent !== "string") {
1245
+ codeContent = codeContent.toString();
1246
+ }
1247
+ codeConfig.value = {
1248
+ ...lodashEs.cloneDeep(method),
1249
+ content: codeContent
1250
+ };
1251
+ await vue.nextTick();
1252
+ dataSource.value = model;
1253
+ dataSourceMethod.value = methodName;
1254
+ codeBlockEditor.value?.show();
1255
+ },
1256
+ deleteCode: async (model, methodName) => {
1257
+ if (!model.methods)
1258
+ return;
1259
+ const index = model.methods.findIndex((method) => method.name === methodName);
1260
+ if (index === -1) {
1261
+ return;
1262
+ }
1263
+ model.methods.splice(index, 1);
1264
+ },
1265
+ submitCode: (values) => {
1266
+ if (!dataSource.value)
1267
+ return;
1268
+ if (!dataSource.value.methods) {
1269
+ dataSource.value.methods = [];
1270
+ }
1271
+ if (values.content) {
1272
+ const parseDSL = getConfig("parseDSL");
1273
+ if (typeof values.content === "string") {
1274
+ values.content = parseDSL(values.content);
1275
+ }
1276
+ }
1277
+ if (dataSourceMethod.value) {
1278
+ const index = dataSource.value.methods.findIndex((method) => method.name === dataSourceMethod.value);
1279
+ dataSource.value.methods.splice(index, 1, values);
1280
+ } else {
1281
+ dataSource.value.methods.push(values);
1282
+ }
1283
+ codeBlockEditor.value?.hide();
1284
+ }
1285
+ };
1286
+ };
1287
+
1288
+ const _hoisted_1$m = { class: "m-editor-data-source-methods" };
1289
+ const _hoisted_2$c = { class: "m-editor-data-source-methods-footer" };
1290
+ const _sfc_main$A = /* @__PURE__ */ vue.defineComponent({
1291
+ ...{
1292
+ name: "MEditorDataSourceMethods"
1293
+ },
1294
+ __name: "DataSourceMethods",
1295
+ props: {
1296
+ config: {},
1297
+ model: {},
1298
+ prop: {},
1299
+ lastValues: {},
1300
+ disabled: { type: Boolean, default: false },
1301
+ name: {}
1302
+ },
1303
+ emits: ["change"],
1304
+ setup(__props, { emit }) {
1305
+ const props = __props;
1306
+ const { codeConfig, codeBlockEditor, createCode, editCode, deleteCode, submitCode } = useDataSourceMethod();
1307
+ const methodColumns = [
1308
+ {
1309
+ label: "名称",
1310
+ prop: "name"
1311
+ },
1312
+ {
1313
+ label: "注释",
1314
+ prop: "desc"
1315
+ },
1316
+ {
1317
+ label: "参数",
1318
+ prop: "params",
1319
+ formatter: (params) => params.map((item) => item.name).join(", ")
1320
+ },
1321
+ {
1322
+ label: "操作",
1323
+ fixed: "right",
1324
+ actions: [
1325
+ {
1326
+ text: "编辑",
1327
+ handler: (row) => {
1328
+ editCode(props.model, row.name);
1329
+ emit("change", props.model[props.name]);
1330
+ }
1331
+ },
1332
+ {
1333
+ text: "删除",
1334
+ buttonType: "danger",
1335
+ handler: (row) => {
1336
+ deleteCode(props.model, row.name);
1337
+ emit("change", props.model[props.name]);
1338
+ }
1339
+ }
1340
+ ]
1341
+ }
1342
+ ];
1343
+ const createCodeHandler = () => {
1344
+ createCode(props.model);
1345
+ emit("change", props.model[props.name]);
1346
+ };
1347
+ const submitCodeHandler = (values) => {
1348
+ submitCode(values);
1349
+ emit("change", props.model[props.name]);
1350
+ };
1351
+ return (_ctx, _cache) => {
1352
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$m, [
1353
+ vue.createVNode(vue.unref(table.MagicTable), {
1354
+ data: _ctx.model[_ctx.name],
1355
+ columns: methodColumns
1356
+ }, null, 8, ["data"]),
1357
+ vue.createElementVNode("div", _hoisted_2$c, [
1358
+ vue.createVNode(vue.unref(design.TMagicButton), {
1359
+ size: "small",
1360
+ type: "primary",
1361
+ disabled: _ctx.disabled,
1362
+ plain: "",
1363
+ onClick: createCodeHandler
1364
+ }, {
1365
+ default: vue.withCtx(() => [
1366
+ vue.createTextVNode("添加")
1367
+ ]),
1368
+ _: 1
1369
+ }, 8, ["disabled"])
1370
+ ]),
1371
+ vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$G, {
1372
+ key: 0,
1373
+ ref_key: "codeBlockEditor",
1374
+ ref: codeBlockEditor,
1375
+ disabled: _ctx.disabled,
1376
+ content: vue.unref(codeConfig),
1377
+ onSubmit: submitCodeHandler
1378
+ }, null, 8, ["disabled", "content"])) : vue.createCommentVNode("", true)
1379
+ ]);
1380
+ };
1381
+ }
1382
+ });
1383
+
1384
+ const _hoisted_1$l = { class: "m-fields-data-source-method-select" };
1385
+ const _hoisted_2$b = { class: "data-source-method-select-container" };
1386
+ const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
1387
+ ...{
1388
+ name: "MEditorDataSourceMethodSelect"
1389
+ },
1390
+ __name: "DataSourceMethodSelect",
1391
+ props: {
1392
+ config: {},
1393
+ model: {},
1394
+ lastValues: {},
1395
+ prop: {},
1396
+ name: {},
1397
+ disabled: { type: Boolean, default: false },
1398
+ size: {}
1399
+ },
1400
+ emits: ["change"],
1401
+ setup(__props, { emit }) {
1402
+ const props = __props;
1403
+ const services = vue.inject("services");
1404
+ const dataSources = vue.computed(() => services?.dataSourceService.get("dataSources"));
1405
+ const getParamItemsConfig = ([dataSourceId, medthodName] = ["", ""]) => {
1406
+ if (!dataSourceId)
1407
+ return [];
1408
+ const paramStatements = dataSources.value?.find((item) => item.id === dataSourceId)?.methods?.find((item) => item.name === medthodName)?.params;
1409
+ if (!paramStatements)
1410
+ return [];
1411
+ return paramStatements.map((paramState) => ({
1412
+ labelWidth: "100px",
1413
+ text: paramState.name,
1414
+ ...paramState
1415
+ }));
1416
+ };
1417
+ const paramsConfig = vue.ref(getParamItemsConfig(props.model.dataSourceMethod));
1418
+ const setParamsConfig = (dataSourceMethod, formState = {}) => {
1419
+ paramsConfig.value = dataSourceMethod ? getParamItemsConfig(dataSourceMethod) : [];
1420
+ if (paramsConfig.value.length) {
1421
+ props.model.params = form.createValues(formState, paramsConfig.value, {}, props.model.params);
1422
+ } else {
1423
+ props.model.params = {};
1424
+ }
1425
+ };
1426
+ const cascaderConfig = {
1427
+ type: "cascader",
1428
+ text: "数据源方法",
1429
+ name: props.name,
1430
+ labelWidth: "80px",
1431
+ options: () => dataSources.value?.filter((ds) => ds.methods?.length)?.map((ds) => ({
1432
+ label: `${ds.title}(${ds.id})`,
1433
+ value: ds.id,
1434
+ children: ds.methods?.map((method) => ({
1435
+ label: method.name,
1436
+ value: method.name
1437
+ }))
1438
+ })) || [],
1439
+ onChange: (formState, dataSourceMethod) => {
1440
+ setParamsConfig(dataSourceMethod, formState);
1441
+ return dataSourceMethod;
1442
+ }
1443
+ };
1444
+ const onChangeHandler = (value) => {
1445
+ props.model.params = value.params;
1446
+ emit("change", props.model);
1447
+ };
1448
+ const { codeBlockEditor, codeConfig, editCode, submitCode } = useDataSourceMethod();
1449
+ const editCodeHandler = () => {
1450
+ const [id, name] = props.model[props.name];
1451
+ const dataSource = services?.dataSourceService.getDataSourceById(id);
1452
+ if (!dataSource)
1453
+ return;
1454
+ editCode(dataSource, name);
1455
+ setParamsConfig([id, name]);
1456
+ };
1457
+ const submitCodeBlockHandler = (value) => {
1458
+ submitCode(value);
1459
+ };
1460
+ return (_ctx, _cache) => {
1461
+ const _component_m_form_container = vue.resolveComponent("m-form-container");
1462
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$l, [
1463
+ vue.createElementVNode("div", _hoisted_2$b, [
1464
+ vue.createVNode(_component_m_form_container, {
1465
+ class: "select",
1466
+ config: cascaderConfig,
1467
+ model: _ctx.model,
1468
+ onChange: onChangeHandler
1469
+ }, null, 8, ["model"]),
1470
+ _ctx.model[_ctx.name] ? (vue.openBlock(), vue.createBlock(_sfc_main$E, {
1471
+ key: 0,
1472
+ class: "icon",
1473
+ icon: !_ctx.disabled ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
1474
+ onClick: editCodeHandler
1475
+ }, null, 8, ["icon"])) : vue.createCommentVNode("", true)
1476
+ ]),
1477
+ paramsConfig.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$F, {
1478
+ key: 0,
1479
+ name: "params",
1480
+ model: _ctx.model,
754
1481
  size: _ctx.size,
755
- fetchSuggestions: querySearch,
756
- triggerOnFocus: false,
757
- clearable: true
758
- }) || {},
759
- {
760
- style: { "width": "100%" },
761
- onBlur: blurHandler,
762
- onChange: changeHandler,
763
- onInput: inputHandler,
764
- onSelect: selectHandler
765
- }
766
- ), {
767
- suffix: vue.withCtx(() => [
768
- vue.createVNode(_sfc_main$E, { icon: vue.unref(iconsVue.Coin) }, null, 8, ["icon"])
769
- ]),
770
- default: vue.withCtx(({ item }) => [
771
- vue.createElementVNode("div", _hoisted_1$n, [
772
- vue.createElementVNode("div", null, vue.toDisplayString(item.text), 1),
773
- vue.createElementVNode("span", _hoisted_2$d, vue.toDisplayString(item.value), 1)
774
- ])
775
- ]),
776
- _: 1
777
- }, 16, ["modelValue"])) : (vue.openBlock(), vue.createElementBlock("div", {
778
- key: 1,
779
- class: vue.normalizeClass(`tmagic-data-source-input-text el-input el-input--${_ctx.size}`),
780
- onMouseup: mouseupHandler
781
- }, [
782
- vue.createElementVNode("div", {
783
- class: vue.normalizeClass(`tmagic-data-source-input-text-wrapper el-input__wrapper ${isFocused.value ? " is-focus" : ""}`)
784
- }, [
785
- vue.createElementVNode("div", _hoisted_3$6, [
786
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(displayState.value, (item, index) => {
787
- return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
788
- item.type === "text" ? (vue.openBlock(), vue.createElementBlock("span", {
789
- key: index,
790
- style: { "margin-right": "2px" }
791
- }, vue.toDisplayString(item.value), 1)) : vue.createCommentVNode("", true),
792
- item.type === "var" ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTag), {
793
- key: index,
794
- size: _ctx.size
795
- }, {
796
- default: vue.withCtx(() => [
797
- vue.createTextVNode(vue.toDisplayString(item.value), 1)
798
- ]),
799
- _: 2
800
- }, 1032, ["size"])) : vue.createCommentVNode("", true)
801
- ], 64);
802
- }), 256)),
803
- vue.createVNode(_sfc_main$E, {
804
- class: "tmagic-data-source-input-icon",
805
- icon: vue.unref(iconsVue.Coin)
806
- }, null, 8, ["icon"])
807
- ])
808
- ], 2)
809
- ], 34));
1482
+ disabled: _ctx.disabled,
1483
+ "params-config": paramsConfig.value,
1484
+ onChange: onChangeHandler
1485
+ }, null, 8, ["model", "size", "disabled", "params-config"])) : vue.createCommentVNode("", true),
1486
+ vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$G, {
1487
+ key: 1,
1488
+ ref_key: "codeBlockEditor",
1489
+ ref: codeBlockEditor,
1490
+ disabled: _ctx.disabled,
1491
+ content: vue.unref(codeConfig),
1492
+ onSubmit: submitCodeBlockHandler
1493
+ }, null, 8, ["disabled", "content"])) : vue.createCommentVNode("", true)
1494
+ ]);
810
1495
  };
811
1496
  }
812
1497
  });
813
1498
 
814
- const _sfc_main$A = /* @__PURE__ */ vue.defineComponent({
1499
+ const _sfc_main$y = /* @__PURE__ */ vue.defineComponent({
815
1500
  ...{
816
1501
  name: "MEditorDataSourceSelect"
817
1502
  },
@@ -864,12 +1549,12 @@
864
1549
  }
865
1550
  });
866
1551
 
867
- const _hoisted_1$m = { class: "m-fields-event-select" };
868
- const _hoisted_2$c = {
1552
+ const _hoisted_1$k = { class: "m-fields-event-select" };
1553
+ const _hoisted_2$a = {
869
1554
  key: 1,
870
1555
  class: "fullWidth"
871
1556
  };
872
- const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
1557
+ const _sfc_main$x = /* @__PURE__ */ vue.defineComponent({
873
1558
  ...{
874
1559
  name: "MEditorEventSelect"
875
1560
  },
@@ -902,7 +1587,7 @@
902
1587
  const defaultActionTypeConfig = {
903
1588
  name: "actionType",
904
1589
  text: "联动类型",
905
- labelWidth: "70px",
1590
+ labelWidth: "80px",
906
1591
  type: "select",
907
1592
  defaultValue: schema.ActionType.COMP,
908
1593
  options: () => [
@@ -914,7 +1599,14 @@
914
1599
  {
915
1600
  text: "代码",
916
1601
  label: "代码",
1602
+ disabled: !Object.keys(services?.codeBlockService.getCodeDsl() || {}).length,
917
1603
  value: schema.ActionType.CODE
1604
+ },
1605
+ {
1606
+ text: "数据源",
1607
+ label: "数据源",
1608
+ disabled: !services?.dataSourceService.get("dataSources")?.filter((ds) => ds.methods?.length).length,
1609
+ value: schema.ActionType.DATA_SOURCE
918
1610
  }
919
1611
  ]
920
1612
  };
@@ -924,7 +1616,7 @@
924
1616
  const defaultTargetCompConfig = {
925
1617
  name: "to",
926
1618
  text: "联动组件",
927
- labelWidth: "70px",
1619
+ labelWidth: "80px",
928
1620
  type: "ui-select",
929
1621
  display: (mForm, { model }) => model.actionType === schema.ActionType.COMP
930
1622
  };
@@ -934,7 +1626,7 @@
934
1626
  const defaultCompActionConfig = {
935
1627
  name: "method",
936
1628
  text: "动作",
937
- labelWidth: "70px",
1629
+ labelWidth: "80px",
938
1630
  type: "select",
939
1631
  display: (mForm, { model }) => model.actionType === schema.ActionType.COMP,
940
1632
  options: (mForm, { model }) => {
@@ -953,10 +1645,21 @@
953
1645
  const defaultCodeActionConfig = {
954
1646
  type: "code-select-col",
955
1647
  labelWidth: 0,
1648
+ name: "codeId",
1649
+ disabled: () => !services?.codeBlockService.getEditStatus(),
956
1650
  display: (mForm, { model }) => model.actionType === schema.ActionType.CODE
957
1651
  };
958
1652
  return { ...defaultCodeActionConfig, ...props.config.codeActionConfig };
959
1653
  });
1654
+ const dataSourceActionConfig = vue.computed(() => {
1655
+ const defaultDataSourceActionConfig = {
1656
+ type: "data-source-method-select",
1657
+ name: "dataSourceMethod",
1658
+ labelWidth: 0,
1659
+ display: (mForm, { model }) => model.actionType === schema.ActionType.DATA_SOURCE
1660
+ };
1661
+ return { ...defaultDataSourceActionConfig, ...props.config.dataSourceActionConfig };
1662
+ });
960
1663
  const tableConfig = vue.computed(() => ({
961
1664
  type: "table",
962
1665
  name: "events",
@@ -998,7 +1701,13 @@
998
1701
  name: "actions",
999
1702
  expandAll: true,
1000
1703
  enableToggleMode: false,
1001
- items: [actionTypeConfig.value, targetCompConfig.value, compActionConfig.value, codeActionConfig.value]
1704
+ items: [
1705
+ actionTypeConfig.value,
1706
+ targetCompConfig.value,
1707
+ compActionConfig.value,
1708
+ codeActionConfig.value,
1709
+ dataSourceActionConfig.value
1710
+ ]
1002
1711
  }
1003
1712
  ]
1004
1713
  }));
@@ -1031,7 +1740,7 @@
1031
1740
  const _component_m_form_table = vue.resolveComponent("m-form-table");
1032
1741
  const _component_m_form_container = vue.resolveComponent("m-form-container");
1033
1742
  const _component_m_form_panel = vue.resolveComponent("m-form-panel");
1034
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$m, [
1743
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$k, [
1035
1744
  isOldVersion.value ? (vue.openBlock(), vue.createBlock(_component_m_form_table, {
1036
1745
  key: 0,
1037
1746
  ref: "eventForm",
@@ -1040,7 +1749,7 @@
1040
1749
  name: "events",
1041
1750
  config: tableConfig.value,
1042
1751
  onChange: onChangeHandler
1043
- }, null, 8, ["size", "model", "config"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$c, [
1752
+ }, null, 8, ["size", "model", "config"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$a, [
1044
1753
  vue.createVNode(vue.unref(design.TMagicButton), {
1045
1754
  class: "create-button",
1046
1755
  type: "primary",
@@ -1082,9 +1791,9 @@
1082
1791
  }
1083
1792
  });
1084
1793
 
1085
- const _hoisted_1$l = { class: "m-fields-key-value" };
1086
- const _hoisted_2$b = /* @__PURE__ */ vue.createElementVNode("span", { class: "m-fileds-key-value-delimiter" }, ":", -1);
1087
- const _sfc_main$y = /* @__PURE__ */ vue.defineComponent({
1794
+ const _hoisted_1$j = { class: "m-fields-key-value" };
1795
+ const _hoisted_2$9 = /* @__PURE__ */ vue.createElementVNode("span", { class: "m-fileds-key-value-delimiter" }, ":", -1);
1796
+ const _sfc_main$w = /* @__PURE__ */ vue.defineComponent({
1088
1797
  ...{
1089
1798
  name: "MEditorKeyValue"
1090
1799
  },
@@ -1127,7 +1836,7 @@
1127
1836
  records.value.splice(index, 1);
1128
1837
  };
1129
1838
  return (_ctx, _cache) => {
1130
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$l, [
1839
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$j, [
1131
1840
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(records.value, (item, index) => {
1132
1841
  return vue.openBlock(), vue.createElementBlock("div", {
1133
1842
  class: "m-fields-key-value-item",
@@ -1141,7 +1850,7 @@
1141
1850
  size: _ctx.size,
1142
1851
  onChange: keyChangeHandler
1143
1852
  }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled", "size"]),
1144
- _hoisted_2$b,
1853
+ _hoisted_2$9,
1145
1854
  vue.createVNode(vue.unref(design.TMagicInput), {
1146
1855
  placeholder: "value",
1147
1856
  modelValue: records.value[index][1],
@@ -1178,12 +1887,12 @@
1178
1887
  }
1179
1888
  });
1180
1889
 
1181
- const _hoisted_1$k = {
1890
+ const _hoisted_1$i = {
1182
1891
  key: 1,
1183
1892
  class: "m-fields-ui-select",
1184
1893
  style: { "display": "flex" }
1185
1894
  };
1186
- const _sfc_main$x = /* @__PURE__ */ vue.defineComponent({
1895
+ const _sfc_main$v = /* @__PURE__ */ vue.defineComponent({
1187
1896
  ...{
1188
1897
  name: "MEditorUISelect"
1189
1898
  },
@@ -1265,7 +1974,7 @@
1265
1974
  ]),
1266
1975
  _: 1
1267
1976
  }, 8, ["icon"])
1268
- ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$k, [
1977
+ ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$i, [
1269
1978
  val.value ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
1270
1979
  vue.createVNode(vue.unref(design.TMagicTooltip), {
1271
1980
  content: "清除",
@@ -1307,172 +2016,28 @@
1307
2016
  content: "点击此处选择",
1308
2017
  placement: "top"
1309
2018
  }, {
1310
- default: vue.withCtx(() => [
1311
- vue.createVNode(vue.unref(design.TMagicButton), {
1312
- text: "",
1313
- style: { "padding": "0", "margin": "0" },
1314
- onClick: startSelect
1315
- }, {
1316
- default: vue.withCtx(() => [
1317
- vue.createTextVNode("点击此处选择")
1318
- ]),
1319
- _: 1
1320
- })
1321
- ]),
1322
- _: 1
1323
- }))
1324
- ]));
1325
- };
1326
- }
1327
- });
1328
-
1329
- const UISelect_vue_vue_type_style_index_0_lang = '';
1330
-
1331
- const _sfc_main$w = /* @__PURE__ */ vue.defineComponent({
1332
- ...{
1333
- name: "MEditorCodeEditor"
1334
- },
1335
- __name: "CodeEditor",
1336
- props: {
1337
- initValues: {},
1338
- modifiedValues: {},
1339
- type: {},
1340
- language: { default: "javascript" },
1341
- options: { default: () => ({
1342
- tabSize: 2
1343
- }) },
1344
- autoSave: { type: Boolean, default: true }
1345
- },
1346
- emits: ["initd", "save"],
1347
- setup(__props, { expose: __expose, emit }) {
1348
- const props = __props;
1349
- const toString = (v, language) => {
1350
- let value = "";
1351
- if (typeof v !== "string") {
1352
- if (props.language.toLocaleLowerCase() === "json") {
1353
- value = JSON.stringify(v, null, 2);
1354
- } else {
1355
- value = serialize(v, {
1356
- space: 2,
1357
- unsafe: true
1358
- }).replace(/"(\w+)":\s/g, "$1: ");
1359
- }
1360
- } else {
1361
- value = v;
1362
- }
1363
- if (language === "javascript" && value.startsWith("{") && value.endsWith("}")) {
1364
- value = `(${value})`;
1365
- }
1366
- return value;
1367
- };
1368
- let vsEditor = null;
1369
- let vsDiffEditor = null;
1370
- const values = vue.ref("");
1371
- const loading = vue.ref(false);
1372
- const codeEditor = vue.ref();
1373
- const resizeObserver = new globalThis.ResizeObserver(
1374
- lodashEs.throttle(() => {
1375
- vsEditor?.layout();
1376
- vsDiffEditor?.layout();
1377
- }, 300)
1378
- );
1379
- const setEditorValue = (v, m) => {
1380
- values.value = toString(v, props.language);
1381
- if (props.type === "diff") {
1382
- const originalModel = monaco__namespace.editor.createModel(values.value, "text/javascript");
1383
- const modifiedModel = monaco__namespace.editor.createModel(toString(m, props.language), "text/javascript");
1384
- return vsDiffEditor?.setModel({
1385
- original: originalModel,
1386
- modified: modifiedModel
1387
- });
1388
- }
1389
- return vsEditor?.setValue(values.value);
1390
- };
1391
- const getEditorValue = () => (props.type === "diff" ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue()) || "";
1392
- const init = async () => {
1393
- if (!codeEditor.value)
1394
- return;
1395
- const options = {
1396
- value: values.value,
1397
- language: props.language,
1398
- theme: "vs-dark",
1399
- ...props.options
1400
- };
1401
- if (props.type === "diff") {
1402
- vsDiffEditor = monaco__namespace.editor.createDiffEditor(codeEditor.value, options);
1403
- } else {
1404
- vsEditor = monaco__namespace.editor.create(codeEditor.value, options);
1405
- }
1406
- setEditorValue(props.initValues, props.modifiedValues);
1407
- loading.value = false;
1408
- emit("initd", vsEditor);
1409
- codeEditor.value.addEventListener("keydown", (e) => {
1410
- if (e.keyCode === 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
1411
- e.preventDefault();
1412
- e.stopPropagation();
1413
- const newValue = getEditorValue();
1414
- values.value = newValue;
1415
- emit("save", newValue);
1416
- }
1417
- });
1418
- if (props.type !== "diff" && props.autoSave) {
1419
- vsEditor?.onDidBlurEditorWidget(() => {
1420
- const newValue = getEditorValue();
1421
- if (values.value !== newValue) {
1422
- values.value = newValue;
1423
- emit("save", newValue);
1424
- }
1425
- });
1426
- }
1427
- resizeObserver.observe(codeEditor.value);
1428
- };
1429
- vue.watch(
1430
- () => props.initValues,
1431
- (v, preV) => {
1432
- if (v !== preV) {
1433
- setEditorValue(props.initValues, props.modifiedValues);
1434
- }
1435
- },
1436
- {
1437
- deep: true,
1438
- immediate: true
1439
- }
1440
- );
1441
- vue.onMounted(async () => {
1442
- loading.value = true;
1443
- init();
1444
- });
1445
- vue.onUnmounted(() => {
1446
- resizeObserver.disconnect();
1447
- });
1448
- __expose({
1449
- values,
1450
- getEditor() {
1451
- return vsEditor || vsDiffEditor;
1452
- },
1453
- getVsEditor() {
1454
- return vsEditor;
1455
- },
1456
- getVsDiffEditor() {
1457
- return vsDiffEditor;
1458
- },
1459
- setEditorValue,
1460
- focus() {
1461
- vsEditor?.focus();
1462
- vsDiffEditor?.focus();
1463
- }
1464
- });
1465
- return (_ctx, _cache) => {
1466
- return vue.openBlock(), vue.createElementBlock("div", {
1467
- ref_key: "codeEditor",
1468
- ref: codeEditor,
1469
- class: "magic-code-editor"
1470
- }, null, 512);
2019
+ default: vue.withCtx(() => [
2020
+ vue.createVNode(vue.unref(design.TMagicButton), {
2021
+ text: "",
2022
+ style: { "padding": "0", "margin": "0" },
2023
+ onClick: startSelect
2024
+ }, {
2025
+ default: vue.withCtx(() => [
2026
+ vue.createTextVNode("点击此处选择")
2027
+ ]),
2028
+ _: 1
2029
+ })
2030
+ ]),
2031
+ _: 1
2032
+ }))
2033
+ ]));
1471
2034
  };
1472
2035
  }
1473
2036
  });
1474
2037
 
1475
- const _sfc_main$v = /* @__PURE__ */ vue.defineComponent({
2038
+ const UISelect_vue_vue_type_style_index_0_lang = '';
2039
+
2040
+ const _sfc_main$u = /* @__PURE__ */ vue.defineComponent({
1476
2041
  ...{
1477
2042
  name: "MEditorResizer"
1478
2043
  },
@@ -1514,7 +2079,7 @@
1514
2079
  }
1515
2080
  });
1516
2081
 
1517
- const _sfc_main$u = /* @__PURE__ */ vue.defineComponent({
2082
+ const _sfc_main$t = /* @__PURE__ */ vue.defineComponent({
1518
2083
  ...{
1519
2084
  name: "MEditorLayout"
1520
2085
  },
@@ -1626,7 +2191,7 @@
1626
2191
  }, [
1627
2192
  vue.renderSlot(_ctx.$slots, "left")
1628
2193
  ], 6),
1629
- vue.createVNode(_sfc_main$v, { onChange: changeLeft })
2194
+ vue.createVNode(_sfc_main$u, { onChange: changeLeft })
1630
2195
  ], 64)) : vue.createCommentVNode("", true),
1631
2196
  vue.createElementVNode("div", {
1632
2197
  class: vue.normalizeClass(["m-editor-layout-center", _ctx.centerClass]),
@@ -1635,7 +2200,7 @@
1635
2200
  vue.renderSlot(_ctx.$slots, "center")
1636
2201
  ], 6),
1637
2202
  hasRight.value && _ctx.$slots.right ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
1638
- vue.createVNode(_sfc_main$v, { onChange: changeRight }),
2203
+ vue.createVNode(_sfc_main$u, { onChange: changeRight }),
1639
2204
  vue.createElementVNode("div", {
1640
2205
  class: vue.normalizeClass(["m-editor-layout-right", _ctx.rightClass]),
1641
2206
  style: vue.normalizeStyle(`width: ${_ctx.right}px`)
@@ -3558,10 +4123,10 @@
3558
4123
  return stage;
3559
4124
  };
3560
4125
 
3561
- const _hoisted_1$j = { class: "m-editor-empty-panel" };
3562
- const _hoisted_2$a = { class: "m-editor-empty-content" };
3563
- const _hoisted_3$5 = /* @__PURE__ */ vue.createElementVNode("p", null, "新增页面", -1);
3564
- const _sfc_main$t = /* @__PURE__ */ vue.defineComponent({
4126
+ const _hoisted_1$h = { class: "m-editor-empty-panel" };
4127
+ const _hoisted_2$8 = { class: "m-editor-empty-content" };
4128
+ const _hoisted_3$4 = /* @__PURE__ */ vue.createElementVNode("p", null, "新增页面", -1);
4129
+ const _sfc_main$s = /* @__PURE__ */ vue.defineComponent({
3565
4130
  ...{
3566
4131
  name: "MEditorAddPageBox"
3567
4132
  },
@@ -3581,8 +4146,8 @@
3581
4146
  });
3582
4147
  };
3583
4148
  return (_ctx, _cache) => {
3584
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$j, [
3585
- vue.createElementVNode("div", _hoisted_2$a, [
4149
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$h, [
4150
+ vue.createElementVNode("div", _hoisted_2$8, [
3586
4151
  vue.createElementVNode("div", {
3587
4152
  class: "m-editor-empty-button",
3588
4153
  onClick: clickHandler
@@ -3590,7 +4155,7 @@
3590
4155
  vue.createElementVNode("div", null, [
3591
4156
  vue.createVNode(_sfc_main$E, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
3592
4157
  ]),
3593
- _hoisted_3$5
4158
+ _hoisted_3$4
3594
4159
  ])
3595
4160
  ])
3596
4161
  ]);
@@ -3598,12 +4163,11 @@
3598
4163
  }
3599
4164
  });
3600
4165
 
3601
- const _hoisted_1$i = { class: "m-editor" };
3602
4166
  const DEFAULT_LEFT_COLUMN_WIDTH = 310;
3603
4167
  const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
3604
4168
  const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
3605
4169
  const RIGHT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorRightColumnWidthData";
3606
- const _sfc_main$s = /* @__PURE__ */ vue.defineComponent({
4170
+ const _sfc_main$r = /* @__PURE__ */ vue.defineComponent({
3607
4171
  ...{
3608
4172
  name: "MEditorFramework"
3609
4173
  },
@@ -3611,6 +4175,7 @@
3611
4175
  setup(__props) {
3612
4176
  const codeOptions = vue.inject("codeOptions", {});
3613
4177
  const { editorService, uiService } = vue.inject("services") || {};
4178
+ const content = vue.ref();
3614
4179
  const root = vue.computed(() => editorService?.get("root"));
3615
4180
  const pageLength = vue.computed(() => editorService?.get("pageLength") || 0);
3616
4181
  const showSrc = vue.computed(() => uiService?.get("showSrc"));
@@ -3626,13 +4191,14 @@
3626
4191
  (length) => {
3627
4192
  const left = columnWidth.value.left || DEFAULT_LEFT_COLUMN_WIDTH;
3628
4193
  columnWidth.value.left = left;
4194
+ const container = content.value || document.body;
3629
4195
  if (length <= 0) {
3630
4196
  columnWidth.value.right = void 0;
3631
- columnWidth.value.center = globalThis.document.body.clientWidth - left;
4197
+ columnWidth.value.center = container.clientWidth - left;
3632
4198
  } else {
3633
4199
  const right = columnWidth.value.right || RightColumnWidthCacheData || DEFAULT_RIGHT_COLUMN_WIDTH;
3634
4200
  columnWidth.value.right = right;
3635
- columnWidth.value.center = globalThis.document.body.clientWidth - left - right;
4201
+ columnWidth.value.center = container.clientWidth - left - right;
3636
4202
  }
3637
4203
  uiService?.set("columnWidth", columnWidth.value);
3638
4204
  },
@@ -3669,18 +4235,22 @@
3669
4235
  }
3670
4236
  };
3671
4237
  return (_ctx, _cache) => {
3672
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$i, [
4238
+ return vue.openBlock(), vue.createElementBlock("div", {
4239
+ class: "m-editor",
4240
+ ref_key: "content",
4241
+ ref: content
4242
+ }, [
3673
4243
  vue.renderSlot(_ctx.$slots, "header"),
3674
4244
  vue.renderSlot(_ctx.$slots, "nav"),
3675
4245
  vue.renderSlot(_ctx.$slots, "content-before"),
3676
4246
  showSrc.value ? vue.renderSlot(_ctx.$slots, "src-code", { key: 0 }, () => [
3677
- vue.createVNode(_sfc_main$w, {
4247
+ vue.createVNode(_sfc_main$K, {
3678
4248
  class: "m-editor-content",
3679
4249
  "init-values": root.value,
3680
4250
  options: vue.unref(codeOptions),
3681
4251
  onSave: saveCode
3682
4252
  }, null, 8, ["init-values", "options"])
3683
- ]) : (vue.openBlock(), vue.createBlock(_sfc_main$u, {
4253
+ ]) : (vue.openBlock(), vue.createBlock(_sfc_main$t, {
3684
4254
  key: 1,
3685
4255
  class: "m-editor-content",
3686
4256
  "left-class": "m-editor-framework-left",
@@ -3699,7 +4269,7 @@
3699
4269
  ]),
3700
4270
  center: vue.withCtx(() => [
3701
4271
  pageLength.value > 0 ? vue.renderSlot(_ctx.$slots, "workspace", { key: 0 }) : vue.renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
3702
- vue.createVNode(_sfc_main$t)
4272
+ vue.createVNode(_sfc_main$s)
3703
4273
  ])
3704
4274
  ]),
3705
4275
  _: 2
@@ -3719,17 +4289,17 @@
3719
4289
  ]), 1032, ["left", "right"])),
3720
4290
  vue.renderSlot(_ctx.$slots, "content-after"),
3721
4291
  vue.renderSlot(_ctx.$slots, "footer")
3722
- ]);
4292
+ ], 512);
3723
4293
  };
3724
4294
  }
3725
4295
  });
3726
4296
 
3727
- const _hoisted_1$h = {
4297
+ const _hoisted_1$g = {
3728
4298
  key: 1,
3729
4299
  class: "menu-item-text"
3730
4300
  };
3731
- const _hoisted_2$9 = { class: "el-dropdown-link menubar-menu-button" };
3732
- const _sfc_main$r = /* @__PURE__ */ vue.defineComponent({
4301
+ const _hoisted_2$7 = { class: "el-dropdown-link menubar-menu-button" };
4302
+ const _sfc_main$q = /* @__PURE__ */ vue.defineComponent({
3733
4303
  ...{
3734
4304
  name: "MEditorToolButton"
3735
4305
  },
@@ -3808,7 +4378,7 @@
3808
4378
  _ctx.data.type === "divider" ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDivider), {
3809
4379
  key: 0,
3810
4380
  direction: _ctx.data.direction || "vertical"
3811
- }, null, 8, ["direction"])) : _ctx.data.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$h, vue.toDisplayString(_ctx.data.text), 1)) : _ctx.data.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
4381
+ }, null, 8, ["direction"])) : _ctx.data.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$g, vue.toDisplayString(_ctx.data.text), 1)) : _ctx.data.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
3812
4382
  _ctx.data.tooltip ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
3813
4383
  key: 0,
3814
4384
  effect: "dark",
@@ -3872,7 +4442,7 @@
3872
4442
  })) : vue.createCommentVNode("", true)
3873
4443
  ]),
3874
4444
  default: vue.withCtx(() => [
3875
- vue.createElementVNode("span", _hoisted_2$9, [
4445
+ vue.createElementVNode("span", _hoisted_2$7, [
3876
4446
  vue.createTextVNode(vue.toDisplayString(_ctx.data.text), 1),
3877
4447
  vue.createVNode(vue.unref(design.TMagicIcon), { class: "el-icon--right" }, {
3878
4448
  default: vue.withCtx(() => [
@@ -3889,7 +4459,7 @@
3889
4459
  }
3890
4460
  });
3891
4461
 
3892
- const _sfc_main$q = /* @__PURE__ */ vue.defineComponent({
4462
+ const _sfc_main$p = /* @__PURE__ */ vue.defineComponent({
3893
4463
  ...{
3894
4464
  name: "MEditorNavMenu"
3895
4465
  },
@@ -4051,7 +4621,7 @@
4051
4621
  style: vue.normalizeStyle(`width: ${columnWidth.value?.[key]}px`)
4052
4622
  }, [
4053
4623
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(buttons.value[key], (item, index) => {
4054
- return vue.openBlock(), vue.createBlock(_sfc_main$r, {
4624
+ return vue.openBlock(), vue.createBlock(_sfc_main$q, {
4055
4625
  data: item,
4056
4626
  key: index
4057
4627
  }, null, 8, ["data"]);
@@ -4063,8 +4633,8 @@
4063
4633
  }
4064
4634
  });
4065
4635
 
4066
- const _hoisted_1$g = { class: "m-editor-props-panel" };
4067
- const _sfc_main$p = /* @__PURE__ */ vue.defineComponent({
4636
+ const _hoisted_1$f = { class: "m-editor-props-panel" };
4637
+ const _sfc_main$o = /* @__PURE__ */ vue.defineComponent({
4068
4638
  ...{
4069
4639
  name: "MEditorPropsPanel"
4070
4640
  },
@@ -4117,7 +4687,7 @@
4117
4687
  };
4118
4688
  __expose({ configForm, submit });
4119
4689
  return (_ctx, _cache) => {
4120
- return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", _hoisted_1$g, [
4690
+ return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", _hoisted_1$f, [
4121
4691
  vue.renderSlot(_ctx.$slots, "props-panel-header"),
4122
4692
  vue.createVNode(vue.unref(form.MForm), {
4123
4693
  ref_key: "configForm",
@@ -4137,7 +4707,7 @@
4137
4707
  }
4138
4708
  });
4139
4709
 
4140
- const _sfc_main$o = /* @__PURE__ */ vue.defineComponent({
4710
+ const _sfc_main$n = /* @__PURE__ */ vue.defineComponent({
4141
4711
  ...{
4142
4712
  name: "MEditorSearchInput"
4143
4713
  },
@@ -4172,8 +4742,8 @@
4172
4742
  }
4173
4743
  });
4174
4744
 
4175
- const _hoisted_1$f = { xmlns: "http://www.w3.org/2000/svg" };
4176
- const _hoisted_2$8 = /* @__PURE__ */ vue.createElementVNode("g", {
4745
+ const _hoisted_1$e = { xmlns: "http://www.w3.org/2000/svg" };
4746
+ const _hoisted_2$6 = /* @__PURE__ */ vue.createElementVNode("g", {
4177
4747
  fill: "#7C878E",
4178
4748
  "fill-rule": "evenodd"
4179
4749
  }, [
@@ -4183,488 +4753,60 @@
4183
4753
  }),
4184
4754
  /* @__PURE__ */ vue.createElementVNode("path", { d: "M8 13.5L2.3 9.2 0.7 10.5 8 16 15.3 10.5 13.7 9.2z" })
4185
4755
  ], -1);
4186
- const _hoisted_3$4 = [
4187
- _hoisted_2$8
4756
+ const _hoisted_3$3 = [
4757
+ _hoisted_2$6
4188
4758
  ];
4189
- const _sfc_main$n = /* @__PURE__ */ vue.defineComponent({
4759
+ const _sfc_main$m = /* @__PURE__ */ vue.defineComponent({
4190
4760
  ...{
4191
4761
  name: "MEditorAppManageIcon"
4192
4762
  },
4193
4763
  __name: "AppManageIcon",
4194
4764
  setup(__props) {
4195
4765
  return (_ctx, _cache) => {
4196
- return vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$f, _hoisted_3$4);
4766
+ return vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$e, _hoisted_3$3);
4197
4767
  };
4198
4768
  }
4199
4769
  });
4200
4770
 
4201
- const _hoisted_1$e = {
4771
+ const _hoisted_1$d = {
4202
4772
  viewBox: "0 0 32 32",
4203
4773
  version: "1.1",
4204
4774
  xmlns: "http://www.w3.org/2000/svg",
4205
4775
  "xmlns:xlink": "http://www.w3.org/1999/xlink"
4206
4776
  };
4207
- const _hoisted_2$7 = /* @__PURE__ */ vue.createStaticVNode('<defs><rect id="path-1" x="0" y="0" width="32" height="32"></rect></defs><g id="组件规范" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="03图标" transform="translate(-561.000000, -2356.000000)"><g id="icon/line/Universal/code" transform="translate(561.000000, 2356.000000)"><g id="路径"><mask id="mask-2" fill="white"><use xlink:href="#path-1"></use></mask><use id="蒙版" fill="#D8D8D8" opacity="0" xlink:href="#path-1"></use><path d="M21.9284587,7.9482233 L29.8079004,15.827665 C29.9055315,15.9252961 29.9055315,16.0835874 29.8079004,16.1812184 L21.9284587,24.0606602 C21.8308276,24.1582912 21.6725364,24.1582912 21.5749053,24.0606602 L20.3374684,22.8232233 C20.2419143,22.7276698 20.2398813,22.5740096 20.331369,22.4759832 L20.3374687,22.4696702 L26.8027181,16.0044417 L20.3374687,9.53921328 C20.2398372,9.44158265 20.2398369,9.2832914 20.3374679,9.18566017 L21.5749053,7.9482233 C21.6725364,7.85059223 21.8308276,7.85059223 21.9284587,7.9482233 Z M10.3999684,7.9482233 L11.6374053,9.18566017 C11.7329594,9.28121371 11.7349925,9.43487387 11.6435048,9.53290029 L11.637405,9.53921328 L5.17215562,16.0044417 L11.637405,22.4696702 C11.7329593,22.5652236 11.7349926,22.7188837 11.643505,22.8169103 L11.6374053,22.8232233 L10.3999684,24.0606602 C10.3023374,24.1582912 10.1440461,24.1582912 10.046415,24.0606602 L2.1669733,16.1812184 C2.06934223,16.0835874 2.06934223,15.9252961 2.1669733,15.827665 L10.046415,7.9482233 C10.1440461,7.85059223 10.3023374,7.85059223 10.3999684,7.9482233 Z M17.2612532,9.29310422 L18.9262468,9.83189578 C19.0576112,9.87440526 19.1296423,10.0153579 19.0871328,10.1467222 L15.0848232,22.514807 C15.0423138,22.6461714 14.9013612,22.7182025 14.7699968,22.675693 L13.1050032,22.1369014 C12.9736388,22.0943919 12.9016077,21.9534393 12.9441172,21.822075 L16.9464268,9.45399022 C16.9889362,9.32262585 17.1298888,9.25059474 17.2612532,9.29310422 Z" id="形状" fill="#1D1F24" mask="url(#mask-2)"></path></g></g><g id="icon切图" transform="translate(226.000000, 1782.000000)"></g></g></g>', 2);
4208
- const _hoisted_4$4 = [
4209
- _hoisted_2$7
4777
+ const _hoisted_2$5 = /* @__PURE__ */ vue.createStaticVNode('<defs><rect id="path-1" x="0" y="0" width="32" height="32"></rect></defs><g id="组件规范" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="03图标" transform="translate(-561.000000, -2356.000000)"><g id="icon/line/Universal/code" transform="translate(561.000000, 2356.000000)"><g id="路径"><mask id="mask-2" fill="white"><use xlink:href="#path-1"></use></mask><use id="蒙版" fill="#D8D8D8" opacity="0" xlink:href="#path-1"></use><path d="M21.9284587,7.9482233 L29.8079004,15.827665 C29.9055315,15.9252961 29.9055315,16.0835874 29.8079004,16.1812184 L21.9284587,24.0606602 C21.8308276,24.1582912 21.6725364,24.1582912 21.5749053,24.0606602 L20.3374684,22.8232233 C20.2419143,22.7276698 20.2398813,22.5740096 20.331369,22.4759832 L20.3374687,22.4696702 L26.8027181,16.0044417 L20.3374687,9.53921328 C20.2398372,9.44158265 20.2398369,9.2832914 20.3374679,9.18566017 L21.5749053,7.9482233 C21.6725364,7.85059223 21.8308276,7.85059223 21.9284587,7.9482233 Z M10.3999684,7.9482233 L11.6374053,9.18566017 C11.7329594,9.28121371 11.7349925,9.43487387 11.6435048,9.53290029 L11.637405,9.53921328 L5.17215562,16.0044417 L11.637405,22.4696702 C11.7329593,22.5652236 11.7349926,22.7188837 11.643505,22.8169103 L11.6374053,22.8232233 L10.3999684,24.0606602 C10.3023374,24.1582912 10.1440461,24.1582912 10.046415,24.0606602 L2.1669733,16.1812184 C2.06934223,16.0835874 2.06934223,15.9252961 2.1669733,15.827665 L10.046415,7.9482233 C10.1440461,7.85059223 10.3023374,7.85059223 10.3999684,7.9482233 Z M17.2612532,9.29310422 L18.9262468,9.83189578 C19.0576112,9.87440526 19.1296423,10.0153579 19.0871328,10.1467222 L15.0848232,22.514807 C15.0423138,22.6461714 14.9013612,22.7182025 14.7699968,22.675693 L13.1050032,22.1369014 C12.9736388,22.0943919 12.9016077,21.9534393 12.9441172,21.822075 L16.9464268,9.45399022 C16.9889362,9.32262585 17.1298888,9.25059474 17.2612532,9.29310422 Z" id="形状" fill="#1D1F24" mask="url(#mask-2)"></path></g></g><g id="icon切图" transform="translate(226.000000, 1782.000000)"></g></g></g>', 2);
4778
+ const _hoisted_4$1 = [
4779
+ _hoisted_2$5
4210
4780
  ];
4211
- const _sfc_main$m = /* @__PURE__ */ vue.defineComponent({
4781
+ const _sfc_main$l = /* @__PURE__ */ vue.defineComponent({
4212
4782
  ...{
4213
4783
  name: "MEditorCodeIcon"
4214
4784
  },
4215
4785
  __name: "CodeIcon",
4216
4786
  setup(__props) {
4217
4787
  return (_ctx, _cache) => {
4218
- return vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$e, _hoisted_4$4);
4219
- };
4220
- }
4221
- });
4222
-
4223
- const _hoisted_1$d = {
4224
- key: 0,
4225
- class: "m-editor-content-bottom"
4226
- };
4227
- const _hoisted_2$6 = {
4228
- key: 1,
4229
- class: "m-editor-content-bottom"
4230
- };
4231
- const _sfc_main$l = /* @__PURE__ */ vue.defineComponent({
4232
- ...{
4233
- name: "MEditorCodeDraftEditor"
4234
- },
4235
- __name: "CodeDraftEditor",
4236
- props: {
4237
- id: {},
4238
- content: {},
4239
- editable: { type: Boolean, default: true },
4240
- autoSaveDraft: { type: Boolean, default: true },
4241
- codeOptions: {},
4242
- language: {}
4243
- },
4244
- emits: ["close", "saveAndClose"],
4245
- setup(__props, { expose: __expose, emit }) {
4246
- const props = __props;
4247
- const services = vue.inject("services");
4248
- const codeContent = vue.ref("");
4249
- const editorContent = vue.ref("");
4250
- const codeEditor = vue.ref();
4251
- const originCodeContent = vue.ref("");
4252
- const isFullScreen = vue.ref(false);
4253
- const codeOptions = vue.computed(() => ({
4254
- ...props.codeOptions,
4255
- readOnly: !props.editable
4256
- }));
4257
- vue.watchEffect(() => {
4258
- codeContent.value = props.content;
4259
- if (!originCodeContent.value) {
4260
- originCodeContent.value = codeContent.value;
4261
- }
4262
- const codeDraft = services?.codeBlockService.getCodeDraft(props.id);
4263
- if (codeDraft) {
4264
- codeContent.value = codeDraft;
4265
- }
4266
- });
4267
- const saveCodeDraft = async (codeValue) => {
4268
- if (!props.autoSaveDraft)
4269
- return;
4270
- if (originCodeContent.value === codeValue) {
4271
- services?.codeBlockService.removeCodeDraft(props.id);
4272
- return;
4273
- }
4274
- services?.codeBlockService.setCodeDraft(props.id, codeValue);
4275
- design.tMagicMessage.success(`代码草稿成功保存到本地 ${utils.datetimeFormatter( new Date())}`);
4276
- };
4277
- const saveAndClose = () => {
4278
- if (!codeEditor.value || !props.editable)
4279
- return;
4280
- editorContent.value = codeEditor.value.getEditor()?.getValue();
4281
- emit("saveAndClose", editorContent.value);
4282
- };
4283
- const close = async () => {
4284
- const codeDraft = services?.codeBlockService.getCodeDraft(props.id);
4285
- if (codeDraft) {
4286
- try {
4287
- await design.tMagicMessageBox.confirm("您有代码修改未保存,是否保存后再关闭?", "提示", {
4288
- confirmButtonText: "保存并关闭",
4289
- cancelButtonText: "直接关闭",
4290
- type: "warning",
4291
- distinguishCancelAndClose: true
4292
- });
4293
- saveAndClose();
4294
- } catch (action) {
4295
- if (action === "cancel") {
4296
- services?.codeBlockService.removeCodeDraft(props.id);
4297
- emit("close");
4298
- }
4299
- }
4300
- } else {
4301
- emit("close");
4302
- }
4303
- };
4304
- const toggleFullScreen = () => {
4305
- isFullScreen.value = !isFullScreen.value;
4306
- if (codeEditor.value) {
4307
- codeEditor.value.focus();
4308
- }
4309
- };
4310
- __expose({
4311
- saveAndClose,
4312
- close
4313
- });
4314
- return (_ctx, _cache) => {
4315
- return vue.openBlock(), vue.createElementBlock("div", {
4316
- class: vue.normalizeClass(["m-editor-wrapper", isFullScreen.value ? "fullScreen" : "normal"])
4317
- }, [
4318
- vue.createVNode(_sfc_main$w, {
4319
- ref_key: "codeEditor",
4320
- ref: codeEditor,
4321
- class: "m-editor-container",
4322
- "init-values": `${codeContent.value}`,
4323
- onSave: saveCodeDraft,
4324
- language: _ctx.language,
4325
- options: codeOptions.value
4326
- }, null, 8, ["init-values", "language", "options"]),
4327
- _ctx.editable ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$d, [
4328
- vue.createVNode(vue.unref(design.TMagicButton), {
4329
- type: "primary",
4330
- class: "button",
4331
- onClick: toggleFullScreen
4332
- }, {
4333
- default: vue.withCtx(() => [
4334
- vue.createTextVNode(vue.toDisplayString(isFullScreen.value ? "退出全屏" : "全屏"), 1)
4335
- ]),
4336
- _: 1
4337
- }),
4338
- vue.createVNode(vue.unref(design.TMagicButton), {
4339
- type: "primary",
4340
- class: "button",
4341
- onClick: saveAndClose
4342
- }, {
4343
- default: vue.withCtx(() => [
4344
- vue.createTextVNode("确认")
4345
- ]),
4346
- _: 1
4347
- }),
4348
- vue.createVNode(vue.unref(design.TMagicButton), {
4349
- class: "button",
4350
- onClick: close
4351
- }, {
4352
- default: vue.withCtx(() => [
4353
- vue.createTextVNode("关闭")
4354
- ]),
4355
- _: 1
4356
- })
4357
- ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$6, [
4358
- vue.createVNode(vue.unref(design.TMagicButton), {
4359
- type: "primary",
4360
- class: "button",
4361
- onClick: toggleFullScreen
4362
- }, {
4363
- default: vue.withCtx(() => [
4364
- vue.createTextVNode(vue.toDisplayString(isFullScreen.value ? "退出全屏" : "全屏"), 1)
4365
- ]),
4366
- _: 1
4367
- }),
4368
- vue.createVNode(vue.unref(design.TMagicButton), {
4369
- class: "button",
4370
- onClick: close
4371
- }, {
4372
- default: vue.withCtx(() => [
4373
- vue.createTextVNode("关闭")
4374
- ]),
4375
- _: 1
4376
- })
4377
- ]))
4378
- ], 2);
4379
- };
4380
- }
4381
- });
4382
-
4383
- const _hoisted_1$c = { class: "code-name-wrapper" };
4384
- const _hoisted_2$5 = /* @__PURE__ */ vue.createElementVNode("div", { class: "code-name-label" }, "代码块名称", -1);
4385
- const _hoisted_3$3 = { class: "code-name-wrapper" };
4386
- const _hoisted_4$3 = /* @__PURE__ */ vue.createElementVNode("div", { class: "code-name-label" }, "参数", -1);
4387
- const _sfc_main$k = /* @__PURE__ */ vue.defineComponent({
4388
- ...{
4389
- name: "MEditorFunctionEditor"
4390
- },
4391
- __name: "FunctionEditor",
4392
- props: {
4393
- id: {},
4394
- name: {},
4395
- content: {},
4396
- editable: { type: Boolean, default: true },
4397
- autoSaveDraft: { type: Boolean, default: true },
4398
- codeOptions: {},
4399
- paramsColConfig: {}
4400
- },
4401
- setup(__props, { expose: __expose }) {
4402
- const props = __props;
4403
- vue.provide("mForm", null);
4404
- const defaultParamColConfig = {
4405
- type: "row",
4406
- label: "参数类型",
4407
- items: [
4408
- {
4409
- text: "参数类型",
4410
- labelWidth: "70px",
4411
- type: "select",
4412
- name: "type",
4413
- options: [
4414
- {
4415
- text: "数字",
4416
- label: "数字",
4417
- value: "number"
4418
- },
4419
- {
4420
- text: "字符串",
4421
- label: "字符串",
4422
- value: "text"
4423
- }
4424
- ]
4425
- }
4426
- ]
4427
- };
4428
- const paramsColConfig = props.paramsColConfig || defaultParamColConfig;
4429
- const tableConfig = {
4430
- type: "table",
4431
- border: true,
4432
- enableFullscreen: false,
4433
- name: "params",
4434
- maxHeight: "300px",
4435
- dropSort: false,
4436
- items: [
4437
- {
4438
- type: "text",
4439
- label: "参数名",
4440
- name: "name",
4441
- width: 200
4442
- },
4443
- {
4444
- type: "text",
4445
- label: "参数注释",
4446
- name: "tip",
4447
- width: 200
4448
- },
4449
- paramsColConfig
4450
- ]
4451
- };
4452
- const services = vue.inject("services");
4453
- const codeName = vue.ref("");
4454
- const codeContent = vue.ref("");
4455
- const evalRes = vue.ref(true);
4456
- const tableModel = vue.ref();
4457
- vue.watchEffect(() => {
4458
- codeName.value = props.name;
4459
- codeContent.value = props.content;
4460
- });
4461
- const initTableModel = () => {
4462
- const codeDsl = lodashEs.cloneDeep(services?.codeBlockService.getCodeDsl());
4463
- if (!codeDsl)
4464
- return;
4465
- tableModel.value = {
4466
- params: codeDsl[props.id]?.params || []
4467
- };
4468
- };
4469
- initTableModel();
4470
- const beforeSave = (codeValue) => {
4471
- try {
4472
- getConfig("parseDSL")(codeValue);
4473
- return true;
4474
- } catch (e) {
4475
- design.tMagicMessage.error(e.stack);
4476
- return false;
4477
- }
4478
- };
4479
- const saveCode = async (codeValue) => {
4480
- if (!props.editable)
4481
- return;
4482
- evalRes.value = beforeSave(codeValue);
4483
- if (evalRes.value) {
4484
- await services?.codeBlockService.setCodeDslById(props.id, {
4485
- name: codeName.value,
4486
- content: codeValue,
4487
- params: tableModel.value?.params || []
4488
- });
4489
- design.tMagicMessage.success("代码成功保存到本地");
4490
- services?.codeBlockService.removeCodeDraft(props.id);
4491
- }
4492
- };
4493
- const saveAndClose = async (codeValue) => {
4494
- await saveCode(codeValue);
4495
- if (evalRes.value) {
4496
- close();
4497
- }
4498
- };
4499
- const close = () => {
4500
- services?.codeBlockService.setCodeEditorShowStatus(false);
4501
- };
4502
- const codeDraftEditor = vue.ref();
4503
- __expose({
4504
- codeDraftEditor
4505
- });
4506
- return (_ctx, _cache) => {
4507
- const _component_m_form_table = vue.resolveComponent("m-form-table");
4508
- return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCard), { shadow: "never" }, {
4509
- header: vue.withCtx(() => [
4510
- vue.createElementVNode("div", _hoisted_1$c, [
4511
- _hoisted_2$5,
4512
- vue.createVNode(vue.unref(design.TMagicInput), {
4513
- class: "code-name-input",
4514
- modelValue: codeName.value,
4515
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => codeName.value = $event),
4516
- disabled: !_ctx.editable
4517
- }, null, 8, ["modelValue", "disabled"])
4518
- ]),
4519
- vue.createElementVNode("div", _hoisted_3$3, [
4520
- _hoisted_4$3,
4521
- vue.createVNode(_component_m_form_table, {
4522
- style: { "width": "800px" },
4523
- config: tableConfig,
4524
- model: tableModel.value,
4525
- enableToggleMode: false,
4526
- name: "params",
4527
- prop: "params",
4528
- size: "small"
4529
- }, null, 8, ["model"])
4530
- ])
4531
- ]),
4532
- default: vue.withCtx(() => [
4533
- vue.createVNode(_sfc_main$l, {
4534
- ref_key: "codeDraftEditor",
4535
- ref: codeDraftEditor,
4536
- id: _ctx.id,
4537
- content: codeContent.value,
4538
- editable: _ctx.editable,
4539
- autoSaveDraft: _ctx.autoSaveDraft,
4540
- codeOptions: _ctx.codeOptions,
4541
- language: "javascript",
4542
- onSaveAndClose: saveAndClose,
4543
- onClose: close
4544
- }, null, 8, ["id", "content", "editable", "autoSaveDraft", "codeOptions"])
4545
- ]),
4546
- _: 1
4547
- });
4548
- };
4549
- }
4550
- });
4551
-
4552
- const _hoisted_1$b = {
4553
- key: 0,
4554
- class: "m-editor-code-block-editor-panel"
4555
- };
4556
- const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
4557
- ...{
4558
- name: "MEditorCodeBlockEditor"
4559
- },
4560
- __name: "CodeBlockEditor",
4561
- props: {
4562
- paramsColConfig: {}
4563
- },
4564
- setup(__props) {
4565
- const services = vue.inject("services");
4566
- const codeOptions = vue.inject("codeOptions", {});
4567
- const size = vue.computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
4568
- const left = vue.ref(200);
4569
- const currentTitle = vue.ref("");
4570
- const codeConfig = vue.ref(null);
4571
- const state = vue.reactive({
4572
- codeList: []
4573
- });
4574
- const id = vue.computed(() => services?.codeBlockService.getId() || "");
4575
- const editable = vue.computed(() => services?.codeBlockService.getEditStatus());
4576
- const selectedIds = vue.computed(() => services?.codeBlockService.getCombineIds() || []);
4577
- vue.watchEffect(async () => {
4578
- codeConfig.value = lodashEs.cloneDeep(await services?.codeBlockService.getCodeContentById(id.value)) || null;
4579
- if (!codeConfig.value)
4580
- return;
4581
- codeConfig.value.content = serializeConfig(codeConfig.value.content);
4582
- });
4583
- vue.watchEffect(async () => {
4584
- const codeDsl = await services?.codeBlockService.getCodeDslByIds(selectedIds.value) || null;
4585
- if (!codeDsl)
4586
- return;
4587
- state.codeList = [];
4588
- lodashEs.forIn(codeDsl, (value, key) => {
4589
- state.codeList.push({
4590
- id: key,
4591
- name: value.name
4592
- });
4593
- });
4594
- currentTitle.value = state.codeList[0]?.name || "";
4595
- });
4596
- const functionEditor = vue.ref();
4597
- const handleClose = async () => {
4598
- await functionEditor.value?.codeDraftEditor?.close();
4599
- };
4600
- return (_ctx, _cache) => {
4601
- return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDrawer), {
4602
- class: "code-editor-dialog",
4603
- "model-value": true,
4604
- title: currentTitle.value,
4605
- "close-on-press-escape": true,
4606
- "append-to-body": true,
4607
- "show-close": false,
4608
- "close-on-click-modal": true,
4609
- size: size.value,
4610
- "before-close": handleClose
4611
- }, {
4612
- default: vue.withCtx(() => [
4613
- vue.createVNode(_sfc_main$u, {
4614
- left: left.value,
4615
- "onUpdate:left": _cache[0] || (_cache[0] = ($event) => left.value = $event),
4616
- "min-left": 45,
4617
- class: "code-editor-layout"
4618
- }, {
4619
- center: vue.withCtx(() => [
4620
- !vue.unref(lodashEs.isEmpty)(codeConfig.value) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
4621
- vue.renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id: id.value }),
4622
- codeConfig.value ? (vue.openBlock(), vue.createBlock(_sfc_main$k, {
4623
- key: 0,
4624
- ref_key: "functionEditor",
4625
- ref: functionEditor,
4626
- id: id.value,
4627
- name: codeConfig.value.name,
4628
- content: codeConfig.value.content,
4629
- paramsColConfig: _ctx.paramsColConfig,
4630
- editable: !!editable.value,
4631
- autoSaveDraft: true,
4632
- codeOptions: vue.unref(codeOptions)
4633
- }, null, 8, ["id", "name", "content", "paramsColConfig", "editable", "codeOptions"])) : vue.createCommentVNode("", true)
4634
- ])) : vue.createCommentVNode("", true)
4635
- ]),
4636
- _: 3
4637
- }, 8, ["left"])
4638
- ]),
4639
- _: 3
4640
- }, 8, ["title", "size"]);
4788
+ return vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$d, _hoisted_4$1);
4641
4789
  };
4642
4790
  }
4643
4791
  });
4644
4792
 
4645
- const _hoisted_1$a = { class: "search-wrapper" };
4646
- const _hoisted_2$4 = ["id"];
4647
- const _hoisted_3$2 = { class: "list-item" };
4648
- const _hoisted_4$2 = {
4793
+ const _hoisted_1$c = ["id"];
4794
+ const _hoisted_2$4 = { class: "list-item" };
4795
+ const _hoisted_3$2 = {
4649
4796
  key: 2,
4650
4797
  class: "right-tool"
4651
4798
  };
4652
- const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
4799
+ const _sfc_main$k = /* @__PURE__ */ vue.defineComponent({
4653
4800
  ...{
4654
4801
  name: "MEditorCodeBlockList"
4655
4802
  },
4656
4803
  __name: "CodeBlockList",
4657
4804
  props: {
4658
- customError: { type: Function },
4659
- paramsColConfig: {}
4805
+ customError: { type: Function }
4660
4806
  },
4661
- setup(__props) {
4807
+ emits: ["edit", "remove"],
4808
+ setup(__props, { expose: __expose, emit }) {
4662
4809
  const props = __props;
4663
- const treeProps = {
4664
- children: "children",
4665
- label: "name",
4666
- value: "id"
4667
- };
4668
4810
  const { codeBlockService, depService, editorService } = vue.inject("services") || {};
4669
4811
  const codeList = vue.computed(
4670
4812
  () => Object.values(depService?.targets["code-block"] || {}).map((target) => {
@@ -4685,167 +4827,184 @@
4685
4827
  );
4686
4828
  const expandedKeys = vue.computed(() => codeList.value.map((item) => item.id));
4687
4829
  const editable = vue.computed(() => codeBlockService?.getEditStatus());
4688
- const isShowCodeBlockEditor = vue.computed(() => codeBlockService?.getCodeEditorShowStatus() || false);
4689
- const createCodeBlock = async () => {
4690
- if (!codeBlockService) {
4691
- design.tMagicMessage.error("新增代码块失败");
4692
- return;
4830
+ const filterNode = (value, data) => {
4831
+ if (!value) {
4832
+ return true;
4833
+ }
4834
+ return `${data.name}${data.id}`.toLocaleLowerCase().indexOf(value.toLocaleLowerCase()) !== -1;
4835
+ };
4836
+ const selectComp = (compId) => {
4837
+ const stage = editorService?.get("stage");
4838
+ editorService?.select(compId);
4839
+ stage?.select(compId);
4840
+ };
4841
+ const clickHandler = (data, node) => {
4842
+ if (data.type === "node") {
4843
+ selectComp(data.id);
4844
+ } else if (data.type === "key") {
4845
+ selectComp(node.parent.data.id);
4693
4846
  }
4694
- const codeConfig = {
4695
- name: "代码块",
4696
- content: `({app, params}) => {
4697
- // place your code here
4698
- }`,
4699
- params: []
4700
- };
4701
- const id = await codeBlockService.getUniqueId();
4702
- await codeBlockService.setCodeDslById(id, codeConfig);
4703
- codeBlockService.setCodeEditorContent(true, id);
4704
4847
  };
4705
- const editCode = async (key) => {
4706
- codeBlockService?.setCodeEditorContent(true, key);
4848
+ const editCode = (id) => {
4849
+ emit("edit", id);
4707
4850
  };
4708
- const deleteCode = async (key) => {
4709
- const currentCode = codeList.value.find((codeItem) => codeItem.id === key);
4851
+ const deleteCode = async (id) => {
4852
+ const currentCode = codeList.value.find((codeItem) => codeItem.id === id);
4710
4853
  const existBinds = Boolean(currentCode?.children.length);
4711
4854
  const undeleteableList = codeBlockService?.getUndeletableList() || [];
4712
- if (!existBinds && !undeleteableList.includes(key)) {
4855
+ if (!existBinds && !undeleteableList.includes(id)) {
4713
4856
  await design.tMagicMessageBox.confirm("确定删除该代码块吗?", "提示", {
4714
4857
  confirmButtonText: "确定",
4715
4858
  cancelButtonText: "取消",
4716
4859
  type: "warning"
4717
4860
  });
4718
- codeBlockService?.deleteCodeDslByIds([key]);
4861
+ emit("remove", id);
4719
4862
  } else {
4720
4863
  if (typeof props.customError === "function") {
4721
- props.customError(key, existBinds ? CodeDeleteErrorType.BIND : CodeDeleteErrorType.UNDELETEABLE);
4864
+ props.customError(id, existBinds ? CodeDeleteErrorType.BIND : CodeDeleteErrorType.UNDELETEABLE);
4722
4865
  } else {
4723
4866
  design.tMagicMessage.error("代码块删除失败");
4724
4867
  }
4725
4868
  }
4726
4869
  };
4727
4870
  const tree = vue.ref();
4728
- const filterNode = (value, data) => {
4729
- if (!value) {
4730
- return true;
4871
+ __expose({
4872
+ filter(val) {
4873
+ tree.value?.filter(val);
4731
4874
  }
4732
- return `${data.name}${data.id}`.toLocaleLowerCase().indexOf(value.toLocaleLowerCase()) !== -1;
4875
+ });
4876
+ return (_ctx, _cache) => {
4877
+ return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTree), {
4878
+ ref_key: "tree",
4879
+ ref: tree,
4880
+ class: "magic-editor-layer-tree",
4881
+ "node-key": "id",
4882
+ "empty-text": "暂无代码块",
4883
+ "default-expanded-keys": expandedKeys.value,
4884
+ "expand-on-click-node": false,
4885
+ data: codeList.value,
4886
+ props: {
4887
+ children: "children",
4888
+ label: "name",
4889
+ value: "id"
4890
+ },
4891
+ "highlight-current": true,
4892
+ "filter-node-method": filterNode,
4893
+ onNodeClick: clickHandler
4894
+ }, {
4895
+ default: vue.withCtx(({ data }) => [
4896
+ vue.createElementVNode("div", {
4897
+ id: data.id,
4898
+ class: "list-container"
4899
+ }, [
4900
+ vue.createElementVNode("div", _hoisted_2$4, [
4901
+ data.type === "code" ? (vue.openBlock(), vue.createBlock(_sfc_main$l, {
4902
+ key: 0,
4903
+ class: "codeIcon"
4904
+ })) : vue.createCommentVNode("", true),
4905
+ data.type === "node" ? (vue.openBlock(), vue.createBlock(_sfc_main$m, {
4906
+ key: 1,
4907
+ class: "compIcon"
4908
+ })) : vue.createCommentVNode("", true),
4909
+ vue.createElementVNode("span", {
4910
+ class: vue.normalizeClass(["name", { code: data.type === "code", hook: data.type === "key" }])
4911
+ }, vue.toDisplayString(data.name) + " (" + vue.toDisplayString(data.id) + ")", 3),
4912
+ data.type === "code" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$2, [
4913
+ vue.createVNode(vue.unref(design.TMagicTooltip), {
4914
+ effect: "dark",
4915
+ content: editable.value ? "编辑" : "查看",
4916
+ placement: "bottom"
4917
+ }, {
4918
+ default: vue.withCtx(() => [
4919
+ vue.createVNode(_sfc_main$E, {
4920
+ icon: editable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
4921
+ class: "edit-icon",
4922
+ onClick: vue.withModifiers(($event) => editCode(data.id), ["stop"])
4923
+ }, null, 8, ["icon", "onClick"])
4924
+ ]),
4925
+ _: 2
4926
+ }, 1032, ["content"]),
4927
+ editable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
4928
+ key: 0,
4929
+ effect: "dark",
4930
+ content: "删除",
4931
+ placement: "bottom"
4932
+ }, {
4933
+ default: vue.withCtx(() => [
4934
+ vue.createVNode(_sfc_main$E, {
4935
+ icon: vue.unref(iconsVue.Close),
4936
+ class: "edit-icon",
4937
+ onClick: vue.withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
4938
+ }, null, 8, ["icon", "onClick"])
4939
+ ]),
4940
+ _: 2
4941
+ }, 1024)) : vue.createCommentVNode("", true),
4942
+ vue.renderSlot(_ctx.$slots, "code-block-panel-tool", {
4943
+ id: data.id,
4944
+ data: data.codeBlockContent
4945
+ })
4946
+ ])) : vue.createCommentVNode("", true)
4947
+ ])
4948
+ ], 8, _hoisted_1$c)
4949
+ ]),
4950
+ _: 3
4951
+ }, 8, ["default-expanded-keys", "data"]);
4733
4952
  };
4953
+ }
4954
+ });
4955
+
4956
+ const _hoisted_1$b = { class: "search-wrapper" };
4957
+ const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
4958
+ ...{
4959
+ name: "MEditorCodeBlockListPanel"
4960
+ },
4961
+ __name: "CodeBlockListPanel",
4962
+ props: {
4963
+ customError: { type: Function }
4964
+ },
4965
+ setup(__props) {
4966
+ const { codeBlockService } = vue.inject("services") || {};
4967
+ const editable = vue.computed(() => codeBlockService?.getEditStatus());
4968
+ const { codeBlockEditor, codeConfig, editCode, deleteCode, createCodeBlock, submitCodeBlockHandler } = useCodeBlockEdit(codeBlockService);
4969
+ const codeBlockList = vue.ref();
4734
4970
  const filterTextChangeHandler = (val) => {
4735
- tree.value?.filter(val);
4736
- };
4737
- const selectComp = (compId) => {
4738
- const stage = editorService?.get("stage");
4739
- editorService?.select(compId);
4740
- stage?.select(compId);
4741
- };
4742
- const clickHandler = (data, node) => {
4743
- if (data.type === "node") {
4744
- selectComp(data.id);
4745
- } else if (data.type === "key") {
4746
- selectComp(node.parent.data.id);
4747
- }
4971
+ codeBlockList.value?.filter(val);
4748
4972
  };
4749
4973
  return (_ctx, _cache) => {
4750
4974
  return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicScrollbar), { class: "m-editor-code-block-list m-editor-dep-list-panel" }, {
4751
4975
  default: vue.withCtx(() => [
4752
4976
  vue.renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
4753
- vue.createElementVNode("div", _hoisted_1$a, [
4754
- vue.createVNode(_sfc_main$o, { onSearch: filterTextChangeHandler }),
4977
+ vue.createElementVNode("div", _hoisted_1$b, [
4978
+ vue.createVNode(_sfc_main$n, { onSearch: filterTextChangeHandler }),
4755
4979
  editable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
4756
4980
  key: 0,
4757
4981
  class: "create-code-button",
4758
4982
  type: "primary",
4759
4983
  size: "small",
4760
- onClick: createCodeBlock
4984
+ onClick: vue.unref(createCodeBlock)
4761
4985
  }, {
4762
4986
  default: vue.withCtx(() => [
4763
4987
  vue.createTextVNode("新增")
4764
4988
  ]),
4765
4989
  _: 1
4766
- })) : vue.createCommentVNode("", true)
4990
+ }, 8, ["onClick"])) : vue.createCommentVNode("", true)
4767
4991
  ])
4768
4992
  ]),
4769
- vue.createVNode(vue.unref(design.TMagicTree), {
4770
- ref_key: "tree",
4771
- ref: tree,
4772
- class: "magic-editor-layer-tree",
4773
- "node-key": "id",
4774
- "empty-text": "暂无代码块",
4775
- "default-expanded-keys": expandedKeys.value,
4776
- "expand-on-click-node": false,
4777
- data: codeList.value,
4778
- props: treeProps,
4779
- "highlight-current": true,
4780
- "filter-node-method": filterNode,
4781
- onNodeClick: clickHandler
4782
- }, {
4783
- default: vue.withCtx(({ data }) => [
4784
- vue.createElementVNode("div", {
4785
- id: data.id,
4786
- class: "list-container"
4787
- }, [
4788
- vue.createElementVNode("div", _hoisted_3$2, [
4789
- data.type === "code" ? (vue.openBlock(), vue.createBlock(_sfc_main$m, {
4790
- key: 0,
4791
- class: "codeIcon"
4792
- })) : vue.createCommentVNode("", true),
4793
- data.type === "node" ? (vue.openBlock(), vue.createBlock(_sfc_main$n, {
4794
- key: 1,
4795
- class: "compIcon"
4796
- })) : vue.createCommentVNode("", true),
4797
- vue.createElementVNode("span", {
4798
- class: vue.normalizeClass(["name", { code: data.type === "code", hook: data.type === "key" }])
4799
- }, vue.toDisplayString(data.name) + " (" + vue.toDisplayString(data.id) + ")", 3),
4800
- data.type === "code" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4$2, [
4801
- vue.createVNode(vue.unref(design.TMagicTooltip), {
4802
- effect: "dark",
4803
- content: editable.value ? "编辑" : "查看",
4804
- placement: "bottom"
4805
- }, {
4806
- default: vue.withCtx(() => [
4807
- vue.createVNode(_sfc_main$E, {
4808
- icon: editable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
4809
- class: "edit-icon",
4810
- onClick: vue.withModifiers(($event) => editCode(`${data.id}`), ["stop"])
4811
- }, null, 8, ["icon", "onClick"])
4812
- ]),
4813
- _: 2
4814
- }, 1032, ["content"]),
4815
- editable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
4816
- key: 0,
4817
- effect: "dark",
4818
- content: "删除",
4819
- placement: "bottom"
4820
- }, {
4821
- default: vue.withCtx(() => [
4822
- vue.createVNode(_sfc_main$E, {
4823
- icon: vue.unref(iconsVue.Close),
4824
- class: "edit-icon",
4825
- onClick: vue.withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
4826
- }, null, 8, ["icon", "onClick"])
4827
- ]),
4828
- _: 2
4829
- }, 1024)) : vue.createCommentVNode("", true),
4830
- vue.renderSlot(_ctx.$slots, "code-block-panel-tool", {
4831
- id: data.id,
4832
- data: data.codeBlockContent
4833
- })
4834
- ])) : vue.createCommentVNode("", true)
4835
- ])
4836
- ], 8, _hoisted_2$4)
4837
- ]),
4838
- _: 3
4839
- }, 8, ["default-expanded-keys", "data"]),
4840
- isShowCodeBlockEditor.value ? (vue.openBlock(), vue.createBlock(_sfc_main$j, {
4993
+ vue.createVNode(_sfc_main$k, {
4994
+ ref_key: "codeBlockList",
4995
+ ref: codeBlockList,
4996
+ "custom-error": _ctx.customError,
4997
+ onEdit: vue.unref(editCode),
4998
+ onRemove: vue.unref(deleteCode)
4999
+ }, null, 8, ["custom-error", "onEdit", "onRemove"]),
5000
+ vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$G, {
4841
5001
  key: 0,
4842
- paramsColConfig: _ctx.paramsColConfig
4843
- }, {
4844
- "code-block-edit-panel-header": vue.withCtx(({ id }) => [
4845
- vue.renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
4846
- ]),
4847
- _: 3
4848
- }, 8, ["paramsColConfig"])) : vue.createCommentVNode("", true)
5002
+ ref_key: "codeBlockEditor",
5003
+ ref: codeBlockEditor,
5004
+ disabled: !editable.value,
5005
+ content: vue.unref(codeConfig),
5006
+ onSubmit: vue.unref(submitCodeBlockHandler)
5007
+ }, null, 8, ["disabled", "content", "onSubmit"])) : vue.createCommentVNode("", true)
4849
5008
  ]),
4850
5009
  _: 3
4851
5010
  });
@@ -4853,14 +5012,15 @@
4853
5012
  }
4854
5013
  });
4855
5014
 
4856
- const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
5015
+ const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
4857
5016
  ...{
4858
5017
  name: "MEditorDataSourceConfigPanel"
4859
5018
  },
4860
5019
  __name: "DataSourceConfigPanel",
4861
5020
  props: {
4862
5021
  title: {},
4863
- values: {}
5022
+ values: {},
5023
+ disabled: { type: Boolean }
4864
5024
  },
4865
5025
  emits: ["submit"],
4866
5026
  setup(__props, { expose: __expose, emit }) {
@@ -4869,7 +5029,7 @@
4869
5029
  const services = vue.inject("services");
4870
5030
  const size = vue.computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
4871
5031
  const dataSourceConfig = vue.computed(() => services?.dataSourceService.getFormConfig(type.value) || []);
4872
- const form$1 = vue.ref();
5032
+ const fomDrawer = vue.ref();
4873
5033
  const initValues = vue.ref({});
4874
5034
  vue.watchEffect(() => {
4875
5035
  initValues.value = props.values;
@@ -4882,84 +5042,53 @@
4882
5042
  type.value = value.type || "base";
4883
5043
  initValues.value = value;
4884
5044
  };
4885
- const submitHandler = async () => {
4886
- try {
4887
- const values = await form$1.value?.submitForm();
4888
- emit("submit", values);
4889
- } catch (error) {
4890
- design.tMagicMessage.error(error.message);
4891
- }
5045
+ const submitHandler = (values) => {
5046
+ emit("submit", values);
4892
5047
  };
4893
- const visible = vue.ref(false);
4894
- const hide = () => {
4895
- visible.value = false;
5048
+ const errorHandler = (error) => {
5049
+ design.tMagicMessage.error(error.message);
4896
5050
  };
4897
5051
  __expose({
4898
5052
  show() {
4899
- visible.value = true;
5053
+ fomDrawer.value?.show();
4900
5054
  },
4901
- hide
5055
+ hide() {
5056
+ fomDrawer.value?.hide();
5057
+ }
4902
5058
  });
4903
5059
  return (_ctx, _cache) => {
4904
- return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDrawer), {
4905
- modelValue: visible.value,
4906
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => visible.value = $event),
5060
+ return vue.openBlock(), vue.createBlock(vue.unref(form.MFormDrawer), {
5061
+ ref_key: "fomDrawer",
5062
+ ref: fomDrawer,
5063
+ "label-width": "80px",
4907
5064
  title: _ctx.title,
4908
- "close-on-press-escape": true,
4909
- "append-to-body": true,
4910
- "show-close": true,
4911
- "close-on-click-modal": true,
4912
- size: size.value
4913
- }, {
4914
- footer: vue.withCtx(() => [
4915
- vue.createElementVNode("div", null, [
4916
- vue.createVNode(vue.unref(design.TMagicButton), {
4917
- type: "primary",
4918
- onClick: submitHandler
4919
- }, {
4920
- default: vue.withCtx(() => [
4921
- vue.createTextVNode("确定")
4922
- ]),
4923
- _: 1
4924
- }),
4925
- vue.createVNode(vue.unref(design.TMagicButton), { onClick: hide }, {
4926
- default: vue.withCtx(() => [
4927
- vue.createTextVNode("关闭")
4928
- ]),
4929
- _: 1
4930
- })
4931
- ])
4932
- ]),
4933
- default: vue.withCtx(() => [
4934
- vue.createVNode(vue.unref(form.MForm), {
4935
- ref_key: "form",
4936
- ref: form$1,
4937
- config: dataSourceConfig.value,
4938
- "init-values": initValues.value,
4939
- onChange: changeHandler
4940
- }, null, 8, ["config", "init-values"])
4941
- ]),
4942
- _: 1
4943
- }, 8, ["modelValue", "title", "size"]);
5065
+ width: size.value,
5066
+ config: dataSourceConfig.value,
5067
+ values: initValues.value,
5068
+ disabled: _ctx.disabled,
5069
+ onChange: changeHandler,
5070
+ onSubmit: submitHandler,
5071
+ onError: errorHandler
5072
+ }, null, 8, ["title", "width", "config", "values", "disabled"]);
4944
5073
  };
4945
5074
  }
4946
5075
  });
4947
5076
 
4948
- const _hoisted_1$9 = { class: "search-wrapper" };
4949
- const _hoisted_2$3 = ["id"];
4950
- const _hoisted_3$1 = { class: "list-item" };
4951
- const _hoisted_4$1 = {
5077
+ const _hoisted_1$a = ["id"];
5078
+ const _hoisted_2$3 = { class: "list-item" };
5079
+ const _hoisted_3$1 = {
4952
5080
  key: 2,
4953
5081
  class: "right-tool"
4954
5082
  };
4955
- const _sfc_main$g = /* @__PURE__ */ vue.defineComponent({
5083
+ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
4956
5084
  ...{
4957
- name: "MEditorDataSourceListPanel"
5085
+ name: "MEditorDataSourceList"
4958
5086
  },
4959
- __name: "DataSourceListPanel",
4960
- setup(__props) {
4961
- const services = vue.inject("services", {});
4962
- const { dataSourceService, depService, editorService } = vue.inject("services") || {};
5087
+ __name: "DataSourceList",
5088
+ emits: ["edit", "remove"],
5089
+ setup(__props, { expose: __expose, emit }) {
5090
+ const { depService, editorService, dataSourceService } = vue.inject("services") || {};
5091
+ const editable = vue.computed(() => dataSourceService?.get("editable") ?? true);
4963
5092
  const list = vue.computed(
4964
5093
  () => Object.values(depService?.targets["data-source"] || {}).map((target) => ({
4965
5094
  id: target.id,
@@ -4973,8 +5102,123 @@
4973
5102
  }))
4974
5103
  }))
4975
5104
  );
5105
+ const editHandler = (id) => {
5106
+ emit("edit", id);
5107
+ };
5108
+ const removeHandler = async (id) => {
5109
+ await design.tMagicMessageBox.confirm("确定删除?", "提示", {
5110
+ confirmButtonText: "确定",
5111
+ cancelButtonText: "取消",
5112
+ type: "warning"
5113
+ });
5114
+ emit("remove", id);
5115
+ };
5116
+ const selectComp = (compId) => {
5117
+ const stage = editorService?.get("stage");
5118
+ editorService?.select(compId);
5119
+ stage?.select(compId);
5120
+ };
5121
+ const clickHandler = (data, node) => {
5122
+ if (data.type === "node") {
5123
+ selectComp(data.id);
5124
+ } else if (data.type === "key") {
5125
+ selectComp(node.parent.data.id);
5126
+ }
5127
+ };
5128
+ const tree = vue.ref();
5129
+ __expose({
5130
+ filter(val) {
5131
+ debugger;
5132
+ tree.value?.filter(val);
5133
+ }
5134
+ });
5135
+ return (_ctx, _cache) => {
5136
+ return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTree), {
5137
+ ref_key: "tree",
5138
+ ref: tree,
5139
+ class: "magic-editor-layer-tree",
5140
+ "node-key": "id",
5141
+ "empty-text": "暂无代码块",
5142
+ "default-expand-all": "",
5143
+ "expand-on-click-node": false,
5144
+ data: list.value,
5145
+ "highlight-current": true,
5146
+ onNodeClick: clickHandler
5147
+ }, {
5148
+ default: vue.withCtx(({ data }) => [
5149
+ vue.createElementVNode("div", {
5150
+ id: data.id,
5151
+ class: "list-container"
5152
+ }, [
5153
+ vue.createElementVNode("div", _hoisted_2$3, [
5154
+ data.type === "code" ? (vue.openBlock(), vue.createBlock(_sfc_main$E, {
5155
+ key: 0,
5156
+ class: "codeIcon",
5157
+ icon: vue.unref(iconsVue.Coin)
5158
+ }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
5159
+ data.type === "node" ? (vue.openBlock(), vue.createBlock(_sfc_main$E, {
5160
+ key: 1,
5161
+ class: "compIcon",
5162
+ icon: vue.unref(iconsVue.Aim)
5163
+ }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
5164
+ vue.createElementVNode("span", {
5165
+ class: vue.normalizeClass(["name", { code: data.type === "code", hook: data.type === "key" }])
5166
+ }, vue.toDisplayString(data.name) + "(" + vue.toDisplayString(data.id) + ")", 3),
5167
+ data.type === "code" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$1, [
5168
+ vue.createVNode(vue.unref(design.TMagicTooltip), {
5169
+ effect: "dark",
5170
+ content: editable.value ? "编辑" : "查看",
5171
+ placement: "bottom"
5172
+ }, {
5173
+ default: vue.withCtx(() => [
5174
+ vue.createVNode(_sfc_main$E, {
5175
+ icon: editable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
5176
+ class: "edit-icon",
5177
+ onClick: vue.withModifiers(($event) => editHandler(`${data.id}`), ["stop"])
5178
+ }, null, 8, ["icon", "onClick"])
5179
+ ]),
5180
+ _: 2
5181
+ }, 1032, ["content"]),
5182
+ editable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
5183
+ key: 0,
5184
+ effect: "dark",
5185
+ content: "删除",
5186
+ placement: "bottom"
5187
+ }, {
5188
+ default: vue.withCtx(() => [
5189
+ vue.createVNode(_sfc_main$E, {
5190
+ icon: vue.unref(iconsVue.Close),
5191
+ class: "edit-icon",
5192
+ onClick: vue.withModifiers(($event) => removeHandler(`${data.id}`), ["stop"])
5193
+ }, null, 8, ["icon", "onClick"])
5194
+ ]),
5195
+ _: 2
5196
+ }, 1024)) : vue.createCommentVNode("", true),
5197
+ vue.renderSlot(_ctx.$slots, "data-source-panel-tool", {
5198
+ id: data.id,
5199
+ data: data.codeBlockContent
5200
+ })
5201
+ ])) : vue.createCommentVNode("", true)
5202
+ ])
5203
+ ], 8, _hoisted_1$a)
5204
+ ]),
5205
+ _: 3
5206
+ }, 8, ["data"]);
5207
+ };
5208
+ }
5209
+ });
5210
+
5211
+ const _hoisted_1$9 = { class: "search-wrapper" };
5212
+ const _sfc_main$g = /* @__PURE__ */ vue.defineComponent({
5213
+ ...{
5214
+ name: "MEditorDataSourceListPanel"
5215
+ },
5216
+ __name: "DataSourceListPanel",
5217
+ setup(__props) {
5218
+ const { dataSourceService } = vue.inject("services") || {};
4976
5219
  const editDialog = vue.ref();
4977
5220
  const dataSourceValues = vue.ref({});
5221
+ const editable = vue.computed(() => dataSourceService?.get("editable") ?? true);
4978
5222
  const addHandler = () => {
4979
5223
  if (!editDialog.value)
4980
5224
  return;
@@ -4982,24 +5226,17 @@
4982
5226
  editDialog.value.show();
4983
5227
  };
4984
5228
  const editHandler = (id) => {
4985
- if (!editDialog.value || !services)
5229
+ if (!editDialog.value)
4986
5230
  return;
4987
5231
  dataSourceValues.value = {
4988
5232
  ...dataSourceService?.getDataSourceById(id)
4989
5233
  };
4990
5234
  editDialog.value.show();
4991
5235
  };
4992
- const removeHandler = async (id) => {
4993
- await design.tMagicMessageBox.confirm("确定删除?", "提示", {
4994
- confirmButtonText: "确定",
4995
- cancelButtonText: "取消",
4996
- type: "warning"
4997
- });
5236
+ const removeHandler = (id) => {
4998
5237
  dataSourceService?.remove(id);
4999
5238
  };
5000
5239
  const submitDataSourceHandler = (value) => {
5001
- if (!services)
5002
- return;
5003
5240
  if (value.id) {
5004
5241
  dataSourceService?.update(value);
5005
5242
  } else {
@@ -5007,28 +5244,17 @@
5007
5244
  }
5008
5245
  editDialog.value?.hide();
5009
5246
  };
5010
- const tree = vue.ref();
5247
+ const dataSourceList = vue.ref();
5011
5248
  const filterTextChangeHandler = (val) => {
5012
- tree.value?.filter(val);
5013
- };
5014
- const selectComp = (compId) => {
5015
- const stage = editorService?.get("stage");
5016
- editorService?.select(compId);
5017
- stage?.select(compId);
5018
- };
5019
- const clickHandler = (data, node) => {
5020
- if (data.type === "node") {
5021
- selectComp(data.id);
5022
- } else if (data.type === "key") {
5023
- selectComp(node.parent.data.id);
5024
- }
5249
+ dataSourceList.value?.filter(val);
5025
5250
  };
5026
5251
  return (_ctx, _cache) => {
5027
5252
  return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicScrollbar), { class: "data-source-list-panel m-editor-dep-list-panel" }, {
5028
5253
  default: vue.withCtx(() => [
5029
5254
  vue.createElementVNode("div", _hoisted_1$9, [
5030
- vue.createVNode(_sfc_main$o, { onSearch: filterTextChangeHandler }),
5031
- vue.createVNode(vue.unref(design.TMagicButton), {
5255
+ vue.createVNode(_sfc_main$n, { onSearch: filterTextChangeHandler }),
5256
+ editable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
5257
+ key: 0,
5032
5258
  type: "primary",
5033
5259
  size: "small",
5034
5260
  onClick: addHandler
@@ -5037,87 +5263,22 @@
5037
5263
  vue.createTextVNode("新增")
5038
5264
  ]),
5039
5265
  _: 1
5040
- })
5266
+ })) : vue.createCommentVNode("", true)
5041
5267
  ]),
5042
- vue.createVNode(vue.unref(design.TMagicTree), {
5043
- ref_key: "tree",
5044
- ref: tree,
5045
- class: "magic-editor-layer-tree",
5046
- "node-key": "id",
5047
- "empty-text": "暂无代码块",
5048
- "default-expand-all": "",
5049
- "expand-on-click-node": false,
5050
- data: list.value,
5051
- "highlight-current": true,
5052
- onNodeClick: clickHandler
5053
- }, {
5054
- default: vue.withCtx(({ data }) => [
5055
- vue.createElementVNode("div", {
5056
- id: data.id,
5057
- class: "list-container"
5058
- }, [
5059
- vue.createElementVNode("div", _hoisted_3$1, [
5060
- data.type === "code" ? (vue.openBlock(), vue.createBlock(_sfc_main$E, {
5061
- key: 0,
5062
- class: "codeIcon",
5063
- icon: vue.unref(iconsVue.Coin)
5064
- }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
5065
- data.type === "node" ? (vue.openBlock(), vue.createBlock(_sfc_main$E, {
5066
- key: 1,
5067
- class: "compIcon",
5068
- icon: vue.unref(iconsVue.Aim)
5069
- }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
5070
- vue.createElementVNode("span", {
5071
- class: vue.normalizeClass(["name", { code: data.type === "code", hook: data.type === "key" }])
5072
- }, vue.toDisplayString(data.name) + "(" + vue.toDisplayString(data.id) + ")", 3),
5073
- data.type === "code" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4$1, [
5074
- vue.createVNode(vue.unref(design.TMagicTooltip), {
5075
- effect: "dark",
5076
- content: "编辑",
5077
- placement: "bottom"
5078
- }, {
5079
- default: vue.withCtx(() => [
5080
- vue.createVNode(_sfc_main$E, {
5081
- class: "edit-icon",
5082
- icon: vue.unref(iconsVue.Edit),
5083
- onClick: vue.withModifiers(($event) => editHandler(`${data.id}`), ["stop"])
5084
- }, null, 8, ["icon", "onClick"])
5085
- ]),
5086
- _: 2
5087
- }, 1024),
5088
- vue.createVNode(vue.unref(design.TMagicTooltip), {
5089
- effect: "dark",
5090
- content: "删除",
5091
- placement: "bottom"
5092
- }, {
5093
- default: vue.withCtx(() => [
5094
- vue.createVNode(_sfc_main$E, {
5095
- icon: vue.unref(iconsVue.Close),
5096
- class: "edit-icon",
5097
- onClick: vue.withModifiers(($event) => removeHandler(`${data.id}`), ["stop"])
5098
- }, null, 8, ["icon", "onClick"])
5099
- ]),
5100
- _: 2
5101
- }, 1024),
5102
- vue.renderSlot(_ctx.$slots, "data-source-panel-tool", {
5103
- id: data.id,
5104
- data: data.codeBlockContent
5105
- })
5106
- ])) : vue.createCommentVNode("", true)
5107
- ])
5108
- ], 8, _hoisted_2$3)
5109
- ]),
5110
- _: 3
5111
- }, 8, ["data"]),
5112
5268
  vue.createVNode(_sfc_main$h, {
5269
+ onEdit: editHandler,
5270
+ onRemove: removeHandler
5271
+ }),
5272
+ vue.createVNode(_sfc_main$i, {
5113
5273
  ref_key: "editDialog",
5114
5274
  ref: editDialog,
5275
+ disabled: !editable.value,
5115
5276
  values: dataSourceValues.value,
5116
5277
  title: typeof dataSourceValues.value.id !== "undefined" ? `编辑${dataSourceValues.value.title}` : "新增",
5117
5278
  onSubmit: submitDataSourceHandler
5118
- }, null, 8, ["values", "title"])
5279
+ }, null, 8, ["disabled", "values", "title"])
5119
5280
  ]),
5120
- _: 3
5281
+ _: 1
5121
5282
  });
5122
5283
  };
5123
5284
  }
@@ -5203,7 +5364,7 @@
5203
5364
  "model-value": collapseValue.value
5204
5365
  }, {
5205
5366
  default: vue.withCtx(() => [
5206
- vue.createVNode(_sfc_main$o, { onSearch: filterTextChangeHandler }),
5367
+ vue.createVNode(_sfc_main$n, { onSearch: filterTextChangeHandler }),
5207
5368
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(list.value, (group, index) => {
5208
5369
  return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
5209
5370
  group.items && group.items.length ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCollapseItem), {
@@ -5360,7 +5521,7 @@
5360
5521
  }, [
5361
5522
  vue.createElementVNode("div", null, [
5362
5523
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.menuData, (item, index) => {
5363
- return vue.openBlock(), vue.createBlock(_sfc_main$r, {
5524
+ return vue.openBlock(), vue.createBlock(_sfc_main$q, {
5364
5525
  "event-type": "mouseup",
5365
5526
  ref_for: true,
5366
5527
  ref_key: "buttons",
@@ -5845,7 +6006,7 @@
5845
6006
  return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicScrollbar), { class: "magic-editor-layer-panel" }, {
5846
6007
  default: vue.withCtx(() => [
5847
6008
  vue.renderSlot(_ctx.$slots, "layer-panel-header"),
5848
- vue.createVNode(_sfc_main$o, { onSearch: filterTextChangeHandler }),
6009
+ vue.createVNode(_sfc_main$n, { onSearch: filterTextChangeHandler }),
5849
6010
  values.value.length ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTree), {
5850
6011
  key: 0,
5851
6012
  class: "magic-editor-layer-tree",
@@ -5949,7 +6110,7 @@
5949
6110
  type: "component",
5950
6111
  icon: iconsVue.EditPen,
5951
6112
  text: "代码编辑",
5952
- component: _sfc_main$i,
6113
+ component: _sfc_main$j,
5953
6114
  slots: {}
5954
6115
  },
5955
6116
  "data-source": {
@@ -6043,16 +6204,6 @@
6043
6204
  ]),
6044
6205
  key: "4"
6045
6206
  } : void 0,
6046
- config.$key === "code-block" || config.slots?.codeBlockEditPanelHeader ? {
6047
- name: "code-block-edit-panel-header",
6048
- fn: vue.withCtx(({ id }) => [
6049
- config.$key === "code-block" ? vue.renderSlot(_ctx.$slots, "code-block-edit-panel-header", {
6050
- key: 0,
6051
- id
6052
- }) : config.slots?.codeBlockEditPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.codeBlockEditPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
6053
- ]),
6054
- key: "5"
6055
- } : void 0,
6056
6207
  config.$key === "layer" || config.slots?.layerNodeContent ? {
6057
6208
  name: "layer-node-content",
6058
6209
  fn: vue.withCtx(({ data: nodeData, node }) => [
@@ -6066,7 +6217,7 @@
6066
6217
  node
6067
6218
  }, null, 8, ["data", "node"])) : vue.createCommentVNode("", true)
6068
6219
  ]),
6069
- key: "6"
6220
+ key: "5"
6070
6221
  } : void 0
6071
6222
  ]), 1040)) : vue.createCommentVNode("", true)
6072
6223
  ]),
@@ -6312,7 +6463,7 @@
6312
6463
  default: vue.withCtx(() => [
6313
6464
  vue.createElementVNode("div", null, [
6314
6465
  vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
6315
- vue.createVNode(_sfc_main$r, {
6466
+ vue.createVNode(_sfc_main$q, {
6316
6467
  data: {
6317
6468
  type: "button",
6318
6469
  text: "复制",
@@ -6320,7 +6471,7 @@
6320
6471
  handler: () => copy(item)
6321
6472
  }
6322
6473
  }, null, 8, ["data"]),
6323
- vue.createVNode(_sfc_main$r, {
6474
+ vue.createVNode(_sfc_main$q, {
6324
6475
  data: {
6325
6476
  type: "button",
6326
6477
  text: "删除",
@@ -7055,22 +7206,14 @@
7055
7206
 
7056
7207
  class CodeBlock extends BaseService {
7057
7208
  state = vue.reactive({
7058
- isShowCodeEditor: false,
7059
7209
  codeDsl: null,
7060
- id: "",
7061
7210
  editable: true,
7062
7211
  combineIds: [],
7063
- undeletableList: []
7212
+ undeletableList: [],
7213
+ paramsColConfig: void 0
7064
7214
  });
7065
7215
  constructor() {
7066
- super([
7067
- "setCodeDslById",
7068
- "setCodeEditorShowStatus",
7069
- "setEditStatus",
7070
- "setCombineIds",
7071
- "setUndeleteableList",
7072
- "deleteCodeDslByIds"
7073
- ]);
7216
+ super(["setCodeDslById", "setEditStatus", "setCombineIds", "setUndeleteableList", "deleteCodeDslByIds"]);
7074
7217
  }
7075
7218
  /**
7076
7219
  * 设置活动的代码块dsl数据源
@@ -7117,7 +7260,10 @@
7117
7260
  const codeConfigProcessed = codeConfig;
7118
7261
  if (codeConfig.content) {
7119
7262
  const parseDSL = getConfig("parseDSL");
7120
- codeConfigProcessed.content = parseDSL(codeConfig.content);
7263
+ if (typeof codeConfig.content === "string") {
7264
+ codeConfig.content = parseDSL(codeConfig.content);
7265
+ }
7266
+ codeConfigProcessed.content = codeConfig.content;
7121
7267
  }
7122
7268
  const existContent = codeDsl[id] || {};
7123
7269
  codeDsl[id] = {
@@ -7135,40 +7281,6 @@
7135
7281
  const codeDsl = this.getCodeDsl();
7136
7282
  return lodashEs.pick(codeDsl, ids);
7137
7283
  }
7138
- /**
7139
- * 设置代码编辑面板展示状态
7140
- * @param {boolean} status 是否展示代码编辑面板
7141
- * @returns {void}
7142
- */
7143
- async setCodeEditorShowStatus(status) {
7144
- this.state.isShowCodeEditor = status;
7145
- }
7146
- /**
7147
- * 获取代码编辑面板展示状态
7148
- * @returns {boolean} 是否展示代码编辑面板
7149
- */
7150
- getCodeEditorShowStatus() {
7151
- return this.state.isShowCodeEditor;
7152
- }
7153
- /**
7154
- * 设置代码编辑面板展示状态及展示内容
7155
- * @param {boolean} status 是否展示代码编辑面板
7156
- * @param {Id} id 代码块id
7157
- * @returns {void}
7158
- */
7159
- setCodeEditorContent(status, id) {
7160
- if (!id)
7161
- return;
7162
- this.setId(id);
7163
- this.state.isShowCodeEditor = status;
7164
- }
7165
- /**
7166
- * 获取当前选中的代码块内容
7167
- * @returns {CodeBlockContent | null}
7168
- */
7169
- getCurrentDsl() {
7170
- return this.getCodeContentById(this.state.id);
7171
- }
7172
7284
  /**
7173
7285
  * 获取编辑状态
7174
7286
  * @returns {boolean} 是否可编辑
@@ -7184,23 +7296,6 @@
7184
7296
  async setEditStatus(status) {
7185
7297
  this.state.editable = status;
7186
7298
  }
7187
- /**
7188
- * 设置当前选中的代码块ID
7189
- * @param {Id} id 代码块id
7190
- * @returns {void}
7191
- */
7192
- setId(id) {
7193
- if (!id)
7194
- return;
7195
- this.state.id = id;
7196
- }
7197
- /**
7198
- * 获取当前选中的代码块ID
7199
- * @returns {Id} id 代码块id
7200
- */
7201
- getId() {
7202
- return this.state.id;
7203
- }
7204
7299
  /**
7205
7300
  * 设置当前选中组件已关联绑定的代码块id数组
7206
7301
  * @param {string[]} ids 代码块id数组
@@ -7262,6 +7357,12 @@
7262
7357
  this.emit("remove", id);
7263
7358
  });
7264
7359
  }
7360
+ setParamsColConfig(config) {
7361
+ this.state.paramsColConfig = config;
7362
+ }
7363
+ getParamsColConfig() {
7364
+ return this.state.paramsColConfig;
7365
+ }
7265
7366
  /**
7266
7367
  * 生成代码块唯一id
7267
7368
  * @returns {Id} 代码块唯一id
@@ -7275,9 +7376,7 @@
7275
7376
  return await this.getUniqueId();
7276
7377
  }
7277
7378
  resetState() {
7278
- this.state.isShowCodeEditor = false;
7279
7379
  this.state.codeDsl = null;
7280
- this.state.id = "";
7281
7380
  this.state.editable = true;
7282
7381
  this.state.combineIds = [];
7283
7382
  this.state.undeletableList = [];
@@ -7410,6 +7509,17 @@
7410
7509
  defaultValue: []
7411
7510
  }
7412
7511
  ]
7512
+ },
7513
+ {
7514
+ type: "panel",
7515
+ title: "方法定义",
7516
+ items: [
7517
+ {
7518
+ name: "methods",
7519
+ type: "data-source-methods",
7520
+ defaultValue: []
7521
+ }
7522
+ ]
7413
7523
  }
7414
7524
  ];
7415
7525
  const getFormConfig = (type, configs) => {
@@ -7426,6 +7536,7 @@
7426
7536
  class DataSource extends BaseService {
7427
7537
  state = vue.reactive({
7428
7538
  dataSources: [],
7539
+ editable: true,
7429
7540
  configs: {}
7430
7541
  });
7431
7542
  set(name, value) {
@@ -8421,11 +8532,11 @@
8421
8532
  const _sfc_main = vue.defineComponent({
8422
8533
  name: "MEditor",
8423
8534
  components: {
8424
- TMagicNavMenu: _sfc_main$q,
8535
+ TMagicNavMenu: _sfc_main$p,
8425
8536
  Sidebar: _sfc_main$a,
8426
8537
  Workspace: _sfc_main$1,
8427
- PropsPanel: _sfc_main$p,
8428
- Framework: _sfc_main$s
8538
+ PropsPanel: _sfc_main$o,
8539
+ Framework: _sfc_main$r
8429
8540
  },
8430
8541
  props: editorProps,
8431
8542
  emits: ["props-panel-mounted", "update:modelValue"],
@@ -8528,9 +8639,6 @@
8528
8639
  data
8529
8640
  })
8530
8641
  ]),
8531
- "code-block-edit-panel-header": vue.withCtx(({ id }) => [
8532
- vue.renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
8533
- ]),
8534
8642
  _: 3
8535
8643
  }, 8, ["data", "layer-content-menu"])
8536
8644
  ])
@@ -8593,49 +8701,55 @@
8593
8701
  app.config.globalProperties.$TMAGIC_EDITOR = option;
8594
8702
  setConfig(option);
8595
8703
  app.component(Editor.name, Editor);
8596
- app.component("m-fields-ui-select", _sfc_main$x);
8597
- app.component("m-fields-code-link", _sfc_main$G);
8598
- app.component("m-fields-vs-code", _sfc_main$H);
8599
- app.component("magic-code-editor", _sfc_main$w);
8600
- app.component("m-fields-code-select", _sfc_main$F);
8704
+ app.component("m-fields-ui-select", _sfc_main$v);
8705
+ app.component("m-fields-code-link", _sfc_main$I);
8706
+ app.component("m-fields-vs-code", _sfc_main$J);
8707
+ app.component("magic-code-editor", _sfc_main$K);
8708
+ app.component("m-fields-code-select", _sfc_main$H);
8601
8709
  app.component("m-fields-code-select-col", _sfc_main$D);
8602
- app.component("m-fields-event-select", _sfc_main$z);
8710
+ app.component("m-fields-event-select", _sfc_main$x);
8603
8711
  app.component("m-fields-data-source-fields", _sfc_main$C);
8604
- app.component("m-fields-key-value", _sfc_main$y);
8712
+ app.component("m-fields-key-value", _sfc_main$w);
8605
8713
  app.component("m-fields-data-source-input", _sfc_main$B);
8606
- app.component("m-fields-data-source-select", _sfc_main$A);
8714
+ app.component("m-fields-data-source-select", _sfc_main$y);
8715
+ app.component("m-fields-data-source-methods", _sfc_main$A);
8716
+ app.component("m-fields-data-source-method-select", _sfc_main$z);
8607
8717
  }
8608
8718
  };
8609
8719
 
8610
8720
  exports.CODE_DRAFT_STORAGE_KEY = CODE_DRAFT_STORAGE_KEY;
8611
8721
  exports.COPY_STORAGE_KEY = COPY_STORAGE_KEY;
8612
- exports.CodeBlockList = _sfc_main$i;
8722
+ exports.CodeBlockEditor = _sfc_main$G;
8723
+ exports.CodeBlockList = _sfc_main$k;
8724
+ exports.CodeBlockListPanel = _sfc_main$j;
8613
8725
  exports.CodeDeleteErrorType = CodeDeleteErrorType;
8614
- exports.CodeSelect = _sfc_main$F;
8726
+ exports.CodeSelect = _sfc_main$H;
8615
8727
  exports.CodeSelectCol = _sfc_main$D;
8616
8728
  exports.ColumnLayout = ColumnLayout;
8617
8729
  exports.ComponentListPanel = _sfc_main$f;
8618
8730
  exports.ContentMenu = _sfc_main$e;
8619
8731
  exports.DataSourceFields = _sfc_main$C;
8620
8732
  exports.DataSourceInput = _sfc_main$B;
8621
- exports.DataSourceSelect = _sfc_main$A;
8622
- exports.EventSelect = _sfc_main$z;
8733
+ exports.DataSourceMethodSelect = _sfc_main$z;
8734
+ exports.DataSourceMethods = _sfc_main$A;
8735
+ exports.DataSourceSelect = _sfc_main$y;
8736
+ exports.EventSelect = _sfc_main$x;
8623
8737
  exports.Fixed2Other = Fixed2Other;
8624
8738
  exports.H_GUIDE_LINE_STORAGE_KEY = H_GUIDE_LINE_STORAGE_KEY;
8625
8739
  exports.Icon = _sfc_main$E;
8626
8740
  exports.KeyBindingCommand = KeyBindingCommand;
8627
- exports.KeyValue = _sfc_main$y;
8741
+ exports.KeyValue = _sfc_main$w;
8628
8742
  exports.Keys = Keys;
8629
8743
  exports.LayerOffset = LayerOffset;
8630
8744
  exports.LayerPanel = _sfc_main$b;
8631
8745
  exports.Layout = Layout;
8632
- exports.LayoutContainer = _sfc_main$u;
8633
- exports.PropsPanel = _sfc_main$p;
8634
- exports.Resizer = _sfc_main$v;
8635
- exports.SplitView = _sfc_main$u;
8636
- exports.TMagicCodeEditor = _sfc_main$w;
8746
+ exports.LayoutContainer = _sfc_main$t;
8747
+ exports.PropsPanel = _sfc_main$o;
8748
+ exports.Resizer = _sfc_main$u;
8749
+ exports.SplitView = _sfc_main$t;
8750
+ exports.TMagicCodeEditor = _sfc_main$K;
8637
8751
  exports.TMagicEditor = Editor;
8638
- exports.ToolButton = _sfc_main$r;
8752
+ exports.ToolButton = _sfc_main$q;
8639
8753
  exports.V_GUIDE_LINE_STORAGE_KEY = V_GUIDE_LINE_STORAGE_KEY;
8640
8754
  exports.beforePaste = beforePaste;
8641
8755
  exports.change2Fixed = change2Fixed;