page-schema-enginer-shun 1.0.7 → 1.0.8

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