@kp-ui/lowcode 1.0.73 → 1.0.75

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,12 +1,11 @@
1
- import i18n from "../../utils/i18n.js";
2
- import zhCN from "ant-design-vue/es/locale/zh_CN";
3
- import { defineAsyncComponent, resolveComponent, resolveDirective, createBlock, openBlock, mergeProps, withCtx, withDirectives, createElementBlock, createVNode, createElementVNode } from "vue";
1
+ import { defineComponent, defineAsyncComponent, ref, getCurrentInstance, computed, onBeforeUnmount, resolveDirective, createBlock, openBlock, unref, withCtx, createVNode, mergeProps, withDirectives, createElementBlock, nextTick } from "vue";
2
+ import { useComRef, TpfConfigProvider, TpfModal, http } from "tmgc2-share";
4
3
  import _sfc_main$1 from "./SubmitButtonRender.vue.js";
5
- /* empty css */
6
- import _export_sfc from "../../../_virtual/_plugin-vue_export-helper.js";
7
- const _sfc_main = {
8
- name: "dynamic-dialog",
9
- mixins: [i18n],
4
+ const _sfc_main = /* @__PURE__ */ defineComponent({
5
+ ...{
6
+ name: "dynamic-dialog"
7
+ },
8
+ __name: "dynamic-dialog",
10
9
  props: {
11
10
  options: {
12
11
  type: Object,
@@ -46,220 +45,208 @@ const _sfc_main = {
46
45
  default: null
47
46
  }
48
47
  },
49
- components: {
50
- SubmitButtonRender: _sfc_main$1,
51
- VFormRender: defineAsyncComponent(() => import("./index.vue.js"))
52
- },
53
- data() {
54
- const elLocaleMap = {
55
- "zh-CN": { ...zhCN },
56
- "en-US": {}
57
- };
58
- return {
59
- isSubmitting: false,
60
- // 添加提交状态标记
61
- isClosing: false,
62
- // 添加关闭状态标记
63
- isLoading: false,
64
- dialogVisible: false,
65
- elLocaleMap
66
- };
67
- },
68
- created() {
69
- },
70
- computed: {
71
- elLocale() {
72
- const curLocale = localStorage.getItem("lowcode_local") || "zh-CN";
73
- return this.elLocaleMap[curLocale];
74
- },
75
- parentForm() {
48
+ setup(__props, { expose: __expose }) {
49
+ var _a;
50
+ const VFormRender = defineAsyncComponent(() => import("./index.vue.js"));
51
+ const props = __props;
52
+ const isLoading = ref(false);
53
+ const dialogVisible = ref(false);
54
+ const dFormRef = useComRef(VFormRender);
55
+ const currentInstance = (_a = getCurrentInstance()) == null ? void 0 : _a.proxy;
56
+ const parentForm = computed(() => {
76
57
  return {
77
- ...this.parentFormRef,
78
- parentDom: this,
79
- getParentFormRef: this.getParentFormRef
58
+ ...props.parentFormRef,
59
+ parentDom: currentInstance,
60
+ getParentFormRef
80
61
  };
81
- },
82
- otherAttrs() {
83
- if (this.options.cancelButtonHidden && this.options.okButtonHidden) {
62
+ });
63
+ const otherAttrs = computed(() => {
64
+ if (props.options.cancelButtonHidden && props.options.okButtonHidden) {
84
65
  return { footer: null };
85
66
  }
86
67
  return {};
87
- },
88
- cancelBtnLabel() {
89
- return this.options.cancelButtonLabel || this.i18nt("designer.hint.cancel");
90
- },
91
- okBtnLabel() {
92
- return this.options.okButtonLabel || this.i18nt("designer.hint.confirm");
93
- }
94
- },
95
- mounted() {
96
- },
97
- beforeUnmount() {
98
- console.log(this.parentFormRef);
99
- this.parentFormRef.setChildFormRef(null);
100
- },
101
- methods: {
102
- async loadFormCode() {
103
- if (this.options.formCode) {
104
- this.isLoading = true;
68
+ });
69
+ onBeforeUnmount(() => {
70
+ console.log(props.parentFormRef);
71
+ props.parentFormRef.setChildFormRef(null);
72
+ });
73
+ const loadFormCode = async () => {
74
+ if (props.options.formCode) {
75
+ isLoading.value = true;
105
76
  try {
106
- const res = await this.$http.get(`/api/tmgc2-query/dataQuery/detail/FormDefinitionManagement`, {
107
- params: { code: this.options.formCode }
77
+ const res = await http.get(`/api/tmgc2-query/dataQuery/detail/FormDefinitionManagement`, {
78
+ params: { code: props.options.formCode }
108
79
  }).then((res2) => res2.data.object.frontendDefinition || "{}");
109
80
  const formJson = JSON.parse(res);
110
81
  console.log("formJson: ", formJson);
111
- this.$refs.dFormRef.setFormJson(formJson);
82
+ dFormRef.value.setFormJson(formJson);
112
83
  } catch (error) {
113
84
  }
114
- this.isLoading = false;
85
+ isLoading.value = false;
115
86
  }
116
- },
117
- setLoading(status) {
87
+ };
88
+ const setLoading = (status) => {
118
89
  console.log("setLoading", status);
119
- this.isLoading = status;
120
- },
121
- setFormJson(formJson) {
122
- this.$refs.dFormRef.setFormJson(formJson);
123
- },
124
- setTitle(title) {
125
- this.options.title = title;
126
- },
127
- beforeOpen() {
128
- this.dialogVisible = true;
129
- },
130
- show() {
131
- this.dialogVisible = true;
132
- this.$nextTick(() => {
133
- var _a;
134
- if (!!this.options.readMode) {
135
- this.$refs["dFormRef"].setReadMode(true);
90
+ isLoading.value = status;
91
+ };
92
+ const setFormJson = (formJson) => {
93
+ dFormRef.value.setFormJson(formJson);
94
+ };
95
+ const setTitle = (title) => {
96
+ props.options.title = title;
97
+ };
98
+ const beforeOpen = () => {
99
+ dialogVisible.value = true;
100
+ };
101
+ const show = () => {
102
+ dialogVisible.value = true;
103
+ nextTick(() => {
104
+ var _a2;
105
+ if (!!props.options.readMode) {
106
+ dFormRef.value.setReadMode(true);
136
107
  }
137
- this.loadFormCode();
138
- (_a = this.$refs["dFormRef"]) == null ? void 0 : _a.setDialogOrDrawerRef(this);
139
- if (this.parentFormRef) {
140
- this.parentFormRef.setChildFormRef(this.$refs["dFormRef"]);
108
+ loadFormCode();
109
+ console.log(dFormRef.value);
110
+ (_a2 = dFormRef.value) == null ? void 0 : _a2.setDialogOrDrawerRef(currentInstance);
111
+ if (props.parentFormRef) {
112
+ props.parentFormRef.setChildFormRef(dFormRef.value);
141
113
  }
142
- this.handleOpenedEvent();
114
+ handleOpenedEvent();
143
115
  });
144
- },
145
- close() {
146
- if (!!this.options.onDialogBeforeClose) {
147
- const customFn = new Function("done", this.options.onDialogBeforeClose);
148
- const closeResult = customFn.call(this);
116
+ };
117
+ const close = () => {
118
+ if (!!props.options.onDialogBeforeClose) {
119
+ const customFn = new Function("done", props.options.onDialogBeforeClose);
120
+ const closeResult = customFn.call(currentInstance);
149
121
  if (closeResult === false) {
150
122
  return;
151
123
  }
152
124
  }
153
- this.dialogVisible = false;
154
- setTimeout(this.deleteWrapperNode, 150);
155
- },
156
- deleteWrapperNode() {
157
- const wrapperNode = document.getElementById(
158
- "vf-dynamic-dialog-wrapper" + this.wrapperId
159
- );
125
+ dialogVisible.value = false;
126
+ setTimeout(deleteWrapperNode, 150);
127
+ };
128
+ const deleteWrapperNode = () => {
129
+ const wrapperNode = document.getElementById("vf-dynamic-dialog-wrapper" + props.wrapperId);
160
130
  if (!!wrapperNode) {
161
131
  document.body.removeChild(wrapperNode);
162
132
  }
163
- },
164
- handleBeforeClose() {
165
- if (!!this.options.onDialogBeforeClose) {
166
- const customFn = new Function(this.options.onDialogBeforeClose);
167
- return customFn.call(this);
133
+ };
134
+ const handleBeforeClose = () => {
135
+ if (!!props.options.onDialogBeforeClose) {
136
+ const customFn = new Function(props.options.onDialogBeforeClose);
137
+ return customFn.call(currentInstance);
168
138
  }
169
139
  return true;
170
- },
171
- handleCloseEvent() {
172
- if (!this.handleBeforeClose()) return;
173
- this.dialogVisible = false;
174
- setTimeout(this.deleteWrapperNode, 150);
175
- },
176
- handleOpenedEvent() {
177
- if (!!this.options.onDialogOpened) {
178
- const customFn = new Function(this.options.onDialogOpened);
179
- customFn.call(this);
140
+ };
141
+ const handleCloseEvent = () => {
142
+ if (!handleBeforeClose()) return;
143
+ dialogVisible.value = false;
144
+ setTimeout(deleteWrapperNode, 150);
145
+ };
146
+ const handleOpenedEvent = () => {
147
+ if (!!props.options.onDialogOpened) {
148
+ const customFn = new Function(props.options.onDialogOpened);
149
+ customFn.call(currentInstance);
180
150
  }
181
- },
182
- getParentFormRef() {
183
- return this.parentFormRef;
184
- },
185
- getFormRef() {
151
+ };
152
+ const getParentFormRef = () => {
153
+ return props.parentFormRef;
154
+ };
155
+ const getFormRef = () => {
186
156
  console.log("getFormRef");
187
- return this.$refs["dFormRef"];
188
- },
189
- getWidgetRef(widgetName, showError = false) {
190
- return this.$refs["dFormRef"].getWidgetRef(widgetName, showError);
191
- },
192
- updateTable() {
193
- var _a, _b, _c;
194
- if ((_c = (_b = (_a = this.vfCtx) == null ? void 0 : _a.parent) == null ? void 0 : _b.exposed) == null ? void 0 : _c.updateTable) {
195
- this.vfCtx.parent.exposed.updateTable();
157
+ return dFormRef.value;
158
+ };
159
+ const getWidgetRef = (widgetName, showError = false) => {
160
+ return dFormRef.value.getWidgetRef(widgetName, showError);
161
+ };
162
+ const updateTable = () => {
163
+ var _a2, _b, _c;
164
+ if ((_c = (_b = (_a2 = props.vfCtx) == null ? void 0 : _a2.parent) == null ? void 0 : _b.exposed) == null ? void 0 : _c.updateTable) {
165
+ props.vfCtx.parent.exposed.updateTable();
196
166
  }
197
- },
198
- getExtraData() {
199
- return this.extraData;
200
- }
167
+ };
168
+ const getExtraData = () => {
169
+ return props.extraData;
170
+ };
171
+ __expose({
172
+ loadFormCode,
173
+ setLoading,
174
+ setFormJson,
175
+ setTitle,
176
+ beforeOpen,
177
+ show,
178
+ close,
179
+ deleteWrapperNode,
180
+ handleBeforeClose,
181
+ handleCloseEvent,
182
+ handleOpenedEvent,
183
+ getParentFormRef,
184
+ getFormRef,
185
+ getWidgetRef,
186
+ updateTable,
187
+ getExtraData
188
+ });
189
+ return (_ctx, _cache) => {
190
+ const _directive_loading = resolveDirective("loading");
191
+ return openBlock(), createBlock(unref(TpfConfigProvider), null, {
192
+ default: withCtx(() => [
193
+ createVNode(unref(TpfModal), mergeProps({
194
+ class: "tpf-model design-model",
195
+ transitionName: !dialogVisible.value ? "" : "zoom",
196
+ maskTransitionName: !dialogVisible.value ? "" : "fade",
197
+ destroyOnClose: true,
198
+ title: __props.options.title,
199
+ bodyStyle: {
200
+ height: __props.options.height,
201
+ overflow: "auto",
202
+ ...JSON.parse(__props.options.bodyStyle || "{}")
203
+ },
204
+ centered: true,
205
+ visible: dialogVisible.value,
206
+ "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => dialogVisible.value = $event),
207
+ width: __props.options.width,
208
+ mask: __props.options.showModal,
209
+ maskClosable: __props.options.closeOnClickModal,
210
+ keyboard: __props.options.closeOnPressEscape,
211
+ onCancel: handleCloseEvent
212
+ }, otherAttrs.value), {
213
+ footerRight: withCtx(() => [
214
+ createVNode(_sfc_main$1, {
215
+ "dialog-visible": dialogVisible.value,
216
+ "onUpdate:dialogVisible": _cache[0] || (_cache[0] = ($event) => dialogVisible.value = $event),
217
+ handleBeforeClose,
218
+ deleteWrapperNode,
219
+ options: __props.options,
220
+ ctx: unref(currentInstance)
221
+ }, null, 8, ["dialog-visible", "options", "ctx"])
222
+ ]),
223
+ default: withCtx(() => [
224
+ withDirectives((openBlock(), createElementBlock("div", { class: "dialog-content" }, [
225
+ createVNode(unref(VFormRender), {
226
+ isLoading: isLoading.value,
227
+ ref_key: "dFormRef",
228
+ ref: dFormRef,
229
+ "form-json": __props.formJson,
230
+ "form-data": __props.formData,
231
+ vfCtx: __props.vfCtx,
232
+ "option-data": __props.optionData,
233
+ "global-dsv": __props.globalDsv,
234
+ "parent-form": parentForm.value,
235
+ "disabled-mode": __props.options.disabledMode,
236
+ "dynamic-creation": true
237
+ }, null, 8, ["isLoading", "form-json", "form-data", "vfCtx", "option-data", "global-dsv", "parent-form", "disabled-mode"])
238
+ ])), [
239
+ [_directive_loading, isLoading.value]
240
+ ])
241
+ ]),
242
+ _: 1
243
+ }, 16, ["transitionName", "maskTransitionName", "title", "bodyStyle", "visible", "width", "mask", "maskClosable", "keyboard"])
244
+ ]),
245
+ _: 1
246
+ });
247
+ };
201
248
  }
202
- };
203
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
204
- const _component_VFormRender = resolveComponent("VFormRender");
205
- const _component_SubmitButtonRender = resolveComponent("SubmitButtonRender");
206
- const _component_a_modal = resolveComponent("a-modal");
207
- const _directive_loading = resolveDirective("loading");
208
- return openBlock(), createBlock(_component_a_modal, mergeProps({
209
- class: "tpf-model design-model",
210
- transitionName: !$data.dialogVisible ? "" : "zoom",
211
- maskTransitionName: !$data.dialogVisible ? "" : "fade",
212
- destroyOnClose: true,
213
- title: $props.options.title,
214
- bodyStyle: {
215
- height: $props.options.height,
216
- overflow: "auto",
217
- ...JSON.parse(this.options.bodyStyle || "{}")
218
- },
219
- centered: true,
220
- visible: $data.dialogVisible,
221
- "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => $data.dialogVisible = $event),
222
- width: $props.options.width,
223
- mask: $props.options.showModal,
224
- maskClosable: $props.options.closeOnClickModal,
225
- keyboard: $props.options.closeOnPressEscape,
226
- onCancel: $options.handleCloseEvent
227
- }, $options.otherAttrs), {
228
- footer: withCtx(() => [
229
- createElementVNode("div", { class: "footer-left" }),
230
- createElementVNode("div", { class: "footer-right" }, [
231
- createVNode(_component_SubmitButtonRender, {
232
- "dialog-visible": $data.dialogVisible,
233
- "onUpdate:dialogVisible": _cache[0] || (_cache[0] = ($event) => $data.dialogVisible = $event),
234
- handleBeforeClose: $options.handleBeforeClose,
235
- deleteWrapperNode: $options.deleteWrapperNode,
236
- options: $props.options,
237
- ctx: this
238
- }, null, 8, ["dialog-visible", "handleBeforeClose", "deleteWrapperNode", "options"])
239
- ])
240
- ]),
241
- default: withCtx(() => [
242
- withDirectives((openBlock(), createElementBlock("div", { class: "dialog-content" }, [
243
- createVNode(_component_VFormRender, {
244
- isLoading: $data.isLoading,
245
- ref: "dFormRef",
246
- "form-json": $props.formJson,
247
- "form-data": $props.formData,
248
- vfCtx: $props.vfCtx,
249
- "option-data": $props.optionData,
250
- "global-dsv": $props.globalDsv,
251
- "parent-form": $options.parentForm,
252
- "disabled-mode": $props.options.disabledMode,
253
- "dynamic-creation": true
254
- }, null, 8, ["isLoading", "form-json", "form-data", "vfCtx", "option-data", "global-dsv", "parent-form", "disabled-mode"])
255
- ])), [
256
- [_directive_loading, $data.isLoading]
257
- ])
258
- ]),
259
- _: 1
260
- }, 16, ["transitionName", "maskTransitionName", "title", "bodyStyle", "visible", "width", "mask", "maskClosable", "keyboard", "onCancel"]);
261
- }
262
- const DynamicDialog = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
249
+ });
263
250
  export {
264
- DynamicDialog as default
251
+ _sfc_main as default
265
252
  };
@@ -0,0 +1,4 @@
1
+ import _sfc_main from "./dynamic-dialog.vue.js";
2
+ export {
3
+ _sfc_main as default
4
+ };
@@ -3,7 +3,7 @@ import emitter from "../../utils/emitter.js";
3
3
  import comps from "../form-designer/form-widget/field-widget/index.js";
4
4
  import { buildDefaultFormJson, getContainerWidgetByName, cloneFormConfigWithoutEventHandler, deepClone, getDSByName, overwriteObj, runDataSourceRequest, getAllContainerWidgets, getAllFieldWidgets, getDefaultFormConfig, traverseFieldWidgets, getFieldWidgetByName, traverseFieldWidgetsOfContainer, insertCustomCssToHead, insertGlobalFunctionsToHtml, generateId } from "../../utils/util.js";
5
5
  import i18n, { changeLocale } from "../../utils/i18n.js";
6
- import DynamicDialog from "./dynamic-dialog.vue.js";
6
+ import _sfc_main$1 from "./dynamic-dialog.vue.js";
7
7
  import DynamicDrawer from "./dynamic-drawer.vue.js";
8
8
  import { fmtHttpParams } from "../../utils/request/fmtHttpParams.js";
9
9
  /* empty css */
@@ -946,7 +946,7 @@ const _sfc_main = {
946
946
  formConfig: cloneFormConfigWithoutEventHandler(topFormRef.formConfig)
947
947
  };
948
948
  const wrapperDivId = generateId() + "";
949
- const dialogInstance = h(DynamicDialog, {
949
+ const dialogInstance = h(_sfc_main$1, {
950
950
  options: dialogCon.options,
951
951
  formJson: dFormJson,
952
952
  formData: { ...formData },
@@ -963,7 +963,7 @@ const _sfc_main = {
963
963
  document.body.appendChild(wrapperDiv);
964
964
  render(dialogInstance, wrapperDiv);
965
965
  document.body.appendChild(dialogInstance.el);
966
- dialogInstance.component.ctx.show();
966
+ dialogInstance.component.exposed.show();
967
967
  },
968
968
  showDrawer(drawerName, formData = {}, extraData = {}) {
969
969
  const topFormRef = this.getTopFormRef();
@@ -1071,7 +1071,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
1071
1071
  _: 3
1072
1072
  }, 8, ["spinning"]);
1073
1073
  }
1074
- const VFormRender = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-88794663"]]);
1074
+ const VFormRender = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-5d8bcc8a"]]);
1075
1075
  export {
1076
1076
  VFormRender as default
1077
1077
  };
@@ -1,6 +1,6 @@
1
1
  import { defineAsyncComponent, createApp, createVNode, mergeProps } from "vue";
2
2
  import { TpfConfigProvider } from "tmgc2-share";
3
- const openCustomerModal = (ops, useMountApp) => {
3
+ const openCustomerModal = (ops) => {
4
4
  console.log("ops: ", ops);
5
5
  const {
6
6
  type,
@@ -26,7 +26,9 @@ const openCustomerModal = (ops, useMountApp) => {
26
26
  onCancel
27
27
  }, args), null)]
28
28
  }));
29
- useMountApp(modal);
29
+ if (window.useMountApp) {
30
+ window.useMountApp(modal);
31
+ }
30
32
  modal.mount(div);
31
33
  };
32
34
  export {
@@ -49,6 +49,7 @@ function createI18n(options) {
49
49
  return message !== null ? message : get(messages, path2);
50
50
  },
51
51
  async setLang(lang) {
52
+ console.log({ lang });
52
53
  locale.lang = lang;
53
54
  if (!(lang in locale.messages)) {
54
55
  if (lang in langLoaders) {
@@ -56,6 +57,7 @@ function createI18n(options) {
56
57
  locale.messages[lang] = messages;
57
58
  }
58
59
  }
60
+ console.log(locale.messages);
59
61
  locale.lang = lang;
60
62
  }
61
63
  };