@kp-ui/lowcode 1.0.85 → 1.0.86

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.
@@ -1,13 +1,13 @@
1
1
  if (typeof window !== "undefined") {
2
2
  let loadSvg = function() {
3
3
  var body = document.body;
4
- var svgDom = document.getElementById("lowcodeDomId");
4
+ var svgDom = document.getElementById("lowcodeSvgDom");
5
5
  if (!svgDom) {
6
6
  svgDom = document.createElementNS("http://www.w3.org/2000/svg", "svg");
7
7
  svgDom.style.position = "absolute";
8
8
  svgDom.style.width = "0";
9
9
  svgDom.style.height = "0";
10
- svgDom.id = "lowcodeDomId";
10
+ svgDom.id = "lowcodeSvgDom";
11
11
  svgDom.setAttribute("xmlns", "http://www.w3.org/2000/svg");
12
12
  svgDom.setAttribute("xmlns:link", "http://www.w3.org/1999/xlink");
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kp-ui/lowcode",
3
- "version": "1.0.85",
3
+ "version": "1.0.86",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -23,12 +23,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
23
23
  const emit = __emit;
24
24
  const [codeEditorRef, openCodeEditor] = useOpenAntdModal();
25
25
  const open = (value) => {
26
- console.log({ value });
27
26
  currentCode.value = value;
28
27
  code.value = value;
29
28
  openCodeEditor();
30
29
  };
31
30
  const hanldeSave = (value) => {
31
+ console.log({ value });
32
32
  emit("save", value);
33
33
  code.value = value;
34
34
  };
@@ -1,7 +1,7 @@
1
1
  import _sfc_main from "./index.vue2.js";
2
2
  /* empty css */
3
3
  import _export_sfc from "../../../_virtual/_plugin-vue_export-helper.js";
4
- const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-d6ceeb37"]]);
4
+ const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-b8286917"]]);
5
5
  export {
6
6
  CodeEditor as default
7
7
  };
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, computed, watch, watchEffect, onMounted, createElementBlock, openBlock, createElementVNode } from "vue";
1
+ import { defineComponent, ref, watchEffect, onMounted, resolveDirective, withDirectives, createElementBlock, openBlock, createElementVNode, nextTick } from "vue";
2
2
  const _hoisted_1 = { class: "ace-container" };
3
3
  const themePath = "ace/theme/sqlserver";
4
4
  const modePath = "ace/mode/javascript";
@@ -6,25 +6,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
6
6
  __name: "index",
7
7
  props: {
8
8
  value: {},
9
- modelValue: {},
10
9
  readonly: { type: Boolean },
11
10
  mode: {},
12
11
  userWorker: { type: Boolean }
13
12
  },
14
- emits: ["update:modelValue", "update:value"],
13
+ emits: ["update:value"],
15
14
  setup(__props, { expose: __expose, emit: __emit }) {
16
15
  const props = __props;
17
16
  const emit = __emit;
18
- const aceRef = ref(null);
17
+ const aceRef = ref();
19
18
  const aceEditor = ref(null);
20
- const stop = ref(false);
21
- const codeValue = computed(() => props.value || props.modelValue);
22
19
  const isLoading = ref(false);
23
- const setValue = (newValue) => {
24
- if (aceEditor.value) {
25
- aceEditor.value.getSession().setValue(newValue);
26
- }
27
- };
28
20
  const getEditorAnnotations = () => {
29
21
  var _a;
30
22
  return (_a = aceEditor.value) == null ? void 0 : _a.getSession().getAnnotations();
@@ -69,16 +61,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
69
61
  }
70
62
  });
71
63
  };
72
- watch(
73
- () => props.value,
74
- (val) => {
75
- if (stop.value) return;
76
- if (val) {
77
- setValue(val);
78
- stop.value = true;
79
- }
80
- }
81
- );
82
64
  const initEditor = async () => {
83
65
  isLoading.value = true;
84
66
  const ace = await import("ace-builds");
@@ -97,10 +79,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
97
79
  await import("ace-builds/src-min-noconflict/mode-groovy");
98
80
  }
99
81
  addAutoCompletion(ace);
