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