page-schema-enginer-shun 1.0.19 → 1.1.0
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/dist/index.cjs.js +112 -26
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +114 -28
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +112 -26
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +8 -8
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineComponent, inject, ref as ref$1, watch, onMounted, createElementBlock, openBlock, createElementVNode, createCommentVNode, createVNode, toDisplayString, unref, mergeProps, withCtx, Fragment, renderList, createBlock, createTextVNode, provide, resolveDynamicComponent, toRefs,
|
|
1
|
+
import { defineComponent, inject, ref as ref$1, watch, onMounted, createElementBlock, openBlock, createElementVNode, createCommentVNode, createVNode, toDisplayString, unref, mergeProps, withCtx, Fragment, renderList, createBlock, createTextVNode, computed, provide, resolveDynamicComponent, toRefs, resolveDirective, withDirectives, nextTick, renderSlot, normalizeProps, guardReactiveProps } from "vue";
|
|
2
2
|
import { useRouter, useRoute } from "vue-router";
|
|
3
3
|
import { defineStore } from "pinia";
|
|
4
|
-
import { ElInput, ElRadioGroup, ElRadio, ElInputNumber, ElSelect, ElOption, ElDialog, ElButton, ElNotification, ElTable, ElTableColumn, ElPagination,
|
|
4
|
+
import { ElInput, ElRadioGroup, ElRadio, ElInputNumber, ElSelect, ElOption, ElMessage, ElDialog, ElButton, ElNotification, ElTable, ElTableColumn, ElPagination, ElRow, ElForm, ElFormItem, ElMessageBox } from "element-plus";
|
|
5
5
|
function _mergeNamespaces(n, m) {
|
|
6
6
|
for (var i = 0; i < m.length; i++) {
|
|
7
7
|
const e = m[i];
|
|
@@ -242,6 +242,15 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
242
242
|
}
|
|
243
243
|
});
|
|
244
244
|
const inputNumber = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-87d45394"]]);
|
|
245
|
+
let requestFn = null;
|
|
246
|
+
function setRequestClient(fn) {
|
|
247
|
+
requestFn = fn;
|
|
248
|
+
}
|
|
249
|
+
function request(options) {
|
|
250
|
+
if (!requestFn) throw new Error("请先使用 setRequestClient 注册请求客户端");
|
|
251
|
+
console.log("requestrequestrequest");
|
|
252
|
+
return requestFn(options);
|
|
253
|
+
}
|
|
245
254
|
const _hoisted_1$8 = { class: "schema-form-select-container" };
|
|
246
255
|
const _hoisted_2$2 = { class: "schema-form-select" };
|
|
247
256
|
const _hoisted_3$1 = { class: "schema-form-select-label" };
|
|
@@ -253,20 +262,102 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
253
262
|
const selectData = ref$1();
|
|
254
263
|
const enumerate = ref$1([]);
|
|
255
264
|
const tip = ref$1();
|
|
265
|
+
const loading = ref$1(false);
|
|
266
|
+
const isRemote = computed(() => {
|
|
267
|
+
var _a;
|
|
268
|
+
return !!((_a = __props.schema.option) == null ? void 0 : _a.remote);
|
|
269
|
+
});
|
|
270
|
+
const bindAttrs = computed(() => {
|
|
271
|
+
var _a;
|
|
272
|
+
const defaultProps = {
|
|
273
|
+
placeholder: "请选择",
|
|
274
|
+
clearable: true
|
|
275
|
+
};
|
|
276
|
+
if ((_a = __props.schema.option) == null ? void 0 : _a.props) {
|
|
277
|
+
return { ...defaultProps, ...__props.schema.option.props };
|
|
278
|
+
}
|
|
279
|
+
const { api, enumList, default: def2, remote, ...rest } = __props.schema.option || {};
|
|
280
|
+
return {
|
|
281
|
+
...defaultProps,
|
|
282
|
+
...rest
|
|
283
|
+
};
|
|
284
|
+
});
|
|
256
285
|
watch(
|
|
257
286
|
() => __props.model,
|
|
258
287
|
() => {
|
|
259
|
-
|
|
288
|
+
var _a;
|
|
289
|
+
if (!loading.value) {
|
|
290
|
+
selectData.value = __props.model ?? ((_a = __props.schema.option) == null ? void 0 : _a.default);
|
|
291
|
+
}
|
|
260
292
|
}
|
|
261
293
|
);
|
|
262
294
|
const getValue = () => {
|
|
263
295
|
return selectData.value !== void 0 ? { [__props.ItemKey]: selectData.value } : {};
|
|
264
296
|
};
|
|
265
|
-
const
|
|
297
|
+
const fetchOptions = async (query = "") => {
|
|
266
298
|
var _a, _b;
|
|
299
|
+
const apiConfig = (_a = __props.schema.option) == null ? void 0 : _a.api;
|
|
300
|
+
if (!apiConfig || !apiConfig.url) return;
|
|
301
|
+
loading.value = true;
|
|
302
|
+
try {
|
|
303
|
+
const params = { ...apiConfig.params || {} };
|
|
304
|
+
if (isRemote.value) {
|
|
305
|
+
const searchKey = apiConfig.searchKey || "keyword";
|
|
306
|
+
params[searchKey] = query;
|
|
307
|
+
}
|
|
308
|
+
const res = await request({
|
|
309
|
+
url: apiConfig.url,
|
|
310
|
+
method: apiConfig.method || "get",
|
|
311
|
+
params: apiConfig.method === "post" ? void 0 : params,
|
|
312
|
+
data: apiConfig.method === "post" ? params : void 0
|
|
313
|
+
});
|
|
314
|
+
let list = [];
|
|
315
|
+
if (Array.isArray(res)) {
|
|
316
|
+
list = res;
|
|
317
|
+
} else if ((res == null ? void 0 : res.data) && Array.isArray(res.data)) {
|
|
318
|
+
list = res.data;
|
|
319
|
+
} else if (((_b = res == null ? void 0 : res.data) == null ? void 0 : _b.list) && Array.isArray(res.data.list)) {
|
|
320
|
+
list = res.data.list;
|
|
321
|
+
} else if ((res == null ? void 0 : res.list) && Array.isArray(res.list)) {
|
|
322
|
+
list = res.list;
|
|
323
|
+
}
|
|
324
|
+
const labelKey = apiConfig.labelKey || "label";
|
|
325
|
+
const valueKey = apiConfig.valueKey || "value";
|
|
326
|
+
enumerate.value = list.map((item) => ({
|
|
327
|
+
label: item[labelKey],
|
|
328
|
+
value: item[valueKey],
|
|
329
|
+
original: item
|
|
330
|
+
}));
|
|
331
|
+
} catch (error2) {
|
|
332
|
+
console.error("Select options load failed:", error2);
|
|
333
|
+
ElMessage.error(error2.message || "加载选项数据失败");
|
|
334
|
+
enumerate.value = [];
|
|
335
|
+
} finally {
|
|
336
|
+
loading.value = false;
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
let timer = null;
|
|
340
|
+
const remoteMethod = (query) => {
|
|
341
|
+
if (timer) clearTimeout(timer);
|
|
342
|
+
timer = setTimeout(() => {
|
|
343
|
+
fetchOptions(query);
|
|
344
|
+
}, 300);
|
|
345
|
+
};
|
|
346
|
+
const handleFocus = () => {
|
|
347
|
+
var _a;
|
|
348
|
+
if (!isRemote.value && ((_a = __props.schema.option) == null ? void 0 : _a.api) && enumerate.value.length === 0) {
|
|
349
|
+
fetchOptions();
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
const buildData = async () => {
|
|
353
|
+
var _a, _b, _c;
|
|
267
354
|
tip.value = null;
|
|
268
|
-
|
|
269
|
-
|
|
355
|
+
selectData.value = __props.model ?? ((_a = __props.schema.option) == null ? void 0 : _a.default);
|
|
356
|
+
if ((_b = __props.schema.option) == null ? void 0 : _b.api) {
|
|
357
|
+
await fetchOptions("");
|
|
358
|
+
} else {
|
|
359
|
+
enumerate.value = ((_c = __props.schema.option) == null ? void 0 : _c.enumList) || [];
|
|
360
|
+
}
|
|
270
361
|
};
|
|
271
362
|
const valid = () => {
|
|
272
363
|
if (selectData.value !== void 0) {
|
|
@@ -290,11 +381,14 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
290
381
|
return openBlock(), createElementBlock("div", _hoisted_1$8, [
|
|
291
382
|
createElementVNode("div", _hoisted_2$2, [
|
|
292
383
|
createElementVNode("span", _hoisted_3$1, toDisplayString(__props.schema.label), 1),
|
|
293
|
-
createVNode(unref(ElSelect), {
|
|
384
|
+
createVNode(unref(ElSelect), mergeProps(bindAttrs.value, {
|
|
294
385
|
modelValue: selectData.value,
|
|
295
386
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => selectData.value = $event),
|
|
296
|
-
|
|
297
|
-
|
|
387
|
+
remote: isRemote.value,
|
|
388
|
+
filterable: isRemote.value || bindAttrs.value.filterable,
|
|
389
|
+
"remote-method": remoteMethod,
|
|
390
|
+
onFocus: handleFocus
|
|
391
|
+
}), {
|
|
298
392
|
default: withCtx(() => [
|
|
299
393
|
(openBlock(true), createElementBlock(Fragment, null, renderList(enumerate.value, (item) => {
|
|
300
394
|
return openBlock(), createBlock(unref(ElOption), {
|
|
@@ -305,14 +399,14 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
305
399
|
}), 128))
|
|
306
400
|
]),
|
|
307
401
|
_: 1
|
|
308
|
-
},
|
|
402
|
+
}, 16, ["modelValue", "remote", "filterable"]),
|
|
309
403
|
tip.value ? (openBlock(), createElementBlock("div", _hoisted_4, toDisplayString(tip.value), 1)) : createCommentVNode("", true)
|
|
310
404
|
])
|
|
311
405
|
]);
|
|
312
406
|
};
|
|
313
407
|
}
|
|
314
408
|
});
|
|
315
|
-
const select = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-
|
|
409
|
+
const select = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-97c33367"]]);
|
|
316
410
|
const formItemConfig = {
|
|
317
411
|
input: {
|
|
318
412
|
component: input
|
|
@@ -6523,7 +6617,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
6523
6617
|
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.schema.properties, (value, key) => {
|
|
6524
6618
|
var _a, _b;
|
|
6525
6619
|
return openBlock(), createElementBlock(Fragment, { key }, [
|
|
6526
|
-
resolveFormItemComponent((_a = value.option) == null ? void 0 : _a.comType) ? (openBlock(), createBlock(resolveDynamicComponent(resolveFormItemComponent((_b = value.option) == null ? void 0 : _b.comType)), {
|
|
6620
|
+
resolveFormItemComponent((_a = value.option) == null ? void 0 : _a.comType) ? (openBlock(), createBlock(resolveDynamicComponent(resolveFormItemComponent((_b = value.option) == null ? void 0 : _b.comType)), mergeProps({
|
|
6527
6621
|
key: 0,
|
|
6528
6622
|
ref_for: true,
|
|
6529
6623
|
ref_key: "formItemListRef",
|
|
@@ -6531,23 +6625,14 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
6531
6625
|
model: __props.model ? __props.model[key] : void 0,
|
|
6532
6626
|
ItemKey: key,
|
|
6533
6627
|
schema: value
|
|
6534
|
-
}, null,
|
|
6628
|
+
}, { ref_for: true }, value.option), null, 16, ["model", "ItemKey", "schema"])) : createCommentVNode("", true)
|
|
6535
6629
|
], 64);
|
|
6536
6630
|
}), 128))
|
|
6537
6631
|
])) : createCommentVNode("", true);
|
|
6538
6632
|
};
|
|
6539
6633
|
}
|
|
6540
6634
|
});
|
|
6541
|
-
const schemaForm = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-
|
|
6542
|
-
let requestFn = null;
|
|
6543
|
-
function setRequestClient(fn) {
|
|
6544
|
-
requestFn = fn;
|
|
6545
|
-
}
|
|
6546
|
-
function request(options) {
|
|
6547
|
-
if (!requestFn) throw new Error("请先使用 setRequestClient 注册请求客户端");
|
|
6548
|
-
console.log("requestrequestrequest");
|
|
6549
|
-
return requestFn(options);
|
|
6550
|
-
}
|
|
6635
|
+
const schemaForm = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-cc1d8aee"]]);
|
|
6551
6636
|
const _hoisted_1$6 = { class: "createForm" };
|
|
6552
6637
|
const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
6553
6638
|
__name: "createForm",
|
|
@@ -7149,15 +7234,16 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
7149
7234
|
var _a2;
|
|
7150
7235
|
return [
|
|
7151
7236
|
(openBlock(true), createElementBlock(Fragment, null, renderList((_a2 = unref(tableConfig2)) == null ? void 0 : _a2.headerButtons, (buttonItem) => {
|
|
7152
|
-
return openBlock(), createBlock(unref(ElButton), {
|
|
7153
|
-
key: buttonItem.eventKey
|
|
7237
|
+
return openBlock(), createBlock(unref(ElButton), mergeProps({
|
|
7238
|
+
key: buttonItem.eventKey
|
|
7239
|
+
}, { ref_for: true }, buttonItem == null ? void 0 : buttonItem.eventOption, {
|
|
7154
7240
|
onClick: ($event) => onOperate({ btnConfig: buttonItem })
|
|
7155
|
-
}, {
|
|
7241
|
+
}), {
|
|
7156
7242
|
default: withCtx(() => [
|
|
7157
7243
|
createTextVNode(toDisplayString(buttonItem.label), 1)
|
|
7158
7244
|
]),
|
|
7159
7245
|
_: 2
|
|
7160
|
-
},
|
|
7246
|
+
}, 1040, ["onClick"]);
|
|
7161
7247
|
}), 128))
|
|
7162
7248
|
];
|
|
7163
7249
|
}),
|
|
@@ -7182,7 +7268,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
7182
7268
|
};
|
|
7183
7269
|
}
|
|
7184
7270
|
});
|
|
7185
|
-
const tablePanel = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-
|
|
7271
|
+
const tablePanel = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-2f2f7b58"]]);
|
|
7186
7272
|
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
7187
7273
|
__name: "input",
|
|
7188
7274
|
props: {
|