82
+ await nextTick();
83
+ if (!aceRef.value) {
84
+ return;
85
+ }
100
86
  aceEditor.value = ace.edit(aceRef.value, {
101
- maxLines: 20,
102
- // 最大行数,超过会自动出现滚动条
103
- minLines: 5,
87
+ minLines: 10,
104
88
  // 最小行数,还未到最大行数时,编辑器会自动伸缩大小
105
89
  fontSize: 12,
106
90
  // 编辑器内字体大小
@@ -108,11 +92,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
108
92
  // 默认设置的主题
109
93
  mode: modePath,
110
94
  // 默认设置的语言模式
111
- tabSize: 2,
95
+ tabSize: 4,
112
96
  // 制表符设置为2个空格大小
113
97
  readOnly: props.readonly,
114
- highlightActiveLine: true,
115
- value: codeValue.value
98
+ highlightActiveLine: true
116
99
  });
117
100
  aceEditor.value.setOptions({
118
101
  enableBasicAutocompletion: true,
@@ -128,9 +111,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
128
111
  } else if (props.mode === "groovy") {
129
112
  setGroovyMode();
130
113
  }
114
+ aceEditor.value.setValue(props.value || "");
131
115
  aceEditor.value.getSession().on("change", (ev) => {
132
116
  var _a, _b;
133
- emit("update:modelValue", (_a = aceEditor.value) == null ? void 0 : _a.getValue());
117
+ console.log((_a = aceEditor.value) == null ? void 0 : _a.getValue());
134
118
  emit("update:value", (_b = aceEditor.value) == null ? void 0 : _b.getValue());
135
119
  });
136
120
  isLoading.value = false;
@@ -144,6 +128,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
144
128
  });
145
129
  });
146
130
  onMounted(() => {
131
+ console.log(121212121333);
147
132
  initEditor();
148
133
  });
149
134
  __expose({
@@ -151,12 +136,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
151
136
  getEditorAnnotations
152
137
  });
153
138
  return (_ctx, _cache) => {
154
- return openBlock(), createElementBlock("div", _hoisted_1, [
139
+ const _directive_loading = resolveDirective("loading");
140
+ return withDirectives((openBlock(), createElementBlock("div", _hoisted_1, [
155
141
  createElementVNode("div", {
156
142
  class: "ace-editor",
157
143
  ref_key: "aceRef",
158
144
  ref: aceRef
159
145
  }, null, 512)
146
+ ])), [
147
+ [_directive_loading, isLoading.value]
160
148
  ]);
161
149
  };
162
150
  }
@@ -92,7 +92,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
92
92
  _: 1
93
93
  }, 8, ["designer", "field", "rules", "design-state", "parent-widget", "parent-list", "index-of-parent-list", "sub-form-row-index", "sub-form-col-index", "sub-form-row-id"])) : createCommentVNode("", true);
94
94
  }
95
- const fileUploadWidget = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-baef62a7"]]);
95
+ const fileUploadWidget = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-6de0a3ab"]]);
96
96
  export {
97
97
  fileUploadWidget as default
98
98
  };
@@ -137,6 +137,9 @@ const _sfc_main = {
137
137
  }
138
138
  },
