page-schema-enginer-shun 1.0.7 → 1.0.9

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 (31) hide show
  1. package/README.md +29 -25
  2. package/dist/index.cjs.js +1473 -0
  3. package/dist/index.cjs.js.map +1 -0
  4. package/dist/index.d.ts +18 -5
  5. package/dist/index.es.js +1473 -0
  6. package/dist/index.es.js.map +1 -0
  7. package/dist/index.umd.js +1472 -0
  8. package/dist/index.umd.js.map +1 -0
  9. package/dist/schema-view/complex-view/search-panel/search-panel.vue.d.ts +8 -0
  10. package/dist/schema-view/complex-view/table-panel/table-panel.vue.d.ts +18 -0
  11. package/dist/schema-view/components/createForm/createForm.vue.d.ts +9 -0
  12. package/dist/schema-view/components/editForm/editForm.vue.d.ts +10 -0
  13. package/dist/schema-view/schema-view.vue.d.ts +15 -0
  14. package/dist/style.css +65 -0
  15. package/dist/wigdets/operation-panel/operation-panel.vue.d.ts +2 -0
  16. package/dist/wigdets/schema-form/complex-view/input/input.vue.d.ts +17 -0
  17. package/dist/wigdets/schema-form/complex-view/input-number/input-number.vue.d.ts +17 -0
  18. package/dist/wigdets/schema-form/complex-view/radio/radio.vue.d.ts +17 -0
  19. package/dist/wigdets/schema-form/complex-view/select/select.vue.d.ts +17 -0
  20. package/dist/wigdets/schema-form/schema-form.vue.d.ts +23 -0
  21. package/dist/wigdets/schema-search/complex-view/input/input.vue.d.ts +36 -0
  22. package/dist/wigdets/schema-search/schema-search-bar.vue.d.ts +33 -0
  23. package/dist/wigdets/schema-table/schema-table.vue.d.ts +38 -0
  24. package/dist/wigdets/schema-table/schema-view/format-date/format-date.vue.d.ts +41 -0
  25. package/dist/wigdets/schema-table/schema-view/format-enum/format-enum.vue.d.ts +41 -0
  26. package/dist/wigdets/schema-table/schema-view/tag/tag.vue.d.ts +41 -0
  27. package/package.json +5 -20
  28. package/dist/http.cjs.js +0 -25
  29. package/dist/http.cjs.js.map +0 -1
  30. package/dist/http.es.js +0 -25
  31. package/dist/http.es.js.map +0 -1
