page-schema-enginer-shun 1.0.4 → 1.0.5

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 (68) hide show
  1. package/README.md +52 -0
  2. package/dist/{style.css → assets/schema-table-BxLEkFw6.css} +3 -12
  3. package/dist/assets/schema-table.vue_vue_type_style_index_0_scoped_63be3fb0_lang-BquQx2nc.js +7 -0
  4. package/dist/assets/schema-table.vue_vue_type_style_index_0_scoped_63be3fb0_lang-BquQx2nc.js.map +1 -0
  5. package/dist/assets/schema-table.vue_vue_type_style_index_0_scoped_63be3fb0_lang-aLF0PCVN.js +8 -0
  6. package/dist/assets/schema-table.vue_vue_type_style_index_0_scoped_63be3fb0_lang-aLF0PCVN.js.map +1 -0
  7. package/dist/assets/schema-view-bW-stnbi.css +10 -0
  8. package/dist/assets/wigdets-klW8Cf0W.css +4 -0
  9. package/dist/entrypoints/http.d.ts +4 -0
  10. package/dist/entrypoints/schema-view.d.ts +7 -0
  11. package/dist/entrypoints/wigdets.d.ts +11 -0
  12. package/dist/http/client.d.ts +2 -0
  13. package/dist/http.cjs.js +2 -0
  14. package/dist/http.cjs.js.map +1 -0
  15. package/dist/http.d.ts +1 -0
  16. package/dist/http.es.js +2 -0
  17. package/dist/http.es.js.map +1 -0
  18. package/dist/index.cjs.js +7 -1414
  19. package/dist/index.cjs.js.map +1 -1
  20. package/dist/index.d.ts +5 -3
  21. package/dist/index.es.js +7 -1415
  22. package/dist/index.es.js.map +1 -1
  23. package/dist/schema-view/router/index.d.ts +8 -0
  24. package/dist/schema-view.cjs.js +9 -0
  25. package/dist/schema-view.cjs.js.map +1 -0
  26. package/dist/schema-view.d.ts +3 -0
  27. package/dist/schema-view.es.js +8 -0
  28. package/dist/schema-view.es.js.map +1 -0
  29. package/dist/wigdets/operation-panel/operation-panel.vue.d.ts +2 -0
  30. package/dist/wigdets.cjs.js +7 -0
  31. package/dist/wigdets.cjs.js.map +1 -0
  32. package/dist/wigdets.d.ts +1 -0
  33. package/dist/wigdets.es.js +6 -0
  34. package/dist/wigdets.es.js.map +1 -0
  35. package/package.json +20 -2
  36. package/dist/index.umd.js +0 -1415
  37. package/dist/index.umd.js.map +0 -1
  38. package/dist/src/index.d.ts +0 -5
  39. package/dist/vite.config.d.ts +0 -2
  40. /package/dist/{src/hooks → hooks}/useSchema.d.ts +0 -0
  41. /package/dist/{src/http → http}/index.d.ts +0 -0
  42. /package/dist/{src/main.d.ts → main.d.ts} +0 -0
  43. /package/dist/{src/pinia → pinia}/modules/user.d.ts +0 -0
  44. /package/dist/{src/router.d.ts → router.d.ts} +0 -0
  45. /package/dist/{src/schema-view → schema-view}/complex-view/search-panel/search-panel.vue.d.ts +0 -0
  46. /package/dist/{src/schema-view → schema-view}/complex-view/table-panel/table-panel.vue.d.ts +0 -0
  47. /package/dist/{src/schema-view → schema-view}/components/component-config.d.ts +0 -0
  48. /package/dist/{src/schema-view → schema-view}/components/createForm/createForm.vue.d.ts +0 -0
  49. /package/dist/{src/schema-view → schema-view}/components/editForm/editForm.vue.d.ts +0 -0
  50. /package/dist/{src/schema-view → schema-view}/hooks/useSchema.d.ts +0 -0
  51. /package/dist/{src/schema-view → schema-view}/schema-view.vue.d.ts +0 -0
  52. /package/dist/{src/schema-view → schema-view}/type.d.ts +0 -0
  53. /package/dist/{src/utils → utils}/request.d.ts +0 -0
  54. /package/dist/{src/wigdets → wigdets}/schema-form/complex-view/form-item-config.d.ts +0 -0
  55. /package/dist/{src/wigdets → wigdets}/schema-form/complex-view/input/input.vue.d.ts +0 -0
  56. /package/dist/{src/wigdets → wigdets}/schema-form/complex-view/input-number/input-number.vue.d.ts +0 -0
  57. /package/dist/{src/wigdets → wigdets}/schema-form/complex-view/radio/radio.vue.d.ts +0 -0
  58. /package/dist/{src/wigdets → wigdets}/schema-form/complex-view/select/select.vue.d.ts +0 -0
  59. /package/dist/{src/wigdets → wigdets}/schema-form/schema-form.vue.d.ts +0 -0
  60. /package/dist/{src/wigdets → wigdets}/schema-search/complex-view/input/input.vue.d.ts +0 -0
  61. /package/dist/{src/wigdets → wigdets}/schema-search/schema-item-config.d.ts +0 -0
  62. /package/dist/{src/wigdets → wigdets}/schema-search/schema-search-bar.vue.d.ts +0 -0
  63. /package/dist/{src/wigdets → wigdets}/schema-table/schema-table.vue.d.ts +0 -0
  64. /package/dist/{src/wigdets → wigdets}/schema-table/schema-view/format-date/format-date.vue.d.ts +0 -0
  65. /package/dist/{src/wigdets → wigdets}/schema-table/schema-view/format-enum/format-enum.vue.d.ts +0 -0
  66. /package/dist/{src/wigdets → wigdets}/schema-table/schema-view/schema-table-item-config.d.ts +0 -0
  67. /package/dist/{src/wigdets → wigdets}/schema-table/schema-view/tag/tag.vue.d.ts +0 -0
  68. /package/dist/{src/wigdets → wigdets}/utls/date.d.ts +0 -0
