page-schema-enginer-shun 1.0.4 → 1.0.6

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