page-schema-enginer-shun 1.0.4

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