cc1-form 1.0.1 → 1.0.2
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/cc1-form.js +230 -223
- package/dist/cc1-form.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/cc1-form.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as N, ref as j, reactive as
|
|
2
|
-
import { ElMessage as ie, ElLoading as de, ElForm as
|
|
3
|
-
class
|
|
1
|
+
import { defineComponent as N, ref as j, reactive as X, resolveComponent as W, createBlock as g, openBlock as f, unref as d, withCtx as h, createElementBlock as w, createCommentVNode as C, Fragment as $, renderList as F, renderSlot as k, normalizeClass as Q, createVNode as v, mergeProps as D, toHandlers as A, resolveDynamicComponent as Z, onMounted as ee, createElementVNode as U, createTextVNode as V, normalizeStyle as se, toDisplayString as J, resolveDirective as ne, withDirectives as re } from "vue";
|
|
2
|
+
import { ElMessage as ie, ElLoading as de, ElForm as K, ElFormItem as _, ElInput as H, ElSwitch as G, ElSelect as M, ElOption as R, ElTreeSelect as te, ElDatePicker as le, ElDialog as q, ElButton as S, ElDropdown as ue, ElDropdownMenu as fe, ElDropdownItem as P, ElTable as pe, ElTableColumn as B, ElPagination as ce } from "element-plus";
|
|
3
|
+
class O {
|
|
4
4
|
/**
|
|
5
5
|
* 路由
|
|
6
6
|
*/
|
|
@@ -41,9 +41,9 @@ class $ {
|
|
|
41
41
|
* @param module
|
|
42
42
|
*/
|
|
43
43
|
static loadModule = async (i) => {
|
|
44
|
-
if (
|
|
44
|
+
if (!O.moduleObj[i])
|
|
45
45
|
throw new Error(`模块${i}未加载,请赋值如:TSys.moduleObj = { ${i}: ()=>import('${i}') }`);
|
|
46
|
-
const r = await
|
|
46
|
+
const r = await O.moduleObj[i]();
|
|
47
47
|
return r.default ?? r;
|
|
48
48
|
};
|
|
49
49
|
/**
|
|
@@ -135,7 +135,7 @@ class $ {
|
|
|
135
135
|
*/
|
|
136
136
|
static getImgPic = (i) => new Promise(async (r, n) => {
|
|
137
137
|
let c = document.getElementById(i.id);
|
|
138
|
-
const m = await
|
|
138
|
+
const m = await O.loadModule("html2canvas");
|
|
139
139
|
try {
|
|
140
140
|
m(c, {
|
|
141
141
|
logging: !1,
|
|
@@ -209,12 +209,12 @@ class L {
|
|
|
209
209
|
* @param option 组件配置
|
|
210
210
|
*/
|
|
211
211
|
parentId: (i, r, n, c) => {
|
|
212
|
-
i ? r.type ===
|
|
212
|
+
i ? r.type === O.EDialog.Insert ? (r.form.parentId = i._id, r.form.sort = i.children.length + 1) : r.form.parentId = i.parentId.substring(i.parentId.lastIndexOf(",") + 1) : (r.form.parentId = "0", r.form.sort = n.length + 1), L.setOptionsData(c, "parentId", [{ _id: "0", title: "根", children: n }]);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
};
|
|
216
216
|
}
|
|
217
|
-
const me = { class: "row curd-row" },
|
|
217
|
+
const me = { class: "row curd-row" }, he = /* @__PURE__ */ N({
|
|
218
218
|
__name: "column",
|
|
219
219
|
props: {
|
|
220
220
|
/**
|
|
@@ -225,7 +225,7 @@ const me = { class: "row curd-row" }, be = /* @__PURE__ */ N({
|
|
|
225
225
|
}
|
|
226
226
|
},
|
|
227
227
|
setup(p, { expose: i }) {
|
|
228
|
-
const r =
|
|
228
|
+
const r = O.isFun, n = O.EDialog, c = j(), m = p, s = X({
|
|
229
229
|
rules: {},
|
|
230
230
|
show: !1,
|
|
231
231
|
showContent: !1,
|
|
@@ -240,16 +240,16 @@ const me = { class: "row curd-row" }, be = /* @__PURE__ */ N({
|
|
|
240
240
|
s.formColumn = [];
|
|
241
241
|
const a = [], o = m.option.form?.maxSpan || 12, u = m.option.form?.defaultSpan || o;
|
|
242
242
|
let t = [];
|
|
243
|
-
const l = (
|
|
244
|
-
if (s.formDefault[
|
|
245
|
-
|
|
246
|
-
let
|
|
243
|
+
const l = (b) => {
|
|
244
|
+
if (s.formDefault[b.key] = b.value, b.isForm) {
|
|
245
|
+
b.form = b.form || { span: u }, b.form.span = b.form.span ?? u;
|
|
246
|
+
let x = b.form.span, y = t.reduce((z, T) => z + T.span, x);
|
|
247
247
|
const E = t.length;
|
|
248
|
-
t.push({ item:
|
|
248
|
+
t.push({ item: b, span: x }), (E === 1 && t[0].span === 0 || y >= o || x === 0 && E > 1) && (a.push(t), t = []), b.rules && (s.rules[b.key] = b.rules);
|
|
249
249
|
}
|
|
250
250
|
};
|
|
251
|
-
e.column.forEach((
|
|
252
|
-
|
|
251
|
+
e.column.forEach((b) => {
|
|
252
|
+
b.isForm = !0, l(b);
|
|
253
253
|
}), t.length > 0 && a.push(t), s.formColumn = a;
|
|
254
254
|
}
|
|
255
255
|
});
|
|
@@ -258,28 +258,28 @@ const me = { class: "row curd-row" }, be = /* @__PURE__ */ N({
|
|
|
258
258
|
conf: s
|
|
259
259
|
}), (e, a) => {
|
|
260
260
|
const o = W("FormList");
|
|
261
|
-
return f(), g(d(
|
|
261
|
+
return f(), g(d(K), {
|
|
262
262
|
ref_key: "ruleFormRef",
|
|
263
263
|
ref: c,
|
|
264
264
|
model: s.form,
|
|
265
265
|
rules: s.rules
|
|
266
266
|
}, {
|
|
267
|
-
default:
|
|
268
|
-
s.showContent ? (f(!0), w(
|
|
267
|
+
default: h(() => [
|
|
268
|
+
s.showContent ? (f(!0), w($, { key: 0 }, F(s.formColumn, (u) => (f(), w("div", me, [
|
|
269
269
|
k(e.$slots, "form-start", {
|
|
270
270
|
row: s.form
|
|
271
271
|
}),
|
|
272
|
-
(f(!0), w(
|
|
272
|
+
(f(!0), w($, null, F(u, (t) => (f(), w($, null, [
|
|
273
273
|
d(r)(t.item.show?.form, s.form) ? (f(), w("div", {
|
|
274
274
|
key: 0,
|
|
275
|
-
class:
|
|
275
|
+
class: Q(t.item.form.span > 0 ? `col-${t.item.form.span}` : "col")
|
|
276
276
|
}, [
|
|
277
|
-
v(d(
|
|
277
|
+
v(d(_), {
|
|
278
278
|
label: t.item.label,
|
|
279
279
|
prop: t.item.key,
|
|
280
280
|
"label-width": t.item.form?.labelWidth || "100px"
|
|
281
281
|
}, {
|
|
282
|
-
default:
|
|
282
|
+
default: h(() => [
|
|
283
283
|
k(e.$slots, "form-" + t.item.key + "-start", {
|
|
284
284
|
row: s.form,
|
|
285
285
|
item: t.item
|
|
@@ -288,19 +288,19 @@ const me = { class: "row curd-row" }, be = /* @__PURE__ */ N({
|
|
|
288
288
|
row: s.form,
|
|
289
289
|
item: t.item
|
|
290
290
|
}, () => [
|
|
291
|
-
t.item.type === "input" ? (f(), g(d(
|
|
291
|
+
t.item.type === "input" ? (f(), g(d(H), D({
|
|
292
292
|
key: 0,
|
|
293
293
|
modelValue: s.form[t.item.key],
|
|
294
294
|
"onUpdate:modelValue": (l) => s.form[t.item.key] = l
|
|
295
|
-
}, { ref_for: !0 }, t.item.options?.input,
|
|
295
|
+
}, { ref_for: !0 }, t.item.options?.input, A(t.item.options?.input?.on), {
|
|
296
296
|
disabled: s.getDisabled(t.item)
|
|
297
|
-
}), null, 16, ["modelValue", "onUpdate:modelValue", "disabled"])) : t.item.type === "switch" ? (f(), g(d(
|
|
297
|
+
}), null, 16, ["modelValue", "onUpdate:modelValue", "disabled"])) : t.item.type === "switch" ? (f(), g(d(G), D({
|
|
298
298
|
key: 1,
|
|
299
299
|
modelValue: s.form[t.item.key],
|
|
300
300
|
"onUpdate:modelValue": (l) => s.form[t.item.key] = l
|
|
301
301
|
}, { ref_for: !0 }, t.item.options?.switch, {
|
|
302
302
|
disabled: s.getDisabled(t.item)
|
|
303
|
-
}), null, 16, ["modelValue", "onUpdate:modelValue", "disabled"])) : t.item.type === "select" ? (f(), g(d(
|
|
303
|
+
}), null, 16, ["modelValue", "onUpdate:modelValue", "disabled"])) : t.item.type === "select" ? (f(), g(d(M), D({
|
|
304
304
|
key: 2,
|
|
305
305
|
modelValue: s.form[t.item.key],
|
|
306
306
|
"onUpdate:modelValue": (l) => s.form[t.item.key] = l
|
|
@@ -308,8 +308,8 @@ const me = { class: "row curd-row" }, be = /* @__PURE__ */ N({
|
|
|
308
308
|
disabled: s.getDisabled(t.item),
|
|
309
309
|
style: { width: "100%" }
|
|
310
310
|
}), {
|
|
311
|
-
default:
|
|
312
|
-
(f(!0), w(
|
|
311
|
+
default: h(() => [
|
|
312
|
+
(f(!0), w($, null, F(t.item.options?.select?.data, (l) => (f(), g(d(R), {
|
|
313
313
|
key: l.value,
|
|
314
314
|
label: l.label,
|
|
315
315
|
value: l.value
|
|
@@ -423,7 +423,7 @@ class I {
|
|
|
423
423
|
}), n;
|
|
424
424
|
};
|
|
425
425
|
}
|
|
426
|
-
const
|
|
426
|
+
const be = {
|
|
427
427
|
key: 0,
|
|
428
428
|
class: "column",
|
|
429
429
|
style: { width: "100%", gap: "10px" }
|
|
@@ -466,7 +466,7 @@ const he = {
|
|
|
466
466
|
},
|
|
467
467
|
emits: ["change"],
|
|
468
468
|
setup(p, { emit: i }) {
|
|
469
|
-
const r = p, n =
|
|
469
|
+
const r = p, n = X({
|
|
470
470
|
show: !1,
|
|
471
471
|
add: (m, s, e) => {
|
|
472
472
|
I.add(m, s, e, () => {
|
|
@@ -485,30 +485,30 @@ const he = {
|
|
|
485
485
|
const c = i;
|
|
486
486
|
return (m, s) => {
|
|
487
487
|
const e = W("el-button"), a = W("el-input");
|
|
488
|
-
return n.show ? (f(), w("div",
|
|
488
|
+
return n.show ? (f(), w("div", be, [
|
|
489
489
|
k(m.$slots, "list-start", { row: p.row }),
|
|
490
|
-
|
|
490
|
+
U("div", null, [
|
|
491
491
|
v(e, {
|
|
492
492
|
link: "",
|
|
493
493
|
type: "primary",
|
|
494
494
|
onClick: s[0] || (s[0] = (o) => n.add(p.field, p.row, p.itemFields))
|
|
495
495
|
}, {
|
|
496
|
-
default:
|
|
496
|
+
default: h(() => [...s[2] || (s[2] = [
|
|
497
497
|
V("添加", -1)
|
|
498
498
|
])]),
|
|
499
499
|
_: 1
|
|
500
500
|
})
|
|
501
501
|
]),
|
|
502
|
-
(f(!0), w(
|
|
502
|
+
(f(!0), w($, null, F(p.row[p.field], (o) => (f(), w("div", ye, [
|
|
503
503
|
k(m.$slots, "item-start", {
|
|
504
504
|
item: o,
|
|
505
505
|
row: p.row
|
|
506
506
|
}),
|
|
507
|
-
(f(!0), w(
|
|
507
|
+
(f(!0), w($, null, F(p.itemFields, (u) => (f(), g(a, {
|
|
508
508
|
modelValue: o[u.value],
|
|
509
509
|
"onUpdate:modelValue": (t) => o[u.value] = t,
|
|
510
510
|
style: se({ width: p.inputWidth }),
|
|
511
|
-
class:
|
|
511
|
+
class: Q(p.inputClass),
|
|
512
512
|
placeholder: u[p.label] || u[p.value],
|
|
513
513
|
onChange: s[1] || (s[1] = (t) => c("change"))
|
|
514
514
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "style", "class", "placeholder"]))), 256)),
|
|
@@ -521,7 +521,7 @@ const he = {
|
|
|
521
521
|
type: "danger",
|
|
522
522
|
onClick: (u) => n.remove(p.field, p.row, o)
|
|
523
523
|
}, {
|
|
524
|
-
default:
|
|
524
|
+
default: h(() => [...s[3] || (s[3] = [
|
|
525
525
|
V("删除", -1)
|
|
526
526
|
])]),
|
|
527
527
|
_: 1
|
|
@@ -540,7 +540,7 @@ class ge {
|
|
|
540
540
|
* @param fileName 文件名
|
|
541
541
|
*/
|
|
542
542
|
static exportToExcel = async (i, r, n) => {
|
|
543
|
-
const c = await
|
|
543
|
+
const c = await O.loadModule("xlsx"), m = i.map((a) => {
|
|
544
544
|
const o = {};
|
|
545
545
|
return r.forEach((u) => {
|
|
546
546
|
o[u.label] = a[u.key];
|
|
@@ -563,34 +563,34 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
563
563
|
};
|
|
564
564
|
return i({
|
|
565
565
|
open: e
|
|
566
|
-
}), (u, t) => (f(), g(d(
|
|
566
|
+
}), (u, t) => (f(), g(d(q), {
|
|
567
567
|
modelValue: r.value,
|
|
568
568
|
"onUpdate:modelValue": t[0] || (t[0] = (l) => r.value = l),
|
|
569
569
|
title: n.value,
|
|
570
570
|
"close-on-click-modal": !1,
|
|
571
571
|
width: "400px"
|
|
572
572
|
}, {
|
|
573
|
-
footer:
|
|
574
|
-
|
|
575
|
-
v(d(
|
|
576
|
-
default:
|
|
573
|
+
footer: h(() => [
|
|
574
|
+
U("span", we, [
|
|
575
|
+
v(d(S), { onClick: o }, {
|
|
576
|
+
default: h(() => [...t[1] || (t[1] = [
|
|
577
577
|
V("取消", -1)
|
|
578
578
|
])]),
|
|
579
579
|
_: 1
|
|
580
580
|
}),
|
|
581
|
-
v(d(
|
|
581
|
+
v(d(S), {
|
|
582
582
|
type: "primary",
|
|
583
583
|
onClick: a
|
|
584
584
|
}, {
|
|
585
|
-
default:
|
|
585
|
+
default: h(() => [...t[2] || (t[2] = [
|
|
586
586
|
V("确认", -1)
|
|
587
587
|
])]),
|
|
588
588
|
_: 1
|
|
589
589
|
})
|
|
590
590
|
])
|
|
591
591
|
]),
|
|
592
|
-
default:
|
|
593
|
-
|
|
592
|
+
default: h(() => [
|
|
593
|
+
U("div", null, J(c.value), 1)
|
|
594
594
|
]),
|
|
595
595
|
_: 1
|
|
596
596
|
}, 8, ["modelValue", "title"]));
|
|
@@ -607,7 +607,10 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
607
607
|
}, xe = { key: 0 }, $e = { key: 1 }, Oe = { key: 2 }, Se = { class: "export-btn" }, Fe = {
|
|
608
608
|
class: "flex items-center",
|
|
609
609
|
style: { gap: "10px" }
|
|
610
|
-
}, Ie = { class: "col fit-width relative" }, Le = { class: "absolute column fit" }, je = { class: "row justify-end mt-20 mb-20" }, ze = { class: "row curd-row" }, Te = {
|
|
610
|
+
}, Ie = { class: "col fit-width relative" }, Le = { class: "absolute column fit" }, je = { class: "row justify-end mt-20 mb-20" }, ze = { class: "row curd-row" }, Te = {
|
|
611
|
+
class: "row form-item-content",
|
|
612
|
+
style: { width: "100%" }
|
|
613
|
+
}, Re = { class: "col" }, _e = { class: "dialog-footer" }, Me = { class: "dialog-footer" }, Ne = /* @__PURE__ */ N({
|
|
611
614
|
__name: "index",
|
|
612
615
|
props: {
|
|
613
616
|
/**
|
|
@@ -618,7 +621,7 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
618
621
|
}
|
|
619
622
|
},
|
|
620
623
|
setup(p, { expose: i }) {
|
|
621
|
-
const r =
|
|
624
|
+
const r = O.EDialog, n = p, c = j(), m = j(), s = O.isFun, e = X({
|
|
622
625
|
search: {
|
|
623
626
|
column: {
|
|
624
627
|
list: []
|
|
@@ -698,7 +701,7 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
698
701
|
size: e.page.size,
|
|
699
702
|
num: e.page.num,
|
|
700
703
|
...e.search.getFormData(),
|
|
701
|
-
final(l,
|
|
704
|
+
final(l, b, x) {
|
|
702
705
|
e.table.loading = !1;
|
|
703
706
|
}
|
|
704
707
|
}), u = o.data || { list: o };
|
|
@@ -722,12 +725,12 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
722
725
|
},
|
|
723
726
|
select: () => {
|
|
724
727
|
if (e.table.selection.list.length === 0)
|
|
725
|
-
throw
|
|
728
|
+
throw O.fail("请选择要导出的数据"), new Error("请选择要导出的数据");
|
|
726
729
|
return e.table.selection.list;
|
|
727
730
|
},
|
|
728
731
|
page: () => {
|
|
729
732
|
if (e.table.data.length === 0)
|
|
730
|
-
throw
|
|
733
|
+
throw O.fail("暂无数据"), new Error("暂无数据");
|
|
731
734
|
return e.table.data;
|
|
732
735
|
},
|
|
733
736
|
all: async () => {
|
|
@@ -785,8 +788,8 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
785
788
|
},
|
|
786
789
|
submit: () => {
|
|
787
790
|
FunUtil.throttle(async () => {
|
|
788
|
-
await m.value?.validate(async (u, t) => new Promise((l,
|
|
789
|
-
u || (
|
|
791
|
+
await m.value?.validate(async (u, t) => new Promise((l, b) => {
|
|
792
|
+
u || (O.fail("请检查表单数据"), b(!1)), l();
|
|
790
793
|
})), e.update.loading = !0;
|
|
791
794
|
const a = e.update.type === r.Insert ? n.option.api.create : n.option.api.update;
|
|
792
795
|
let o = JSONUtil.cp(e.update.form);
|
|
@@ -819,7 +822,7 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
819
822
|
},
|
|
820
823
|
open: (a) => {
|
|
821
824
|
if (a.length === 0) {
|
|
822
|
-
|
|
825
|
+
O.fail("请选择要删除的数据");
|
|
823
826
|
return;
|
|
824
827
|
}
|
|
825
828
|
e.remove.items = a, e.remove.show = !0;
|
|
@@ -833,7 +836,7 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
833
836
|
final(o, u, t) {
|
|
834
837
|
e.table.loading = !1;
|
|
835
838
|
}
|
|
836
|
-
}),
|
|
839
|
+
}), O.success("操作成功"), e.table.data.length <= 1 && e.page.num > 1 && (e.page.num -= 1), e.remove.close(), await e.table.getList();
|
|
837
840
|
});
|
|
838
841
|
}
|
|
839
842
|
},
|
|
@@ -878,19 +881,19 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
878
881
|
activeLabel: "开启",
|
|
879
882
|
inactiveValue: !1,
|
|
880
883
|
inactiveLabel: "关闭",
|
|
881
|
-
tableBeforeChange: async (
|
|
884
|
+
tableBeforeChange: async (x, y) => {
|
|
882
885
|
const E = u.options?.switch;
|
|
883
886
|
try {
|
|
884
887
|
return await c.value?.open({
|
|
885
888
|
title: "确认修改",
|
|
886
|
-
content: `确认要${y[
|
|
889
|
+
content: `确认要${y[x] === E.activeValue ? E.inactiveLabel : E.activeLabel}吗?`
|
|
887
890
|
}), e.table.loading = !0, await n.option.api.update({
|
|
888
891
|
_id: y._id,
|
|
889
|
-
[
|
|
890
|
-
final(z, T,
|
|
892
|
+
[x]: y[x] === E.activeValue ? E.inactiveValue : E.activeValue,
|
|
893
|
+
final(z, T, Y) {
|
|
891
894
|
e.table.loading = !1;
|
|
892
895
|
}
|
|
893
|
-
}),
|
|
896
|
+
}), O.success("操作成功"), e.table.getList(), !0;
|
|
894
897
|
} catch {
|
|
895
898
|
return !1;
|
|
896
899
|
}
|
|
@@ -925,9 +928,9 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
925
928
|
table: 0,
|
|
926
929
|
form: 0
|
|
927
930
|
}
|
|
928
|
-
},
|
|
929
|
-
Object.keys(l).forEach((
|
|
930
|
-
|
|
931
|
+
}, b = u;
|
|
932
|
+
Object.keys(l).forEach((x) => {
|
|
933
|
+
b[x] = ObjectUtil.deepMerge(l[x], b[x] || {});
|
|
931
934
|
});
|
|
932
935
|
};
|
|
933
936
|
a.column.forEach(o), a.table?.column?.forEach(o);
|
|
@@ -940,22 +943,22 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
940
943
|
};
|
|
941
944
|
const o = [], u = n.option.form?.maxSpan || 12, t = n.option.form?.defaultSpan || u / 2;
|
|
942
945
|
let l = [];
|
|
943
|
-
const
|
|
946
|
+
const b = (y) => {
|
|
944
947
|
if (e.update.formDefault[y.key] = y.value, y.table.table && (y.show.table && e.table.column.show.list.push(y.key), y.table.table && e.table.column.show.listSource.push(y.key)), y.isForm) {
|
|
945
948
|
y.form = y.form || { span: t }, y.form.span = y.form.span ?? t;
|
|
946
|
-
let E = y.form.span, z = l.reduce((
|
|
949
|
+
let E = y.form.span, z = l.reduce((Y, ae) => Y + ae.span, E);
|
|
947
950
|
const T = l.length;
|
|
948
951
|
l.push({ item: y, span: E }), (T === 1 && l[0].span === 0 || z >= u || E === 0 && T > 1) && (o.push(l), l = []), y.rules && (e.update.rules[y.key] = y.rules);
|
|
949
952
|
}
|
|
950
953
|
};
|
|
951
954
|
a.column.forEach((y) => {
|
|
952
|
-
y.isForm = !0,
|
|
955
|
+
y.isForm = !0, b(y);
|
|
953
956
|
}), n.option.table?.column?.forEach((y) => {
|
|
954
|
-
y.isForm = !1,
|
|
957
|
+
y.isForm = !1, b(y);
|
|
955
958
|
}), e.search.column.list = a.column.concat(a.table?.column || []), e.table.column.list = e.search.column.list.filter((y) => y.table?.table), e.search.column.list.sort((y, E) => y.sort?.search - E.sort?.search), e.table.column.list.sort((y, E) => y.sort?.table - E.sort?.table), l.length > 0 && o.push(l), e.update.formColumn = o;
|
|
956
|
-
const
|
|
957
|
-
|
|
958
|
-
e.search.formDefault[y] =
|
|
959
|
+
const x = n.option.search?.formDefault;
|
|
960
|
+
x && Object.keys(x).forEach((y) => {
|
|
961
|
+
e.search.formDefault[y] = x[y];
|
|
959
962
|
}), a.column.forEach((y) => {
|
|
960
963
|
y.show?.search || (e.search.formDefault[y.key] = void 0);
|
|
961
964
|
}), e.search.form = JSONUtil.cp(e.search.formDefault);
|
|
@@ -968,37 +971,37 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
968
971
|
}), (a, o) => {
|
|
969
972
|
const u = ne("loading");
|
|
970
973
|
return f(), w("div", ve, [
|
|
971
|
-
|
|
974
|
+
U("div", Ce, [
|
|
972
975
|
k(a.$slots, "box-left"),
|
|
973
|
-
|
|
976
|
+
U("div", Ve, [
|
|
974
977
|
p.option.search?.show !== !1 ? (f(), w("div", De, [
|
|
975
|
-
v(d(
|
|
978
|
+
v(d(K), {
|
|
976
979
|
model: e.search.form,
|
|
977
980
|
inline: ""
|
|
978
981
|
}, {
|
|
979
|
-
default:
|
|
982
|
+
default: h(() => [
|
|
980
983
|
k(a.$slots, "search-start", {
|
|
981
984
|
row: e.search.form
|
|
982
985
|
}),
|
|
983
|
-
(f(!0), w(
|
|
986
|
+
(f(!0), w($, null, F(e.search.column.list, (t) => (f(), w($, {
|
|
984
987
|
key: t.key
|
|
985
988
|
}, [
|
|
986
|
-
(typeof t.show?.search == "function" ? t.show?.search(e.search.form) : t.show?.search) ? (f(), g(d(
|
|
989
|
+
(typeof t.show?.search == "function" ? t.show?.search(e.search.form) : t.show?.search) ? (f(), g(d(_), {
|
|
987
990
|
key: 0,
|
|
988
991
|
label: t.label
|
|
989
992
|
}, {
|
|
990
|
-
default:
|
|
993
|
+
default: h(() => [
|
|
991
994
|
k(a.$slots, "search-" + t.key, {
|
|
992
995
|
row: e.search.form
|
|
993
996
|
}, () => [
|
|
994
|
-
t.type === "input" ? (f(), g(d(
|
|
997
|
+
t.type === "input" ? (f(), g(d(H), {
|
|
995
998
|
key: 0,
|
|
996
999
|
modelValue: e.search.form[t.key],
|
|
997
1000
|
"onUpdate:modelValue": (l) => e.search.form[t.key] = l,
|
|
998
1001
|
placeholder: `请输入${t.label}`,
|
|
999
1002
|
clearable: "",
|
|
1000
1003
|
disabled: t.disabled?.search
|
|
1001
|
-
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder", "disabled"])) : t.type === "switch" ? (f(), g(d(
|
|
1004
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder", "disabled"])) : t.type === "switch" ? (f(), g(d(M), {
|
|
1002
1005
|
key: 1,
|
|
1003
1006
|
modelValue: e.search.form[t.key],
|
|
1004
1007
|
"onUpdate:modelValue": (l) => e.search.form[t.key] = l,
|
|
@@ -1006,7 +1009,7 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
1006
1009
|
clearable: "",
|
|
1007
1010
|
disabled: t.disabled?.search
|
|
1008
1011
|
}, {
|
|
1009
|
-
default:
|
|
1012
|
+
default: h(() => [
|
|
1010
1013
|
(f(), g(d(R), {
|
|
1011
1014
|
key: t.options?.switch?.activeValue,
|
|
1012
1015
|
label: t.options?.switch?.activeLabel,
|
|
@@ -1019,7 +1022,7 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
1019
1022
|
}, null, 8, ["label", "value"]))
|
|
1020
1023
|
]),
|
|
1021
1024
|
_: 2
|
|
1022
|
-
}, 1032, ["modelValue", "onUpdate:modelValue", "placeholder", "disabled"])) : t.type === "select" ? (f(), g(d(
|
|
1025
|
+
}, 1032, ["modelValue", "onUpdate:modelValue", "placeholder", "disabled"])) : t.type === "select" ? (f(), g(d(M), {
|
|
1023
1026
|
key: 2,
|
|
1024
1027
|
modelValue: e.search.form[t.key],
|
|
1025
1028
|
"onUpdate:modelValue": (l) => e.search.form[t.key] = l,
|
|
@@ -1027,8 +1030,8 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
1027
1030
|
clearable: "",
|
|
1028
1031
|
disabled: t.disabled?.search
|
|
1029
1032
|
}, {
|
|
1030
|
-
default:
|
|
1031
|
-
(f(!0), w(
|
|
1033
|
+
default: h(() => [
|
|
1034
|
+
(f(!0), w($, null, F(t.options?.select?.data, (l) => (f(), g(d(R), {
|
|
1032
1035
|
key: l.value,
|
|
1033
1036
|
label: l.label,
|
|
1034
1037
|
value: l.value
|
|
@@ -1044,23 +1047,23 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
1044
1047
|
k(a.$slots, "search-center", {
|
|
1045
1048
|
row: e.search.form
|
|
1046
1049
|
}),
|
|
1047
|
-
v(d(
|
|
1048
|
-
default:
|
|
1049
|
-
p.option.tools?.search ? (f(), g(d(
|
|
1050
|
+
v(d(_), null, {
|
|
1051
|
+
default: h(() => [
|
|
1052
|
+
p.option.tools?.search ? (f(), g(d(S), {
|
|
1050
1053
|
key: 0,
|
|
1051
1054
|
type: "primary",
|
|
1052
1055
|
onClick: e.search.submit
|
|
1053
1056
|
}, {
|
|
1054
|
-
default:
|
|
1057
|
+
default: h(() => [...o[7] || (o[7] = [
|
|
1055
1058
|
V(" 搜索 ", -1)
|
|
1056
1059
|
])]),
|
|
1057
1060
|
_: 1
|
|
1058
1061
|
}, 8, ["onClick"])) : C("", !0),
|
|
1059
|
-
p.option.tools?.reset ? (f(), g(d(
|
|
1062
|
+
p.option.tools?.reset ? (f(), g(d(S), {
|
|
1060
1063
|
key: 1,
|
|
1061
1064
|
onClick: e.search.reset
|
|
1062
1065
|
}, {
|
|
1063
|
-
default:
|
|
1066
|
+
default: h(() => [...o[8] || (o[8] = [
|
|
1064
1067
|
V("重置", -1)
|
|
1065
1068
|
])]),
|
|
1066
1069
|
_: 1
|
|
@@ -1075,36 +1078,36 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
1075
1078
|
_: 3
|
|
1076
1079
|
}, 8, ["model"])
|
|
1077
1080
|
])) : C("", !0),
|
|
1078
|
-
|
|
1079
|
-
|
|
1081
|
+
U("div", Ee, [
|
|
1082
|
+
U("div", Ue, [
|
|
1080
1083
|
d(s)(p.option.tools?.add) ? (f(), w("div", xe, [
|
|
1081
|
-
v(d(
|
|
1084
|
+
v(d(S), {
|
|
1082
1085
|
type: "primary",
|
|
1083
1086
|
onClick: o[0] || (o[0] = (t) => e.update.open(d(r).Insert))
|
|
1084
1087
|
}, {
|
|
1085
|
-
default:
|
|
1088
|
+
default: h(() => [...o[9] || (o[9] = [
|
|
1086
1089
|
V("新增", -1)
|
|
1087
1090
|
])]),
|
|
1088
1091
|
_: 1
|
|
1089
1092
|
})
|
|
1090
1093
|
])) : C("", !0),
|
|
1091
1094
|
p.option.table?.selectable && d(s)(p.option.tools?.delete) ? (f(), w("div", $e, [
|
|
1092
|
-
v(d(
|
|
1095
|
+
v(d(S), {
|
|
1093
1096
|
type: "danger",
|
|
1094
1097
|
onClick: o[1] || (o[1] = (t) => e.remove.open(e.table.selection.list))
|
|
1095
1098
|
}, {
|
|
1096
|
-
default:
|
|
1099
|
+
default: h(() => [...o[10] || (o[10] = [
|
|
1097
1100
|
V(" 删除 ", -1)
|
|
1098
1101
|
])]),
|
|
1099
1102
|
_: 1
|
|
1100
1103
|
})
|
|
1101
1104
|
])) : C("", !0),
|
|
1102
1105
|
p.option.tools?.expand ? (f(), w("div", Oe, [
|
|
1103
|
-
v(d(
|
|
1106
|
+
v(d(S), {
|
|
1104
1107
|
type: "warning",
|
|
1105
1108
|
onClick: o[2] || (o[2] = (t) => e.table.expand.all())
|
|
1106
1109
|
}, {
|
|
1107
|
-
default:
|
|
1110
|
+
default: h(() => [...o[11] || (o[11] = [
|
|
1108
1111
|
V("展开/收缩", -1)
|
|
1109
1112
|
])]),
|
|
1110
1113
|
_: 1
|
|
@@ -1114,23 +1117,23 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
1114
1117
|
key: 3,
|
|
1115
1118
|
onCommand: e.table.export
|
|
1116
1119
|
}, {
|
|
1117
|
-
dropdown:
|
|
1120
|
+
dropdown: h(() => [
|
|
1118
1121
|
v(d(fe), null, {
|
|
1119
|
-
default:
|
|
1122
|
+
default: h(() => [
|
|
1120
1123
|
v(d(P), { command: "select" }, {
|
|
1121
|
-
default:
|
|
1124
|
+
default: h(() => [...o[13] || (o[13] = [
|
|
1122
1125
|
V("导出选中", -1)
|
|
1123
1126
|
])]),
|
|
1124
1127
|
_: 1
|
|
1125
1128
|
}),
|
|
1126
1129
|
v(d(P), { command: "page" }, {
|
|
1127
|
-
default:
|
|
1130
|
+
default: h(() => [...o[14] || (o[14] = [
|
|
1128
1131
|
V("导出本页", -1)
|
|
1129
1132
|
])]),
|
|
1130
1133
|
_: 1
|
|
1131
1134
|
}),
|
|
1132
1135
|
v(d(P), { command: "all" }, {
|
|
1133
|
-
default:
|
|
1136
|
+
default: h(() => [...o[15] || (o[15] = [
|
|
1134
1137
|
V("导出全部", -1)
|
|
1135
1138
|
])]),
|
|
1136
1139
|
_: 1
|
|
@@ -1139,10 +1142,10 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
1139
1142
|
_: 1
|
|
1140
1143
|
})
|
|
1141
1144
|
]),
|
|
1142
|
-
default:
|
|
1143
|
-
|
|
1144
|
-
v(d(
|
|
1145
|
-
default:
|
|
1145
|
+
default: h(() => [
|
|
1146
|
+
U("div", Se, [
|
|
1147
|
+
v(d(S), { type: "warning" }, {
|
|
1148
|
+
default: h(() => [...o[12] || (o[12] = [
|
|
1146
1149
|
V("导出", -1)
|
|
1147
1150
|
])]),
|
|
1148
1151
|
_: 1
|
|
@@ -1153,12 +1156,12 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
1153
1156
|
}, 8, ["onCommand"])) : C("", !0),
|
|
1154
1157
|
k(a.$slots, "tools-left")
|
|
1155
1158
|
]),
|
|
1156
|
-
|
|
1159
|
+
U("div", Fe, [
|
|
1157
1160
|
k(a.$slots, "tools-right")
|
|
1158
1161
|
])
|
|
1159
1162
|
]),
|
|
1160
|
-
|
|
1161
|
-
|
|
1163
|
+
U("div", Ie, [
|
|
1164
|
+
U("div", Le, [
|
|
1162
1165
|
re((f(), g(d(pe), D({
|
|
1163
1166
|
data: e.table.data
|
|
1164
1167
|
}, p.option.table, {
|
|
@@ -1166,14 +1169,14 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
1166
1169
|
"expand-row-keys": e.table.expand.rowKeys,
|
|
1167
1170
|
onExpandChange: e.table.expand.change
|
|
1168
1171
|
}), {
|
|
1169
|
-
default:
|
|
1172
|
+
default: h(() => [
|
|
1170
1173
|
p.option.table?.selectable && d(s)(p.option.tools?.delete) ? (f(), g(d(B), {
|
|
1171
1174
|
key: 0,
|
|
1172
1175
|
type: "selection",
|
|
1173
1176
|
selectable: typeof p.option.table?.selectable == "function" ? p.option.table?.selectable : void 0,
|
|
1174
1177
|
width: "55"
|
|
1175
1178
|
}, null, 8, ["selectable"])) : C("", !0),
|
|
1176
|
-
(f(!0), w(
|
|
1179
|
+
(f(!0), w($, null, F(e.table.column.list, (t) => (f(), w($, {
|
|
1177
1180
|
key: t.key
|
|
1178
1181
|
}, [
|
|
1179
1182
|
e.table.column.show.list.includes(t.key) ? (f(), g(d(B), D({
|
|
@@ -1181,18 +1184,18 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
1181
1184
|
prop: t.key,
|
|
1182
1185
|
label: t.label
|
|
1183
1186
|
}, { ref_for: !0 }, t.table), {
|
|
1184
|
-
default:
|
|
1187
|
+
default: h(({ row: l }) => [
|
|
1185
1188
|
k(a.$slots, "table-" + t.key, {
|
|
1186
1189
|
row: l,
|
|
1187
1190
|
item: t
|
|
1188
1191
|
}, () => [
|
|
1189
|
-
t.type === "switch" ? (f(), g(d(
|
|
1192
|
+
t.type === "switch" ? (f(), g(d(G), D({
|
|
1190
1193
|
key: 0,
|
|
1191
1194
|
modelValue: l[t.key],
|
|
1192
|
-
"onUpdate:modelValue": (
|
|
1195
|
+
"onUpdate:modelValue": (b) => l[t.key] = b,
|
|
1193
1196
|
"before-change": () => t.options?.switch?.tableBeforeChange?.(t.key, l)
|
|
1194
|
-
}, { ref_for: !0 }, t.options?.switch), null, 16, ["modelValue", "onUpdate:modelValue", "before-change"])) : (f(), w(
|
|
1195
|
-
V(
|
|
1197
|
+
}, { ref_for: !0 }, t.options?.switch), null, 16, ["modelValue", "onUpdate:modelValue", "before-change"])) : (f(), w($, { key: 1 }, [
|
|
1198
|
+
V(J(l[t.key]), 1)
|
|
1196
1199
|
], 64))
|
|
1197
1200
|
])
|
|
1198
1201
|
]),
|
|
@@ -1206,37 +1209,37 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
1206
1209
|
align: "center",
|
|
1207
1210
|
fixed: "right"
|
|
1208
1211
|
}, {
|
|
1209
|
-
default:
|
|
1212
|
+
default: h(({ row: t }) => [
|
|
1210
1213
|
k(a.$slots, "table-op-left", { row: t }),
|
|
1211
|
-
d(s)(p.option.tools?.add, t) ? (f(), g(d(
|
|
1214
|
+
d(s)(p.option.tools?.add, t) ? (f(), g(d(S), {
|
|
1212
1215
|
key: 0,
|
|
1213
1216
|
link: "",
|
|
1214
1217
|
type: "primary",
|
|
1215
1218
|
onClick: (l) => e.update.open(d(r).Insert, t)
|
|
1216
1219
|
}, {
|
|
1217
|
-
default:
|
|
1220
|
+
default: h(() => [...o[16] || (o[16] = [
|
|
1218
1221
|
V(" 新增 ", -1)
|
|
1219
1222
|
])]),
|
|
1220
1223
|
_: 1
|
|
1221
1224
|
}, 8, ["onClick"])) : C("", !0),
|
|
1222
|
-
d(s)(p.option.tools?.update, t) ? (f(), g(d(
|
|
1225
|
+
d(s)(p.option.tools?.update, t) ? (f(), g(d(S), {
|
|
1223
1226
|
key: 1,
|
|
1224
1227
|
link: "",
|
|
1225
1228
|
type: "warning",
|
|
1226
1229
|
onClick: (l) => e.update.open(d(r).Update, t)
|
|
1227
1230
|
}, {
|
|
1228
|
-
default:
|
|
1231
|
+
default: h(() => [...o[17] || (o[17] = [
|
|
1229
1232
|
V(" 编辑 ", -1)
|
|
1230
1233
|
])]),
|
|
1231
1234
|
_: 1
|
|
1232
1235
|
}, 8, ["onClick"])) : C("", !0),
|
|
1233
|
-
d(s)(p.option.tools?.delete, t) ? (f(), g(d(
|
|
1236
|
+
d(s)(p.option.tools?.delete, t) ? (f(), g(d(S), {
|
|
1234
1237
|
key: 2,
|
|
1235
1238
|
link: "",
|
|
1236
1239
|
type: "danger",
|
|
1237
1240
|
onClick: (l) => e.remove.open([t])
|
|
1238
1241
|
}, {
|
|
1239
|
-
default:
|
|
1242
|
+
default: h(() => [...o[18] || (o[18] = [
|
|
1240
1243
|
V(" 删除 ", -1)
|
|
1241
1244
|
])]),
|
|
1242
1245
|
_: 1
|
|
@@ -1252,7 +1255,7 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
1252
1255
|
])
|
|
1253
1256
|
])
|
|
1254
1257
|
]),
|
|
1255
|
-
|
|
1258
|
+
U("div", je, [
|
|
1256
1259
|
e.page.total > e.page.size ? (f(), g(d(ce), {
|
|
1257
1260
|
key: 0,
|
|
1258
1261
|
"current-page": e.page.num,
|
|
@@ -1271,126 +1274,130 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
1271
1274
|
]),
|
|
1272
1275
|
k(a.$slots, "box-right")
|
|
1273
1276
|
]),
|
|
1274
|
-
v(d(
|
|
1277
|
+
v(d(q), D({
|
|
1275
1278
|
modelValue: e.update.show,
|
|
1276
1279
|
"onUpdate:modelValue": o[5] || (o[5] = (t) => e.update.show = t),
|
|
1277
1280
|
title: e.update.title,
|
|
1278
1281
|
"close-on-click-modal": !1,
|
|
1279
1282
|
"before-close": e.update.close
|
|
1280
1283
|
}, p.option.dialog), {
|
|
1281
|
-
footer:
|
|
1282
|
-
|
|
1283
|
-
v(d(
|
|
1284
|
+
footer: h(() => [
|
|
1285
|
+
U("span", _e, [
|
|
1286
|
+
v(d(S), {
|
|
1284
1287
|
onClick: e.update.close
|
|
1285
1288
|
}, {
|
|
1286
|
-
default:
|
|
1289
|
+
default: h(() => [...o[19] || (o[19] = [
|
|
1287
1290
|
V("关闭", -1)
|
|
1288
1291
|
])]),
|
|
1289
1292
|
_: 1
|
|
1290
1293
|
}, 8, ["onClick"]),
|
|
1291
|
-
v(d(
|
|
1294
|
+
v(d(S), {
|
|
1292
1295
|
type: "primary",
|
|
1293
1296
|
onClick: e.update.submit,
|
|
1294
1297
|
loading: e.update.loading
|
|
1295
1298
|
}, {
|
|
1296
|
-
default:
|
|
1299
|
+
default: h(() => [...o[20] || (o[20] = [
|
|
1297
1300
|
V(" 提交 ", -1)
|
|
1298
1301
|
])]),
|
|
1299
1302
|
_: 1
|
|
1300
1303
|
}, 8, ["onClick", "loading"])
|
|
1301
1304
|
])
|
|
1302
1305
|
]),
|
|
1303
|
-
default:
|
|
1304
|
-
v(d(
|
|
1306
|
+
default: h(() => [
|
|
1307
|
+
v(d(K), {
|
|
1305
1308
|
ref_key: "ruleFormRef",
|
|
1306
1309
|
ref: m,
|
|
1307
1310
|
model: e.update.form,
|
|
1308
1311
|
rules: e.update.rules
|
|
1309
1312
|
}, {
|
|
1310
|
-
default:
|
|
1311
|
-
e.update.showContent ? (f(!0), w(
|
|
1313
|
+
default: h(() => [
|
|
1314
|
+
e.update.showContent ? (f(!0), w($, { key: 0 }, F(e.update.formColumn, (t) => (f(), w("div", ze, [
|
|
1312
1315
|
k(a.$slots, "form-start", {
|
|
1313
1316
|
row: e.update.form
|
|
1314
1317
|
}),
|
|
1315
|
-
(f(!0), w(
|
|
1318
|
+
(f(!0), w($, null, F(t, (l) => (f(), w($, null, [
|
|
1316
1319
|
d(s)(l.item.show?.form, e.update.form) ? (f(), w("div", {
|
|
1317
1320
|
key: 0,
|
|
1318
|
-
class:
|
|
1321
|
+
class: Q(l.item.form.span > 0 ? `col-${l.item.form.span}` : "col")
|
|
1319
1322
|
}, [
|
|
1320
|
-
v(d(
|
|
1323
|
+
v(d(_), {
|
|
1321
1324
|
label: l.item.label,
|
|
1322
1325
|
prop: l.item.key,
|
|
1323
1326
|
"label-width": l.item.form?.labelWidth || "100px"
|
|
1324
1327
|
}, {
|
|
1325
|
-
default:
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
item: l.item
|
|
1329
|
-
}),
|
|
1330
|
-
k(a.$slots, "form-" + l.item.key, {
|
|
1331
|
-
row: e.update.form,
|
|
1332
|
-
item: l.item
|
|
1333
|
-
}, () => [
|
|
1334
|
-
l.item.type === "input" ? (f(), g(d(K), D({
|
|
1335
|
-
key: 0,
|
|
1336
|
-
modelValue: e.update.form[l.item.key],
|
|
1337
|
-
"onUpdate:modelValue": (h) => e.update.form[l.item.key] = h
|
|
1338
|
-
}, { ref_for: !0 }, l.item.options?.input, Y(l.item.options?.input?.on), {
|
|
1339
|
-
disabled: e.update.getDisabled(l.item)
|
|
1340
|
-
}), null, 16, ["modelValue", "onUpdate:modelValue", "disabled"])) : l.item.type === "switch" ? (f(), g(d(H), D({
|
|
1341
|
-
key: 1,
|
|
1342
|
-
modelValue: e.update.form[l.item.key],
|
|
1343
|
-
"onUpdate:modelValue": (h) => e.update.form[l.item.key] = h
|
|
1344
|
-
}, { ref_for: !0 }, l.item.options?.switch, {
|
|
1345
|
-
disabled: e.update.getDisabled(l.item)
|
|
1346
|
-
}), null, 16, ["modelValue", "onUpdate:modelValue", "disabled"])) : l.item.type === "select" ? (f(), g(d(_), D({
|
|
1347
|
-
key: 2,
|
|
1348
|
-
modelValue: e.update.form[l.item.key],
|
|
1349
|
-
"onUpdate:modelValue": (h) => e.update.form[l.item.key] = h
|
|
1350
|
-
}, { ref_for: !0 }, l.item.options?.select, {
|
|
1351
|
-
disabled: e.update.getDisabled(l.item),
|
|
1352
|
-
style: { width: "100%" }
|
|
1353
|
-
}), {
|
|
1354
|
-
default: b(() => [
|
|
1355
|
-
(f(!0), w(x, null, F(l.item.options?.select?.data, (h) => (f(), g(d(R), {
|
|
1356
|
-
key: h.value,
|
|
1357
|
-
label: h.label,
|
|
1358
|
-
value: h.value
|
|
1359
|
-
}, null, 8, ["label", "value"]))), 128))
|
|
1360
|
-
]),
|
|
1361
|
-
_: 2
|
|
1362
|
-
}, 1040, ["modelValue", "onUpdate:modelValue", "disabled"])) : l.item.type === "list" ? (f(), g(oe, D({
|
|
1363
|
-
key: 3,
|
|
1328
|
+
default: h(() => [
|
|
1329
|
+
U("div", Te, [
|
|
1330
|
+
k(a.$slots, "form-" + l.item.key + "-start", {
|
|
1364
1331
|
row: e.update.form,
|
|
1365
|
-
|
|
1366
|
-
},
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1332
|
+
item: l.item
|
|
1333
|
+
}),
|
|
1334
|
+
U("div", Re, [
|
|
1335
|
+
k(a.$slots, "form-" + l.item.key, {
|
|
1336
|
+
row: e.update.form,
|
|
1337
|
+
item: l.item
|
|
1338
|
+
}, () => [
|
|
1339
|
+
l.item.type === "input" ? (f(), g(d(H), D({
|
|
1340
|
+
key: 0,
|
|
1341
|
+
modelValue: e.update.form[l.item.key],
|
|
1342
|
+
"onUpdate:modelValue": (b) => e.update.form[l.item.key] = b
|
|
1343
|
+
}, { ref_for: !0 }, l.item.options?.input, A(l.item.options?.input?.on || {}), {
|
|
1344
|
+
disabled: e.update.getDisabled(l.item)
|
|
1345
|
+
}), null, 16, ["modelValue", "onUpdate:modelValue", "disabled"])) : l.item.type === "switch" ? (f(), g(d(G), D({
|
|
1346
|
+
key: 1,
|
|
1347
|
+
modelValue: e.update.form[l.item.key],
|
|
1348
|
+
"onUpdate:modelValue": (b) => e.update.form[l.item.key] = b
|
|
1349
|
+
}, { ref_for: !0 }, l.item.options?.switch, {
|
|
1350
|
+
disabled: e.update.getDisabled(l.item)
|
|
1351
|
+
}), null, 16, ["modelValue", "onUpdate:modelValue", "disabled"])) : l.item.type === "select" ? (f(), g(d(M), D({
|
|
1352
|
+
key: 2,
|
|
1353
|
+
modelValue: e.update.form[l.item.key],
|
|
1354
|
+
"onUpdate:modelValue": (b) => e.update.form[l.item.key] = b
|
|
1355
|
+
}, { ref_for: !0 }, l.item.options?.select, A(l.item.options?.select?.on || {}), {
|
|
1356
|
+
disabled: e.update.getDisabled(l.item),
|
|
1357
|
+
style: { width: "100%" }
|
|
1358
|
+
}), {
|
|
1359
|
+
default: h(() => [
|
|
1360
|
+
(f(!0), w($, null, F(l.item.options?.select?.data, (b) => (f(), g(d(R), {
|
|
1361
|
+
key: b.value,
|
|
1362
|
+
label: b.label,
|
|
1363
|
+
value: b.value
|
|
1364
|
+
}, null, 8, ["label", "value"]))), 128))
|
|
1365
|
+
]),
|
|
1366
|
+
_: 2
|
|
1367
|
+
}, 1040, ["modelValue", "onUpdate:modelValue", "disabled"])) : l.item.type === "list" ? (f(), g(oe, D({
|
|
1368
|
+
key: 3,
|
|
1369
|
+
row: e.update.form,
|
|
1370
|
+
field: l.item.key
|
|
1371
|
+
}, { ref_for: !0 }, l.item.options?.list, {
|
|
1372
|
+
disabled: e.update.getDisabled(l.item),
|
|
1373
|
+
style: { width: "100%" }
|
|
1374
|
+
}), null, 16, ["row", "field", "disabled"])) : l.item.type === "tree-select" ? (f(), g(d(te), D({
|
|
1375
|
+
key: 4,
|
|
1376
|
+
modelValue: e.update.form[l.item.key],
|
|
1377
|
+
"onUpdate:modelValue": (b) => e.update.form[l.item.key] = b
|
|
1378
|
+
}, { ref_for: !0 }, l.item.options?.treeSelect, {
|
|
1379
|
+
disabled: e.update.getDisabled(l.item),
|
|
1380
|
+
style: { width: "100%" }
|
|
1381
|
+
}), null, 16, ["modelValue", "onUpdate:modelValue", "disabled"])) : l.item.type === "datetime" ? (f(), g(d(le), D({
|
|
1382
|
+
key: 5,
|
|
1383
|
+
modelValue: e.update.form[l.item.key],
|
|
1384
|
+
"onUpdate:modelValue": (b) => e.update.form[l.item.key] = b
|
|
1385
|
+
}, { ref_for: !0 }, l.item.options?.datetime, {
|
|
1386
|
+
disabled: e.update.getDisabled(l.item)
|
|
1387
|
+
}), null, 16, ["modelValue", "onUpdate:modelValue", "disabled"])) : d(L).customComponent[l.item.type] ? (f(), g(Z(d(L).customComponent[l.item.type]), D({
|
|
1388
|
+
key: 6,
|
|
1389
|
+
modelValue: e.update.form[l.item.key],
|
|
1390
|
+
"onUpdate:modelValue": (b) => e.update.form[l.item.key] = b
|
|
1391
|
+
}, { ref_for: !0 }, l.item.options?.[l.item.type], {
|
|
1392
|
+
disabled: e.update.getDisabled(l.item)
|
|
1393
|
+
}), null, 16, ["modelValue", "onUpdate:modelValue", "disabled"])) : C("", !0)
|
|
1394
|
+
])
|
|
1395
|
+
]),
|
|
1396
|
+
k(a.$slots, "form-" + l.item.key + "-end", {
|
|
1397
|
+
row: e.update.form,
|
|
1398
|
+
item: l.item
|
|
1399
|
+
})
|
|
1400
|
+
])
|
|
1394
1401
|
]),
|
|
1395
1402
|
_: 2
|
|
1396
1403
|
}, 1032, ["label", "prop", "label-width"])
|
|
@@ -1406,36 +1413,36 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
1406
1413
|
]),
|
|
1407
1414
|
_: 3
|
|
1408
1415
|
}, 16, ["modelValue", "title", "before-close"]),
|
|
1409
|
-
v(d(
|
|
1416
|
+
v(d(q), {
|
|
1410
1417
|
modelValue: e.remove.show,
|
|
1411
1418
|
"onUpdate:modelValue": o[6] || (o[6] = (t) => e.remove.show = t),
|
|
1412
1419
|
title: e.remove.title,
|
|
1413
1420
|
"close-on-click-modal": !1
|
|
1414
1421
|
}, {
|
|
1415
|
-
footer:
|
|
1416
|
-
|
|
1417
|
-
v(d(
|
|
1422
|
+
footer: h(() => [
|
|
1423
|
+
U("span", Me, [
|
|
1424
|
+
v(d(S), {
|
|
1418
1425
|
onClick: e.remove.close
|
|
1419
1426
|
}, {
|
|
1420
|
-
default:
|
|
1427
|
+
default: h(() => [...o[21] || (o[21] = [
|
|
1421
1428
|
V("关闭", -1)
|
|
1422
1429
|
])]),
|
|
1423
1430
|
_: 1
|
|
1424
1431
|
}, 8, ["onClick"]),
|
|
1425
|
-
v(d(
|
|
1432
|
+
v(d(S), {
|
|
1426
1433
|
type: "danger",
|
|
1427
1434
|
onClick: e.remove.submit,
|
|
1428
1435
|
loading: e.remove.loading
|
|
1429
1436
|
}, {
|
|
1430
|
-
default:
|
|
1437
|
+
default: h(() => [...o[22] || (o[22] = [
|
|
1431
1438
|
V(" 确认删除 ", -1)
|
|
1432
1439
|
])]),
|
|
1433
1440
|
_: 1
|
|
1434
1441
|
}, 8, ["onClick", "loading"])
|
|
1435
1442
|
])
|
|
1436
1443
|
]),
|
|
1437
|
-
default:
|
|
1438
|
-
|
|
1444
|
+
default: h(() => [
|
|
1445
|
+
U("div", null, "确认要删除【" + J(e.remove.items.length) + "】条数据吗?", 1)
|
|
1439
1446
|
]),
|
|
1440
1447
|
_: 1
|
|
1441
1448
|
}, 8, ["modelValue", "title"]),
|
|
@@ -1446,8 +1453,8 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
1446
1453
|
]);
|
|
1447
1454
|
};
|
|
1448
1455
|
}
|
|
1449
|
-
}),
|
|
1450
|
-
if (p.component("TCurd",
|
|
1456
|
+
}), We = (p, i) => {
|
|
1457
|
+
if (p.component("TCurd", Ne), p.component("TFormList", oe), p.component("TColumn", he), i?.customComponent) {
|
|
1451
1458
|
L.customComponent = i.customComponent;
|
|
1452
1459
|
for (const r in i.customComponent)
|
|
1453
1460
|
p.component(r, i.customComponent[r]);
|
|
@@ -1456,10 +1463,10 @@ const we = { class: "dialog-footer" }, ke = /* @__PURE__ */ N({
|
|
|
1456
1463
|
export {
|
|
1457
1464
|
I as ArrUtil,
|
|
1458
1465
|
ge as ExcelUtil,
|
|
1459
|
-
|
|
1460
|
-
|
|
1466
|
+
he as TColumn,
|
|
1467
|
+
Ne as TCurd,
|
|
1461
1468
|
L as TForm,
|
|
1462
1469
|
oe as TFormList,
|
|
1463
|
-
|
|
1464
|
-
|
|
1470
|
+
O as TSys,
|
|
1471
|
+
We as install
|
|
1465
1472
|
};
|
package/dist/cc1-form.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(y,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("element-plus")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus"],e):(y=typeof globalThis<"u"?globalThis:y||self,e(y.cc1Form={},y.Vue,y.ElementPlus))})(this,(function(y,e,p){"use strict";class b{static router;static routes;static getRouterPath=()=>this.router.currentRoute.value.path;static EDialog={Insert:"Insert",Update:"Update",Remove:"Remove"};static isFun=(d,i)=>typeof d=="function"?d(i):d;static getRouterParams=()=>{const d=this.router.currentRoute.value.query||{},i=this.router.currentRoute.value.params||{};return Object.keys(d).length?d:Object.keys(i).length?i:{}};static moduleObj={};static loadModule=async d=>{if(!b.moduleObj[d])throw new Error(`模块${d}未加载,请赋值如:TSys.moduleObj = { ${d}: ()=>import('${d}') }`);const i=await b.moduleObj[d]();return i.default??i};static tipMessages={};static tipMessagesGap=500;static showMessage(d,i,s={}){const m=Date.now();if(!this.tipMessages[d]||m-this.tipMessages[d]>this.tipMessagesGap){this.tipMessages[d]=m;const u=Object.assign({message:d,type:i},s);p.ElMessage(u),setTimeout(()=>{delete this.tipMessages[d]},this.tipMessagesGap)}}static fail=(d,i={})=>{this.showMessage(d,"error",i)};static success=(d,i={})=>{this.showMessage(d,"success",i)};static loadingObj=null;static loadingTimer=null;static loading=(d=!0,i="加载中")=>{Timer.un(this.loadingTimer),this.loadingTimer=Timer.once(()=>{d?this.loadingObj=p.ElLoading.service({lock:!0,text:i,background:"rgba(0, 0, 0, 0.3)"}):this.loadingObj&&(this.loadingObj.close(),this.loadingObj=null)},50)};static openUrl=(d,i=!0)=>{if(i){let s=screen.width/2-500,m=screen.height/2-800/2-30;window.open(d,"_blank","toolbar=no, location=yes, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=1000, height=800, top="+m+", left="+s)}else window.open(d,"DescriptiveWindowName"+StrUtil.getId(),"resizable,scrollbars=yes,status=1,width=1024, height=600, top=0, left=0")};static getImgPic=d=>new Promise(async(i,s)=>{let m=document.getElementById(d.id);const u=await b.loadModule("html2canvas");try{u(m,{logging:!1,allowTaint:!0,scale:window.devicePixelRatio,width:d.windowWidth,height:d.windowHeight,windowWidth:d.windowWidth,windowHeight:d.windowHeight,useCORS:!0,backgroundColor:"#ffffff00"}).then(function(r){let t=r.toDataURL("image/png");i(t)})}catch(r){s(r)}});static async download(d,i="download.png"){const s=document.createElement("a");s.style.display="none",s.href=d,s.setAttribute("download",i),typeof s.download>"u"&&s.setAttribute("target","_blank"),document.body.appendChild(s),s.click(),document.body.removeChild(s),window.URL.revokeObjectURL(d)}}class C{static customComponent={};static findOptions=(d,i)=>{const s=d.column.find(u=>u.key===i),m=u=>u.replace(/-([a-z])/g,(r,t)=>t.toUpperCase());if(s)return s.options[m(s.type)]};static setOptionsData=(d,i,s)=>{const m=C.findOptions(d,i);m&&(m.data=s)};static form={openBefore:{parentId:(d,i,s,m)=>{d?i.type===b.EDialog.Insert?(i.form.parentId=d._id,i.form.sort=d.children.length+1):i.form.parentId=d.parentId.substring(d.parentId.lastIndexOf(",")+1):(i.form.parentId="0",i.form.sort=s.length+1),C.setOptionsData(m,"parentId",[{_id:"0",title:"根",children:s}])}}}}const F={class:"row curd-row"},N=e.defineComponent({__name:"column",props:{option:{default:{}}},setup(f,{expose:d}){const i=b.isFun,s=b.EDialog,m=e.ref(),u=f,r=e.reactive({rules:{},show:!1,showContent:!1,loading:!1,type:s.Insert,form:{},formDefault:{},formColumn:[],getDisabled:t=>t.disabled?.[r.type===s.Insert?"create":"update"],initColumnForm:()=>{const t=u.option;r.formColumn=[];const n=[],a=u.option.form?.maxSpan||12,c=u.option.form?.defaultSpan||a;let o=[];const l=h=>{if(r.formDefault[h.key]=h.value,h.isForm){h.form=h.form||{span:c},h.form.span=h.form.span??c;let w=h.form.span,k=o.reduce((B,E)=>B+E.span,w);const g=o.length;o.push({item:h,span:w}),(g===1&&o[0].span===0||k>=a||w===0&&g>1)&&(n.push(o),o=[]),h.rules&&(r.rules[h.key]=h.rules)}};t.column.forEach(h=>{h.isForm=!0,l(h)}),o.length>0&&n.push(o),r.formColumn=n}});return r.initColumnForm(),d({ref:m,conf:r}),(t,n)=>{const a=e.resolveComponent("FormList");return e.openBlock(),e.createBlock(e.unref(p.ElForm),{ref_key:"ruleFormRef",ref:m,model:r.form,rules:r.rules},{default:e.withCtx(()=>[r.showContent?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(r.formColumn,c=>(e.openBlock(),e.createElementBlock("div",F,[e.renderSlot(t.$slots,"form-start",{row:r.form}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c,o=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.unref(i)(o.item.show?.form,r.form)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(o.item.form.span>0?`col-${o.item.form.span}`:"col")},[e.createVNode(e.unref(p.ElFormItem),{label:o.item.label,prop:o.item.key,"label-width":o.item.form?.labelWidth||"100px"},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"form-"+o.item.key+"-start",{row:r.form,item:o.item}),e.renderSlot(t.$slots,"form-"+o.item.key,{row:r.form,item:o.item},()=>[o.item.type==="input"?(e.openBlock(),e.createBlock(e.unref(p.ElInput),e.mergeProps({key:0,modelValue:r.form[o.item.key],"onUpdate:modelValue":l=>r.form[o.item.key]=l},{ref_for:!0},o.item.options?.input,e.toHandlers(o.item.options?.input?.on),{disabled:r.getDisabled(o.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):o.item.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSwitch),e.mergeProps({key:1,modelValue:r.form[o.item.key],"onUpdate:modelValue":l=>r.form[o.item.key]=l},{ref_for:!0},o.item.options?.switch,{disabled:r.getDisabled(o.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):o.item.type==="select"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),e.mergeProps({key:2,modelValue:r.form[o.item.key],"onUpdate:modelValue":l=>r.form[o.item.key]=l},{ref_for:!0},o.item.options?.select,{disabled:r.getDisabled(o.item),style:{width:"100%"}}),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.item.options?.select?.data,l=>(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:l.value,label:l.label,value:l.value},null,8,["label","value"]))),128))]),_:2},1040,["modelValue","onUpdate:modelValue","disabled"])):o.item.type==="list"?(e.openBlock(),e.createBlock(a,e.mergeProps({key:3,row:r.form,field:o.item.key},{ref_for:!0},o.item.options?.list,{disabled:r.getDisabled(o.item),style:{width:"100%"}}),null,16,["row","field","disabled"])):o.item.type==="tree-select"?(e.openBlock(),e.createBlock(e.unref(p.ElTreeSelect),e.mergeProps({key:4,modelValue:r.form[o.item.key],"onUpdate:modelValue":l=>r.form[o.item.key]=l},{ref_for:!0},o.item.options?.treeSelect,{disabled:r.getDisabled(o.item),style:{width:"100%"}}),null,16,["modelValue","onUpdate:modelValue","disabled"])):o.item.type==="datetime"?(e.openBlock(),e.createBlock(e.unref(p.ElDatePicker),e.mergeProps({key:5,modelValue:r.form[o.item.key],"onUpdate:modelValue":l=>r.form[o.item.key]=l},{ref_for:!0},o.item.options?.datetime,{disabled:r.getDisabled(o.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.unref(C).customComponent[o.item.type]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(C).customComponent[o.item.type]),e.mergeProps({key:6,modelValue:r.form[o.item.key],"onUpdate:modelValue":l=>r.form[o.item.key]=l},{ref_for:!0},o.item.options?.[o.item.type],{disabled:r.getDisabled(o.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.createCommentVNode("",!0)]),e.renderSlot(t.$slots,"form-"+o.item.key+"-end",{row:r.form,item:o.item})]),_:2},1032,["label","prop","label-width"])],2)):e.createCommentVNode("",!0)],64))),256)),e.renderSlot(t.$slots,"form-end",{row:r.form})]))),256)):e.createCommentVNode("",!0)]),_:3},8,["model","rules"])}}});class V{static getIdFun=()=>StrUtil.uuid();static setId=(d,i,s)=>{i[d]||(i[d]=[]),i[d].forEach(m=>{s.forEach(u=>{let r=u.default??"";u.type==="number"&&(r=u.default??0),u.type==="boolean"&&(r=u.default??!1),u.type==="time"&&(r=u.default??new Date),m[u.value]===void 0&&(m[u.value]=r)}),m._id||(m._id=V.getIdFun())})};static add=(d,i,s,m)=>{const u=JSONUtil.cp(s);V.setId(d,i,s),i[d].push(u.reduce((r,t)=>{let n=t.default??"";return t.type==="number"&&(n=t.default??0),t.type==="boolean"&&(n=t.default??!1),t.type==="time"&&(n=t.default??new Date),r[t.value]=n,r},{_id:V.getIdFun()})),m?.(i)};static remove=(d,i,s,m)=>{i[d]=i[d].filter(u=>u._id!==s._id),m?.(i)};static getNoIdData=(d,i)=>{const s=JSONUtil.cp(d);return s.forEach(m=>{m._id&&delete m._id,i&&m[i]&&V.getNoIdData(m[i],i)}),s}}const $={key:0,class:"column",style:{width:"100%",gap:"10px"}},T={class:"row items-center",style:{gap:"10px",width:"100%"}},x=e.defineComponent({__name:"list",props:{row:{default:{}},label:{default:"label"},value:{default:"value"},itemFields:{default:[{label:"label",value:"label"},{label:"value",value:"value"}]},field:{default:"value"},inputWidth:{default:"120px"},inputClass:{default:""}},emits:["change"],setup(f,{emit:d}){const i=f,s=e.reactive({show:!1,add:(u,r,t)=>{V.add(u,r,t,()=>{m("change")})},remove:(u,r,t)=>{V.remove(u,r,t,()=>{m("change")})}});e.onMounted(()=>{V.setId(i.field,i.row,i.itemFields),s.show=!0});const m=d;return(u,r)=>{const t=e.resolveComponent("el-button"),n=e.resolveComponent("el-input");return s.show?(e.openBlock(),e.createElementBlock("div",$,[e.renderSlot(u.$slots,"list-start",{row:f.row}),e.createElementVNode("div",null,[e.createVNode(t,{link:"",type:"primary",onClick:r[0]||(r[0]=a=>s.add(f.field,f.row,f.itemFields))},{default:e.withCtx(()=>[...r[2]||(r[2]=[e.createTextVNode("添加",-1)])]),_:1})]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.row[f.field],a=>(e.openBlock(),e.createElementBlock("div",T,[e.renderSlot(u.$slots,"item-start",{item:a,row:f.row}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.itemFields,c=>(e.openBlock(),e.createBlock(n,{modelValue:a[c.value],"onUpdate:modelValue":o=>a[c.value]=o,style:e.normalizeStyle({width:f.inputWidth}),class:e.normalizeClass(f.inputClass),placeholder:c[f.label]||c[f.value],onChange:r[1]||(r[1]=o=>m("change"))},null,8,["modelValue","onUpdate:modelValue","style","class","placeholder"]))),256)),e.renderSlot(u.$slots,"item-end",{item:a,row:f.row}),e.createVNode(t,{link:"",type:"danger",onClick:c=>s.remove(f.field,f.row,a)},{default:e.withCtx(()=>[...r[3]||(r[3]=[e.createTextVNode("删除",-1)])]),_:1},8,["onClick"])]))),256)),e.renderSlot(u.$slots,"list-end",{row:f.row})])):e.createCommentVNode("",!0)}}});class S{static exportToExcel=async(d,i,s)=>{const m=await b.loadModule("xlsx"),u=d.map(n=>{const a={};return i.forEach(c=>{a[c.label]=n[c.key]}),a}),r=m.utils.json_to_sheet(u),t=m.utils.book_new();m.utils.book_append_sheet(t,r,"Sheet1"),s?typeof s=="function"&&(s=s()):s=`导出数据_${new Date().Format("yyyy-MM-dd")}_${new Date().getTime()}`,m.writeFile(t,`${s}.xlsx`)}}const O={class:"dialog-footer"},I=e.defineComponent({__name:"switchConfirm",setup(f,{expose:d}){const i=e.ref(!1),s=e.ref("确认修改"),m=e.ref("确认要修改状态吗?");let u=null,r=null;const t=c=>(c?.title&&(s.value=c.title),c?.content&&(m.value=c.content),i.value=!0,new Promise((o,l)=>{u=o,r=l})),n=()=>{i.value=!1,u?.(!0),u=null,r=null},a=()=>{i.value=!1,r?.(new Error("用户取消操作")),u=null,r=null};return d({open:t}),(c,o)=>(e.openBlock(),e.createBlock(e.unref(p.ElDialog),{modelValue:i.value,"onUpdate:modelValue":o[0]||(o[0]=l=>i.value=l),title:s.value,"close-on-click-modal":!1,width:"400px"},{footer:e.withCtx(()=>[e.createElementVNode("span",O,[e.createVNode(e.unref(p.ElButton),{onClick:a},{default:e.withCtx(()=>[...o[1]||(o[1]=[e.createTextVNode("取消",-1)])]),_:1}),e.createVNode(e.unref(p.ElButton),{type:"primary",onClick:n},{default:e.withCtx(()=>[...o[2]||(o[2]=[e.createTextVNode("确认",-1)])]),_:1})])]),default:e.withCtx(()=>[e.createElementVNode("div",null,e.toDisplayString(m.value),1)]),_:1},8,["modelValue","title"]))}}),L={class:"col relative cc1-form-box"},j={class:"absolute row fit",style:{overflow:"hidden"}},z={class:"col column"},M={key:0,class:"relative curd-search"},R={class:"mb-20 flex justify-between items-center"},_={class:"flex items-center",style:{gap:"10px"}},W={key:0},A={key:1},J={key:2},K={class:"export-btn"},H={class:"flex items-center",style:{gap:"10px"}},q={class:"col fit-width relative"},G={class:"absolute column fit"},X={class:"row justify-end mt-20 mb-20"},Q={class:"row curd-row"},Y={class:"dialog-footer"},Z={class:"dialog-footer"},D=e.defineComponent({__name:"index",props:{option:{default:{}}},setup(f,{expose:d}){const i=b.EDialog,s=f,m=e.ref(),u=e.ref(),r=b.isFun,t=e.reactive({search:{column:{list:[]},form:{},formDefault:{},getFormData:()=>{let n={};s.option.column.forEach(c=>{(typeof c.show?.search=="function"?c.show?.search(t.search.form):c.show?.search)&&(n[c.key]=t.search.form[c.key])});const a=s.option.search?.before?.(n);return a&&(n=a),n},reset:()=>{const n=t.search.formDefault;Object.keys(n).forEach(a=>{s.option.search?.resetMode==="default"?n[a]=t.search.formDefault[a]:n[a]=void 0}),t.search.form=JSONUtil.cp(n),t.page.num=1,t.table.getList()},submit:()=>{t.page.num=1,t.table.getList()}},page:{size:s.option.page?.size||10,sizeList:s.option.page?.sizeList||[10,20,50,100],num:1,total:0,layout:s.option.page?.layout||"total, sizes, prev, pager, next, jumper"},table:{loading:!1,data:[],expand:{isExpand:!1,rowKeys:[],change:(n,a)=>{},all:()=>{if(t.table.expand.isExpand)t.table.expand.rowKeys=[];else{const n=a=>{let c=[];return a.forEach(o=>{c.push(o._id),o.children&&o.children.length>0&&(c=c.concat(n(o.children)))}),c};t.table.expand.rowKeys=n(t.table.data)}t.table.expand.isExpand=!t.table.expand.isExpand}},column:{list:[],show:{listSource:[],list:[]}},getList:async()=>{t.table.loading=!0;const n=s.option.api.list,a=await n({size:t.page.size,num:t.page.num,...t.search.getFormData(),final(l,h,w){t.table.loading=!1}}),c=a.data||{list:a};let o=Array.isArray(c.list)?c.list:c;t.table.data=s.option.data?await s.option.data(o):o,t.page.total=c.total||0},selection:{list:[],change:n=>{t.table.selection.list=n}},exportFun:{start:async n=>{let a=await t.table.exportFun[n](),c=s.option.column;const o=JSONUtil.cp({data:a,columns:c}),l=s.option.tools?.export||{};l.before&&l.before(o),S.exportToExcel(o.data,o.columns,l.fileName)},select:()=>{if(t.table.selection.list.length===0)throw b.fail("请选择要导出的数据"),new Error("请选择要导出的数据");return t.table.selection.list},page:()=>{if(t.table.data.length===0)throw b.fail("暂无数据"),new Error("暂无数据");return t.table.data},all:async()=>{t.table.loading=!0;const n=s.option.api.list,{data:a}=await n({size:999999,num:1,final(c,o,l){t.table.loading=!1}});return a.list}},export:n=>{t.table.exportFun.start(n)}},update:{title:"",rules:{},show:!1,showContent:!1,loading:!1,type:i.Insert,form:{},formDefault:{},formColumn:[],getDisabled:n=>n.disabled?.[t.update.type===i.Insert?"create":"update"],edit:{data:{},getApiData:n=>{if(s.option.form?.editAll)return n;let a={_id:t.update.edit.data._id};return Object.keys(t.update.edit.data).forEach(c=>{n[c]!==t.update.edit.data[c]&&(a[c]=n[c])}),a}},open:(n,a)=>{t.update.showContent||FunUtil.throttle(async()=>{t.update.type=n;const c=n===i.Insert;t.update.edit.data=a,t.update.title=c?"新增":"编辑",t.update.form=JSONUtil.cp(c?t.update.formDefault:a),await s.option.form?.openBefore?.(a,t.update),t.update.show=!0,t.update.showContent=!0,s.option.form?.openAfter?.(a,t.update)})},submit:()=>{FunUtil.throttle(async()=>{await u.value?.validate(async(c,o)=>new Promise((l,h)=>{c||(b.fail("请检查表单数据"),h(!1)),l()})),t.update.loading=!0;const n=t.update.type===i.Insert?s.option.api.create:s.option.api.update;let a=JSONUtil.cp(t.update.form);delete a.children,await s.option.form?.submitBefore?.(a,t.update),Object.keys(a).forEach(c=>{if(typeof a[c]=="string"&&a[c].indexOf("T")>-1){const o=new Date(a[c]).getTime();!isNaN(o)&&o>new Date("1971-01-01").getTime()&&(a[c]=o)}}),await n({...a,final(c,o,l){t.update.loading=!1}}),t.update.close(),await t.table.getList(),s.option.form?.submitAfter?.(a,t.update)})},close:()=>{t.update.show=!1,setTimeout(()=>{t.update.showContent=!1},350)}},remove:{title:"确认删除",show:!1,items:[],loading:!1,close:()=>{t.remove.show=!1},open:n=>{if(n.length===0){b.fail("请选择要删除的数据");return}t.remove.items=n,t.remove.show=!0},submit:()=>{FunUtil.throttle(async()=>{t.table.loading=!0;const n=s.option.api.delete;await n({_id:t.remove.items.map(a=>a._id),final(a,c,o){t.table.loading=!1}}),b.success("操作成功"),t.table.data.length<=1&&t.page.num>1&&(t.page.num-=1),t.remove.close(),await t.table.getList()})}},init:()=>{t.initCurdConfig(),t.initColumnOptions(),t.initColumnForm()},initCurdConfig:()=>{const a={tools:{search:!0,reset:!0,expand:!1,add:o=>o===void 0,update:!0,delete:!0,export:{show:!0}},table:{headerCellClassName:"table-header",rowKey:"_id",emptyText:"暂无数据",highlightCurrentRow:!0}},c=s.option;Object.keys(a).forEach(o=>{c[o]=ObjectUtil.deepMerge(a[o],c[o]||{})})},initColumnOptions:()=>{const n=s.option,a=c=>{const l={options:{switch:{activeValue:!0,activeLabel:"开启",inactiveValue:!1,inactiveLabel:"关闭",tableBeforeChange:async(w,k)=>{const g=c.options?.switch;try{return await m.value?.open({title:"确认修改",content:`确认要${k[w]===g.activeValue?g.inactiveLabel:g.activeLabel}吗?`}),t.table.loading=!0,await s.option.api.update({_id:k._id,[w]:k[w]===g.activeValue?g.inactiveValue:g.activeValue,final(B,E,U){t.table.loading=!1}}),b.success("操作成功"),t.table.getList(),!0}catch{return!1}}},treeSelect:{rowKey:"_id",nodeKey:"_id",multiple:!0,renderAfterExpand:!1,showCheckbox:!0,checkStrictly:!0,checkOnClickNode:!0,props:{label:"title",children:"children"}},datetime:{type:"datetime"}},table:{table:!0,minWidth:"100px",align:"center"},show:{table:!0,search:!1,form:!0},sort:{search:0,table:0,form:0}},h=c;Object.keys(l).forEach(w=>{h[w]=ObjectUtil.deepMerge(l[w],h[w]||{})})};n.column.forEach(a),n.table?.column?.forEach(a)},initColumnForm:()=>{const n=s.option;t.update.formColumn=[],t.table.column.show={list:[],listSource:[]};const a=[],c=s.option.form?.maxSpan||12,o=s.option.form?.defaultSpan||c/2;let l=[];const h=k=>{if(t.update.formDefault[k.key]=k.value,k.table.table&&(k.show.table&&t.table.column.show.list.push(k.key),k.table.table&&t.table.column.show.listSource.push(k.key)),k.isForm){k.form=k.form||{span:o},k.form.span=k.form.span??o;let g=k.form.span,B=l.reduce((U,v)=>U+v.span,g);const E=l.length;l.push({item:k,span:g}),(E===1&&l[0].span===0||B>=c||g===0&&E>1)&&(a.push(l),l=[]),k.rules&&(t.update.rules[k.key]=k.rules)}};n.column.forEach(k=>{k.isForm=!0,h(k)}),s.option.table?.column?.forEach(k=>{k.isForm=!1,h(k)}),t.search.column.list=n.column.concat(n.table?.column||[]),t.table.column.list=t.search.column.list.filter(k=>k.table?.table),t.search.column.list.sort((k,g)=>k.sort?.search-g.sort?.search),t.table.column.list.sort((k,g)=>k.sort?.table-g.sort?.table),l.length>0&&a.push(l),t.update.formColumn=a;const w=s.option.search?.formDefault;w&&Object.keys(w).forEach(k=>{t.search.formDefault[k]=w[k]}),n.column.forEach(k=>{k.show?.search||(t.search.formDefault[k.key]=void 0)}),t.search.form=JSONUtil.cp(t.search.formDefault)}});return t.init(),e.onMounted(()=>{t.table.getList()}),d({conf:t}),(n,a)=>{const c=e.resolveDirective("loading");return e.openBlock(),e.createElementBlock("div",L,[e.createElementVNode("div",j,[e.renderSlot(n.$slots,"box-left"),e.createElementVNode("div",z,[f.option.search?.show!==!1?(e.openBlock(),e.createElementBlock("div",M,[e.createVNode(e.unref(p.ElForm),{model:t.search.form,inline:""},{default:e.withCtx(()=>[e.renderSlot(n.$slots,"search-start",{row:t.search.form}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.search.column.list,o=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:o.key},[(typeof o.show?.search=="function"?o.show?.search(t.search.form):o.show?.search)?(e.openBlock(),e.createBlock(e.unref(p.ElFormItem),{key:0,label:o.label},{default:e.withCtx(()=>[e.renderSlot(n.$slots,"search-"+o.key,{row:t.search.form},()=>[o.type==="input"?(e.openBlock(),e.createBlock(e.unref(p.ElInput),{key:0,modelValue:t.search.form[o.key],"onUpdate:modelValue":l=>t.search.form[o.key]=l,placeholder:`请输入${o.label}`,clearable:"",disabled:o.disabled?.search},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled"])):o.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),{key:1,modelValue:t.search.form[o.key],"onUpdate:modelValue":l=>t.search.form[o.key]=l,placeholder:`请选择${o.label}`,clearable:"",disabled:o.disabled?.search},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:o.options?.switch?.activeValue,label:o.options?.switch?.activeLabel,value:o.options?.switch?.activeValue},null,8,["label","value"])),(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:o.options?.switch?.inactiveValue,label:o.options?.switch?.inactiveLabel,value:o.options?.switch?.inactiveValue},null,8,["label","value"]))]),_:2},1032,["modelValue","onUpdate:modelValue","placeholder","disabled"])):o.type==="select"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),{key:2,modelValue:t.search.form[o.key],"onUpdate:modelValue":l=>t.search.form[o.key]=l,placeholder:`请选择${o.label}`,clearable:"",disabled:o.disabled?.search},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options?.select?.data,l=>(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:l.value,label:l.label,value:l.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","placeholder","disabled"])):e.createCommentVNode("",!0)])]),_:2},1032,["label"])):e.createCommentVNode("",!0)],64))),128)),e.renderSlot(n.$slots,"search-center",{row:t.search.form}),e.createVNode(e.unref(p.ElFormItem),null,{default:e.withCtx(()=>[f.option.tools?.search?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:0,type:"primary",onClick:t.search.submit},{default:e.withCtx(()=>[...a[7]||(a[7]=[e.createTextVNode(" 搜索 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),f.option.tools?.reset?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:1,onClick:t.search.reset},{default:e.withCtx(()=>[...a[8]||(a[8]=[e.createTextVNode("重置",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0)]),_:1}),e.renderSlot(n.$slots,"search-end",{row:t.search.form})]),_:3},8,["model"])])):e.createCommentVNode("",!0),e.createElementVNode("div",R,[e.createElementVNode("div",_,[e.unref(r)(f.option.tools?.add)?(e.openBlock(),e.createElementBlock("div",W,[e.createVNode(e.unref(p.ElButton),{type:"primary",onClick:a[0]||(a[0]=o=>t.update.open(e.unref(i).Insert))},{default:e.withCtx(()=>[...a[9]||(a[9]=[e.createTextVNode("新增",-1)])]),_:1})])):e.createCommentVNode("",!0),f.option.table?.selectable&&e.unref(r)(f.option.tools?.delete)?(e.openBlock(),e.createElementBlock("div",A,[e.createVNode(e.unref(p.ElButton),{type:"danger",onClick:a[1]||(a[1]=o=>t.remove.open(t.table.selection.list))},{default:e.withCtx(()=>[...a[10]||(a[10]=[e.createTextVNode(" 删除 ",-1)])]),_:1})])):e.createCommentVNode("",!0),f.option.tools?.expand?(e.openBlock(),e.createElementBlock("div",J,[e.createVNode(e.unref(p.ElButton),{type:"warning",onClick:a[2]||(a[2]=o=>t.table.expand.all())},{default:e.withCtx(()=>[...a[11]||(a[11]=[e.createTextVNode("展开/收缩",-1)])]),_:1})])):e.createCommentVNode("",!0),f.option.tools?.export?.show?(e.openBlock(),e.createBlock(e.unref(p.ElDropdown),{key:3,onCommand:t.table.export},{dropdown:e.withCtx(()=>[e.createVNode(e.unref(p.ElDropdownMenu),null,{default:e.withCtx(()=>[e.createVNode(e.unref(p.ElDropdownItem),{command:"select"},{default:e.withCtx(()=>[...a[13]||(a[13]=[e.createTextVNode("导出选中",-1)])]),_:1}),e.createVNode(e.unref(p.ElDropdownItem),{command:"page"},{default:e.withCtx(()=>[...a[14]||(a[14]=[e.createTextVNode("导出本页",-1)])]),_:1}),e.createVNode(e.unref(p.ElDropdownItem),{command:"all"},{default:e.withCtx(()=>[...a[15]||(a[15]=[e.createTextVNode("导出全部",-1)])]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createElementVNode("div",K,[e.createVNode(e.unref(p.ElButton),{type:"warning"},{default:e.withCtx(()=>[...a[12]||(a[12]=[e.createTextVNode("导出",-1)])]),_:1})])]),_:1},8,["onCommand"])):e.createCommentVNode("",!0),e.renderSlot(n.$slots,"tools-left")]),e.createElementVNode("div",H,[e.renderSlot(n.$slots,"tools-right")])]),e.createElementVNode("div",q,[e.createElementVNode("div",G,[e.withDirectives((e.openBlock(),e.createBlock(e.unref(p.ElTable),e.mergeProps({data:t.table.data},f.option.table,{onSelectionChange:t.table.selection.change,"expand-row-keys":t.table.expand.rowKeys,onExpandChange:t.table.expand.change}),{default:e.withCtx(()=>[f.option.table?.selectable&&e.unref(r)(f.option.tools?.delete)?(e.openBlock(),e.createBlock(e.unref(p.ElTableColumn),{key:0,type:"selection",selectable:typeof f.option.table?.selectable=="function"?f.option.table?.selectable:void 0,width:"55"},null,8,["selectable"])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.table.column.list,o=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:o.key},[t.table.column.show.list.includes(o.key)?(e.openBlock(),e.createBlock(e.unref(p.ElTableColumn),e.mergeProps({key:0,prop:o.key,label:o.label},{ref_for:!0},o.table),{default:e.withCtx(({row:l})=>[e.renderSlot(n.$slots,"table-"+o.key,{row:l,item:o},()=>[o.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSwitch),e.mergeProps({key:0,modelValue:l[o.key],"onUpdate:modelValue":h=>l[o.key]=h,"before-change":()=>o.options?.switch?.tableBeforeChange?.(o.key,l)},{ref_for:!0},o.options?.switch),null,16,["modelValue","onUpdate:modelValue","before-change"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(l[o.key]),1)],64))])]),_:2},1040,["prop","label"])):e.createCommentVNode("",!0)],64))),128)),e.unref(r)(f.option.tools?.add)||e.unref(r)(f.option.tools?.update)||e.unref(r)(f.option.tools?.delete)||n.$slots["table-op-left"]||n.$slots["table-op-right"]?(e.openBlock(),e.createBlock(e.unref(p.ElTableColumn),{key:1,label:"操作",width:"180",align:"center",fixed:"right"},{default:e.withCtx(({row:o})=>[e.renderSlot(n.$slots,"table-op-left",{row:o}),e.unref(r)(f.option.tools?.add,o)?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:0,link:"",type:"primary",onClick:l=>t.update.open(e.unref(i).Insert,o)},{default:e.withCtx(()=>[...a[16]||(a[16]=[e.createTextVNode(" 新增 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.unref(r)(f.option.tools?.update,o)?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:1,link:"",type:"warning",onClick:l=>t.update.open(e.unref(i).Update,o)},{default:e.withCtx(()=>[...a[17]||(a[17]=[e.createTextVNode(" 编辑 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.unref(r)(f.option.tools?.delete,o)?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:2,link:"",type:"danger",onClick:l=>t.remove.open([o])},{default:e.withCtx(()=>[...a[18]||(a[18]=[e.createTextVNode(" 删除 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.renderSlot(n.$slots,"table-op-right",{row:o})]),_:3})):e.createCommentVNode("",!0)]),_:3},16,["data","onSelectionChange","expand-row-keys","onExpandChange"])),[[c,t.table.loading]])])]),e.createElementVNode("div",X,[t.page.total>t.page.size?(e.openBlock(),e.createBlock(e.unref(p.ElPagination),{key:0,"current-page":t.page.num,"onUpdate:currentPage":a[3]||(a[3]=o=>t.page.num=o),"page-size":t.page.size,"onUpdate:pageSize":a[4]||(a[4]=o=>t.page.size=o),background:"","page-sizes":t.page.sizeList,"pager-count":7,layout:t.page.layout,total:t.page.total,onSizeChange:t.table.getList,onCurrentChange:t.table.getList},null,8,["current-page","page-size","page-sizes","layout","total","onSizeChange","onCurrentChange"])):e.createCommentVNode("",!0)])]),e.renderSlot(n.$slots,"box-right")]),e.createVNode(e.unref(p.ElDialog),e.mergeProps({modelValue:t.update.show,"onUpdate:modelValue":a[5]||(a[5]=o=>t.update.show=o),title:t.update.title,"close-on-click-modal":!1,"before-close":t.update.close},f.option.dialog),{footer:e.withCtx(()=>[e.createElementVNode("span",Y,[e.createVNode(e.unref(p.ElButton),{onClick:t.update.close},{default:e.withCtx(()=>[...a[19]||(a[19]=[e.createTextVNode("关闭",-1)])]),_:1},8,["onClick"]),e.createVNode(e.unref(p.ElButton),{type:"primary",onClick:t.update.submit,loading:t.update.loading},{default:e.withCtx(()=>[...a[20]||(a[20]=[e.createTextVNode(" 提交 ",-1)])]),_:1},8,["onClick","loading"])])]),default:e.withCtx(()=>[e.createVNode(e.unref(p.ElForm),{ref_key:"ruleFormRef",ref:u,model:t.update.form,rules:t.update.rules},{default:e.withCtx(()=>[t.update.showContent?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(t.update.formColumn,o=>(e.openBlock(),e.createElementBlock("div",Q,[e.renderSlot(n.$slots,"form-start",{row:t.update.form}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o,l=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.unref(r)(l.item.show?.form,t.update.form)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(l.item.form.span>0?`col-${l.item.form.span}`:"col")},[e.createVNode(e.unref(p.ElFormItem),{label:l.item.label,prop:l.item.key,"label-width":l.item.form?.labelWidth||"100px"},{default:e.withCtx(()=>[e.renderSlot(n.$slots,"form-"+l.item.key+"-start",{row:t.update.form,item:l.item}),e.renderSlot(n.$slots,"form-"+l.item.key,{row:t.update.form,item:l.item},()=>[l.item.type==="input"?(e.openBlock(),e.createBlock(e.unref(p.ElInput),e.mergeProps({key:0,modelValue:t.update.form[l.item.key],"onUpdate:modelValue":h=>t.update.form[l.item.key]=h},{ref_for:!0},l.item.options?.input,e.toHandlers(l.item.options?.input?.on),{disabled:t.update.getDisabled(l.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):l.item.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSwitch),e.mergeProps({key:1,modelValue:t.update.form[l.item.key],"onUpdate:modelValue":h=>t.update.form[l.item.key]=h},{ref_for:!0},l.item.options?.switch,{disabled:t.update.getDisabled(l.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):l.item.type==="select"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),e.mergeProps({key:2,modelValue:t.update.form[l.item.key],"onUpdate:modelValue":h=>t.update.form[l.item.key]=h},{ref_for:!0},l.item.options?.select,{disabled:t.update.getDisabled(l.item),style:{width:"100%"}}),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.item.options?.select?.data,h=>(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:h.value,label:h.label,value:h.value},null,8,["label","value"]))),128))]),_:2},1040,["modelValue","onUpdate:modelValue","disabled"])):l.item.type==="list"?(e.openBlock(),e.createBlock(x,e.mergeProps({key:3,row:t.update.form,field:l.item.key},{ref_for:!0},l.item.options?.list,{disabled:t.update.getDisabled(l.item),style:{width:"100%"}}),null,16,["row","field","disabled"])):l.item.type==="tree-select"?(e.openBlock(),e.createBlock(e.unref(p.ElTreeSelect),e.mergeProps({key:4,modelValue:t.update.form[l.item.key],"onUpdate:modelValue":h=>t.update.form[l.item.key]=h},{ref_for:!0},l.item.options?.treeSelect,{disabled:t.update.getDisabled(l.item),style:{width:"100%"}}),null,16,["modelValue","onUpdate:modelValue","disabled"])):l.item.type==="datetime"?(e.openBlock(),e.createBlock(e.unref(p.ElDatePicker),e.mergeProps({key:5,modelValue:t.update.form[l.item.key],"onUpdate:modelValue":h=>t.update.form[l.item.key]=h},{ref_for:!0},l.item.options?.datetime,{disabled:t.update.getDisabled(l.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.unref(C).customComponent[l.item.type]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(C).customComponent[l.item.type]),e.mergeProps({key:6,modelValue:t.update.form[l.item.key],"onUpdate:modelValue":h=>t.update.form[l.item.key]=h},{ref_for:!0},l.item.options?.[l.item.type],{disabled:t.update.getDisabled(l.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.createCommentVNode("",!0)]),e.renderSlot(n.$slots,"form-"+l.item.key+"-end",{row:t.update.form,item:l.item})]),_:2},1032,["label","prop","label-width"])],2)):e.createCommentVNode("",!0)],64))),256)),e.renderSlot(n.$slots,"form-end",{row:t.update.form})]))),256)):e.createCommentVNode("",!0)]),_:3},8,["model","rules"])]),_:3},16,["modelValue","title","before-close"]),e.createVNode(e.unref(p.ElDialog),{modelValue:t.remove.show,"onUpdate:modelValue":a[6]||(a[6]=o=>t.remove.show=o),title:t.remove.title,"close-on-click-modal":!1},{footer:e.withCtx(()=>[e.createElementVNode("span",Z,[e.createVNode(e.unref(p.ElButton),{onClick:t.remove.close},{default:e.withCtx(()=>[...a[21]||(a[21]=[e.createTextVNode("关闭",-1)])]),_:1},8,["onClick"]),e.createVNode(e.unref(p.ElButton),{type:"danger",onClick:t.remove.submit,loading:t.remove.loading},{default:e.withCtx(()=>[...a[22]||(a[22]=[e.createTextVNode(" 确认删除 ",-1)])]),_:1},8,["onClick","loading"])])]),default:e.withCtx(()=>[e.createElementVNode("div",null,"确认要删除【"+e.toDisplayString(t.remove.items.length)+"】条数据吗?",1)]),_:1},8,["modelValue","title"]),e.createVNode(I,{ref_key:"switchConfirmRef",ref:m},null,512)])}}}),P=(f,d)=>{if(f.component("TCurd",D),f.component("TFormList",x),f.component("TColumn",N),d?.customComponent){C.customComponent=d.customComponent;for(const i in d.customComponent)f.component(i,d.customComponent[i])}};y.ArrUtil=V,y.ExcelUtil=S,y.TColumn=N,y.TCurd=D,y.TForm=C,y.TFormList=x,y.TSys=b,y.install=P,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(y,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("element-plus")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus"],e):(y=typeof globalThis<"u"?globalThis:y||self,e(y.cc1Form={},y.Vue,y.ElementPlus))})(this,(function(y,e,p){"use strict";class b{static router;static routes;static getRouterPath=()=>this.router.currentRoute.value.path;static EDialog={Insert:"Insert",Update:"Update",Remove:"Remove"};static isFun=(d,i)=>typeof d=="function"?d(i):d;static getRouterParams=()=>{const d=this.router.currentRoute.value.query||{},i=this.router.currentRoute.value.params||{};return Object.keys(d).length?d:Object.keys(i).length?i:{}};static moduleObj={};static loadModule=async d=>{if(!b.moduleObj[d])throw new Error(`模块${d}未加载,请赋值如:TSys.moduleObj = { ${d}: ()=>import('${d}') }`);const i=await b.moduleObj[d]();return i.default??i};static tipMessages={};static tipMessagesGap=500;static showMessage(d,i,s={}){const m=Date.now();if(!this.tipMessages[d]||m-this.tipMessages[d]>this.tipMessagesGap){this.tipMessages[d]=m;const u=Object.assign({message:d,type:i},s);p.ElMessage(u),setTimeout(()=>{delete this.tipMessages[d]},this.tipMessagesGap)}}static fail=(d,i={})=>{this.showMessage(d,"error",i)};static success=(d,i={})=>{this.showMessage(d,"success",i)};static loadingObj=null;static loadingTimer=null;static loading=(d=!0,i="加载中")=>{Timer.un(this.loadingTimer),this.loadingTimer=Timer.once(()=>{d?this.loadingObj=p.ElLoading.service({lock:!0,text:i,background:"rgba(0, 0, 0, 0.3)"}):this.loadingObj&&(this.loadingObj.close(),this.loadingObj=null)},50)};static openUrl=(d,i=!0)=>{if(i){let s=screen.width/2-500,m=screen.height/2-800/2-30;window.open(d,"_blank","toolbar=no, location=yes, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=1000, height=800, top="+m+", left="+s)}else window.open(d,"DescriptiveWindowName"+StrUtil.getId(),"resizable,scrollbars=yes,status=1,width=1024, height=600, top=0, left=0")};static getImgPic=d=>new Promise(async(i,s)=>{let m=document.getElementById(d.id);const u=await b.loadModule("html2canvas");try{u(m,{logging:!1,allowTaint:!0,scale:window.devicePixelRatio,width:d.windowWidth,height:d.windowHeight,windowWidth:d.windowWidth,windowHeight:d.windowHeight,useCORS:!0,backgroundColor:"#ffffff00"}).then(function(r){let t=r.toDataURL("image/png");i(t)})}catch(r){s(r)}});static async download(d,i="download.png"){const s=document.createElement("a");s.style.display="none",s.href=d,s.setAttribute("download",i),typeof s.download>"u"&&s.setAttribute("target","_blank"),document.body.appendChild(s),s.click(),document.body.removeChild(s),window.URL.revokeObjectURL(d)}}class V{static customComponent={};static findOptions=(d,i)=>{const s=d.column.find(u=>u.key===i),m=u=>u.replace(/-([a-z])/g,(r,t)=>t.toUpperCase());if(s)return s.options[m(s.type)]};static setOptionsData=(d,i,s)=>{const m=V.findOptions(d,i);m&&(m.data=s)};static form={openBefore:{parentId:(d,i,s,m)=>{d?i.type===b.EDialog.Insert?(i.form.parentId=d._id,i.form.sort=d.children.length+1):i.form.parentId=d.parentId.substring(d.parentId.lastIndexOf(",")+1):(i.form.parentId="0",i.form.sort=s.length+1),V.setOptionsData(m,"parentId",[{_id:"0",title:"根",children:s}])}}}}const F={class:"row curd-row"},N=e.defineComponent({__name:"column",props:{option:{default:{}}},setup(f,{expose:d}){const i=b.isFun,s=b.EDialog,m=e.ref(),u=f,r=e.reactive({rules:{},show:!1,showContent:!1,loading:!1,type:s.Insert,form:{},formDefault:{},formColumn:[],getDisabled:t=>t.disabled?.[r.type===s.Insert?"create":"update"],initColumnForm:()=>{const t=u.option;r.formColumn=[];const n=[],a=u.option.form?.maxSpan||12,c=u.option.form?.defaultSpan||a;let o=[];const l=h=>{if(r.formDefault[h.key]=h.value,h.isForm){h.form=h.form||{span:c},h.form.span=h.form.span??c;let w=h.form.span,k=o.reduce((B,E)=>B+E.span,w);const g=o.length;o.push({item:h,span:w}),(g===1&&o[0].span===0||k>=a||w===0&&g>1)&&(n.push(o),o=[]),h.rules&&(r.rules[h.key]=h.rules)}};t.column.forEach(h=>{h.isForm=!0,l(h)}),o.length>0&&n.push(o),r.formColumn=n}});return r.initColumnForm(),d({ref:m,conf:r}),(t,n)=>{const a=e.resolveComponent("FormList");return e.openBlock(),e.createBlock(e.unref(p.ElForm),{ref_key:"ruleFormRef",ref:m,model:r.form,rules:r.rules},{default:e.withCtx(()=>[r.showContent?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(r.formColumn,c=>(e.openBlock(),e.createElementBlock("div",F,[e.renderSlot(t.$slots,"form-start",{row:r.form}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c,o=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.unref(i)(o.item.show?.form,r.form)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(o.item.form.span>0?`col-${o.item.form.span}`:"col")},[e.createVNode(e.unref(p.ElFormItem),{label:o.item.label,prop:o.item.key,"label-width":o.item.form?.labelWidth||"100px"},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"form-"+o.item.key+"-start",{row:r.form,item:o.item}),e.renderSlot(t.$slots,"form-"+o.item.key,{row:r.form,item:o.item},()=>[o.item.type==="input"?(e.openBlock(),e.createBlock(e.unref(p.ElInput),e.mergeProps({key:0,modelValue:r.form[o.item.key],"onUpdate:modelValue":l=>r.form[o.item.key]=l},{ref_for:!0},o.item.options?.input,e.toHandlers(o.item.options?.input?.on),{disabled:r.getDisabled(o.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):o.item.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSwitch),e.mergeProps({key:1,modelValue:r.form[o.item.key],"onUpdate:modelValue":l=>r.form[o.item.key]=l},{ref_for:!0},o.item.options?.switch,{disabled:r.getDisabled(o.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):o.item.type==="select"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),e.mergeProps({key:2,modelValue:r.form[o.item.key],"onUpdate:modelValue":l=>r.form[o.item.key]=l},{ref_for:!0},o.item.options?.select,{disabled:r.getDisabled(o.item),style:{width:"100%"}}),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.item.options?.select?.data,l=>(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:l.value,label:l.label,value:l.value},null,8,["label","value"]))),128))]),_:2},1040,["modelValue","onUpdate:modelValue","disabled"])):o.item.type==="list"?(e.openBlock(),e.createBlock(a,e.mergeProps({key:3,row:r.form,field:o.item.key},{ref_for:!0},o.item.options?.list,{disabled:r.getDisabled(o.item),style:{width:"100%"}}),null,16,["row","field","disabled"])):o.item.type==="tree-select"?(e.openBlock(),e.createBlock(e.unref(p.ElTreeSelect),e.mergeProps({key:4,modelValue:r.form[o.item.key],"onUpdate:modelValue":l=>r.form[o.item.key]=l},{ref_for:!0},o.item.options?.treeSelect,{disabled:r.getDisabled(o.item),style:{width:"100%"}}),null,16,["modelValue","onUpdate:modelValue","disabled"])):o.item.type==="datetime"?(e.openBlock(),e.createBlock(e.unref(p.ElDatePicker),e.mergeProps({key:5,modelValue:r.form[o.item.key],"onUpdate:modelValue":l=>r.form[o.item.key]=l},{ref_for:!0},o.item.options?.datetime,{disabled:r.getDisabled(o.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.unref(V).customComponent[o.item.type]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(V).customComponent[o.item.type]),e.mergeProps({key:6,modelValue:r.form[o.item.key],"onUpdate:modelValue":l=>r.form[o.item.key]=l},{ref_for:!0},o.item.options?.[o.item.type],{disabled:r.getDisabled(o.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.createCommentVNode("",!0)]),e.renderSlot(t.$slots,"form-"+o.item.key+"-end",{row:r.form,item:o.item})]),_:2},1032,["label","prop","label-width"])],2)):e.createCommentVNode("",!0)],64))),256)),e.renderSlot(t.$slots,"form-end",{row:r.form})]))),256)):e.createCommentVNode("",!0)]),_:3},8,["model","rules"])}}});class C{static getIdFun=()=>StrUtil.uuid();static setId=(d,i,s)=>{i[d]||(i[d]=[]),i[d].forEach(m=>{s.forEach(u=>{let r=u.default??"";u.type==="number"&&(r=u.default??0),u.type==="boolean"&&(r=u.default??!1),u.type==="time"&&(r=u.default??new Date),m[u.value]===void 0&&(m[u.value]=r)}),m._id||(m._id=C.getIdFun())})};static add=(d,i,s,m)=>{const u=JSONUtil.cp(s);C.setId(d,i,s),i[d].push(u.reduce((r,t)=>{let n=t.default??"";return t.type==="number"&&(n=t.default??0),t.type==="boolean"&&(n=t.default??!1),t.type==="time"&&(n=t.default??new Date),r[t.value]=n,r},{_id:C.getIdFun()})),m?.(i)};static remove=(d,i,s,m)=>{i[d]=i[d].filter(u=>u._id!==s._id),m?.(i)};static getNoIdData=(d,i)=>{const s=JSONUtil.cp(d);return s.forEach(m=>{m._id&&delete m._id,i&&m[i]&&C.getNoIdData(m[i],i)}),s}}const $={key:0,class:"column",style:{width:"100%",gap:"10px"}},T={class:"row items-center",style:{gap:"10px",width:"100%"}},x=e.defineComponent({__name:"list",props:{row:{default:{}},label:{default:"label"},value:{default:"value"},itemFields:{default:[{label:"label",value:"label"},{label:"value",value:"value"}]},field:{default:"value"},inputWidth:{default:"120px"},inputClass:{default:""}},emits:["change"],setup(f,{emit:d}){const i=f,s=e.reactive({show:!1,add:(u,r,t)=>{C.add(u,r,t,()=>{m("change")})},remove:(u,r,t)=>{C.remove(u,r,t,()=>{m("change")})}});e.onMounted(()=>{C.setId(i.field,i.row,i.itemFields),s.show=!0});const m=d;return(u,r)=>{const t=e.resolveComponent("el-button"),n=e.resolveComponent("el-input");return s.show?(e.openBlock(),e.createElementBlock("div",$,[e.renderSlot(u.$slots,"list-start",{row:f.row}),e.createElementVNode("div",null,[e.createVNode(t,{link:"",type:"primary",onClick:r[0]||(r[0]=a=>s.add(f.field,f.row,f.itemFields))},{default:e.withCtx(()=>[...r[2]||(r[2]=[e.createTextVNode("添加",-1)])]),_:1})]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.row[f.field],a=>(e.openBlock(),e.createElementBlock("div",T,[e.renderSlot(u.$slots,"item-start",{item:a,row:f.row}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.itemFields,c=>(e.openBlock(),e.createBlock(n,{modelValue:a[c.value],"onUpdate:modelValue":o=>a[c.value]=o,style:e.normalizeStyle({width:f.inputWidth}),class:e.normalizeClass(f.inputClass),placeholder:c[f.label]||c[f.value],onChange:r[1]||(r[1]=o=>m("change"))},null,8,["modelValue","onUpdate:modelValue","style","class","placeholder"]))),256)),e.renderSlot(u.$slots,"item-end",{item:a,row:f.row}),e.createVNode(t,{link:"",type:"danger",onClick:c=>s.remove(f.field,f.row,a)},{default:e.withCtx(()=>[...r[3]||(r[3]=[e.createTextVNode("删除",-1)])]),_:1},8,["onClick"])]))),256)),e.renderSlot(u.$slots,"list-end",{row:f.row})])):e.createCommentVNode("",!0)}}});class S{static exportToExcel=async(d,i,s)=>{const m=await b.loadModule("xlsx"),u=d.map(n=>{const a={};return i.forEach(c=>{a[c.label]=n[c.key]}),a}),r=m.utils.json_to_sheet(u),t=m.utils.book_new();m.utils.book_append_sheet(t,r,"Sheet1"),s?typeof s=="function"&&(s=s()):s=`导出数据_${new Date().Format("yyyy-MM-dd")}_${new Date().getTime()}`,m.writeFile(t,`${s}.xlsx`)}}const O={class:"dialog-footer"},I=e.defineComponent({__name:"switchConfirm",setup(f,{expose:d}){const i=e.ref(!1),s=e.ref("确认修改"),m=e.ref("确认要修改状态吗?");let u=null,r=null;const t=c=>(c?.title&&(s.value=c.title),c?.content&&(m.value=c.content),i.value=!0,new Promise((o,l)=>{u=o,r=l})),n=()=>{i.value=!1,u?.(!0),u=null,r=null},a=()=>{i.value=!1,r?.(new Error("用户取消操作")),u=null,r=null};return d({open:t}),(c,o)=>(e.openBlock(),e.createBlock(e.unref(p.ElDialog),{modelValue:i.value,"onUpdate:modelValue":o[0]||(o[0]=l=>i.value=l),title:s.value,"close-on-click-modal":!1,width:"400px"},{footer:e.withCtx(()=>[e.createElementVNode("span",O,[e.createVNode(e.unref(p.ElButton),{onClick:a},{default:e.withCtx(()=>[...o[1]||(o[1]=[e.createTextVNode("取消",-1)])]),_:1}),e.createVNode(e.unref(p.ElButton),{type:"primary",onClick:n},{default:e.withCtx(()=>[...o[2]||(o[2]=[e.createTextVNode("确认",-1)])]),_:1})])]),default:e.withCtx(()=>[e.createElementVNode("div",null,e.toDisplayString(m.value),1)]),_:1},8,["modelValue","title"]))}}),L={class:"col relative cc1-form-box"},j={class:"absolute row fit",style:{overflow:"hidden"}},z={class:"col column"},M={key:0,class:"relative curd-search"},R={class:"mb-20 flex justify-between items-center"},_={class:"flex items-center",style:{gap:"10px"}},W={key:0},A={key:1},J={key:2},K={class:"export-btn"},H={class:"flex items-center",style:{gap:"10px"}},q={class:"col fit-width relative"},G={class:"absolute column fit"},X={class:"row justify-end mt-20 mb-20"},Q={class:"row curd-row"},Y={class:"row form-item-content",style:{width:"100%"}},Z={class:"col"},P={class:"dialog-footer"},v={class:"dialog-footer"},D=e.defineComponent({__name:"index",props:{option:{default:{}}},setup(f,{expose:d}){const i=b.EDialog,s=f,m=e.ref(),u=e.ref(),r=b.isFun,t=e.reactive({search:{column:{list:[]},form:{},formDefault:{},getFormData:()=>{let n={};s.option.column.forEach(c=>{(typeof c.show?.search=="function"?c.show?.search(t.search.form):c.show?.search)&&(n[c.key]=t.search.form[c.key])});const a=s.option.search?.before?.(n);return a&&(n=a),n},reset:()=>{const n=t.search.formDefault;Object.keys(n).forEach(a=>{s.option.search?.resetMode==="default"?n[a]=t.search.formDefault[a]:n[a]=void 0}),t.search.form=JSONUtil.cp(n),t.page.num=1,t.table.getList()},submit:()=>{t.page.num=1,t.table.getList()}},page:{size:s.option.page?.size||10,sizeList:s.option.page?.sizeList||[10,20,50,100],num:1,total:0,layout:s.option.page?.layout||"total, sizes, prev, pager, next, jumper"},table:{loading:!1,data:[],expand:{isExpand:!1,rowKeys:[],change:(n,a)=>{},all:()=>{if(t.table.expand.isExpand)t.table.expand.rowKeys=[];else{const n=a=>{let c=[];return a.forEach(o=>{c.push(o._id),o.children&&o.children.length>0&&(c=c.concat(n(o.children)))}),c};t.table.expand.rowKeys=n(t.table.data)}t.table.expand.isExpand=!t.table.expand.isExpand}},column:{list:[],show:{listSource:[],list:[]}},getList:async()=>{t.table.loading=!0;const n=s.option.api.list,a=await n({size:t.page.size,num:t.page.num,...t.search.getFormData(),final(l,h,w){t.table.loading=!1}}),c=a.data||{list:a};let o=Array.isArray(c.list)?c.list:c;t.table.data=s.option.data?await s.option.data(o):o,t.page.total=c.total||0},selection:{list:[],change:n=>{t.table.selection.list=n}},exportFun:{start:async n=>{let a=await t.table.exportFun[n](),c=s.option.column;const o=JSONUtil.cp({data:a,columns:c}),l=s.option.tools?.export||{};l.before&&l.before(o),S.exportToExcel(o.data,o.columns,l.fileName)},select:()=>{if(t.table.selection.list.length===0)throw b.fail("请选择要导出的数据"),new Error("请选择要导出的数据");return t.table.selection.list},page:()=>{if(t.table.data.length===0)throw b.fail("暂无数据"),new Error("暂无数据");return t.table.data},all:async()=>{t.table.loading=!0;const n=s.option.api.list,{data:a}=await n({size:999999,num:1,final(c,o,l){t.table.loading=!1}});return a.list}},export:n=>{t.table.exportFun.start(n)}},update:{title:"",rules:{},show:!1,showContent:!1,loading:!1,type:i.Insert,form:{},formDefault:{},formColumn:[],getDisabled:n=>n.disabled?.[t.update.type===i.Insert?"create":"update"],edit:{data:{},getApiData:n=>{if(s.option.form?.editAll)return n;let a={_id:t.update.edit.data._id};return Object.keys(t.update.edit.data).forEach(c=>{n[c]!==t.update.edit.data[c]&&(a[c]=n[c])}),a}},open:(n,a)=>{t.update.showContent||FunUtil.throttle(async()=>{t.update.type=n;const c=n===i.Insert;t.update.edit.data=a,t.update.title=c?"新增":"编辑",t.update.form=JSONUtil.cp(c?t.update.formDefault:a),await s.option.form?.openBefore?.(a,t.update),t.update.show=!0,t.update.showContent=!0,s.option.form?.openAfter?.(a,t.update)})},submit:()=>{FunUtil.throttle(async()=>{await u.value?.validate(async(c,o)=>new Promise((l,h)=>{c||(b.fail("请检查表单数据"),h(!1)),l()})),t.update.loading=!0;const n=t.update.type===i.Insert?s.option.api.create:s.option.api.update;let a=JSONUtil.cp(t.update.form);delete a.children,await s.option.form?.submitBefore?.(a,t.update),Object.keys(a).forEach(c=>{if(typeof a[c]=="string"&&a[c].indexOf("T")>-1){const o=new Date(a[c]).getTime();!isNaN(o)&&o>new Date("1971-01-01").getTime()&&(a[c]=o)}}),await n({...a,final(c,o,l){t.update.loading=!1}}),t.update.close(),await t.table.getList(),s.option.form?.submitAfter?.(a,t.update)})},close:()=>{t.update.show=!1,setTimeout(()=>{t.update.showContent=!1},350)}},remove:{title:"确认删除",show:!1,items:[],loading:!1,close:()=>{t.remove.show=!1},open:n=>{if(n.length===0){b.fail("请选择要删除的数据");return}t.remove.items=n,t.remove.show=!0},submit:()=>{FunUtil.throttle(async()=>{t.table.loading=!0;const n=s.option.api.delete;await n({_id:t.remove.items.map(a=>a._id),final(a,c,o){t.table.loading=!1}}),b.success("操作成功"),t.table.data.length<=1&&t.page.num>1&&(t.page.num-=1),t.remove.close(),await t.table.getList()})}},init:()=>{t.initCurdConfig(),t.initColumnOptions(),t.initColumnForm()},initCurdConfig:()=>{const a={tools:{search:!0,reset:!0,expand:!1,add:o=>o===void 0,update:!0,delete:!0,export:{show:!0}},table:{headerCellClassName:"table-header",rowKey:"_id",emptyText:"暂无数据",highlightCurrentRow:!0}},c=s.option;Object.keys(a).forEach(o=>{c[o]=ObjectUtil.deepMerge(a[o],c[o]||{})})},initColumnOptions:()=>{const n=s.option,a=c=>{const l={options:{switch:{activeValue:!0,activeLabel:"开启",inactiveValue:!1,inactiveLabel:"关闭",tableBeforeChange:async(w,k)=>{const g=c.options?.switch;try{return await m.value?.open({title:"确认修改",content:`确认要${k[w]===g.activeValue?g.inactiveLabel:g.activeLabel}吗?`}),t.table.loading=!0,await s.option.api.update({_id:k._id,[w]:k[w]===g.activeValue?g.inactiveValue:g.activeValue,final(B,E,U){t.table.loading=!1}}),b.success("操作成功"),t.table.getList(),!0}catch{return!1}}},treeSelect:{rowKey:"_id",nodeKey:"_id",multiple:!0,renderAfterExpand:!1,showCheckbox:!0,checkStrictly:!0,checkOnClickNode:!0,props:{label:"title",children:"children"}},datetime:{type:"datetime"}},table:{table:!0,minWidth:"100px",align:"center"},show:{table:!0,search:!1,form:!0},sort:{search:0,table:0,form:0}},h=c;Object.keys(l).forEach(w=>{h[w]=ObjectUtil.deepMerge(l[w],h[w]||{})})};n.column.forEach(a),n.table?.column?.forEach(a)},initColumnForm:()=>{const n=s.option;t.update.formColumn=[],t.table.column.show={list:[],listSource:[]};const a=[],c=s.option.form?.maxSpan||12,o=s.option.form?.defaultSpan||c/2;let l=[];const h=k=>{if(t.update.formDefault[k.key]=k.value,k.table.table&&(k.show.table&&t.table.column.show.list.push(k.key),k.table.table&&t.table.column.show.listSource.push(k.key)),k.isForm){k.form=k.form||{span:o},k.form.span=k.form.span??o;let g=k.form.span,B=l.reduce((U,te)=>U+te.span,g);const E=l.length;l.push({item:k,span:g}),(E===1&&l[0].span===0||B>=c||g===0&&E>1)&&(a.push(l),l=[]),k.rules&&(t.update.rules[k.key]=k.rules)}};n.column.forEach(k=>{k.isForm=!0,h(k)}),s.option.table?.column?.forEach(k=>{k.isForm=!1,h(k)}),t.search.column.list=n.column.concat(n.table?.column||[]),t.table.column.list=t.search.column.list.filter(k=>k.table?.table),t.search.column.list.sort((k,g)=>k.sort?.search-g.sort?.search),t.table.column.list.sort((k,g)=>k.sort?.table-g.sort?.table),l.length>0&&a.push(l),t.update.formColumn=a;const w=s.option.search?.formDefault;w&&Object.keys(w).forEach(k=>{t.search.formDefault[k]=w[k]}),n.column.forEach(k=>{k.show?.search||(t.search.formDefault[k.key]=void 0)}),t.search.form=JSONUtil.cp(t.search.formDefault)}});return t.init(),e.onMounted(()=>{t.table.getList()}),d({conf:t}),(n,a)=>{const c=e.resolveDirective("loading");return e.openBlock(),e.createElementBlock("div",L,[e.createElementVNode("div",j,[e.renderSlot(n.$slots,"box-left"),e.createElementVNode("div",z,[f.option.search?.show!==!1?(e.openBlock(),e.createElementBlock("div",M,[e.createVNode(e.unref(p.ElForm),{model:t.search.form,inline:""},{default:e.withCtx(()=>[e.renderSlot(n.$slots,"search-start",{row:t.search.form}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.search.column.list,o=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:o.key},[(typeof o.show?.search=="function"?o.show?.search(t.search.form):o.show?.search)?(e.openBlock(),e.createBlock(e.unref(p.ElFormItem),{key:0,label:o.label},{default:e.withCtx(()=>[e.renderSlot(n.$slots,"search-"+o.key,{row:t.search.form},()=>[o.type==="input"?(e.openBlock(),e.createBlock(e.unref(p.ElInput),{key:0,modelValue:t.search.form[o.key],"onUpdate:modelValue":l=>t.search.form[o.key]=l,placeholder:`请输入${o.label}`,clearable:"",disabled:o.disabled?.search},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled"])):o.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),{key:1,modelValue:t.search.form[o.key],"onUpdate:modelValue":l=>t.search.form[o.key]=l,placeholder:`请选择${o.label}`,clearable:"",disabled:o.disabled?.search},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:o.options?.switch?.activeValue,label:o.options?.switch?.activeLabel,value:o.options?.switch?.activeValue},null,8,["label","value"])),(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:o.options?.switch?.inactiveValue,label:o.options?.switch?.inactiveLabel,value:o.options?.switch?.inactiveValue},null,8,["label","value"]))]),_:2},1032,["modelValue","onUpdate:modelValue","placeholder","disabled"])):o.type==="select"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),{key:2,modelValue:t.search.form[o.key],"onUpdate:modelValue":l=>t.search.form[o.key]=l,placeholder:`请选择${o.label}`,clearable:"",disabled:o.disabled?.search},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options?.select?.data,l=>(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:l.value,label:l.label,value:l.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","placeholder","disabled"])):e.createCommentVNode("",!0)])]),_:2},1032,["label"])):e.createCommentVNode("",!0)],64))),128)),e.renderSlot(n.$slots,"search-center",{row:t.search.form}),e.createVNode(e.unref(p.ElFormItem),null,{default:e.withCtx(()=>[f.option.tools?.search?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:0,type:"primary",onClick:t.search.submit},{default:e.withCtx(()=>[...a[7]||(a[7]=[e.createTextVNode(" 搜索 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),f.option.tools?.reset?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:1,onClick:t.search.reset},{default:e.withCtx(()=>[...a[8]||(a[8]=[e.createTextVNode("重置",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0)]),_:1}),e.renderSlot(n.$slots,"search-end",{row:t.search.form})]),_:3},8,["model"])])):e.createCommentVNode("",!0),e.createElementVNode("div",R,[e.createElementVNode("div",_,[e.unref(r)(f.option.tools?.add)?(e.openBlock(),e.createElementBlock("div",W,[e.createVNode(e.unref(p.ElButton),{type:"primary",onClick:a[0]||(a[0]=o=>t.update.open(e.unref(i).Insert))},{default:e.withCtx(()=>[...a[9]||(a[9]=[e.createTextVNode("新增",-1)])]),_:1})])):e.createCommentVNode("",!0),f.option.table?.selectable&&e.unref(r)(f.option.tools?.delete)?(e.openBlock(),e.createElementBlock("div",A,[e.createVNode(e.unref(p.ElButton),{type:"danger",onClick:a[1]||(a[1]=o=>t.remove.open(t.table.selection.list))},{default:e.withCtx(()=>[...a[10]||(a[10]=[e.createTextVNode(" 删除 ",-1)])]),_:1})])):e.createCommentVNode("",!0),f.option.tools?.expand?(e.openBlock(),e.createElementBlock("div",J,[e.createVNode(e.unref(p.ElButton),{type:"warning",onClick:a[2]||(a[2]=o=>t.table.expand.all())},{default:e.withCtx(()=>[...a[11]||(a[11]=[e.createTextVNode("展开/收缩",-1)])]),_:1})])):e.createCommentVNode("",!0),f.option.tools?.export?.show?(e.openBlock(),e.createBlock(e.unref(p.ElDropdown),{key:3,onCommand:t.table.export},{dropdown:e.withCtx(()=>[e.createVNode(e.unref(p.ElDropdownMenu),null,{default:e.withCtx(()=>[e.createVNode(e.unref(p.ElDropdownItem),{command:"select"},{default:e.withCtx(()=>[...a[13]||(a[13]=[e.createTextVNode("导出选中",-1)])]),_:1}),e.createVNode(e.unref(p.ElDropdownItem),{command:"page"},{default:e.withCtx(()=>[...a[14]||(a[14]=[e.createTextVNode("导出本页",-1)])]),_:1}),e.createVNode(e.unref(p.ElDropdownItem),{command:"all"},{default:e.withCtx(()=>[...a[15]||(a[15]=[e.createTextVNode("导出全部",-1)])]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createElementVNode("div",K,[e.createVNode(e.unref(p.ElButton),{type:"warning"},{default:e.withCtx(()=>[...a[12]||(a[12]=[e.createTextVNode("导出",-1)])]),_:1})])]),_:1},8,["onCommand"])):e.createCommentVNode("",!0),e.renderSlot(n.$slots,"tools-left")]),e.createElementVNode("div",H,[e.renderSlot(n.$slots,"tools-right")])]),e.createElementVNode("div",q,[e.createElementVNode("div",G,[e.withDirectives((e.openBlock(),e.createBlock(e.unref(p.ElTable),e.mergeProps({data:t.table.data},f.option.table,{onSelectionChange:t.table.selection.change,"expand-row-keys":t.table.expand.rowKeys,onExpandChange:t.table.expand.change}),{default:e.withCtx(()=>[f.option.table?.selectable&&e.unref(r)(f.option.tools?.delete)?(e.openBlock(),e.createBlock(e.unref(p.ElTableColumn),{key:0,type:"selection",selectable:typeof f.option.table?.selectable=="function"?f.option.table?.selectable:void 0,width:"55"},null,8,["selectable"])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.table.column.list,o=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:o.key},[t.table.column.show.list.includes(o.key)?(e.openBlock(),e.createBlock(e.unref(p.ElTableColumn),e.mergeProps({key:0,prop:o.key,label:o.label},{ref_for:!0},o.table),{default:e.withCtx(({row:l})=>[e.renderSlot(n.$slots,"table-"+o.key,{row:l,item:o},()=>[o.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSwitch),e.mergeProps({key:0,modelValue:l[o.key],"onUpdate:modelValue":h=>l[o.key]=h,"before-change":()=>o.options?.switch?.tableBeforeChange?.(o.key,l)},{ref_for:!0},o.options?.switch),null,16,["modelValue","onUpdate:modelValue","before-change"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(l[o.key]),1)],64))])]),_:2},1040,["prop","label"])):e.createCommentVNode("",!0)],64))),128)),e.unref(r)(f.option.tools?.add)||e.unref(r)(f.option.tools?.update)||e.unref(r)(f.option.tools?.delete)||n.$slots["table-op-left"]||n.$slots["table-op-right"]?(e.openBlock(),e.createBlock(e.unref(p.ElTableColumn),{key:1,label:"操作",width:"180",align:"center",fixed:"right"},{default:e.withCtx(({row:o})=>[e.renderSlot(n.$slots,"table-op-left",{row:o}),e.unref(r)(f.option.tools?.add,o)?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:0,link:"",type:"primary",onClick:l=>t.update.open(e.unref(i).Insert,o)},{default:e.withCtx(()=>[...a[16]||(a[16]=[e.createTextVNode(" 新增 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.unref(r)(f.option.tools?.update,o)?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:1,link:"",type:"warning",onClick:l=>t.update.open(e.unref(i).Update,o)},{default:e.withCtx(()=>[...a[17]||(a[17]=[e.createTextVNode(" 编辑 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.unref(r)(f.option.tools?.delete,o)?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:2,link:"",type:"danger",onClick:l=>t.remove.open([o])},{default:e.withCtx(()=>[...a[18]||(a[18]=[e.createTextVNode(" 删除 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.renderSlot(n.$slots,"table-op-right",{row:o})]),_:3})):e.createCommentVNode("",!0)]),_:3},16,["data","onSelectionChange","expand-row-keys","onExpandChange"])),[[c,t.table.loading]])])]),e.createElementVNode("div",X,[t.page.total>t.page.size?(e.openBlock(),e.createBlock(e.unref(p.ElPagination),{key:0,"current-page":t.page.num,"onUpdate:currentPage":a[3]||(a[3]=o=>t.page.num=o),"page-size":t.page.size,"onUpdate:pageSize":a[4]||(a[4]=o=>t.page.size=o),background:"","page-sizes":t.page.sizeList,"pager-count":7,layout:t.page.layout,total:t.page.total,onSizeChange:t.table.getList,onCurrentChange:t.table.getList},null,8,["current-page","page-size","page-sizes","layout","total","onSizeChange","onCurrentChange"])):e.createCommentVNode("",!0)])]),e.renderSlot(n.$slots,"box-right")]),e.createVNode(e.unref(p.ElDialog),e.mergeProps({modelValue:t.update.show,"onUpdate:modelValue":a[5]||(a[5]=o=>t.update.show=o),title:t.update.title,"close-on-click-modal":!1,"before-close":t.update.close},f.option.dialog),{footer:e.withCtx(()=>[e.createElementVNode("span",P,[e.createVNode(e.unref(p.ElButton),{onClick:t.update.close},{default:e.withCtx(()=>[...a[19]||(a[19]=[e.createTextVNode("关闭",-1)])]),_:1},8,["onClick"]),e.createVNode(e.unref(p.ElButton),{type:"primary",onClick:t.update.submit,loading:t.update.loading},{default:e.withCtx(()=>[...a[20]||(a[20]=[e.createTextVNode(" 提交 ",-1)])]),_:1},8,["onClick","loading"])])]),default:e.withCtx(()=>[e.createVNode(e.unref(p.ElForm),{ref_key:"ruleFormRef",ref:u,model:t.update.form,rules:t.update.rules},{default:e.withCtx(()=>[t.update.showContent?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(t.update.formColumn,o=>(e.openBlock(),e.createElementBlock("div",Q,[e.renderSlot(n.$slots,"form-start",{row:t.update.form}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o,l=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.unref(r)(l.item.show?.form,t.update.form)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(l.item.form.span>0?`col-${l.item.form.span}`:"col")},[e.createVNode(e.unref(p.ElFormItem),{label:l.item.label,prop:l.item.key,"label-width":l.item.form?.labelWidth||"100px"},{default:e.withCtx(()=>[e.createElementVNode("div",Y,[e.renderSlot(n.$slots,"form-"+l.item.key+"-start",{row:t.update.form,item:l.item}),e.createElementVNode("div",Z,[e.renderSlot(n.$slots,"form-"+l.item.key,{row:t.update.form,item:l.item},()=>[l.item.type==="input"?(e.openBlock(),e.createBlock(e.unref(p.ElInput),e.mergeProps({key:0,modelValue:t.update.form[l.item.key],"onUpdate:modelValue":h=>t.update.form[l.item.key]=h},{ref_for:!0},l.item.options?.input,e.toHandlers(l.item.options?.input?.on||{}),{disabled:t.update.getDisabled(l.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):l.item.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSwitch),e.mergeProps({key:1,modelValue:t.update.form[l.item.key],"onUpdate:modelValue":h=>t.update.form[l.item.key]=h},{ref_for:!0},l.item.options?.switch,{disabled:t.update.getDisabled(l.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):l.item.type==="select"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),e.mergeProps({key:2,modelValue:t.update.form[l.item.key],"onUpdate:modelValue":h=>t.update.form[l.item.key]=h},{ref_for:!0},l.item.options?.select,e.toHandlers(l.item.options?.select?.on||{}),{disabled:t.update.getDisabled(l.item),style:{width:"100%"}}),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.item.options?.select?.data,h=>(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:h.value,label:h.label,value:h.value},null,8,["label","value"]))),128))]),_:2},1040,["modelValue","onUpdate:modelValue","disabled"])):l.item.type==="list"?(e.openBlock(),e.createBlock(x,e.mergeProps({key:3,row:t.update.form,field:l.item.key},{ref_for:!0},l.item.options?.list,{disabled:t.update.getDisabled(l.item),style:{width:"100%"}}),null,16,["row","field","disabled"])):l.item.type==="tree-select"?(e.openBlock(),e.createBlock(e.unref(p.ElTreeSelect),e.mergeProps({key:4,modelValue:t.update.form[l.item.key],"onUpdate:modelValue":h=>t.update.form[l.item.key]=h},{ref_for:!0},l.item.options?.treeSelect,{disabled:t.update.getDisabled(l.item),style:{width:"100%"}}),null,16,["modelValue","onUpdate:modelValue","disabled"])):l.item.type==="datetime"?(e.openBlock(),e.createBlock(e.unref(p.ElDatePicker),e.mergeProps({key:5,modelValue:t.update.form[l.item.key],"onUpdate:modelValue":h=>t.update.form[l.item.key]=h},{ref_for:!0},l.item.options?.datetime,{disabled:t.update.getDisabled(l.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.unref(V).customComponent[l.item.type]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(V).customComponent[l.item.type]),e.mergeProps({key:6,modelValue:t.update.form[l.item.key],"onUpdate:modelValue":h=>t.update.form[l.item.key]=h},{ref_for:!0},l.item.options?.[l.item.type],{disabled:t.update.getDisabled(l.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.createCommentVNode("",!0)])]),e.renderSlot(n.$slots,"form-"+l.item.key+"-end",{row:t.update.form,item:l.item})])]),_:2},1032,["label","prop","label-width"])],2)):e.createCommentVNode("",!0)],64))),256)),e.renderSlot(n.$slots,"form-end",{row:t.update.form})]))),256)):e.createCommentVNode("",!0)]),_:3},8,["model","rules"])]),_:3},16,["modelValue","title","before-close"]),e.createVNode(e.unref(p.ElDialog),{modelValue:t.remove.show,"onUpdate:modelValue":a[6]||(a[6]=o=>t.remove.show=o),title:t.remove.title,"close-on-click-modal":!1},{footer:e.withCtx(()=>[e.createElementVNode("span",v,[e.createVNode(e.unref(p.ElButton),{onClick:t.remove.close},{default:e.withCtx(()=>[...a[21]||(a[21]=[e.createTextVNode("关闭",-1)])]),_:1},8,["onClick"]),e.createVNode(e.unref(p.ElButton),{type:"danger",onClick:t.remove.submit,loading:t.remove.loading},{default:e.withCtx(()=>[...a[22]||(a[22]=[e.createTextVNode(" 确认删除 ",-1)])]),_:1},8,["onClick","loading"])])]),default:e.withCtx(()=>[e.createElementVNode("div",null,"确认要删除【"+e.toDisplayString(t.remove.items.length)+"】条数据吗?",1)]),_:1},8,["modelValue","title"]),e.createVNode(I,{ref_key:"switchConfirmRef",ref:m},null,512)])}}}),ee=(f,d)=>{if(f.component("TCurd",D),f.component("TFormList",x),f.component("TColumn",N),d?.customComponent){V.customComponent=d.customComponent;for(const i in d.customComponent)f.component(i,d.customComponent[i])}};y.ArrUtil=C,y.ExcelUtil=S,y.TColumn=N,y.TCurd=D,y.TForm=V,y.TFormList=x,y.TSys=b,y.install=ee,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
|