139
139
  async handlePreview(file) {
140
+ if (file.fileCode) {
141
+ return this.$message.error("文件上传完才能预览!");
142
+ }
140
143
  if ([".png", ".jpg", ".jpeg", ".gif"].includes(file.fileType)) {
141
144
  const url = await this.getFileUrl(file.fileCode);
142
145
  this.previewImage = url;
@@ -1,7 +1,8 @@
1
- import { defineComponent, ref, resolveComponent, createElementBlock, openBlock, Fragment, createVNode, withCtx, normalizeClass, createTextVNode, toDisplayString, unref } from "vue";
1
+ import { defineComponent, ref, resolveComponent, createElementBlock, openBlock, Fragment, createVNode, withCtx, normalizeClass, createTextVNode, toDisplayString, unref, createElementVNode } from "vue";
2
2
  import { useI18n } from "../../utils/i18n.js";
3
+ import CodeEditor from "../code-editor/index.vue.js";
3
4
  import { message } from "ant-design-vue";
4
- import { useOpenAntdModal, TpfCodeEditor } from "tmgc2-share";
5
+ const _hoisted_1 = { class: "dialog-footer" };
5
6
  const _sfc_main = /* @__PURE__ */ defineComponent({
6
7
  __name: "methoad-item",
7
8
  props: {
@@ -16,15 +17,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
16
17
  const { i18nt } = useI18n();
17
18
  const props = __props;
18
19
  const emit = __emit;
19
- const [codeEditorRef, openTpfCodeEditor] = useOpenAntdModal();
20
+ const ecEditor = ref();
20
21
  const formEventHandlerCode = ref("");
21
22
  const showFormEventDialogFlag = ref(false);
22
23
  const editFormEventHandler = (eventName) => {
23
24
  formEventHandlerCode.value = props.formConfig[eventName];
24
- openTpfCodeEditor();
25
+ showFormEventDialogFlag.value = true;
25
26
  };
26
27
  const saveFormEventHandler = () => {
27
- const codeHints = codeEditorRef.value.ecEditor.getEditorAnnotations();
28
+ const codeHints = ecEditor.value.getEditorAnnotations();
28
29
  let syntaxErrorFlag = false;
29
30
  if (!!codeHints && codeHints.length > 0) {
30
31
  codeHints.forEach((chItem) => {
@@ -43,6 +44,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
43
44
  return (_ctx, _cache) => {
44
45
  const _component_a_button = resolveComponent("a-button");
45
46
  const _component_a_form_item = resolveComponent("a-form-item");
47
+ const _component_a_alert = resolveComponent("a-alert");
48
+ const _component_a_modal = resolveComponent("a-modal");
46
49
  return openBlock(), createElementBlock(Fragment, null, [
47
50
  createVNode(_component_a_form_item, {
48
51
  label: _ctx.eventName,
@@ -64,15 +67,61 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
64
67
  ]),
65
68
  _: 1
66
69
  }, 8, ["label"]),
67
- createVNode(unref(TpfCodeEditor), {
68
- modelValue: formEventHandlerCode.value,
69
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => formEventHandlerCode.value = $event),
70
- mode: "javascript",
71
- ref_key: "codeEditorRef",
72
- ref: codeEditorRef,
73
- eventHeader: "form." + _ctx.eventParamsMap[_ctx.eventName],
74
- onSetCode: saveFormEventHandler
75
- }, null, 8, ["modelValue", "eventHeader"])
70
+ createVNode(_component_a_modal, {
71
+ title: unref(i18nt)("designer.setting.editFormEventHandler"),
72
+ visible: showFormEventDialogFlag.value,
73
+ "onUpdate:visible": _cache[3] || (_cache[3] = ($event) => showFormEventDialogFlag.value = $event),
74
+ "show-close": true,
75
+ "custom-class": "drag-dialog small-padding-dialog",
76
+ "append-to-body": "",
77
+ "close-on-click-modal": false,
78
+ "close-on-press-escape": false,
79
+ "destroy-on-close": true,
80
+ width: 800
81
+ }, {
82
+ footer: withCtx(() => [
83
+ createElementVNode("div", _hoisted_1, [
84
+ createVNode(_component_a_button, {
85
+ onClick: _cache[2] || (_cache[2] = ($event) => showFormEventDialogFlag.value = false)
86
+ }, {
87
+ default: withCtx(() => [
88
+ createTextVNode(toDisplayString(unref(i18nt)("designer.hint.cancel")), 1)
89
+ ]),
90
+ _: 1
91
+ }),
92
+ createVNode(_component_a_button, {
93
+ type: "primary",
94
+ onClick: saveFormEventHandler
95
+ }, {
96
+ default: withCtx(() => [
97
+ createTextVNode(toDisplayString(unref(i18nt)("designer.hint.confirm")), 1)
98
+ ]),
99
+ _: 1
100
+ })
101
+ ])
102
+ ]),
103
+ default: withCtx(() => [
104
+ createVNode(_component_a_alert, {
105
+ type: "info",
106
+ closable: false,
107
+ message: "form." + _ctx.eventParamsMap[_ctx.eventName]
108
+ }, null, 8, ["message"]),
109
+ createVNode(CodeEditor, {
110
+ mode: "javascript",
111
+ readonly: false,
112
+ modelValue: formEventHandlerCode.value,
113
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => formEventHandlerCode.value = $event),
114
+ ref_key: "ecEditor",
115
+ ref: ecEditor
116
+ }, null, 8, ["modelValue"]),
117
+ createVNode(_component_a_alert, {
118
+ type: "info",
119
+ closable: false,
120
+ message: "}"
121
+ })
122
+ ]),
123
+ _: 1
124
+ }, 8, ["title", "visible"])
76
125
  ], 64);
77
126
  };
78
127
  }