package/dist/index.umd.js DELETED
@@ -1,1415 +0,0 @@
1
- (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue"), require("vue-router"), require("pinia"), require("ajv"), require("element-plus")) : typeof define === "function" && define.amd ? define(["exports", "vue", "vue-router", "pinia", "ajv", "element-plus"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.PageSchemaEngine = {}, global.Vue, global.vueRouter, global.pinia, global.Ajv, global.elementPlus));
3
- })(this, function(exports2, vue, vueRouter, pinia, Ajv, elementPlus) {
4
- "use strict";
5
- const useUserStore = pinia.defineStore("user", {
6
- state: () => ({
7
- name: "DemoUser"
8
- })
9
- });
10
- const _hoisted_1$b = { class: "schema-form-input-container" };
11
- const _hoisted_2$5 = { class: "schema-form-input" };
12
- const _hoisted_3$3 = { class: "schema-form-input-item-label" };
13
- const _hoisted_4$2 = { key: 0 };
14
- const _hoisted_5 = {
15
- key: 0,
16
- style: { "color": "red", "margin-top": "10px" }
17
- };
18
- const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
19
- __name: "input",
20
- props: ["model", "ItemKey", "schema"],
21
- setup(__props, { expose: __expose }) {
22
- const ajvInstance = vue.inject("ajvInstance");
23
- const dataValue = vue.ref();
24
- const tipsMessage = vue.ref(null);
25
- const valid = () => {
26
- var _a;
27
- if (((_a = __props.schema.option) == null ? void 0 : _a.required) && !dataValue.value) {
28
- tipsMessage.value = "请输入";
29
- return false;
30
- }
31
- const validate = ajvInstance.compile(__props.schema);
32
- const valid2 = validate(dataValue.value);
33
- console.log(valid2, validate.errors);
34
- if (!valid2 && validate.errors && validate.errors[0]) {
35
- if (validate.errors[0].keyword == "minLength") {
36
- tipsMessage.value = "最小长度为" + validate.errors[0].params.limit;
37
- }
38
- return false;
39
- }
40
- return true;
41
- };
42
- vue.watch(
43
- () => __props.model,
44
- () => {
45
- initData();
46
- }
47
- );
48
- const onBlur = () => {
49
- valid();
50
- };
51
- const onFocus = () => {
52
- tipsMessage.value = null;
53
- };
54
- const getValue = () => {
55
- return dataValue.value !== void 0 ? { [__props.ItemKey]: dataValue.value } : {};
56
- };
57
- const initData = () => {
58
- var _a;
59
- dataValue.value = __props.model ?? ((_a = __props.schema.option) == null ? void 0 : _a.default);
60
- tipsMessage.value = null;
61
- };
62
- const reset = () => {
63
- dataValue.value = void 0;
64
- };
65
- vue.onMounted(() => {
66
- initData();
67
- });
68
- __expose({
69
- valid,
70
- getValue,
71
- reset
72
- });
73
- return (_ctx, _cache) => {
74
- var _a, _b;
75
- const _component_el_input = vue.resolveComponent("el-input");
76
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
77
- vue.createElementVNode("div", _hoisted_2$5, [
78
- vue.createElementVNode("span", _hoisted_3$3, vue.toDisplayString((_a = __props.schema) == null ? void 0 : _a.label), 1),
79
- ((_b = __props.schema.option) == null ? void 0 : _b.required) ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_4$2, "*")) : vue.createCommentVNode("", true),
80
- vue.createVNode(_component_el_input, vue.mergeProps({
81
- modelValue: dataValue.value,
82
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => dataValue.value = $event)
83
- }, __props.schema.option, {
84
- onBlur,
85
- onFocus
86
- }), null, 16, ["modelValue"])
87
- ]),
88
- tipsMessage.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_5, vue.toDisplayString(tipsMessage.value), 1)) : vue.createCommentVNode("", true)
89
- ]);
90
- };
91
- }
92
- });
93
- const _export_sfc = (sfc, props) => {
94
- const target = sfc.__vccOpts || sfc;
95
- for (const [key, val] of props) {
96
- target[key] = val;
97
- }
98
- return target;
99
- };
100
- const input = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-5d94c475"]]);
101
- const _hoisted_1$a = { class: "schema-form-radio-container" };
102
- const _hoisted_2$4 = { class: "schema-form-radio" };
103
- const _hoisted_3$2 = { class: "schema-form-radio-label" };
104
- const _hoisted_4$1 = { key: 0 };
105
- const _sfc_main$e = /* @__PURE__ */ vue.defineComponent({
106
- __name: "radio",
107
- props: ["model", "ItemKey", "schema"],
108
- setup(__props, { expose: __expose }) {
109
- const radioData = vue.ref();
110
- const enumerate = vue.ref([]);
111
- const tip = vue.ref();
112
- vue.watch(
113
- () => __props.model,
114
- () => {
115
- buildData();
116
- }
117
- );
118
- const getValue = () => {
119
- return radioData.value !== void 0 ? { [__props.ItemKey]: radioData.value } : {};
120
- };
121
- const buildData = () => {
122
- var _a, _b;
123
- tip.value = null;
124
- enumerate.value = ((_a = __props.schema.option) == null ? void 0 : _a.enumList) || [];
125
- radioData.value = __props.model ?? ((_b = __props.schema.option) == null ? void 0 : _b.default);
126
- };
127
- const valid = () => {
128
- if (radioData.value !== void 0) {
129
- return true;
130
- }
131
- tip.value = "请选择一项";
132
- return false;
133
- };
134
- vue.onMounted(() => {
135
- buildData();
136
- });
137
- const reset = () => {
138
- radioData.value = void 0;
139
- };
140
- __expose({
141
- getValue,
142
- valid,
143
- reset
144
- });
145
- return (_ctx, _cache) => {
146
- const _component_el_radio = vue.resolveComponent("el-radio");
147
- const _component_el_radio_group = vue.resolveComponent("el-radio-group");
148
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, [
149
- vue.createElementVNode("div", _hoisted_2$4, [
150
- vue.createElementVNode("span", _hoisted_3$2, vue.toDisplayString(__props.schema.label), 1),
151
- vue.createVNode(_component_el_radio_group, {
152
- modelValue: radioData.value,
153
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => radioData.value = $event)
154
- }, {
155
- default: vue.withCtx(() => [
156
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(enumerate.value, (item) => {
157
- return vue.openBlock(), vue.createBlock(_component_el_radio, {
158
- key: item.value,
159
- value: item.value,
160
- size: "large"
161
- }, {
162
- default: vue.withCtx(() => [
163
- vue.createTextVNode(vue.toDisplayString(item.label), 1)
164
- ]),
165
- _: 2
166
- }, 1032, ["value"]);
167
- }), 128))
168
- ]),
169
- _: 1
170
- }, 8, ["modelValue"]),
171
- tip.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4$1, vue.toDisplayString(tip.value), 1)) : vue.createCommentVNode("", true)
172
- ])
173
- ]);
174
- };
175
- }
176
- });
177
- const radio = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-844b46ca"]]);
178
- const _hoisted_1$9 = { class: "schema-form-input-number-container" };
179
- const _hoisted_2$3 = { class: "schema-form-input-number" };
180
- const _hoisted_3$1 = { class: "schema-form-input-number-label" };
181
- const _sfc_main$d = /* @__PURE__ */ vue.defineComponent({
182
- __name: "input-number",
183
- props: ["model", "ItemKey", "schema"],
184
- setup(__props, { expose: __expose }) {
185
- const num = vue.ref(0);
186
- const tip = vue.ref();
187
- const getValue = () => {
188
- return num.value !== void 0 ? { [__props.ItemKey]: num.value } : {};
189
- };
190
- const buildData = () => {
191
- var _a;
192
- tip.value = null;
193
- num.value = __props.model ?? ((_a = __props.schema.option) == null ? void 0 : _a.default);
194
- };
195
- const valid = () => {
196
- if (num.value !== void 0) {
197
- return true;
198
- }
199
- tip.value = "请选择一项";
200
- return false;
201
- };
202
- const handleChange = () => {
203
- };
204
- const reset = () => {
205
- num.value = 0;
206
- };
207
- vue.onMounted(() => {
208
- buildData();
209
- });
210
- __expose({
211
- getValue,
212
- valid,
213
- reset
214
- });
215
- return (_ctx, _cache) => {
216
- const _component_el_input_number = vue.resolveComponent("el-input-number");
217
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
218
- vue.createElementVNode("div", _hoisted_2$3, [
219
- vue.createElementVNode("div", _hoisted_3$1, vue.toDisplayString(__props.schema.label), 1),
220
- vue.createVNode(_component_el_input_number, vue.mergeProps({
221
- modelValue: num.value,
222
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => num.value = $event)
223
- }, __props.schema.option, { onChange: handleChange }), null, 16, ["modelValue"])
224
- ])
225
- ]);
226
- };
227
- }
228
- });
229
- const inputNumber = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-be909ea6"]]);
230
- const _hoisted_1$8 = { class: "schema-form-select-container" };
231
- const _hoisted_2$2 = { class: "schema-form-select" };
232
- const _hoisted_3 = { class: "schema-form-select-label" };
233
- const _hoisted_4 = { key: 0 };
234
- const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
235
- __name: "select",
236
- props: ["model", "ItemKey", "schema"],
237
- setup(__props, { expose: __expose }) {
238
- const selectData = vue.ref();
239
- const enumerate = vue.ref([]);
240
- const tip = vue.ref();
241
- vue.watch(
242
- () => __props.model,
243
- () => {
244
- buildData();
245
- }
246
- );
247
- const getValue = () => {
248
- return selectData.value !== void 0 ? { [__props.ItemKey]: selectData.value } : {};
249
- };
250
- const buildData = () => {
251
- var _a, _b;
252
- tip.value = null;
253
- enumerate.value = ((_a = __props.schema.option) == null ? void 0 : _a.enumList) || [];
254
- selectData.value = __props.model ?? ((_b = __props.schema.option) == null ? void 0 : _b.default);
255
- };
256
- const valid = () => {
257
- if (selectData.value !== void 0) {
258
- return true;
259
- }
260
- tip.value = "请选择一项";
261
- return false;
262
- };
263
- vue.onMounted(() => {
264
- buildData();
265
- });
266
- const reset = () => {
267
- selectData.value = void 0;
268
- };
269
- __expose({
270
- getValue,
271
- valid,
272
- reset
273
- });
274
- return (_ctx, _cache) => {
275
- const _component_el_option = vue.resolveComponent("el-option");
276
- const _component_el_select = vue.resolveComponent("el-select");
277
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
278
- vue.createElementVNode("div", _hoisted_2$2, [
279
- vue.createElementVNode("span", _hoisted_3, vue.toDisplayString(__props.schema.label), 1),
280
- vue.createVNode(_component_el_select, {
281
- modelValue: selectData.value,
282
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => selectData.value = $event),
283
- placeholder: "请选择"
284
- }, {
285
- default: vue.withCtx(() => [
286
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(enumerate.value, (item) => {
287
- return vue.openBlock(), vue.createBlock(_component_el_option, {
288
- key: item.value,
289
- label: item.label,
290
- value: item.value
291
- }, null, 8, ["label", "value"]);
292
- }), 128))
293
- ]),
294
- _: 1
295
- }, 8, ["modelValue"]),
296
- tip.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4, vue.toDisplayString(tip.value), 1)) : vue.createCommentVNode("", true)
297
- ])
298
- ]);
299
- };
300
- }
301
- });
302
- const select = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-65d85e93"]]);
303
- const formItemConfig = {
304
- input: {
305
- component: input
306
- },
307
- radio: {
308
- component: radio
309
- },
310
- inputNumber: {
311
- component: inputNumber
312
- },
313
- select: {
314
- component: select
315
- }
316
- };
317
- const _hoisted_1$7 = {
318
- key: 0,
319
- class: "schema-form-complex-view"
320
- };
321
- const _sfc_main$b = /* @__PURE__ */ vue.defineComponent({
322
- __name: "schema-form",
323
- props: {
324
- schema: {},
325
- model: {}
326
- },
327
- setup(__props, { expose: __expose }) {
328
- const ajvInstance = new Ajv({ strict: false });
329
- const formItemListRef = vue.ref([]);
330
- const resolveFormItemComponent = (comType) => {
331
- var _a;
332
- if (!comType) return null;
333
- return ((_a = formItemConfig[comType]) == null ? void 0 : _a.component) ?? null;
334
- };
335
- const getValue = () => {
336
- let dtoObj = {};
337
- (formItemListRef.value || []).forEach((item) => {
338
- if (item && typeof item.getValue === "function") {
339
- dtoObj = { ...dtoObj, ...item.getValue() };
340
- }
341
- });
342
- return dtoObj;
343
- };
344
- const valid = () => {
345
- return (formItemListRef.value || []).every(
346
- (item) => item && typeof item.valid === "function" && item.valid()
347
- );
348
- };
349
- const reset = () => {
350
- (formItemListRef.value || []).forEach((item) => {
351
- if (item && typeof item.reset === "function") item.reset();
352
- });
353
- };
354
- __expose({
355
- valid,
356
- getValue,
357
- reset
358
- });
359
- vue.provide("ajvInstance", ajvInstance);
360
- return (_ctx, _cache) => {
361
- return __props.schema && __props.schema.properties ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, [
362
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.schema.properties, (value, key) => {
363
- var _a, _b;
364
- return vue.openBlock(), vue.createElementBlock(vue.Fragment, { key }, [
365
- resolveFormItemComponent((_a = value.option) == null ? void 0 : _a.comType) ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(resolveFormItemComponent((_b = value.option) == null ? void 0 : _b.comType)), {
366
- key: 0,
367
- ref_for: true,
368
- ref_key: "formItemListRef",
369
- ref: formItemListRef,
370
- model: __props.model ? __props.model[key] : void 0,
371
- ItemKey: key,
372
- schema: value
373
- }, null, 8, ["model", "ItemKey", "schema"])) : vue.createCommentVNode("", true)
374
- ], 64);
375
- }), 128))
376
- ])) : vue.createCommentVNode("", true);
377
- };
378
- }
379
- });
380
- const schemaForm = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-81b6c9bb"]]);
381
- let requestFn = null;
382
- function setRequestClient(fn) {
383
- requestFn = fn;
384
- }
385
- function request(options) {
386
- if (!requestFn) throw new Error("请先使用 setRequestClient 注册请求客户端");
387
- console.log("requestrequestrequest");
388
- return requestFn(options);
389
- }
390
- const _hoisted_1$6 = { class: "createForm" };
391
- const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
392
- __name: "createForm",
393
- emits: ["command"],
394
- setup(__props, { expose: __expose, emit: __emit }) {
395
- const { components, api } = vue.inject("schemeViewData");
396
- const emit = __emit;
397
- const schemaFormRef = vue.ref(null);
398
- const submit = async () => {
399
- var _a;
400
- const values = (_a = schemaFormRef.value) == null ? void 0 : _a.getValue();
401
- console.log(values);
402
- if (!api.add) return;
403
- const res = await request({
404
- url: api.add,
405
- method: "post",
406
- data: values
407
- });
408
- if (!res || !res.data) return;
409
- elementPlus.ElNotification({
410
- title: "Title",
411
- message: "添加成功"
412
- });
413
- close();
414
- emit("command", { event: "loadTableData" });
415
- };
416
- const name = vue.ref("createForm");
417
- const isShow = vue.ref(false);
418
- const show = () => {
419
- isShow.value = true;
420
- };
421
- const close = () => {
422
- var _a;
423
- isShow.value = false;
424
- (_a = schemaFormRef.value) == null ? void 0 : _a.reset();
425
- };
426
- vue.onMounted(() => {
427
- });
428
- __expose({
429
- name,
430
- show
431
- });
432
- vueRouter.useRouter();
433
- vueRouter.useRoute();
434
- useUserStore();
435
- return (_ctx, _cache) => {
436
- const _component_el_button = vue.resolveComponent("el-button");
437
- const _component_el_dialog = vue.resolveComponent("el-dialog");
438
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
439
- vue.createVNode(_component_el_dialog, {
440
- modelValue: isShow.value,
441
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isShow.value = $event),
442
- title: "新建",
443
- width: "600"
444
- }, {
445
- default: vue.withCtx(() => {
446
- var _a, _b;
447
- return [
448
- vue.createVNode(schemaForm, {
449
- ref_key: "schemaFormRef",
450
- ref: schemaFormRef,
451
- schema: (_a = vue.unref(components)[name.value]) == null ? void 0 : _a.schema,
452
- config: (_b = vue.unref(components)[name.value]) == null ? void 0 : _b.config
453
- }, null, 8, ["schema", "config"])
454
- ];
455
- }),
456
- footer: vue.withCtx(() => [
457
- vue.createVNode(_component_el_button, {
458
- type: "primary",
459
- onClick: submit
460
- }, {
461
- default: vue.withCtx(() => [..._cache[1] || (_cache[1] = [
462
- vue.createTextVNode("提交", -1)
463
- ])]),
464
- _: 1
465
- }),
466
- vue.createVNode(_component_el_button, {
467
- type: "primary",
468
- onClick: close
469
- }, {
470
- default: vue.withCtx(() => [..._cache[2] || (_cache[2] = [
471
- vue.createTextVNode("取消", -1)
472
- ])]),
473
- _: 1
474
- })
475
- ]),
476
- _: 1
477
- }, 8, ["modelValue"])
478
- ]);
479
- };
480
- }
481
- });
482
- const createFormC = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-7f4df64c"]]);
483
- const _hoisted_1$5 = { class: "editForm" };
484
- const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
485
- __name: "editForm",
486
- emits: ["command"],
487
- setup(__props, { expose: __expose, emit: __emit }) {
488
- const { components, api } = vue.inject("schemeViewData");
489
- const emit = __emit;
490
- const isDrawer = vue.ref(false);
491
- const name = vue.ref("editForm");
492
- const model = vue.ref();
493
- const mainKey = vue.ref();
494
- const show = async (rowData) => {
495
- var _a, _b;
496
- mainKey.value = (_b = (_a = components.value[name.value]) == null ? void 0 : _a.config) == null ? void 0 : _b.mainKey;
497
- model.value = rowData;
498
- isDrawer.value = true;
499
- };
500
- const close = () => {
501
- isDrawer.value = false;
502
- model.value = null;
503
- };
504
- const schemaFormRef = vue.ref(null);
505
- const submit = () => {
506
- var _a, _b;
507
- if (!((_a = schemaFormRef.value) == null ? void 0 : _a.valid())) return;
508
- const data = (_b = schemaFormRef.value) == null ? void 0 : _b.getValue();
509
- if (!api.update) return;
510
- request({
511
- url: api.update,
512
- method: "put",
513
- data: {
514
- [mainKey.value]: model.value[mainKey.value],
515
- ...data
516
- }
517
- }).then((res) => {
518
- elementPlus.ElNotification({
519
- message: "修改成功",
520
- type: "success"
521
- });
522
- close();
523
- emit("command", {
524
- event: "loadTableData"
525
- });
526
- });
527
- };
528
- vue.onMounted(() => {
529
- });
530
- __expose({
531
- show,
532
- name,
533
- close
534
- });
535
- vueRouter.useRouter();
536
- vueRouter.useRoute();
537
- useUserStore();
538
- return (_ctx, _cache) => {
539
- const _component_el_button = vue.resolveComponent("el-button");
540
- const _component_el_dialog = vue.resolveComponent("el-dialog");
541
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$5, [
542
- vue.createVNode(_component_el_dialog, {
543
- modelValue: isDrawer.value,
544
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isDrawer.value = $event),
545
- title: "编辑",
546
- width: "600"
547
- }, {
548
- default: vue.withCtx(() => {
549
- var _a, _b;
550
- return [
551
- vue.createVNode(schemaForm, {
552
- ref_key: "schemaFormRef",
553
- ref: schemaFormRef,
554
- schema: (_a = vue.unref(components)[name.value]) == null ? void 0 : _a.schema,
555
- config: (_b = vue.unref(components)[name.value]) == null ? void 0 : _b.config,
556
- model: model.value
557
- }, null, 8, ["schema", "config", "model"])
558
- ];
559
- }),
560
- footer: vue.withCtx(() => [
561
- vue.createVNode(_component_el_button, {
562
- type: "primary",
563
- onClick: submit
564
- }, {
565
- default: vue.withCtx(() => [..._cache[1] || (_cache[1] = [
566
- vue.createTextVNode("修改", -1)
567
- ])]),
568
- _: 1
569
- })
570
- ]),
571
- _: 1
572
- }, 8, ["modelValue"])
573
- ]);
574
- };
575
- }
576
- });
577
- const componentConfig = {
578
- createForm: {
579
- component: createFormC
580
- },
581
- editForm: {
582
- component: _sfc_main$9
583
- }
584
- };
585
- let requestAdapter;
586
- const service = async (config) => {
587
- return requestAdapter(config);
588
- };
589
- const _sfc_main$8 = /* @__PURE__ */ vue.defineComponent({
590
- __name: "tag",
591
- props: {
592
- row: {
593
- type: Object,
594
- default: () => {
595
- }
596
- },
597
- column: {
598
- type: Object,
599
- default: () => {
600
- }
601
- },
602
- index: {
603
- type: Number,
604
- default: 0
605
- },
606
- itemKey: {
607
- type: String,
608
- default: ""
609
- }
610
- },
611
- setup(__props) {
612
- return (_ctx, _cache) => {
613
- return vue.openBlock(), vue.createElementBlock("div", null, vue.toDisplayString(__props.row[__props.itemKey]), 1);
614
- };
615
- }
616
- });
617
- const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
618
- __name: "format-enum",
619
- props: {
620
- row: {
621
- type: Object,
622
- default: () => {
623
- }
624
- },
625
- column: {
626
- type: Object,
627
- default: () => {
628
- }
629
- },
630
- index: {
631
- type: Number,
632
- default: 0
633
- },
634
- itemKey: {
635
- type: String,
636
- default: ""
637
- }
638
- },
639
- setup(__props) {
640
- const enumeration = vue.ref([]);
641
- const getLabel = (value) => {
642
- var _a;
643
- if (enumeration.value && enumeration.value.length > 0) {
644
- const item = (_a = enumeration.value) == null ? void 0 : _a.find((item2) => item2.value == value);
645
- if (!item) return;
646
- return item == null ? void 0 : item.label;
647
- }
648
- return null;
649
- };
650
- vue.watch([__props.row, __props.column, __props.index, __props.itemKey], (newVal) => {
651
- initData();
652
- });
653
- const initData = () => {
654
- var _a, _b;
655
- enumeration.value = ((_b = (_a = __props.column.option) == null ? void 0 : _a.formatEnumConfig) == null ? void 0 : _b.enumeration) || [];
656
- };
657
- vue.onMounted(() => {
658
- initData();
659
- });
660
- return (_ctx, _cache) => {
661
- return vue.openBlock(), vue.createElementBlock("div", null, [
662
- vue.createElementVNode("div", null, vue.toDisplayString(getLabel(__props.row[__props.itemKey])), 1)
663
- ]);
664
- };
665
- }
666
- });
667
- function formatDate(input2, pattern = "yyyy-MM-dd hh:mm:ss") {
668
- const date = input2 instanceof Date ? input2 : new Date(input2);
669
- const map = {
670
- "M+": date.getMonth() + 1,
671
- "d+": date.getDate(),
672
- "h+": date.getHours(),
673
- "m+": date.getMinutes(),
674
- "s+": date.getSeconds(),
675
- "q+": Math.floor((date.getMonth() + 3) / 3),
676
- S: date.getMilliseconds()
677
- };
678
- let result = pattern;
679
- if (/(y+)/.test(result)) {
680
- result = result.replace(
681
- RegExp.$1,
682
- (date.getFullYear() + "").substr(4 - RegExp.$1.length)
683
- );
684
- }
685
- for (const k in map) {
686
- if (new RegExp("(" + k + ")").test(result)) {
687
- const val = map[k];
688
- result = result.replace(
689
- RegExp.$1,
690
- RegExp.$1.length === 1 ? String(val) : ("00" + val).substr(("" + val).length)
691
- );
692
- }
693
- }
694
- return result;
695
- }
696
- const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
697
- __name: "format-date",
698
- props: {
699
- row: {
700
- type: Object,
701
- default: () => {
702
- }
703
- },
704
- column: {
705
- type: Object,
706
- default: () => {
707
- }
708
- },
709
- index: {
710
- type: Number,
711
- default: 0
712
- },
713
- itemKey: {
714
- type: String,
715
- default: ""
716
- }
717
- },
718
- setup(__props) {
719
- const getDate = (value) => {
720
- var _a, _b;
721
- const formatString = ((_b = (_a = __props.column.option) == null ? void 0 : _a.formatDateConfig) == null ? void 0 : _b.formatString) || "yyyy-MM-dd hh:mm:ss";
722
- return formatDate(value, formatString);
723
- };
724
- vue.watch([__props.row, __props.column, __props.index, __props.itemKey], (newVal) => {
725
- });
726
- return (_ctx, _cache) => {
727
- return vue.openBlock(), vue.createElementBlock("div", null, [
728
- vue.createElementVNode("div", null, vue.toDisplayString(getDate(__props.row[__props.itemKey])), 1)
729
- ]);
730
- };
731
- }
732
- });
733
- const tableConfig = {
734
- tag: {
735
- component: _sfc_main$8
736
- },
737
- formatEnum: {
738
- component: _sfc_main$7
739
- },
740
- formatDate: {
741
- component: _sfc_main$6
742
- }
743
- };
744
- const _hoisted_1$4 = { class: "schema-table" };
745
- const _hoisted_2$1 = { class: "gva-pagination" };
746
- const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
747
- __name: "schema-table",
748
- props: {
749
- schema: {},
750
- api: {},
751
- buttons: {},
752
- apiParms: {}
753
- },
754
- emits: ["operate"],
755
- setup(__props, { expose: __expose, emit: __emit }) {
756
- const emit = __emit;
757
- const tableData = vue.ref([]);
758
- const pageSize = vue.ref(10);
759
- const currentPage = vue.ref(1);
760
- const total = vue.ref(0);
761
- const loading = vue.ref(false);
762
- const operationWidth = vue.computed(() => {
763
- var _a;
764
- return ((_a = __props.buttons) == null ? void 0 : _a.length) > 0 ? __props.buttons.reduce((prev, cur) => prev + cur.label.length * 40, 50) : 50;
765
- });
766
- const buildComponetnName = (comTypeName) => {
767
- var _a;
768
- const componentName = (_a = tableConfig[comTypeName]) == null ? void 0 : _a.component;
769
- return componentName || "";
770
- };
771
- const fetDatbleData = async () => {
772
- var _a, _b, _c, _d;
773
- if (!__props.api.getList) {
774
- return;
775
- }
776
- if (loading.value) return;
777
- showLoding();
778
- const res = await service({
779
- url: __props.api.getList,
780
- method: "get",
781
- params: {
782
- ...__props.apiParms,
783
- page: currentPage.value,
784
- pageSize: pageSize.value
785
- }
786
- });
787
- hideLoding();
788
- if (!res || !res.data) {
789
- return;
790
- }
791
- tableData.value = buildTableData(res.data.list) || [];
792
- total.value = Number(
793
- ((_a = res.data) == null ? void 0 : _a.total) ?? ((_b = res.data) == null ? void 0 : _b.count) ?? ((_d = (_c = res.data) == null ? void 0 : _c.pagination) == null ? void 0 : _d.total) ?? 0
794
- );
795
- };
796
- const initData = () => {
797
- currentPage.value = 1;
798
- pageSize.value = 10;
799
- total.value = 0;
800
- vue.nextTick(async () => {
801
- await loadTableData();
802
- });
803
- };
804
- const operatetionHandler = ({ btnConfig, rowData }) => {
805
- emit("operate", { btnConfig, rowData });
806
- };
807
- const onPageSizeChange = async (val) => {
808
- console.log(val, "onPageSizeChange");
809
- pageSize.value = val;
810
- await loadTableData();
811
- };
812
- const onCureentPage = async (val) => {
813
- console.log(val, "onCureentPage");
814
- currentPage.value = val;
815
- await loadTableData();
816
- };
817
- const buildTableData = (listData) => {
818
- var _a;
819
- if (!((_a = __props.schema) == null ? void 0 : _a.properties)) return listData;
820
- return listData.map((dataItem) => {
821
- var _a2;
822
- for (const key in dataItem) {
823
- const schemaItem = __props.schema.properties[key];
824
- if (((_a2 = schemaItem == null ? void 0 : schemaItem.options) == null ? void 0 : _a2.tofixed) && typeof dataItem[key] === "number") {
825
- dataItem[key] = dataItem[key].toFixed(schemaItem.options.tofixed);
826
- }
827
- }
828
- return dataItem;
829
- });
830
- };
831
- let timer = null;
832
- const loadTableData = async () => {
833
- clearTimeout(timer);
834
- timer = setTimeout(async () => {
835
- await fetDatbleData();
836
- timer = null;
837
- }, 100);
838
- };
839
- const showLoding = () => {
840
- loading.value = true;
841
- };
842
- const hideLoding = () => {
843
- loading.value = false;
844
- };
845
- vue.watch(
846
- () => [__props.schema, __props.api, __props.apiParms],
847
- () => {
848
- initData();
849
- }
850
- );
851
- vue.onMounted(() => {
852
- initData();
853
- });
854
- __expose({
855
- initData,
856
- loadTableData,
857
- showLoding,
858
- hideLoding
859
- });
860
- vueRouter.useRouter();
861
- vueRouter.useRoute();
862
- useUserStore();
863
- return (_ctx, _cache) => {
864
- const _component_el_table_column = vue.resolveComponent("el-table-column");
865
- const _component_el_button = vue.resolveComponent("el-button");
866
- const _component_el_table = vue.resolveComponent("el-table");
867
- const _component_el_pagination = vue.resolveComponent("el-pagination");
868
- const _directive_loading = vue.resolveDirective("loading");
869
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$4, [
870
- __props.schema && __props.schema.properties ? vue.withDirectives((vue.openBlock(), vue.createBlock(_component_el_table, {
871
- key: 0,
872
- data: tableData.value,
873
- style: { "width": "100%" },
874
- border: ""
875
- }, {
876
- default: vue.withCtx(() => {
877
- var _a;
878
- return [
879
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.schema.properties, (value, keyItem) => {
880
- var _a2, _b;
881
- return vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: keyItem }, [
882
- ((_a2 = value.option) == null ? void 0 : _a2.visible) !== false ? (vue.openBlock(), vue.createBlock(_component_el_table_column, vue.mergeProps({
883
- key: 0,
884
- prop: keyItem,
885
- label: value.label
886
- }, { ref_for: true }, value.option), vue.createSlots({ _: 2 }, [
887
- ((_b = value.option) == null ? void 0 : _b.comType) ? {
888
- name: "default",
889
- fn: vue.withCtx((scope) => [
890
- (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(buildComponetnName(value.option.comType)), {
891
- row: scope.row,
892
- column: value,
893
- index: scope.$index,
894
- itemKey: keyItem
895
- }, null, 8, ["row", "column", "index", "itemKey"]))
896
- ]),
897
- key: "0"
898
- } : void 0
899
- ]), 1040, ["prop", "label"])) : vue.createCommentVNode("", true)
900
- ], 64);
901
- }), 128)),
902
- ((_a = __props.buttons) == null ? void 0 : _a.length) > 0 ? (vue.openBlock(), vue.createBlock(_component_el_table_column, {
903
- key: 0,
904
- label: "操作",
905
- align: "center",
906
- width: operationWidth.value
907
- }, {
908
- default: vue.withCtx((scope) => [
909
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.buttons, (item, index) => {
910
- return vue.openBlock(), vue.createBlock(_component_el_button, vue.mergeProps({ key: index }, { ref_for: true }, item, {
911
- onClick: ($event) => operatetionHandler({ btnConfig: item, rowData: scope.row })
912
- }), {
913
- default: vue.withCtx(() => [
914
- vue.createTextVNode(vue.toDisplayString(item.label), 1)
915
- ]),
916
- _: 2
917
- }, 1040, ["onClick"]);
918
- }), 128))
919
- ]),
920
- _: 1
921
- }, 8, ["width"])) : vue.createCommentVNode("", true)
922
- ];
923
- }),
924
- _: 1
925
- }, 8, ["data"])), [
926
- [_directive_loading, loading.value]
927
- ]) : vue.createCommentVNode("", true),
928
- vue.createElementVNode("div", _hoisted_2$1, [
929
- vue.createVNode(_component_el_pagination, {
930
- layout: "total, prev, pager, next, sizes",
931
- total: total.value,
932
- "page-size": pageSize.value,
933
- "current-page": currentPage.value,
934
- onSizeChange: onPageSizeChange,
935
- onCurrentChange: onCureentPage
936
- }, null, 8, ["total", "page-size", "current-page"])
937
- ])
938
- ]);
939
- };
940
- }
941
- });
942
- const SchemaTable = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-fb006ee8"]]);
943
- const _hoisted_1$3 = { class: "table-panel" };
944
- const _hoisted_2 = { class: "operation-panel" };
945
- const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
946
- __name: "table-panel",
947
- emits: ["operate"],
948
- setup(__props, { expose: __expose, emit: __emit }) {
949
- const { tableConfig: tableConfig2, tableSchema, api, apiParms } = vue.inject("schemeViewData");
950
- const emit = __emit;
951
- const schemaTableRef = vue.ref();
952
- const handlers = {
953
- addEvent: (payload) => addEvent(payload)
954
- };
955
- const onOperate = ({ btnConfig, rowData = null }) => {
956
- var _a;
957
- console.log("onOperate", btnConfig, rowData);
958
- const { eventKey } = btnConfig;
959
- if (eventKey) (_a = handlers[eventKey]) == null ? void 0 : _a.call(handlers, { btnConfig, rowData });
960
- emit("operate", { btnConfig, rowData });
961
- };
962
- const addEvent = ({ btnConfig, rowData }) => {
963
- console.log("新增按钮");
964
- emit("operate", { btnConfig, rowData });
965
- };
966
- const initTableData = async () => {
967
- var _a;
968
- await ((_a = schemaTableRef == null ? void 0 : schemaTableRef.value) == null ? void 0 : _a.initData());
969
- };
970
- const loadTableData = async () => {
971
- var _a;
972
- await ((_a = schemaTableRef == null ? void 0 : schemaTableRef.value) == null ? void 0 : _a.loadTableData());
973
- };
974
- vue.onMounted(() => {
975
- });
976
- __expose({
977
- initTableData,
978
- loadTableData
979
- });
980
- vueRouter.useRouter();
981
- vueRouter.useRoute();
982
- useUserStore();
983
- return (_ctx, _cache) => {
984
- var _a, _b;
985
- const _component_el_button = vue.resolveComponent("el-button");
986
- const _component_el_row = vue.resolveComponent("el-row");
987
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, [
988
- vue.createElementVNode("div", _hoisted_2, [
989
- ((_a = vue.unref(tableConfig2)) == null ? void 0 : _a.headerButtons.length) > 0 ? (vue.openBlock(), vue.createBlock(_component_el_row, { key: 0 }, {
990
- default: vue.withCtx(() => {
991
- var _a2;
992
- return [
993
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList((_a2 = vue.unref(tableConfig2)) == null ? void 0 : _a2.headerButtons, (buttonItem) => {
994
- return vue.openBlock(), vue.createBlock(_component_el_button, {
995
- key: buttonItem.eventKey,
996
- onClick: ($event) => onOperate({ btnConfig: buttonItem })
997
- }, {
998
- default: vue.withCtx(() => [
999
- vue.createTextVNode(vue.toDisplayString(buttonItem.label), 1)
1000
- ]),
1001
- _: 2
1002
- }, 1032, ["onClick"]);
1003
- }), 128))
1004
- ];
1005
- }),
1006
- _: 1
1007
- })) : vue.createCommentVNode("", true)
1008
- ]),
1009
- vue.createVNode(SchemaTable, {
1010
- ref_key: "schemaTableRef",
1011
- ref: schemaTableRef,
1012
- schema: vue.unref(tableSchema),
1013
- api: vue.unref(api),
1014
- buttons: ((_b = vue.unref(tableConfig2)) == null ? void 0 : _b.rowButtons) ?? [],
1015
- onOperate,
1016
- apiParms: vue.unref(apiParms)
1017
- }, {
1018
- cell: vue.withCtx((slotProps) => [
1019
- vue.renderSlot(_ctx.$slots, "cell", vue.normalizeProps(vue.guardReactiveProps(slotProps)), void 0, true)
1020
- ]),
1021
- _: 3
1022
- }, 8, ["schema", "api", "buttons", "apiParms"])
1023
- ]);
1024
- };
1025
- }
1026
- });
1027
- const tablePanel = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-cef68da3"]]);
1028
- const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
1029
- __name: "input",
1030
- props: {
1031
- schemaKey: {
1032
- type: String,
1033
- default: ""
1034
- },
1035
- schema: {
1036
- type: Object,
1037
- default: () => {
1038
- }
1039
- }
1040
- },
1041
- emits: ["loaded"],
1042
- setup(__props, { expose: __expose, emit: __emit }) {
1043
- const dtoValue = vue.ref();
1044
- const props = __props;
1045
- const getValue = () => {
1046
- return dtoValue.value !== void 0 ? {
1047
- [props.schemaKey]: dtoValue.value
1048
- } : {};
1049
- };
1050
- const reset = () => {
1051
- var _a, _b;
1052
- dtoValue.value = (_b = (_a = props.schema) == null ? void 0 : _a.option) == null ? void 0 : _b.default;
1053
- };
1054
- __expose({
1055
- getValue,
1056
- reset
1057
- });
1058
- return (_ctx, _cache) => {
1059
- const _component_el_input = vue.resolveComponent("el-input");
1060
- return vue.openBlock(), vue.createBlock(_component_el_input, vue.mergeProps({
1061
- type: "text",
1062
- modelValue: dtoValue.value,
1063
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => dtoValue.value = $event)
1064
- }, __props.schema), null, 16, ["modelValue"]);
1065
- };
1066
- }
1067
- });
1068
- const SearchConfig = {
1069
- input: {
1070
- component: _sfc_main$3
1071
- }
1072
- };
1073
- const _hoisted_1$2 = { class: "gva-search-box" };
1074
- const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
1075
- __name: "schema-search-bar",
1076
- props: {
1077
- schema: {},
1078
- schemaConfig: {}
1079
- },
1080
- emits: ["search", "reset", "load", "loaded"],
1081
- setup(__props, { expose: __expose, emit: __emit }) {
1082
- vue.ref(SearchConfig);
1083
- const emit = __emit;
1084
- const props = __props;
1085
- const SearchComList = vue.ref([]);
1086
- const hanleSearchComList = (el) => {
1087
- if (el) SearchComList.value.push(el);
1088
- };
1089
- const getValue = () => {
1090
- let dtoObj = {};
1091
- (SearchComList.value || []).forEach((item) => {
1092
- if (item && typeof item.getValue === "function") {
1093
- dtoObj = {
1094
- ...dtoObj,
1095
- ...item.getValue()
1096
- };
1097
- }
1098
- });
1099
- return dtoObj;
1100
- };
1101
- let childComLocadCount = 0;
1102
- const handleChildLoaded = (el) => {
1103
- childComLocadCount++;
1104
- if (childComLocadCount >= Object.keys(props.schema.properties).length) {
1105
- emit("loaded", getValue());
1106
- }
1107
- };
1108
- const search = () => {
1109
- emit("search", getValue());
1110
- };
1111
- const reset = () => {
1112
- emit("reset");
1113
- (SearchComList.value || []).forEach((item) => {
1114
- if (item && typeof item.reset === "function") item.reset();
1115
- });
1116
- };
1117
- const load = () => {
1118
- emit("load");
1119
- };
1120
- __expose({
1121
- search,
1122
- reset,
1123
- load
1124
- });
1125
- return (_ctx, _cache) => {
1126
- const _component_el_form_item = vue.resolveComponent("el-form-item");
1127
- const _component_el_button = vue.resolveComponent("el-button");
1128
- const _component_el_form = vue.resolveComponent("el-form");
1129
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
1130
- vue.createVNode(_component_el_form, {
1131
- inline: true,
1132
- class: "flex items-center justify-start flex-wrap"
1133
- }, {
1134
- default: vue.withCtx(() => [
1135
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.schema.properties, (value, key) => {
1136
- return vue.openBlock(), vue.createBlock(_component_el_form_item, {
1137
- key,
1138
- label: value.label
1139
- }, {
1140
- default: vue.withCtx(() => [
1141
- value.option.comType ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(SearchConfig)[value.option.comType].component), vue.mergeProps({
1142
- key: 0,
1143
- ref_for: true,
1144
- ref: hanleSearchComList
1145
- }, { ref_for: true }, value.option, {
1146
- onLoaded: handleChildLoaded,
1147
- schema: value,
1148
- schemaKey: key
1149
- }), null, 16, ["schema", "schemaKey"])) : vue.createCommentVNode("", true)
1150
- ]),
1151
- _: 2
1152
- }, 1032, ["label"]);
1153
- }), 128)),
1154
- vue.createVNode(_component_el_form_item, null, {
1155
- default: vue.withCtx(() => [
1156
- vue.createVNode(_component_el_button, {
1157
- type: "primary",
1158
- onClick: search
1159
- }, {
1160
- default: vue.withCtx(() => [..._cache[0] || (_cache[0] = [
1161
- vue.createTextVNode(" 查询 ", -1)
1162
- ])]),
1163
- _: 1
1164
- }),
1165
- vue.createVNode(_component_el_button, { onClick: reset }, {
1166
- default: vue.withCtx(() => [..._cache[1] || (_cache[1] = [
1167
- vue.createTextVNode("重置", -1)
1168
- ])]),
1169
- _: 1
1170
- })
1171
- ]),
1172
- _: 1
1173
- })
1174
- ]),
1175
- _: 1
1176
- })
1177
- ]);
1178
- };
1179
- }
1180
- });
1181
- const _hoisted_1$1 = { class: "search-panel" };
1182
- const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
1183
- __name: "search-panel",
1184
- props: {},
1185
- emits: ["Search", "Reset"],
1186
- setup(__props, { emit: __emit }) {
1187
- const { serachConfig, searchSchema } = vue.inject("schemeViewData");
1188
- const emit = __emit;
1189
- const handleSearch = (Searchobj) => {
1190
- emit("Search", Searchobj);
1191
- };
1192
- vue.onMounted(() => {
1193
- });
1194
- return (_ctx, _cache) => {
1195
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
1196
- vue.createVNode(_sfc_main$2, {
1197
- schema: vue.unref(searchSchema),
1198
- schemaConfig: vue.unref(serachConfig),
1199
- onSearch: handleSearch
1200
- }, null, 8, ["schema", "schemaConfig"])
1201
- ]);
1202
- };
1203
- }
1204
- });
1205
- const searchPanel = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-633fcc6e"]]);
1206
- const useSchema = (schemaConfigDoc) => {
1207
- const {
1208
- api,
1209
- schema,
1210
- tableConfig: tableSchemaConfig,
1211
- searchConfig,
1212
- components: componentsConfig
1213
- } = schemaConfigDoc;
1214
- const tableSchema = vue.ref({ properties: {} });
1215
- const tableConfig2 = vue.ref({
1216
- headerButtons: [],
1217
- rowButtons: []
1218
- });
1219
- const serachConfig = vue.ref({});
1220
- const searchSchema = vue.ref({ properties: {} });
1221
- const components = vue.ref(
1222
- {}
1223
- );
1224
- const buidData = () => {
1225
- tableSchema.value = { properties: {} };
1226
- tableConfig2.value.rowButtons = tableSchemaConfig.rowButtons || [];
1227
- tableConfig2.value.headerButtons = tableSchemaConfig.headerButtons || [];
1228
- serachConfig.value = {};
1229
- searchSchema.value = { properties: {} };
1230
- components.value = {};
1231
- vue.nextTick(() => {
1232
- tableSchema.value = buildDtoSchema(schema, "table");
1233
- tableConfig2.value.headerButtons = tableConfig2.value.headerButtons || [];
1234
- tableConfig2.value.rowButtons = tableConfig2.value.rowButtons || [];
1235
- serachConfig.value = searchConfig;
1236
- searchSchema.value = buildDtoSchema(schema, "search");
1237
- if (componentsConfig && Object.keys(componentsConfig).length > 0) {
1238
- const dtoCompontns = {};
1239
- for (const comKey in componentsConfig) {
1240
- dtoCompontns[comKey] = {
1241
- schema: buildDtoSchema(schema, comKey),
1242
- config: componentsConfig[comKey]
1243
- };
1244
- components.value = dtoCompontns;
1245
- }
1246
- }
1247
- });
1248
- };
1249
- const buildDtoSchema = (_schema, comName) => {
1250
- const dtoSchema = {
1251
- properties: {}
1252
- };
1253
- if (!_schema.properties) return dtoSchema;
1254
- const { require: require2 } = _schema;
1255
- for (const key in _schema.properties) {
1256
- const props = _schema.properties[key];
1257
- if (props[`${comName}Option`]) {
1258
- let dtoProps = {};
1259
- for (const pkey in props) {
1260
- if (pkey.indexOf("Option") < 0) {
1261
- dtoProps[pkey] = props[pkey];
1262
- }
1263
- }
1264
- dtoProps = Object.assign({}, dtoProps, {
1265
- option: props[`${comName}Option`]
1266
- });
1267
- if (require2 && require2.length > 0 && require2.find((vp) => vp === key)) {
1268
- dtoProps.option.required = true;
1269
- }
1270
- dtoSchema.properties[key] = dtoProps;
1271
- }
1272
- }
1273
- return dtoSchema;
1274
- };
1275
- vue.onMounted(() => {
1276
- buidData();
1277
- });
1278
- return {
1279
- api,
1280
- tableSchema,
1281
- tableConfig: tableConfig2,
1282
- serachConfig,
1283
- searchSchema,
1284
- components
1285
- };
1286
- };
1287
- const _hoisted_1 = { class: "schema-view" };
1288
- const _sfc_main = /* @__PURE__ */ vue.defineComponent({
1289
- __name: "schema-view",
1290
- props: {
1291
- config: {}
1292
- },
1293
- setup(__props) {
1294
- const props = __props;
1295
- const {
1296
- api,
1297
- tableSchema,
1298
- tableConfig: tableConfig2,
1299
- serachConfig,
1300
- searchSchema,
1301
- components
1302
- } = useSchema(props.config);
1303
- const apiParms = vue.ref({});
1304
- const componentListRef = vue.ref([]);
1305
- const tablePanelRef = vue.ref(null);
1306
- const handleSearch = (Searchobj) => {
1307
- apiParms.value = Searchobj;
1308
- console.log(Searchobj);
1309
- };
1310
- const handleReset = (Searchobj) => {
1311
- apiParms.value = {};
1312
- console.log(Searchobj);
1313
- };
1314
- const onCommand = (data) => {
1315
- var _a;
1316
- console.log("data", data);
1317
- const { event } = data;
1318
- if (event === "loadTableData") {
1319
- (_a = tablePanelRef.value) == null ? void 0 : _a.loadTableData();
1320
- }
1321
- };
1322
- const remove = async ({ btnConfig, rowData }) => {
1323
- const { parms } = btnConfig.eventOption;
1324
- if (!api.delete) {
1325
- elementPlus.ElMessage.error("未配置删除接口地址");
1326
- return;
1327
- }
1328
- let obj = {};
1329
- const key = Object.keys(parms)[0];
1330
- let skey = parms[key].split("::")[1];
1331
- if (skey) {
1332
- obj = { [skey]: rowData[skey] };
1333
- } else {
1334
- obj = { [key]: parms[key] };
1335
- }
1336
- elementPlus.ElMessageBox.confirm("确认删除该记录吗?", "提示", {
1337
- confirmButtonText: "确定",
1338
- cancelButtonText: "取消",
1339
- type: "warning"
1340
- }).then(async () => {
1341
- var _a;
1342
- if (api == null ? void 0 : api.delete) {
1343
- const res = await request({
1344
- url: api == null ? void 0 : api.delete,
1345
- method: "delete",
1346
- data: obj
1347
- });
1348
- if (res.code === 0) {
1349
- elementPlus.ElMessage.success("删除成功");
1350
- (_a = tablePanelRef.value) == null ? void 0 : _a.loadTableData();
1351
- }
1352
- }
1353
- }).catch(() => {
1354
- });
1355
- };
1356
- const showComponent = ({ btnConfig, rowData = null }) => {
1357
- const { comName } = btnConfig.eventOption;
1358
- if (!comName) return;
1359
- const component = componentListRef.value.find(
1360
- (item) => item.name === comName
1361
- );
1362
- if (!component) return;
1363
- component.show(rowData);
1364
- };
1365
- const EventHandleMap = {
1366
- showComponent,
1367
- remove
1368
- };
1369
- const handleOperate = ({ btnConfig, rowData = null }) => {
1370
- var _a;
1371
- const { eventKey } = btnConfig;
1372
- (_a = EventHandleMap[eventKey]) == null ? void 0 : _a.call(EventHandleMap, { btnConfig, rowData });
1373
- };
1374
- vue.onMounted(() => {
1375
- });
1376
- vue.provide("schemeViewData", {
1377
- tableSchema,
1378
- tableConfig: tableConfig2,
1379
- api,
1380
- serachConfig,
1381
- searchSchema,
1382
- apiParms,
1383
- components
1384
- });
1385
- return (_ctx, _cache) => {
1386
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
1387
- vue.createVNode(searchPanel, {
1388
- onSearch: handleSearch,
1389
- onReset: handleReset
1390
- }),
1391
- vue.createVNode(tablePanel, {
1392
- ref_key: "tablePanelRef",
1393
- ref: tablePanelRef,
1394
- onOperate: handleOperate
1395
- }, null, 512),
1396
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(components), (value, key) => {
1397
- return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(componentConfig)[key].component), {
1398
- ref_for: true,
1399
- ref_key: "componentListRef",
1400
- ref: componentListRef,
1401
- key,
1402
- onCommand
1403
- }, null, 32);
1404
- }), 128))
1405
- ]);
1406
- };
1407
- }
1408
- });
1409
- const SchemaView = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-6aa05693"]]);
1410
- exports2.SchemaView = SchemaView;
1411
- exports2.default = SchemaView;
1412
- exports2.setRequestClient = setRequestClient;
1413
- Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
1414
- });
1415
- //# sourceMappingURL=index.umd.js.map