@@ -0,0 +1,1473 @@
1
+ import { defineComponent, inject, ref, watch, onMounted, resolveComponent, createElementBlock, openBlock, createElementVNode, createCommentVNode, createVNode, toDisplayString, mergeProps, withCtx, Fragment, renderList, createBlock, createTextVNode, provide, resolveDynamicComponent, unref, toRefs, 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$c = { 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$g = /* @__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$c, [
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$g, [["__scopeId", "data-v-5d94c475"]]);
102
+ const _hoisted_1$b = { 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$f = /* @__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$b, [
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$f, [["__scopeId", "data-v-a791fef4"]]);
179
+ const _hoisted_1$a = { 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$e = /* @__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$a, [
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$e, [["__scopeId", "data-v-44583072"]]);
231
+ const _hoisted_1$9 = { 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$d = /* @__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$9, [
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$d, [["__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$8 = {
319
+ key: 0,
320
+ class: "schema-form-complex-view"
321
+ };
322
+ const _sfc_main$c = /* @__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$8, [
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$c, [["__scopeId", "data-v-0e3bb5f7"]]);
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$7 = { class: "createForm" };
392
+ const _sfc_main$b = /* @__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 || res.code != 0) 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$7, [
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$b, [["__scopeId", "data-v-cb04a018"]]);
484
+ const _hoisted_1$6 = { class: "editForm" };
485
+ const _sfc_main$a = /* @__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$6, [
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$a
584
+ }
585
+ };
586
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
587
+ __name: "tag",
588
+ props: {
589
+ row: {
590
+ type: Object,
591
+ default: () => {
592
+ }
593
+ },
594
+ column: {
595
+ type: Object,
596
+ default: () => {
597
+ }
598
+ },
599
+ index: {
600
+ type: Number,
601
+ default: 0
602
+ },
603
+ itemKey: {
604
+ type: String,
605
+ default: ""
606
+ }
607
+ },
608
+ setup(__props) {
609
+ return (_ctx, _cache) => {
610
+ return openBlock(), createElementBlock("div", null, toDisplayString(__props.row[__props.itemKey]), 1);
611
+ };
612
+ }
613
+ });
614
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
615
+ __name: "format-enum",
616
+ props: {
617
+ row: {
618
+ type: Object,
619
+ default: () => {
620
+ }
621
+ },
622
+ column: {
623
+ type: Object,
624
+ default: () => {
625
+ }
626
+ },
627
+ index: {
628
+ type: Number,
629
+ default: 0
630
+ },
631
+ itemKey: {
632
+ type: String,
633
+ default: ""
634
+ }
635
+ },
636
+ setup(__props) {
637
+ const props = __props;
638
+ const { row, column, index, itemKey } = toRefs(props);
639
+ const enumeration = ref([]);
640
+ const getLabel = (value) => {
641
+ var _a;
642
+ if (enumeration.value && enumeration.value.length > 0) {
643
+ const item = (_a = enumeration.value) == null ? void 0 : _a.find((item2) => item2.value == value);
644
+ if (!item) return;
645
+ return item == null ? void 0 : item.label;
646
+ }
647
+ return null;
648
+ };
649
+ watch([row, column, index, itemKey], (newVal) => {
650
+ initData();
651
+ });
652
+ const initData = () => {
653
+ var _a, _b;
654
+ enumeration.value = ((_b = (_a = column.value.option) == null ? void 0 : _a.formatEnumConfig) == null ? void 0 : _b.enumeration) || [];
655
+ };
656
+ onMounted(() => {
657
+ initData();
658
+ });
659
+ return (_ctx, _cache) => {
660
+ return openBlock(), createElementBlock("div", null, [
661
+ createElementVNode("div", null, toDisplayString(getLabel(unref(row)[unref(itemKey)])), 1)
662
+ ]);
663
+ };
664
+ }
665
+ });
666
+ function formatDate(input2, pattern = "yyyy-MM-dd hh:mm:ss") {
667
+ const date = input2 instanceof Date ? input2 : new Date(input2);
668
+ const map = {
669
+ "M+": date.getMonth() + 1,
670
+ "d+": date.getDate(),
671
+ "h+": date.getHours(),
672
+ "m+": date.getMinutes(),
673
+ "s+": date.getSeconds(),
674
+ "q+": Math.floor((date.getMonth() + 3) / 3),
675
+ S: date.getMilliseconds()
676
+ };
677
+ let result = pattern;
678
+ if (/(y+)/.test(result)) {
679
+ result = result.replace(
680
+ RegExp.$1,
681
+ (date.getFullYear() + "").substr(4 - RegExp.$1.length)
682
+ );
683
+ }
684
+ for (const k in map) {
685
+ if (new RegExp("(" + k + ")").test(result)) {
686
+ const val = map[k];
687
+ result = result.replace(
688
+ RegExp.$1,
689
+ RegExp.$1.length === 1 ? String(val) : ("00" + val).substr(("" + val).length)
690
+ );
691
+ }
692
+ }
693
+ return result;
694
+ }
695
+ function formatTimeToStr(times, pattern) {
696
+ return formatDate(times, pattern ?? "yyyy-MM-dd hh:mm:ss");
697
+ }
698
+ function computedAge(birthday) {
699
+ const birthDate = new Date(birthday);
700
+ const today = /* @__PURE__ */ new Date();
701
+ let age = today.getFullYear() - birthDate.getFullYear();
702
+ const monthDifference = today.getMonth() - birthDate.getMonth();
703
+ if (monthDifference < 0 || monthDifference === 0 && today.getDate() < birthDate.getDate()) {
704
+ age--;
705
+ }
706
+ return age;
707
+ }
708
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
709
+ __name: "format-date",
710
+ props: {
711
+ row: {
712
+ type: Object,
713
+ default: () => {
714
+ }
715
+ },
716
+ column: {
717
+ type: Object,
718
+ default: () => {
719
+ }
720
+ },
721
+ index: {
722
+ type: Number,
723
+ default: 0
724
+ },
725
+ itemKey: {
726
+ type: String,
727
+ default: ""
728
+ }
729
+ },
730
+ setup(__props) {
731
+ const props = __props;
732
+ const { row, column, index, itemKey } = toRefs(props);
733
+ const getDate = (value) => {
734
+ var _a, _b;
735
+ const formatString = ((_b = (_a = column.value.option) == null ? void 0 : _a.formatDateConfig) == null ? void 0 : _b.formatString) || "yyyy-MM-dd hh:mm:ss";
736
+ return formatDate(value, formatString);
737
+ };
738
+ watch([row, column, index, itemKey], () => {
739
+ });
740
+ return (_ctx, _cache) => {
741
+ return openBlock(), createElementBlock("div", null, [
742
+ createElementVNode("div", null, toDisplayString(getDate(unref(row)[unref(itemKey)])), 1)
743
+ ]);
744
+ };
745
+ }
746
+ });
747
+ const tableConfig = {
748
+ tag: {
749
+ component: _sfc_main$9
750
+ },
751
+ formatEnum: {
752
+ component: _sfc_main$8
753
+ },
754
+ formatDate: {
755
+ component: _sfc_main$7
756
+ }
757
+ };
758
+ const _hoisted_1$5 = { class: "schema-table" };
759
+ const _hoisted_2$1 = { class: "gva-pagination" };
760
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
761
+ __name: "schema-table",
762
+ props: {
763
+ schema: {},
764
+ api: {},
765
+ buttons: {},
766
+ apiParms: {}
767
+ },
768
+ emits: ["operate"],
769
+ setup(__props, { expose: __expose, emit: __emit }) {
770
+ const emit = __emit;
771
+ const tableData = ref([]);
772
+ const pageSize = ref(10);
773
+ const currentPage = ref(1);
774
+ const total = ref(0);
775
+ const loading = ref(false);
776
+ const operationWidth = computed(() => {
777
+ var _a;
778
+ return ((_a = __props.buttons) == null ? void 0 : _a.length) > 0 ? __props.buttons.reduce((prev, cur) => prev + cur.label.length * 40, 50) : 50;
779
+ });
780
+ const buildComponetnName = (comTypeName) => {
781
+ var _a;
782
+ const componentName = (_a = tableConfig[comTypeName]) == null ? void 0 : _a.component;
783
+ return componentName || "";
784
+ };
785
+ const fetDatbleData = async () => {
786
+ var _a, _b, _c, _d;
787
+ if (!__props.api.getList) {
788
+ return;
789
+ }
790
+ if (loading.value) return;
791
+ showLoding();
792
+ const res = await request({
793
+ url: __props.api.getList,
794
+ method: "get",
795
+ params: {
796
+ ...__props.apiParms,
797
+ page: currentPage.value,
798
+ pageSize: pageSize.value
799
+ }
800
+ });
801
+ hideLoding();
802
+ if (!res || !res.data) {
803
+ return;
804
+ }
805
+ tableData.value = buildTableData(res.data.list) || [];
806
+ total.value = Number(
807
+ ((_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
808
+ );
809
+ };
810
+ const initData = () => {
811
+ currentPage.value = 1;
812
+ pageSize.value = 10;
813
+ total.value = 0;
814
+ nextTick(async () => {
815
+ await loadTableData();
816
+ });
817
+ };
818
+ const operatetionHandler = ({ btnConfig, rowData }) => {
819
+ emit("operate", { btnConfig, rowData });
820
+ };
821
+ const onPageSizeChange = async (val) => {
822
+ console.log(val, "onPageSizeChange");
823
+ pageSize.value = val;
824
+ await loadTableData();
825
+ };
826
+ const onCureentPage = async (val) => {
827
+ console.log(val, "onCureentPage");
828
+ currentPage.value = val;
829
+ await loadTableData();
830
+ };
831
+ const buildTableData = (listData) => {
832
+ var _a;
833
+ if (!((_a = __props.schema) == null ? void 0 : _a.properties)) return listData;
834
+ return listData.map((dataItem) => {
835
+ var _a2;
836
+ for (const key in dataItem) {
837
+ const schemaItem = __props.schema.properties[key];
838
+ if (((_a2 = schemaItem == null ? void 0 : schemaItem.options) == null ? void 0 : _a2.tofixed) && typeof dataItem[key] === "number") {
839
+ dataItem[key] = dataItem[key].toFixed(schemaItem.options.tofixed);
840
+ }
841
+ }
842
+ return dataItem;
843
+ });
844
+ };
845
+ let timer = null;
846
+ const loadTableData = async () => {
847
+ clearTimeout(timer);
848
+ timer = setTimeout(async () => {
849
+ await fetDatbleData();
850
+ timer = null;
851
+ }, 100);
852
+ };
853
+ const showLoding = () => {
854
+ loading.value = true;
855
+ };
856
+ const hideLoding = () => {
857
+ loading.value = false;
858
+ };
859
+ watch(
860
+ () => [__props.schema, __props.api, __props.apiParms],
861
+ () => {
862
+ initData();
863
+ }
864
+ );
865
+ onMounted(() => {
866
+ initData();
867
+ });
868
+ __expose({
869
+ initData,
870
+ loadTableData,
871
+ showLoding,
872
+ hideLoding
873
+ });
874
+ useRouter();
875
+ useRoute();
876
+ useUserStore();
877
+ return (_ctx, _cache) => {
878
+ const _component_el_table_column = resolveComponent("el-table-column");
879
+ const _component_el_button = resolveComponent("el-button");
880
+ const _component_el_table = resolveComponent("el-table");
881
+ const _component_el_pagination = resolveComponent("el-pagination");
882
+ const _directive_loading = resolveDirective("loading");
883
+ return openBlock(), createElementBlock("div", _hoisted_1$5, [
884
+ __props.schema && __props.schema.properties ? withDirectives((openBlock(), createBlock(_component_el_table, {
885
+ key: 0,
886
+ data: tableData.value,
887
+ style: { "width": "100%" },
888
+ border: ""
889
+ }, {
890
+ default: withCtx(() => {
891
+ var _a;
892
+ return [
893
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.schema.properties, (value, keyItem) => {
894
+ var _a2, _b;
895
+ return openBlock(), createElementBlock(Fragment, { key: keyItem }, [
896
+ ((_a2 = value.option) == null ? void 0 : _a2.visible) !== false ? (openBlock(), createBlock(_component_el_table_column, mergeProps({
897
+ key: 0,
898
+ prop: keyItem,
899
+ label: value.label
900
+ }, { ref_for: true }, value.option), createSlots({ _: 2 }, [
901
+ ((_b = value.option) == null ? void 0 : _b.comType) ? {
902
+ name: "default",
903
+ fn: withCtx((scope) => [
904
+ (openBlock(), createBlock(resolveDynamicComponent(buildComponetnName(value.option.comType)), {
905
+ row: scope.row,
906
+ column: value,
907
+ index: scope.$index,
908
+ itemKey: keyItem
909
+ }, null, 8, ["row", "column", "index", "itemKey"]))
910
+ ]),
911
+ key: "0"
912
+ } : void 0
913
+ ]), 1040, ["prop", "label"])) : createCommentVNode("", true)
914
+ ], 64);
915
+ }), 128)),
916
+ ((_a = __props.buttons) == null ? void 0 : _a.length) > 0 ? (openBlock(), createBlock(_component_el_table_column, {
917
+ key: 0,
918
+ label: "操作",
919
+ align: "center",
920
+ width: operationWidth.value
921
+ }, {
922
+ default: withCtx((scope) => [
923
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.buttons, (item, index) => {
924
+ return openBlock(), createBlock(_component_el_button, mergeProps({ key: index }, { ref_for: true }, item, {
925
+ onClick: ($event) => operatetionHandler({ btnConfig: item, rowData: scope.row })
926
+ }), {
927
+ default: withCtx(() => [
928
+ createTextVNode(toDisplayString(item.label), 1)
929
+ ]),
930
+ _: 2
931
+ }, 1040, ["onClick"]);
932
+ }), 128))
933
+ ]),
934
+ _: 1
935
+ }, 8, ["width"])) : createCommentVNode("", true)
936
+ ];
937
+ }),
938
+ _: 1
939
+ }, 8, ["data"])), [
940
+ [_directive_loading, loading.value]
941
+ ]) : createCommentVNode("", true),
942
+ createElementVNode("div", _hoisted_2$1, [
943
+ createVNode(_component_el_pagination, {
944
+ layout: "total, prev, pager, next, sizes",
945
+ total: total.value,
946
+ "page-size": pageSize.value,
947
+ "current-page": currentPage.value,
948
+ onSizeChange: onPageSizeChange,
949
+ onCurrentChange: onCureentPage
950
+ }, null, 8, ["total", "page-size", "current-page"])
951
+ ])
952
+ ]);
953
+ };
954
+ }
955
+ });
956
+ const SchemaTable = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-502fe21c"]]);
957
+ const _hoisted_1$4 = { class: "table-panel" };
958
+ const _hoisted_2 = { class: "operation-panel" };
959
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
960
+ __name: "table-panel",
961
+ emits: ["operate"],
962
+ setup(__props, { expose: __expose, emit: __emit }) {
963
+ const { tableConfig: tableConfig2, tableSchema, api, apiParms } = inject("schemeViewData");
964
+ const emit = __emit;
965
+ const schemaTableRef = ref();
966
+ const handlers = {
967
+ addEvent: (payload) => addEvent(payload)
968
+ };
969
+ const onOperate = ({ btnConfig, rowData = null }) => {
970
+ var _a;
971
+ console.log("onOperate", btnConfig, rowData);
972
+ const { eventKey } = btnConfig;
973
+ if (eventKey) (_a = handlers[eventKey]) == null ? void 0 : _a.call(handlers, { btnConfig, rowData });
974
+ emit("operate", { btnConfig, rowData });
975
+ };
976
+ const addEvent = ({ btnConfig, rowData }) => {
977
+ console.log("新增按钮");
978
+ emit("operate", { btnConfig, rowData });
979
+ };
980
+ const initTableData = async () => {
981
+ var _a;
982
+ await ((_a = schemaTableRef == null ? void 0 : schemaTableRef.value) == null ? void 0 : _a.initData());
983
+ };
984
+ const loadTableData = async () => {
985
+ var _a;
986
+ await ((_a = schemaTableRef == null ? void 0 : schemaTableRef.value) == null ? void 0 : _a.loadTableData());
987
+ };
988
+ onMounted(() => {
989
+ });
990
+ __expose({
991
+ initTableData,
992
+ loadTableData
993
+ });
994
+ useRouter();
995
+ useRoute();
996
+ useUserStore();
997
+ return (_ctx, _cache) => {
998
+ var _a, _b;
999
+ const _component_el_button = resolveComponent("el-button");
1000
+ const _component_el_row = resolveComponent("el-row");
1001
+ return openBlock(), createElementBlock("div", _hoisted_1$4, [
1002
+ createElementVNode("div", _hoisted_2, [
1003
+ ((_a = unref(tableConfig2)) == null ? void 0 : _a.headerButtons.length) > 0 ? (openBlock(), createBlock(_component_el_row, { key: 0 }, {
1004
+ default: withCtx(() => {
1005
+ var _a2;
1006
+ return [
1007
+ (openBlock(true), createElementBlock(Fragment, null, renderList((_a2 = unref(tableConfig2)) == null ? void 0 : _a2.headerButtons, (buttonItem) => {
1008
+ return openBlock(), createBlock(_component_el_button, {
1009
+ key: buttonItem.eventKey,
1010
+ onClick: ($event) => onOperate({ btnConfig: buttonItem })
1011
+ }, {
1012
+ default: withCtx(() => [
1013
+ createTextVNode(toDisplayString(buttonItem.label), 1)
1014
+ ]),
1015
+ _: 2
1016
+ }, 1032, ["onClick"]);
1017
+ }), 128))
1018
+ ];
1019
+ }),
1020
+ _: 1
1021
+ })) : createCommentVNode("", true)
1022
+ ]),
1023
+ createVNode(SchemaTable, {
1024
+ ref_key: "schemaTableRef",
1025
+ ref: schemaTableRef,
1026
+ schema: unref(tableSchema),
1027
+ api: unref(api),
1028
+ buttons: ((_b = unref(tableConfig2)) == null ? void 0 : _b.rowButtons) ?? [],
1029
+ onOperate,
1030
+ apiParms: unref(apiParms)
1031
+ }, {
1032
+ cell: withCtx((slotProps) => [
1033
+ renderSlot(_ctx.$slots, "cell", normalizeProps(guardReactiveProps(slotProps)), void 0, true)
1034
+ ]),
1035
+ _: 3
1036
+ }, 8, ["schema", "api", "buttons", "apiParms"])
1037
+ ]);
1038
+ };
1039
+ }
1040
+ });
1041
+ const tablePanel = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-cef68da3"]]);
1042
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1043
+ __name: "input",
1044
+ props: {
1045
+ schemaKey: {
1046
+ type: String,
1047
+ default: ""
1048
+ },
1049
+ schema: {
1050
+ type: Object,
1051
+ default: () => {
1052
+ }
1053
+ }
1054
+ },
1055
+ emits: ["loaded"],
1056
+ setup(__props, { expose: __expose, emit: __emit }) {
1057
+ const dtoValue = ref();
1058
+ const props = __props;
1059
+ const getValue = () => {
1060
+ return dtoValue.value !== void 0 ? {
1061
+ [props.schemaKey]: dtoValue.value
1062
+ } : {};
1063
+ };
1064
+ const reset = () => {
1065
+ var _a, _b;
1066
+ dtoValue.value = (_b = (_a = props.schema) == null ? void 0 : _a.option) == null ? void 0 : _b.default;
1067
+ };
1068
+ __expose({
1069
+ getValue,
1070
+ reset
1071
+ });
1072
+ return (_ctx, _cache) => {
1073
+ const _component_el_input = resolveComponent("el-input");
1074
+ return openBlock(), createBlock(_component_el_input, mergeProps({
1075
+ type: "text",
1076
+ modelValue: dtoValue.value,
1077
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => dtoValue.value = $event)
1078
+ }, __props.schema), null, 16, ["modelValue"]);
1079
+ };
1080
+ }
1081
+ });
1082
+ const SearchConfig = {
1083
+ input: {
1084
+ component: _sfc_main$4
1085
+ }
1086
+ };
1087
+ const _hoisted_1$3 = { class: "gva-search-box" };
1088
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1089
+ __name: "schema-search-bar",
1090
+ props: {
1091
+ schema: {},
1092
+ schemaConfig: {}
1093
+ },
1094
+ emits: ["search", "reset", "load", "loaded"],
1095
+ setup(__props, { expose: __expose, emit: __emit }) {
1096
+ ref(SearchConfig);
1097
+ const emit = __emit;
1098
+ const props = __props;
1099
+ const SearchComList = ref([]);
1100
+ const hanleSearchComList = (el) => {
1101
+ if (el) SearchComList.value.push(el);
1102
+ };
1103
+ const getValue = () => {
1104
+ let dtoObj = {};
1105
+ (SearchComList.value || []).forEach((item) => {
1106
+ if (item && typeof item.getValue === "function") {
1107
+ dtoObj = {
1108
+ ...dtoObj,
1109
+ ...item.getValue()
1110
+ };
1111
+ }
1112
+ });
1113
+ return dtoObj;
1114
+ };
1115
+ let childComLocadCount = 0;
1116
+ const handleChildLoaded = (el) => {
1117
+ childComLocadCount++;
1118
+ if (childComLocadCount >= Object.keys(props.schema.properties).length) {
1119
+ emit("loaded", getValue());
1120
+ }
1121
+ };
1122
+ const search = () => {
1123
+ emit("search", getValue());
1124
+ };
1125
+ const reset = () => {
1126
+ emit("reset");
1127
+ (SearchComList.value || []).forEach((item) => {
1128
+ if (item && typeof item.reset === "function") item.reset();
1129
+ });
1130
+ };
1131
+ const load = () => {
1132
+ emit("load");
1133
+ };
1134
+ __expose({
1135
+ search,
1136
+ reset,
1137
+ load
1138
+ });
1139
+ return (_ctx, _cache) => {
1140
+ const _component_el_form_item = resolveComponent("el-form-item");
1141
+ const _component_el_button = resolveComponent("el-button");
1142
+ const _component_el_form = resolveComponent("el-form");
1143
+ return openBlock(), createElementBlock("div", _hoisted_1$3, [
1144
+ createVNode(_component_el_form, {
1145
+ inline: true,
1146
+ class: "flex items-center justify-start flex-wrap"
1147
+ }, {
1148
+ default: withCtx(() => [
1149
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.schema.properties, (value, key) => {
1150
+ return openBlock(), createBlock(_component_el_form_item, {
1151
+ key,
1152
+ label: value.label
1153
+ }, {
1154
+ default: withCtx(() => [
1155
+ value.option.comType ? (openBlock(), createBlock(resolveDynamicComponent(unref(SearchConfig)[value.option.comType].component), mergeProps({
1156
+ key: 0,
1157
+ ref_for: true,
1158
+ ref: hanleSearchComList
1159
+ }, { ref_for: true }, value.option, {
1160
+ onLoaded: handleChildLoaded,
1161
+ schema: value,
1162
+ schemaKey: key
1163
+ }), null, 16, ["schema", "schemaKey"])) : createCommentVNode("", true)
1164
+ ]),
1165
+ _: 2
1166
+ }, 1032, ["label"]);
1167
+ }), 128)),
1168
+ createVNode(_component_el_form_item, null, {
1169
+ default: withCtx(() => [
1170
+ createVNode(_component_el_button, {
1171
+ type: "primary",
1172
+ onClick: search
1173
+ }, {
1174
+ default: withCtx(() => [..._cache[0] || (_cache[0] = [
1175
+ createTextVNode(" 查询 ", -1)
1176
+ ])]),
1177
+ _: 1
1178
+ }),
1179
+ createVNode(_component_el_button, { onClick: reset }, {
1180
+ default: withCtx(() => [..._cache[1] || (_cache[1] = [
1181
+ createTextVNode("重置", -1)
1182
+ ])]),
1183
+ _: 1
1184
+ })
1185
+ ]),
1186
+ _: 1
1187
+ })
1188
+ ]),
1189
+ _: 1
1190
+ })
1191
+ ]);
1192
+ };
1193
+ }
1194
+ });
1195
+ const _hoisted_1$2 = { class: "search-panel" };
1196
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1197
+ __name: "search-panel",
1198
+ props: {},
1199
+ emits: ["Search", "Reset"],
1200
+ setup(__props, { emit: __emit }) {
1201
+ const { serachConfig, searchSchema } = inject("schemeViewData");
1202
+ const emit = __emit;
1203
+ const handleSearch = (Searchobj) => {
1204
+ emit("Search", Searchobj);
1205
+ };
1206
+ onMounted(() => {
1207
+ });
1208
+ return (_ctx, _cache) => {
1209
+ return openBlock(), createElementBlock("div", _hoisted_1$2, [
1210
+ createVNode(_sfc_main$3, {
1211
+ schema: unref(searchSchema),
1212
+ schemaConfig: unref(serachConfig),
1213
+ onSearch: handleSearch
1214
+ }, null, 8, ["schema", "schemaConfig"])
1215
+ ]);
1216
+ };
1217
+ }
1218
+ });
1219
+ const searchPanel = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-633fcc6e"]]);
1220
+ const useSchema = (schemaConfigDoc) => {
1221
+ const {
1222
+ api,
1223
+ schema,
1224
+ tableConfig: tableSchemaConfig,
1225
+ searchConfig,
1226
+ components: componentsConfig
1227
+ } = schemaConfigDoc;
1228
+ const tableSchema = ref({ properties: {} });
1229
+ const tableConfig2 = ref({
1230
+ headerButtons: [],
1231
+ rowButtons: []
1232
+ });
1233
+ const serachConfig = ref({});
1234
+ const searchSchema = ref({ properties: {} });
1235
+ const components = ref(
1236
+ {}
1237
+ );
1238
+ const buidData = () => {
1239
+ tableSchema.value = { properties: {} };
1240
+ tableConfig2.value.rowButtons = tableSchemaConfig.rowButtons || [];
1241
+ tableConfig2.value.headerButtons = tableSchemaConfig.headerButtons || [];
1242
+ serachConfig.value = {};
1243
+ searchSchema.value = { properties: {} };
1244
+ components.value = {};
1245
+ nextTick(() => {
1246
+ tableSchema.value = buildDtoSchema(schema, "table");
1247
+ tableConfig2.value.headerButtons = tableConfig2.value.headerButtons || [];
1248
+ tableConfig2.value.rowButtons = tableConfig2.value.rowButtons || [];
1249
+ serachConfig.value = searchConfig;
1250
+ searchSchema.value = buildDtoSchema(schema, "search");
1251
+ if (componentsConfig && Object.keys(componentsConfig).length > 0) {
1252
+ const dtoCompontns = {};
1253
+ for (const comKey in componentsConfig) {
1254
+ dtoCompontns[comKey] = {
1255
+ schema: buildDtoSchema(schema, comKey),
1256
+ config: componentsConfig[comKey]
1257
+ };
1258
+ components.value = dtoCompontns;
1259
+ }
1260
+ }
1261
+ });
1262
+ };
1263
+ const buildDtoSchema = (_schema, comName) => {
1264
+ const dtoSchema = {
1265
+ properties: {}
1266
+ };
1267
+ if (!_schema.properties) return dtoSchema;
1268
+ const { require: require2 } = _schema;
1269
+ for (const key in _schema.properties) {
1270
+ const props = _schema.properties[key];
1271
+ if (props[`${comName}Option`]) {
1272
+ let dtoProps = {};
1273
+ for (const pkey in props) {
1274
+ if (pkey.indexOf("Option") < 0) {
1275
+ dtoProps[pkey] = props[pkey];
1276
+ }
1277
+ }
1278
+ dtoProps = Object.assign({}, dtoProps, {
1279
+ option: props[`${comName}Option`]
1280
+ });
1281
+ if (require2 && require2.length > 0 && require2.find((vp) => vp === key)) {
1282
+ dtoProps.option.required = true;
1283
+ }
1284
+ dtoSchema.properties[key] = dtoProps;
1285
+ }
1286
+ }
1287
+ return dtoSchema;
1288
+ };
1289
+ onMounted(() => {
1290
+ buidData();
1291
+ });
1292
+ return {
1293
+ api,
1294
+ tableSchema,
1295
+ tableConfig: tableConfig2,
1296
+ serachConfig,
1297
+ searchSchema,
1298
+ components
1299
+ };
1300
+ };
1301
+ const _hoisted_1$1 = { class: "schema-view" };
1302
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1303
+ __name: "schema-view",
1304
+ props: {
1305
+ config: {}
1306
+ },
1307
+ setup(__props) {
1308
+ const props = __props;
1309
+ const {
1310
+ api,
1311
+ tableSchema,
1312
+ tableConfig: tableConfig2,
1313
+ serachConfig,
1314
+ searchSchema,
1315
+ components
1316
+ } = useSchema(props.config);
1317
+ const apiParms = ref({});
1318
+ const componentListRef = ref([]);
1319
+ const tablePanelRef = ref(null);
1320
+ const handleSearch = (Searchobj) => {
1321
+ apiParms.value = Searchobj;
1322
+ console.log(Searchobj);
1323
+ };
1324
+ const handleReset = (Searchobj) => {
1325
+ apiParms.value = {};
1326
+ console.log(Searchobj);
1327
+ };
1328
+ const onCommand = (data) => {
1329
+ var _a;
1330
+ console.log("data", data);
1331
+ const { event } = data;
1332
+ if (event === "loadTableData") {
1333
+ (_a = tablePanelRef.value) == null ? void 0 : _a.loadTableData();
1334
+ }
1335
+ };
1336
+ const remove = async ({ btnConfig, rowData }) => {
1337
+ const { parms } = btnConfig.eventOption;
1338
+ if (!api.delete) {
1339
+ ElMessage.error("未配置删除接口地址");
1340
+ return;
1341
+ }
1342
+ let obj = {};
1343
+ const key = Object.keys(parms)[0];
1344
+ let skey = parms[key].split("::")[1];
1345
+ if (skey) {
1346
+ obj = { [skey]: rowData[skey] };
1347
+ } else {
1348
+ obj = { [key]: parms[key] };
1349
+ }
1350
+ ElMessageBox.confirm("确认删除该记录吗?", "提示", {
1351
+ confirmButtonText: "确定",
1352
+ cancelButtonText: "取消",
1353
+ type: "warning"
1354
+ }).then(async () => {
1355
+ var _a;
1356
+ if (api == null ? void 0 : api.delete) {
1357
+ const res = await request({
1358
+ url: api == null ? void 0 : api.delete,
1359
+ method: "delete",
1360
+ data: obj
1361
+ });
1362
+ if (res.code === 0) {
1363
+ ElMessage.success("删除成功");
1364
+ (_a = tablePanelRef.value) == null ? void 0 : _a.loadTableData();
1365
+ }
1366
+ }
1367
+ }).catch(() => {
1368
+ });
1369
+ };
1370
+ const showComponent = ({ btnConfig, rowData = null }) => {
1371
+ const { comName } = btnConfig.eventOption;
1372
+ if (!comName) return;
1373
+ const component = componentListRef.value.find(
1374
+ (item) => item.name === comName
1375
+ );
1376
+ if (!component) return;
1377
+ component.show(rowData);
1378
+ };
1379
+ const EventHandleMap = {
1380
+ showComponent,
1381
+ remove
1382
+ };
1383
+ const handleOperate = ({ btnConfig, rowData = null }) => {
1384
+ var _a;
1385
+ const { eventKey } = btnConfig;
1386
+ (_a = EventHandleMap[eventKey]) == null ? void 0 : _a.call(EventHandleMap, { btnConfig, rowData });
1387
+ };
1388
+ onMounted(() => {
1389
+ });
1390
+ provide("schemeViewData", {
1391
+ tableSchema,
1392
+ tableConfig: tableConfig2,
1393
+ api,
1394
+ serachConfig,
1395
+ searchSchema,
1396
+ apiParms,
1397
+ components
1398
+ });
1399
+ return (_ctx, _cache) => {
1400
+ return openBlock(), createElementBlock("div", _hoisted_1$1, [
1401
+ createVNode(searchPanel, {
1402
+ onSearch: handleSearch,
1403
+ onReset: handleReset
1404
+ }),
1405
+ createVNode(tablePanel, {
1406
+ ref_key: "tablePanelRef",
1407
+ ref: tablePanelRef,
1408
+ onOperate: handleOperate
1409
+ }, null, 512),
1410
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(components), (value, key) => {
1411
+ return openBlock(), createBlock(resolveDynamicComponent(unref(componentConfig)[key].component), {
1412
+ ref_for: true,
1413
+ ref_key: "componentListRef",
1414
+ ref: componentListRef,
1415
+ key,
1416
+ onCommand
1417
+ }, null, 32);
1418
+ }), 128))
1419
+ ]);
1420
+ };
1421
+ }
1422
+ });
1423
+ const schemaView = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-6aa05693"]]);
1424
+ let routerClient = null;
1425
+ function setRouterClient(client) {
1426
+ routerClient = client;
1427
+ }
1428
+ function navigate(to, type = "push") {
1429
+ if (!routerClient) throw new Error("请先使用 setRouterClient 注册路由客户端");
1430
+ const fn = (type === "replace" ? routerClient.replace : routerClient.push) || routerClient.push;
1431
+ return fn(to);
1432
+ }
1433
+ function back() {
1434
+ if (!routerClient || !routerClient.back) return;
1435
+ return routerClient.back();
1436
+ }
1437
+ const _sfc_main = {};
1438
+ const _hoisted_1 = { class: "operation-panel-placeholder" };
1439
+ function _sfc_render(_ctx, _cache) {
1440
+ return openBlock(), createElementBlock("div", _hoisted_1);
1441
+ }
1442
+ const operationPanel = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-e002ae22"]]);
1443
+ let requestAdapter;
1444
+ const setRequestAdapter = (adapter) => {
1445
+ console.log("设置requestAdapter", adapter);
1446
+ requestAdapter = adapter;
1447
+ };
1448
+ const service = async (config) => {
1449
+ console.log("调用service", config);
1450
+ return requestAdapter(config);
1451
+ };
1452
+ export {
1453
+ _sfc_main$7 as FormatDate,
1454
+ _sfc_main$8 as FormatEnum,
1455
+ operationPanel as OperationPanel,
1456
+ schemaForm as SchemaForm,
1457
+ _sfc_main$3 as SchemaSearchBar,
1458
+ SchemaTable,
1459
+ schemaView as SchemaView,
1460
+ _sfc_main$9 as Tag,
1461
+ back,
1462
+ computedAge,
1463
+ formatDate,
1464
+ formatTimeToStr,
1465
+ navigate,
1466
+ request,
1467
+ service,
1468
+ setRequestAdapter,
1469
+ setRequestClient,
1470
+ setRouterClient,
1471
+ useSchema
1472
+ };
1473
+ //# sourceMappingURL=index.es.js.map