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