@hotmi754/element-crud 1.0.4

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.
@@ -0,0 +1,1745 @@
1
+ import { ref as V, watch as He, unref as G, shallowRef as he, computed as N, useSlots as pe, defineComponent as U, createVNode as z, h as s, toRefs as ne, inject as ae, provide as oe, mergeProps as q, onActivated as Fe, onDeactivated as qe, useAttrs as Ke, onMounted as Je, nextTick as te, withDirectives as Ge } from "vue";
2
+ import { useDebounceFn as Ne, useThrottleFn as Qe, reactiveOmit as Ye } from "@vueuse/core";
3
+ import { ElIcon as Xe, ElDrawer as Ze, ElButton as I, ElCheckbox as ue, ElTableColumn as K, useAttrs as Ve, ElTable as et, ElForm as tt, ElFormItem as nt, ElInput as lt, ElInputNumber as at, ElDatePicker as ot, ElTreeSelect as rt, ElCascader as ut, ElCheckboxGroup as it, ElRadioGroup as ct, ElRadio as st, ElSelect as dt, ElOption as ft, ElDialog as ht, paginationProps as pt, ElPagination as gt, vLoading as mt } from "element-plus";
4
+ import { upperFirst as vt, get as ie, has as yt, set as bt, omit as St, pick as Ct, keys as wt } from "lodash-es";
5
+ import * as Tt from "@element-plus/icons-vue";
6
+ import xt from "vuedraggable-es";
7
+ function zt({
8
+ el: e = window,
9
+ isDebounce: n = !0,
10
+ listener: r,
11
+ wait: a = 80,
12
+ name: l,
13
+ options: i,
14
+ autoRemove: g = !0
15
+ }) {
16
+ let d;
17
+ const h = V(!1);
18
+ if (e) {
19
+ const u = V(e), b = n ? Ne(r, a) : Qe(r, a), c = a ? b : r, o = (x) => {
20
+ h.value = !0, x.removeEventListener(l, c, i);
21
+ }, f = (x) => x.addEventListener(l, c, i), T = He(
22
+ u,
23
+ (x, S, A) => {
24
+ x && (!G(h) && f(x), A(() => {
25
+ g && o(x);
26
+ }));
27
+ },
28
+ {
29
+ immediate: !0
30
+ }
31
+ );
32
+ return d = () => {
33
+ o(u.value), T();
34
+ }, { removeEvent: d };
35
+ }
36
+ }
37
+ const Et = Object.prototype.toString;
38
+ function ge(e, n) {
39
+ return Et.call(e) === `[object ${n}]`;
40
+ }
41
+ function Ft(e) {
42
+ return typeof e < "u";
43
+ }
44
+ function Nt(e) {
45
+ return !Ft(e);
46
+ }
47
+ function Ae(e) {
48
+ return e !== null && ge(e, "Object");
49
+ }
50
+ function Vt(e) {
51
+ return e == null ? !0 : Q(e) || L(e) ? e.length === 0 : e instanceof Map || e instanceof Set ? e.size === 0 : Ae(e) ? Object.keys(e).length === 0 : !1;
52
+ }
53
+ function At(e) {
54
+ return ge(e, "Number");
55
+ }
56
+ function L(e) {
57
+ return ge(e, "String");
58
+ }
59
+ function ce(e) {
60
+ return typeof e == "function";
61
+ }
62
+ function Q(e) {
63
+ return e && Array.isArray(e);
64
+ }
65
+ function Re(e, n, r = !0) {
66
+ const a = [];
67
+ for (let l = 0; l < e.length; l++) {
68
+ const i = { ...e[l] };
69
+ (r ? i[n] : !i[n]) && (i.children && i.children.length && (i.children = Re(i.children, n, r)), a.push(i));
70
+ }
71
+ return a;
72
+ }
73
+ function ke(e, n = "px") {
74
+ if (!e) return "";
75
+ if (L(e))
76
+ return e;
77
+ if (At(e))
78
+ return `${e}${n}`;
79
+ }
80
+ const se = "element_crud_table_config";
81
+ let W = {};
82
+ const M = V({});
83
+ function Zt(e, n = {}) {
84
+ if (e) {
85
+ e.tableWidthConfig && (W.tableWidthConfig = {
86
+ ...W.tableWidthConfig || {},
87
+ ...e.tableWidthConfig,
88
+ ...n.tableWidthConfig || {}
89
+ });
90
+ for (const r in e)
91
+ r !== "tableWidthConfig" && (W[r] = e[r]);
92
+ }
93
+ }
94
+ function en() {
95
+ W = {}, M.value = {};
96
+ }
97
+ function de() {
98
+ return W;
99
+ }
100
+ function Rt(e) {
101
+ const n = W.tableWidthConfig || {};
102
+ return e.map((r) => {
103
+ const a = { ...r };
104
+ return a.width && isNaN(parseInt(a.width)) && (a.width = n[a.width] || ""), a.minWidth && isNaN(parseInt(a.minWidth)) && (a.minWidth = n[a.minWidth] || ""), a;
105
+ });
106
+ }
107
+ function kt() {
108
+ try {
109
+ const e = JSON.parse(localStorage.getItem(se) || "{}"), n = de(), r = {};
110
+ for (const a in n) {
111
+ if (a === "tableWidthConfig") continue;
112
+ const l = n[a], i = e[a], g = typeof l == "function" ? l() : l;
113
+ Array.isArray(g) && (r[a] = g.map((d, h) => {
114
+ const u = i == null ? void 0 : i.find((b) => b.prop === d.prop);
115
+ return {
116
+ prop: d.prop,
117
+ hide: u ? !!u.hide : !!d.hide,
118
+ sort: u ? u.sort : h
119
+ };
120
+ }));
121
+ }
122
+ M.value = r;
123
+ } catch {
124
+ M.value = {};
125
+ }
126
+ }
127
+ function Oe() {
128
+ return Object.keys(M.value).length === 0 && kt(), {
129
+ getTableConfig: (a) => {
130
+ const i = de()[a];
131
+ return i ? Rt(
132
+ typeof i == "function" ? i() : i
133
+ ).map((d) => {
134
+ var u;
135
+ const h = (u = M.value[a]) == null ? void 0 : u.find(
136
+ (b) => b.prop === d.prop
137
+ );
138
+ return {
139
+ ...d,
140
+ hide: h ? h.hide : d.hide,
141
+ sort: h ? h.sort : 0
142
+ };
143
+ }).sort((d, h) => d.sort - h.sort) : (console.warn(
144
+ `[ElementCrud] Table config "${a}" not found. Did you register it via registerTableConfig()?`
145
+ ), []);
146
+ },
147
+ setTableConfig: (a, l) => {
148
+ const i = l.map((g, d) => ({
149
+ prop: g.prop,
150
+ hide: !!g.hide,
151
+ sort: d
152
+ }));
153
+ M.value[a] = i, ze((g) => {
154
+ g[a] = i;
155
+ });
156
+ },
157
+ resetTableConfig: (a) => {
158
+ const i = de()[a];
159
+ if (!i) return;
160
+ const g = typeof i == "function" ? i() : i;
161
+ M.value[a] = g.map((d, h) => ({
162
+ prop: d.prop,
163
+ hide: !!d.hide,
164
+ sort: h
165
+ })), ze((d) => {
166
+ d[a] = M.value[a];
167
+ });
168
+ }
169
+ };
170
+ }
171
+ function ze(e) {
172
+ try {
173
+ const n = JSON.parse(localStorage.getItem(se) || "{}");
174
+ e(n), localStorage.setItem(se, JSON.stringify(n));
175
+ } catch {
176
+ }
177
+ }
178
+ function Ot(e) {
179
+ const { getTableConfig: n } = Oe();
180
+ return N(() => {
181
+ const r = L(e.columns) ? (() => {
182
+ const a = n(e.columns);
183
+ return Vt(a) ? [] : a;
184
+ })() : e.columns;
185
+ return Re(r || [], "hide", !1);
186
+ });
187
+ }
188
+ function Bt(e) {
189
+ return N(() => ({
190
+ showOverflowTooltip: e.showOverflowTooltip || !1,
191
+ align: e.align,
192
+ headerAlign: e.headerAlign
193
+ }));
194
+ }
195
+ function J(e, n) {
196
+ return N(() => {
197
+ const r = G(e), a = G(n), l = Ae(r) ? { ...r } : void 0;
198
+ return l && (l.slot && delete l.slot, l.children && delete l.children), Object.assign({}, a, l);
199
+ });
200
+ }
201
+ function Be() {
202
+ const e = he({});
203
+ function n() {
204
+ var c, o;
205
+ (o = (c = e.value) == null ? void 0 : c.clearSelection) == null || o.call(c);
206
+ }
207
+ const r = () => {
208
+ var c, o;
209
+ return (o = (c = e.value) == null ? void 0 : c.getSelectionRows) == null ? void 0 : o.call(c);
210
+ };
211
+ function a(c, o) {
212
+ var f, T;
213
+ (T = (f = e.value) == null ? void 0 : f.toggleRowSelection) == null || T.call(f, c, o);
214
+ }
215
+ function l() {
216
+ var c, o;
217
+ (o = (c = e.value) == null ? void 0 : c.toggleAllSelection) == null || o.call(c);
218
+ }
219
+ function i(c, o) {
220
+ var f, T;
221
+ (T = (f = e.value) == null ? void 0 : f.toggleRowExpansion) == null || T.call(f, c, o);
222
+ }
223
+ function g(c) {
224
+ var o, f;
225
+ (f = (o = e.value) == null ? void 0 : o.setCurrentRow) == null || f.call(o, c);
226
+ }
227
+ function d() {
228
+ var c, o;
229
+ (o = (c = e.value) == null ? void 0 : c.clearSort) == null || o.call(c);
230
+ }
231
+ function h(c) {
232
+ var o, f;
233
+ (f = (o = e.value) == null ? void 0 : o.clearFilter) == null || f.call(o, c);
234
+ }
235
+ function u() {
236
+ var c, o;
237
+ (o = (c = e.value) == null ? void 0 : c.doLayout) == null || o.call(c);
238
+ }
239
+ function b(c, o) {
240
+ var f, T;
241
+ (T = (f = e.value) == null ? void 0 : f.sort) == null || T.call(f, c, o);
242
+ }
243
+ return {
244
+ table: e,
245
+ clearSelection: n,
246
+ getSelectionRows: r,
247
+ toggleRowSelection: a,
248
+ toggleAllSelection: l,
249
+ toggleRowExpansion: i,
250
+ setCurrentRow: g,
251
+ clearSort: d,
252
+ clearFilter: h,
253
+ doLayout: u,
254
+ sort: b
255
+ };
256
+ }
257
+ function jt() {
258
+ const e = pe(), n = {}, r = {}, a = {};
259
+ for (const l in e) {
260
+ const i = e[l];
261
+ if (/^table-/.test(l)) {
262
+ const g = l.replace("table-", "");
263
+ n[g] = i;
264
+ }
265
+ (/^search-/.test(l) || /^moreSearch-/.test(l)) && (a[l] = i), /^filter-/.test(l) && (r[l] = i);
266
+ }
267
+ return {
268
+ tableSlots: n,
269
+ searchSlots: a,
270
+ filterSlots: r
271
+ };
272
+ }
273
+ function Dt(e) {
274
+ const n = V(""), r = `#${e}-header`, a = `#${e}-footer`;
275
+ function l() {
276
+ var d, h;
277
+ const i = ((d = document.querySelector(a)) == null ? void 0 : d.clientHeight) || 0, g = ((h = document.querySelector(r)) == null ? void 0 : h.clientHeight) || 0;
278
+ n.value = `calc(100% - ${i + g}px)`;
279
+ }
280
+ return {
281
+ tableHeight: n,
282
+ calcTableHeight: l
283
+ };
284
+ }
285
+ const It = {
286
+ /**
287
+ * 列表列配置项
288
+ * 支持数组或字符串(字符串时从 tableConfig 获取)
289
+ */
290
+ tableColumns: {
291
+ type: [Array, String],
292
+ default: () => []
293
+ },
294
+ /**
295
+ * 表单筛选配置
296
+ */
297
+ searchColumns: {
298
+ type: Array,
299
+ default: () => []
300
+ },
301
+ /**
302
+ * 更多表单筛选配置
303
+ */
304
+ moreSearchColumns: {
305
+ type: Array,
306
+ default: () => []
307
+ },
308
+ /**
309
+ * 绑定的搜索参数
310
+ */
311
+ search: {
312
+ type: Object,
313
+ default: () => ({})
314
+ },
315
+ /**
316
+ * 请求方法
317
+ * @param {{ pageInfo: { page: number, limit: number }, params: Object }} options
318
+ * @returns {{ data: Array, total: number, success: boolean }}
319
+ */
320
+ request: {
321
+ type: Function,
322
+ default: () => {
323
+ }
324
+ },
325
+ /**
326
+ * 防抖时间(毫秒)
327
+ */
328
+ debounceTime: {
329
+ type: Number,
330
+ default: 500
331
+ },
332
+ /**
333
+ * 请求后回调
334
+ */
335
+ afterRequest: {
336
+ type: Function,
337
+ default: () => {
338
+ }
339
+ },
340
+ /**
341
+ * 是否初始化时请求
342
+ */
343
+ init: {
344
+ type: Boolean,
345
+ default: !0
346
+ },
347
+ /**
348
+ * 分页每页条数
349
+ */
350
+ limit: {
351
+ type: Number,
352
+ default: 20
353
+ },
354
+ /**
355
+ * 底部 footer 反转
356
+ */
357
+ footerReverse: {
358
+ type: Boolean,
359
+ default: !1
360
+ }
361
+ }, Mt = {
362
+ /**
363
+ * 是否多选表格
364
+ */
365
+ selection: {
366
+ type: [Boolean, Object],
367
+ default: !1
368
+ },
369
+ /**
370
+ * 是否展开表格
371
+ */
372
+ expand: {
373
+ type: [Boolean, Object],
374
+ default: !1
375
+ },
376
+ /**
377
+ * row 空值填充
378
+ */
379
+ emptyFill: {
380
+ type: String,
381
+ default: "--"
382
+ },
383
+ /**
384
+ * 是否显示序号列
385
+ */
386
+ index: {
387
+ type: [Boolean, Object],
388
+ default: !1
389
+ },
390
+ /**
391
+ * 是否有操作列
392
+ */
393
+ action: {
394
+ type: [Boolean, Object],
395
+ default: !1
396
+ },
397
+ /**
398
+ * 是否有行排序列
399
+ */
400
+ drop: {
401
+ type: [Boolean, Object],
402
+ default: !1
403
+ },
404
+ /**
405
+ * 列配置项
406
+ * 支持数组或字符串(字符串时从 tableConfig 获取)
407
+ */
408
+ columns: {
409
+ type: [Array, String],
410
+ default: () => []
411
+ },
412
+ /**
413
+ * 源数据
414
+ */
415
+ data: {
416
+ type: Array,
417
+ default: () => []
418
+ },
419
+ /**
420
+ * 表格高度
421
+ */
422
+ height: {
423
+ type: [String, Number]
424
+ },
425
+ /**
426
+ * 表格最大高度
427
+ */
428
+ maxHeight: {
429
+ type: [String, Number]
430
+ },
431
+ /**
432
+ * 同 element-plus table
433
+ */
434
+ fit: {
435
+ type: Boolean,
436
+ default: !0
437
+ },
438
+ /**
439
+ * 斑马纹
440
+ */
441
+ stripe: Boolean,
442
+ /**
443
+ * 边框
444
+ */
445
+ border: Boolean,
446
+ /**
447
+ * 行数据的 Key
448
+ */
449
+ rowKey: {
450
+ type: [String, Function]
451
+ },
452
+ /**
453
+ * 是否显示表头
454
+ */
455
+ showHeader: {
456
+ type: Boolean,
457
+ default: !0
458
+ },
459
+ /**
460
+ * 是否显示合计行
461
+ */
462
+ showSummary: {
463
+ type: Boolean,
464
+ default: !1
465
+ },
466
+ /**
467
+ * 合计计算方法
468
+ */
469
+ summaryMethod: {
470
+ type: Function
471
+ },
472
+ /**
473
+ * 行 className
474
+ */
475
+ rowClassName: {
476
+ type: [String, Function]
477
+ },
478
+ /**
479
+ * 行 style
480
+ */
481
+ rowStyle: {
482
+ type: [Object, Function]
483
+ },
484
+ /**
485
+ * 单元格 className
486
+ */
487
+ cellClassName: {
488
+ type: [String, Function]
489
+ },
490
+ /**
491
+ * 单元格 style
492
+ */
493
+ cellStyle: {
494
+ type: [Object, Function]
495
+ },
496
+ headerRowClassName: [String, Function],
497
+ headerRowStyle: [Object, Function],
498
+ headerCellClassName: [String, Function],
499
+ headerCellStyle: [Object, Function],
500
+ highlightCurrentRow: Boolean,
501
+ currentRowKey: [String, Number],
502
+ emptyText: String,
503
+ expandRowKeys: Array,
504
+ defaultExpandAll: Boolean,
505
+ defaultSort: Object,
506
+ tooltipEffect: String,
507
+ spanMethod: Function,
508
+ selectOnIndeterminate: {
509
+ type: Boolean,
510
+ default: !0
511
+ },
512
+ indent: {
513
+ type: Number,
514
+ default: 16
515
+ },
516
+ treeProps: {
517
+ type: Object,
518
+ default: () => ({
519
+ hasChildren: "hasChildren",
520
+ children: "children"
521
+ })
522
+ },
523
+ lazy: Boolean,
524
+ load: Function,
525
+ style: {
526
+ type: Object,
527
+ default: () => ({})
528
+ },
529
+ className: {
530
+ type: String,
531
+ default: ""
532
+ },
533
+ /**
534
+ * 是否显示溢出提示
535
+ */
536
+ showOverflowTooltip: {
537
+ type: Boolean,
538
+ default: !1
539
+ },
540
+ /**
541
+ * 对齐方式
542
+ */
543
+ align: {
544
+ type: String,
545
+ default: void 0
546
+ },
547
+ /**
548
+ * 表头对齐方式
549
+ */
550
+ headerAlign: {
551
+ type: String,
552
+ default: void 0
553
+ },
554
+ /**
555
+ * 尺寸
556
+ */
557
+ size: {
558
+ type: String,
559
+ default: void 0
560
+ },
561
+ /**
562
+ * 自定义表格宽度配置项
563
+ */
564
+ widthOptions: {
565
+ type: Object,
566
+ default: () => ({})
567
+ }
568
+ }, Y = /* @__PURE__ */ U({
569
+ name: "Icon",
570
+ props: {
571
+ size: {
572
+ type: Number,
573
+ default: 16
574
+ },
575
+ color: {
576
+ type: String
577
+ },
578
+ name: {
579
+ required: !0,
580
+ type: String,
581
+ default: "Fold"
582
+ },
583
+ type: {
584
+ type: String
585
+ }
586
+ },
587
+ setup(e) {
588
+ const n = N(() => {
589
+ if (!e.size && !e.color && !e.type) return {};
590
+ const i = e.color || !e.type ? e.color : `var(--el-color-${e.type})`;
591
+ return {
592
+ fontSize: Nt(e.size) ? void 0 : ke(e.size),
593
+ color: i
594
+ };
595
+ }), r = N(() => e.color || !e.type ? {
596
+ color: e.color
597
+ } : {
598
+ color: `var(--el-color-${e.type})`
599
+ }), a = N(() => /^el-/.test(e.name)), l = N(() => a.value ? vt(e.name.replace("el-", "")) : "#icon-" + e.name);
600
+ return () => {
601
+ if (a.value) {
602
+ const i = Tt[l.value];
603
+ return z(Xe, {
604
+ size: e.size,
605
+ color: e.color,
606
+ class: "el-svg-icon",
607
+ style: r.value
608
+ }, {
609
+ default: () => [i ? z(i, null, null) : null]
610
+ });
611
+ }
612
+ return z("svg", {
613
+ class: "svg-icon",
614
+ "aria-hidden": "true",
615
+ style: n.value
616
+ }, [z("use", {
617
+ "xlink:href": l.value
618
+ }, null)]);
619
+ };
620
+ }
621
+ });
622
+ function je() {
623
+ const e = V(!1);
624
+ return {
625
+ visible: e,
626
+ openDialog: () => {
627
+ e.value = !0;
628
+ },
629
+ closeDialog: () => {
630
+ e.value = !1;
631
+ }
632
+ };
633
+ }
634
+ const Ut = {
635
+ title: {
636
+ type: String,
637
+ default: "列表显示字段"
638
+ },
639
+ type: {
640
+ type: String,
641
+ required: !0
642
+ }
643
+ }, me = /* @__PURE__ */ U({
644
+ name: "MColumnSettings",
645
+ props: Ut,
646
+ emits: ["update:modelValue", "submit"],
647
+ setup(e, {
648
+ emit: n,
649
+ expose: r
650
+ }) {
651
+ const {
652
+ setTableConfig: a,
653
+ getTableConfig: l,
654
+ resetTableConfig: i
655
+ } = Oe(), {
656
+ visible: g,
657
+ openDialog: d,
658
+ closeDialog: h
659
+ } = je(), u = V([]), b = () => {
660
+ d(), u.value = JSON.parse(JSON.stringify(l(e.type) || [])).filter((S) => S.label);
661
+ }, c = (S) => !o(S.relatedContext.element), o = (S) => S.fixed === "left", f = () => {
662
+ a(e.type, u.value), n("update:modelValue", u.value), n("submit"), h();
663
+ }, T = () => {
664
+ i(e.type), n("submit"), h();
665
+ }, x = (S) => {
666
+ S.hide = !S.hide;
667
+ };
668
+ return r({
669
+ init: b
670
+ }), () => s("div", {
671
+ class: "m-column-settings"
672
+ }, [s(Ze, {
673
+ modelValue: g.value,
674
+ "onUpdate:modelValue": (S) => g.value = S,
675
+ size: "280px",
676
+ direction: "rtl",
677
+ modal: !0,
678
+ withHeader: !1,
679
+ appendToBody: !0,
680
+ destroyOnClose: !0,
681
+ onClose: h
682
+ }, {
683
+ default: () => [s("div", {
684
+ class: "m-drawer-title"
685
+ }, [s("span", null, e.title), s(Y, {
686
+ class: "cursor-pointer",
687
+ name: "el-close",
688
+ size: 16,
689
+ onClick: h
690
+ })]), s("div", {
691
+ class: "settings-body"
692
+ }, [s(xt, {
693
+ modelValue: u.value,
694
+ "onUpdate:modelValue": (S) => u.value = S,
695
+ draggable: ".settings-item",
696
+ filter: ".forbid",
697
+ itemKey: "prop",
698
+ move: c,
699
+ handle: ".handle"
700
+ }, {
701
+ item: ({
702
+ element: S
703
+ }) => s("div", {
704
+ class: "settings-item"
705
+ }, [s(Y, {
706
+ class: ["handle", "cursor-move", "mr-2", o(S) ? "forbid cursor-not-allowed" : ""],
707
+ name: "sortDot",
708
+ size: 20
709
+ }), s(ue, {
710
+ checked: !S.hide,
711
+ disabled: S.disabled,
712
+ onChange: () => x(S)
713
+ }, () => S.label)])
714
+ })])],
715
+ footer: () => s("div", {
716
+ class: "settings-footer"
717
+ }, [s(I, {
718
+ plain: !0,
719
+ onClick: h
720
+ }, () => "取消"), s(I, {
721
+ type: "primary",
722
+ onClick: f
723
+ }, () => "保存"), s(I, {
724
+ type: "primary",
725
+ plain: !0,
726
+ onClick: T
727
+ }, () => "恢复默认")])
728
+ })]);
729
+ }
730
+ }), De = /* @__PURE__ */ U({
731
+ name: "MTableItem",
732
+ props: {
733
+ item: {
734
+ type: Object,
735
+ required: !0
736
+ },
737
+ size: {
738
+ type: String,
739
+ default: void 0
740
+ }
741
+ },
742
+ setup(e, {
743
+ slots: n
744
+ }) {
745
+ const {
746
+ item: r
747
+ } = ne(e), a = ae("defaultBind"), l = J(r, a), i = ae("columns"), g = ae("emptyFill");
748
+ function d(u) {
749
+ const b = he();
750
+ return n[r.value.prop + "-header"] ? n[r.value.prop + "-header"]({
751
+ ...u,
752
+ size: e.size
753
+ }) : r.value.isSetting ? z("div", {
754
+ style: {
755
+ display: "flex",
756
+ alignItems: "center",
757
+ justifyContent: {
758
+ right: "flex-end",
759
+ center: "center",
760
+ left: "flex-start"
761
+ }[r.value.align || r.value.headerAlign]
762
+ }
763
+ }, [z("span", null, [r.value.label]), z(Y, {
764
+ name: r.value.icon || "el-operation",
765
+ onClick: () => b.value.init()
766
+ }, null), L(i) ? z(me, {
767
+ ref: b,
768
+ type: i
769
+ }, null) : null]) : r.value.label;
770
+ }
771
+ function h(u) {
772
+ var c, o;
773
+ let b = [];
774
+ if ((o = (c = r.value) == null ? void 0 : c.children) != null && o.length) {
775
+ const f = r.value.children.map((T) => s(De, {
776
+ item: T,
777
+ size: e.size
778
+ }, n));
779
+ b.push(f);
780
+ } else n[r.value.prop] ? b.push(n[r.value.prop]({
781
+ ...u,
782
+ size: e.size
783
+ })) : r.value.render ? b.push(ce(r.value.render) ? r.value.render(u.row, u.$index) : String(r.value.render)) : b.push(ie(u.row, r.value.prop, "") ?? g);
784
+ return b;
785
+ }
786
+ return () => z(K, l.value, {
787
+ header: (u) => d(u),
788
+ default: (u) => h(u)
789
+ });
790
+ }
791
+ }), Ie = /* @__PURE__ */ U({
792
+ name: "Table",
793
+ props: Mt,
794
+ setup(e, {
795
+ slots: n,
796
+ expose: r
797
+ }) {
798
+ const {
799
+ selection: a,
800
+ expand: l,
801
+ index: i,
802
+ action: g,
803
+ height: d
804
+ } = ne(e), h = Ve(), u = Ot(e), b = Bt(e), c = J(a, b);
805
+ J(l, b);
806
+ const o = J(i, b), f = J(g, b), {
807
+ table: T,
808
+ clearSelection: x,
809
+ toggleRowSelection: S,
810
+ toggleAllSelection: A,
811
+ toggleRowExpansion: y,
812
+ setCurrentRow: w,
813
+ clearSort: E,
814
+ clearFilter: R,
815
+ doLayout: t,
816
+ sort: p,
817
+ getSelectionRows: v
818
+ } = Be(), k = Ye(e, "showOverflowTooltip", "align", "headerAlign");
819
+ oe("defaultBind", b), oe("columns", e.columns), oe("emptyFill", e.emptyFill), r({
820
+ clearSelection: x,
821
+ toggleRowSelection: S,
822
+ toggleAllSelection: A,
823
+ toggleRowExpansion: y,
824
+ setCurrentRow: w,
825
+ clearSort: E,
826
+ clearFilter: R,
827
+ doLayout: t,
828
+ getSelectionRows: v,
829
+ sort: p
830
+ });
831
+ function D() {
832
+ let m = [];
833
+ function P() {
834
+ const j = he();
835
+ return z("div", {
836
+ class: "flex items-center",
837
+ style: {
838
+ justifyContent: {
839
+ right: "flex-end",
840
+ center: "center",
841
+ left: "flex-start"
842
+ }[f.value.align || f.value.headerAlign]
843
+ }
844
+ }, [z("span", null, [f.value.label]), z(Y, {
845
+ name: f.value.icon || "el-operation",
846
+ onClick: () => j.value.init()
847
+ }, null), L(e.columns) ? z(me, {
848
+ ref: j,
849
+ type: e.columns
850
+ }, null) : null]);
851
+ }
852
+ if (l.value !== !1 && n.expand && m.push(z(K, q(bindExpand.value, {
853
+ type: "expand"
854
+ }), {
855
+ default: (j) => n.expand && n.expand(j)
856
+ })), a.value && m.push(z(K, q(c.value, {
857
+ type: "selection"
858
+ }), null)), i.value && m.push(z(K, q(o.value, {
859
+ type: "index"
860
+ }), null)), u.value) {
861
+ const j = u.value.map((O) => s(De, {
862
+ item: O,
863
+ size: e.size
864
+ }, n));
865
+ m = m.concat(j);
866
+ }
867
+ return n.default && (m = m.concat(n.default())), g.value !== !1 && n.action && m.push(z(K, f.value, {
868
+ default: (j) => n.action && n.action({
869
+ ...j,
870
+ size: e.size
871
+ }),
872
+ header: (j) => n["action-header"] ? n["action-header"]({
873
+ ...j,
874
+ size: e.size
875
+ }) : f.value.isSetting ? P() : s("span", {}, f.value.label)
876
+ })), m;
877
+ }
878
+ return () => z("div", {
879
+ style: {
880
+ height: ke(d.value)
881
+ }
882
+ }, [z(et, q(k, h.value, {
883
+ ref: T,
884
+ height: d.value ? "100%" : null
885
+ }), {
886
+ default: () => D(),
887
+ append: n.append,
888
+ empty: n.empty
889
+ })]);
890
+ }
891
+ }), _t = {
892
+ modelValue: {
893
+ type: Object,
894
+ default: () => ({})
895
+ },
896
+ columns: {
897
+ type: Array,
898
+ default: () => []
899
+ },
900
+ inline: {
901
+ type: Boolean,
902
+ default: !1
903
+ },
904
+ labelWidth: {
905
+ type: [String, Number],
906
+ default: 80
907
+ },
908
+ labelPosition: {
909
+ type: String,
910
+ default: "top"
911
+ },
912
+ size: {
913
+ type: String,
914
+ default: void 0
915
+ },
916
+ menu: {
917
+ type: Object,
918
+ default: () => ({})
919
+ }
920
+ }, _ = "value", ee = "label", Lt = [
921
+ "component",
922
+ "prop",
923
+ "data",
924
+ "render",
925
+ "children",
926
+ "slot",
927
+ "class",
928
+ "initValue",
929
+ "labelName",
930
+ "valueName",
931
+ "all",
932
+ "placeholder",
933
+ "prefixIcon",
934
+ "size",
935
+ "width",
936
+ "type",
937
+ "props"
938
+ ], fe = U({
939
+ name: "MForm",
940
+ props: _t,
941
+ emits: ["update:modelValue", "change"],
942
+ setup(e, { emit: n, slots: r, expose: a }) {
943
+ const { columns: l, modelValue: i, inline: g } = ne(e), d = V(null), h = N({
944
+ get: () => e.modelValue,
945
+ set: (t) => n("update:modelValue", t)
946
+ });
947
+ function u(t, p) {
948
+ const v = { ...h.value };
949
+ bt(v, t, p), n("update:modelValue", v), n("change", v);
950
+ }
951
+ function b(t) {
952
+ var p;
953
+ return (p = d.value) == null ? void 0 : p.validate(t);
954
+ }
955
+ function c() {
956
+ var t;
957
+ (t = d.value) == null || t.resetFields();
958
+ }
959
+ function o(t) {
960
+ var p;
961
+ (p = d.value) == null || p.clearValidate(t);
962
+ }
963
+ function f(t, p) {
964
+ var v;
965
+ (v = d.value) == null || v.validateField(t, p);
966
+ }
967
+ function T(t) {
968
+ var p, v;
969
+ (v = (p = d.value) == null ? void 0 : p.scrollToField) == null || v.call(p, t);
970
+ }
971
+ a({ validate: b, resetFields: c, clearValidate: o, validateField: f, scrollToField: T });
972
+ const x = V({ checked: !1, indeterminate: !1 });
973
+ function S(t) {
974
+ var p;
975
+ if (["cascader", "select"].includes(t.component) && t.all && !t.multiple) {
976
+ const v = [...t.data ?? []], k = L(t.all) ? t.all : "全部", D = t.labelName || ee;
977
+ return ((p = v == null ? void 0 : v[0]) == null ? void 0 : p[D]) !== k && v.unshift({
978
+ [D]: k,
979
+ [t.valueName || _]: 0
980
+ }), v;
981
+ }
982
+ return t.data;
983
+ }
984
+ function A() {
985
+ n("change", h.value);
986
+ }
987
+ function y(t, p) {
988
+ var v;
989
+ if (t.multiple && t.all) {
990
+ const k = ((v = S(t)) == null ? void 0 : v.length) || 0;
991
+ !p || p.length === 0 ? x.value = { checked: !1, indeterminate: !1 } : p.length === k ? x.value = { checked: !0, indeterminate: !1 } : x.value = { checked: !1, indeterminate: !0 };
992
+ }
993
+ A();
994
+ }
995
+ function w(t, p) {
996
+ p ? u(
997
+ t.prop,
998
+ (S(t) || []).map(
999
+ (v) => v[t.valueName || _]
1000
+ )
1001
+ ) : u(t.prop, []), x.value = { checked: !!p, indeterminate: !1 };
1002
+ }
1003
+ function E(t, p) {
1004
+ const v = St(t, Lt), k = t.width !== void 0 ? typeof t.width == "number" ? `${t.width}px` : String(t.width) : void 0, D = k ? { width: k } : {};
1005
+ switch (t.component) {
1006
+ case "select": {
1007
+ const m = t.labelName || ee, P = t.valueName || _, j = S(t);
1008
+ return s(
1009
+ dt,
1010
+ {
1011
+ ...v,
1012
+ modelValue: p,
1013
+ "onUpdate:modelValue": (O) => u(t.prop, O),
1014
+ size: t.size,
1015
+ style: D,
1016
+ fitInputWidth: !0,
1017
+ onChange: (O) => y(t, O),
1018
+ ...t.clearable === void 0 ? { clearable: !0 } : {}
1019
+ },
1020
+ {
1021
+ ...t.multiple && t.all ? {
1022
+ header: () => s(
1023
+ ue,
1024
+ {
1025
+ modelValue: x.value.checked,
1026
+ indeterminate: x.value.indeterminate,
1027
+ onChange: (O) => w(t, O)
1028
+ },
1029
+ () => L(t.all) ? t.all : "全部"
1030
+ )
1031
+ } : {},
1032
+ default: () => (j || []).map(
1033
+ (O) => s(ft, {
1034
+ key: O[P],
1035
+ label: O[m],
1036
+ value: O[P],
1037
+ disabled: O.disabled
1038
+ })
1039
+ )
1040
+ }
1041
+ );
1042
+ }
1043
+ case "radio":
1044
+ return s(
1045
+ ct,
1046
+ {
1047
+ ...v,
1048
+ modelValue: p,
1049
+ "onUpdate:modelValue": (m) => u(t.prop, m),
1050
+ size: t.size,
1051
+ onChange: A
1052
+ },
1053
+ () => (t.data || []).map(
1054
+ (m) => s(
1055
+ st,
1056
+ {
1057
+ key: m[t.valueName || _],
1058
+ label: m[t.valueName || _],
1059
+ disabled: m.disabled
1060
+ },
1061
+ () => m[t.labelName || ee]
1062
+ )
1063
+ )
1064
+ );
1065
+ case "checkbox":
1066
+ return s(
1067
+ it,
1068
+ {
1069
+ ...v,
1070
+ modelValue: p ?? [],
1071
+ "onUpdate:modelValue": (m) => u(t.prop, m),
1072
+ size: t.size,
1073
+ onChange: A
1074
+ },
1075
+ () => (t.data || []).map(
1076
+ (m) => s(
1077
+ ue,
1078
+ {
1079
+ key: m[t.valueName || _],
1080
+ label: m[t.valueName || _],
1081
+ disabled: m.disabled
1082
+ },
1083
+ () => m[t.labelName || ee]
1084
+ )
1085
+ )
1086
+ );
1087
+ case "cascader":
1088
+ return s(ut, {
1089
+ ...v,
1090
+ modelValue: p,
1091
+ "onUpdate:modelValue": (m) => u(t.prop, m),
1092
+ options: S(t) || [],
1093
+ props: t.props || {},
1094
+ size: t.size,
1095
+ style: D,
1096
+ clearable: !0,
1097
+ onChange: A
1098
+ });
1099
+ case "treeSelect":
1100
+ return s(rt, {
1101
+ ...v,
1102
+ modelValue: p,
1103
+ "onUpdate:modelValue": (m) => u(t.prop, m),
1104
+ data: t.data || [],
1105
+ size: t.size,
1106
+ style: D,
1107
+ onChange: A
1108
+ });
1109
+ case "date":
1110
+ return s(ot, {
1111
+ ...v,
1112
+ modelValue: p,
1113
+ "onUpdate:modelValue": (m) => u(t.prop, m),
1114
+ type: t.type || "date",
1115
+ size: t.size,
1116
+ style: D,
1117
+ onChange: A
1118
+ });
1119
+ case "inputNumber":
1120
+ return s(at, {
1121
+ ...v,
1122
+ modelValue: p,
1123
+ "onUpdate:modelValue": (m) => u(t.prop, m),
1124
+ size: t.size,
1125
+ style: D,
1126
+ onChange: A
1127
+ });
1128
+ case "input":
1129
+ default:
1130
+ return s(lt, {
1131
+ ...v,
1132
+ modelValue: p,
1133
+ "onUpdate:modelValue": (m) => u(t.prop, m),
1134
+ placeholder: t.placeholder,
1135
+ size: t.size,
1136
+ style: D,
1137
+ clearable: t.clearable === void 0 ? !0 : t.clearable,
1138
+ onKeydown: (m) => {
1139
+ m.key === "Enter" && A();
1140
+ }
1141
+ });
1142
+ }
1143
+ }
1144
+ function R(t) {
1145
+ return s(
1146
+ nt,
1147
+ {
1148
+ key: t.prop,
1149
+ label: t.label,
1150
+ prop: t.prop
1151
+ },
1152
+ {
1153
+ default: () => {
1154
+ const p = yt(h.value, t.prop), v = p ? ie(h.value, t.prop, "") : t.initValue !== void 0 ? t.initValue : "";
1155
+ return r[t.prop] ? r[t.prop]({
1156
+ item: t,
1157
+ value: p ? ie(h.value, t.prop) : v,
1158
+ setValue: (k) => u(t.prop, k)
1159
+ }) : E(t, v);
1160
+ }
1161
+ }
1162
+ );
1163
+ }
1164
+ return () => {
1165
+ const t = l.value.map((p, v) => Array.isArray(p) ? p.map(
1166
+ (k) => s("div", { key: `${k.prop}-${v}`, class: "m-form-item-group" }, [
1167
+ R(k)
1168
+ ])
1169
+ ) : R(p));
1170
+ return s(
1171
+ tt,
1172
+ {
1173
+ ref: d,
1174
+ model: h.value,
1175
+ inline: g.value,
1176
+ labelWidth: e.labelWidth,
1177
+ labelPosition: e.labelPosition,
1178
+ size: e.size
1179
+ },
1180
+ {
1181
+ default: () => [...t, r.default && r.default()]
1182
+ }
1183
+ );
1184
+ };
1185
+ }
1186
+ }), re = /* @__PURE__ */ new Map(), Me = /* @__PURE__ */ U({
1187
+ name: "Filter",
1188
+ props: {
1189
+ searchColumns: {
1190
+ type: Array,
1191
+ default: () => []
1192
+ },
1193
+ moreSearchColumns: {
1194
+ type: Array,
1195
+ default: () => []
1196
+ },
1197
+ modelValue: {
1198
+ type: Object,
1199
+ default: () => ({})
1200
+ },
1201
+ size: {
1202
+ type: String,
1203
+ default: "default"
1204
+ },
1205
+ labelWidth: {
1206
+ type: [String, Number],
1207
+ default: 80
1208
+ },
1209
+ width: {
1210
+ type: String,
1211
+ default: "240px"
1212
+ },
1213
+ isSearch: {
1214
+ type: Boolean,
1215
+ default: !0
1216
+ },
1217
+ isMore: {
1218
+ type: Boolean,
1219
+ default: !0
1220
+ },
1221
+ isReset: {
1222
+ type: Boolean,
1223
+ default: !1
1224
+ }
1225
+ },
1226
+ emits: ["search", "update:modelValue", "reset", "change", "more", "activated"],
1227
+ setup(e, {
1228
+ emit: n,
1229
+ expose: r
1230
+ }) {
1231
+ const a = pe(), {
1232
+ visible: l,
1233
+ openDialog: i,
1234
+ closeDialog: g
1235
+ } = je(), d = N({
1236
+ get: () => e.modelValue,
1237
+ set: (y) => n("update:modelValue", y)
1238
+ }), h = N(() => e.searchColumns.map((y, w) => (w > 1 && (y.class = y.class ? y.class + " hidden-below-2xl" : "hidden-below-2xl"), y))), u = {}, b = {};
1239
+ for (const y in a) {
1240
+ const w = a[y];
1241
+ if (/^search-/.test(y)) {
1242
+ const E = y.replace("search-", "");
1243
+ u[E] = w;
1244
+ }
1245
+ if (/^moreSearch-/.test(y)) {
1246
+ const E = y.replace("moreSearch-", "");
1247
+ b[E] = w;
1248
+ }
1249
+ }
1250
+ let c;
1251
+ try {
1252
+ c = void 0;
1253
+ } catch {
1254
+ }
1255
+ Fe(() => {
1256
+ c && re.has(c) && (d.value = re.get(c), n("activated"));
1257
+ }), qe(() => {
1258
+ c && re.set(c, G(d));
1259
+ });
1260
+ const o = () => {
1261
+ const y = {};
1262
+ e.searchColumns && e.searchColumns.forEach((w) => {
1263
+ Q(w) ? w.forEach((E) => {
1264
+ y[E.prop] = E.initValue ?? "";
1265
+ }) : y[w.prop] = w.initValue ?? "";
1266
+ }), e.moreSearchColumns && e.moreSearchColumns.forEach((w) => {
1267
+ Q(w) ? w.forEach((E) => {
1268
+ y[E.prop] = E.initValue ?? "";
1269
+ }) : y[w.prop] = w.initValue ?? "";
1270
+ }), d.value = y;
1271
+ };
1272
+ function f() {
1273
+ n("search");
1274
+ }
1275
+ function T() {
1276
+ l.value = !1, n("search");
1277
+ }
1278
+ function x() {
1279
+ o(), n("search"), n("reset"), g();
1280
+ }
1281
+ function S() {
1282
+ i(), n("more");
1283
+ }
1284
+ function A(y) {
1285
+ n("change", y);
1286
+ }
1287
+ return r({
1288
+ initSearchParams: o
1289
+ }), () => {
1290
+ var y, w, E;
1291
+ return s("div", {
1292
+ class: "m-filter"
1293
+ }, [s("div", {
1294
+ class: "m-filter-l"
1295
+ }, [s(fe, {
1296
+ modelValue: d.value,
1297
+ "onUpdate:modelValue": (R) => d.value = R,
1298
+ columns: h.value,
1299
+ inline: !0,
1300
+ onChange: A
1301
+ }, u), (y = a.default) == null ? void 0 : y.call(a), ((w = a["menu-left"]) == null ? void 0 : w.call(a)) || s("div", {
1302
+ class: "flex items-center"
1303
+ }, [e.isSearch && s(I, {
1304
+ type: "primary",
1305
+ onClick: f
1306
+ }, () => "搜索"), e.isMore && e.moreSearchColumns.length > 0 && s(I, {
1307
+ onClick: S
1308
+ }, () => "更多筛选"), e.isReset && s(I, {
1309
+ onClick: x
1310
+ }, () => "重置")])].filter(Boolean)), s("div", {
1311
+ class: "m-filter-r"
1312
+ }, [(E = a["menu-right"]) == null ? void 0 : E.call(a)]), e.moreSearchColumns.length > 0 ? s(ht, {
1313
+ modelValue: l.value,
1314
+ "onUpdate:modelValue": (R) => l.value = R,
1315
+ top: "150px",
1316
+ width: "900px",
1317
+ draggable: !0
1318
+ }, {
1319
+ header: () => {
1320
+ var R;
1321
+ return s("div", {
1322
+ class: "flex justify-between items-center"
1323
+ }, [s("span", null, "更多筛选"), (R = a["moreSearch-title-right"]) == null ? void 0 : R.call(a)]);
1324
+ },
1325
+ default: () => s(fe, {
1326
+ modelValue: d.value,
1327
+ "onUpdate:modelValue": (R) => d.value = R,
1328
+ columns: e.moreSearchColumns,
1329
+ labelWidth: e.labelWidth
1330
+ }, b),
1331
+ footer: () => s("div", null, [s(I, {
1332
+ type: "primary",
1333
+ onClick: T
1334
+ }, () => "确定"), s(I, {
1335
+ onClick: g
1336
+ }, () => "取消"), s(I, {
1337
+ onClick: x
1338
+ }, () => "重置")])
1339
+ }) : null]);
1340
+ };
1341
+ }
1342
+ });
1343
+ Math.easeInOutQuad = function(e, n, r, a) {
1344
+ return e /= a / 2, e < 1 ? r / 2 * e * e + n : (e--, -r / 2 * (e * (e - 2) - 1) + n);
1345
+ };
1346
+ let Pt = (function() {
1347
+ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(e) {
1348
+ window.setTimeout(e, 1e3 / 60);
1349
+ };
1350
+ })();
1351
+ function Wt(e) {
1352
+ document.documentElement.scrollTop = e, document.body.parentNode.scrollTop = e, document.body.scrollTop = e;
1353
+ }
1354
+ function $t() {
1355
+ return document.documentElement.scrollTop || document.body.parentNode.scrollTop || document.body.scrollTop;
1356
+ }
1357
+ function Ee(e, n, r) {
1358
+ const a = $t(), l = e - a, i = 20;
1359
+ let g = 0;
1360
+ n = typeof n > "u" ? 500 : n;
1361
+ let d = function() {
1362
+ g += i;
1363
+ let h = Math.easeInOutQuad(g, a, l, n);
1364
+ Wt(h), g < n && Pt(d);
1365
+ };
1366
+ d();
1367
+ }
1368
+ const Ue = /* @__PURE__ */ U({
1369
+ name: "Pagination",
1370
+ props: {
1371
+ total: {
1372
+ required: !0,
1373
+ type: Number
1374
+ },
1375
+ page: {
1376
+ type: Number,
1377
+ default: 1
1378
+ },
1379
+ limit: {
1380
+ type: Number,
1381
+ default: 20
1382
+ },
1383
+ pageSizes: {
1384
+ type: Array,
1385
+ default() {
1386
+ return [10, 20, 30, 50];
1387
+ }
1388
+ },
1389
+ layout: {
1390
+ type: String,
1391
+ default: "total, sizes, prev, pager, next, jumper"
1392
+ },
1393
+ autoScroll: {
1394
+ type: Boolean,
1395
+ default: !0
1396
+ },
1397
+ hidden: {
1398
+ type: Boolean,
1399
+ default: !1
1400
+ },
1401
+ background: {
1402
+ type: Boolean,
1403
+ default: !0
1404
+ },
1405
+ simple: {
1406
+ type: Boolean,
1407
+ default: !1
1408
+ }
1409
+ },
1410
+ emits: ["update:page", "update:limit", "pagination"],
1411
+ setup(e, {
1412
+ emit: n
1413
+ }) {
1414
+ const r = Ve(), a = N(() => Ct(r.value, wt(pt))), l = N(() => e.simple ? "prev, pager, next" : e.layout), i = N({
1415
+ get() {
1416
+ return e.page;
1417
+ },
1418
+ set(u) {
1419
+ n("update:page", u);
1420
+ }
1421
+ }), g = N({
1422
+ get() {
1423
+ return e.limit;
1424
+ },
1425
+ set(u) {
1426
+ n("update:limit", u);
1427
+ }
1428
+ });
1429
+ function d(u) {
1430
+ n("pagination", {
1431
+ page: i.value,
1432
+ limit: u
1433
+ }), e.autoScroll && Ee(0, 800);
1434
+ }
1435
+ function h(u) {
1436
+ n("pagination", {
1437
+ page: u,
1438
+ limit: g.value
1439
+ }), e.autoScroll && Ee(0, 800);
1440
+ }
1441
+ return () => z("div", {
1442
+ class: "m-pagination"
1443
+ }, [z(gt, q(a.value, {
1444
+ currentPage: i.value
1445
+ }, {
1446
+ "onUpdate:currentPage": (u) => i.value = u
1447
+ }, {
1448
+ pageSize: g.value
1449
+ }, {
1450
+ "onUpdate:pageSize": (u) => g.value = u
1451
+ }, {
1452
+ layout: l.value,
1453
+ "page-sizes": e.pageSizes,
1454
+ total: e.total,
1455
+ background: e.background,
1456
+ onSizeChange: d,
1457
+ onCurrentChange: h
1458
+ }), null)]);
1459
+ }
1460
+ }), Ht = U({
1461
+ name: "Crud",
1462
+ props: It,
1463
+ emits: ["update:search", "reset"],
1464
+ setup(e, { emit: n, expose: r }) {
1465
+ const a = Ke(), l = pe(), i = V([]), { tableSlots: g, filterSlots: d, searchSlots: h } = jt(), u = `a${Math.floor(Math.random() * 1e6)}`, { tableHeight: b, calcTableHeight: c } = Dt(u), o = V(!1), f = V(0), { tableColumns: T, searchColumns: x, moreSearchColumns: S, footerReverse: A } = ne(e), y = V([]), w = V(1), E = V(e.limit), R = V(e.pageSizes), t = V({});
1466
+ zt({
1467
+ el: window,
1468
+ name: "resize",
1469
+ listener: () => {
1470
+ c();
1471
+ }
1472
+ });
1473
+ const {
1474
+ table: p,
1475
+ clearSelection: v,
1476
+ toggleRowSelection: k,
1477
+ toggleAllSelection: D,
1478
+ toggleRowExpansion: m,
1479
+ setCurrentRow: P,
1480
+ clearSort: j,
1481
+ clearFilter: O,
1482
+ doLayout: _e,
1483
+ sort: Le
1484
+ } = Be();
1485
+ async function Pe() {
1486
+ try {
1487
+ if (ce(e.request)) {
1488
+ o.value = !0;
1489
+ const {
1490
+ data: C,
1491
+ success: F,
1492
+ total: Z
1493
+ } = await e.request({
1494
+ pageInfo: { page: w.value, limit: E.value },
1495
+ params: t.value
1496
+ });
1497
+ o.value = !1, F ? (f.value = Z, y.value = C) : (y.value = [], f.value = 0), te(() => {
1498
+ var H;
1499
+ ce(e.afterRequest) && ((H = e.afterRequest) == null || H.call(e, G(y)));
1500
+ });
1501
+ } else
1502
+ throw new TypeError(
1503
+ "Type of the default value for 'request' prop must be a function"
1504
+ );
1505
+ } catch (C) {
1506
+ throw o.value = !1, C;
1507
+ }
1508
+ }
1509
+ const le = () => {
1510
+ e.searchColumns && e.searchColumns.forEach((C) => {
1511
+ Q(C) ? C.forEach((F) => {
1512
+ t.value[F.prop] = F.initValue ?? "";
1513
+ }) : t.value[C.prop] = C.initValue ?? "";
1514
+ }), e.moreSearchColumns && e.moreSearchColumns.forEach((C) => {
1515
+ Q(C) ? C.forEach((F) => {
1516
+ t.value[F.prop] = F.initValue ?? "";
1517
+ }) : t.value[C.prop] = C.initValue ?? "";
1518
+ });
1519
+ }, X = Ne(Pe, e.debounceTime);
1520
+ Je(() => {
1521
+ le(), e.init && X(), te(() => {
1522
+ c();
1523
+ });
1524
+ });
1525
+ let ve = !0;
1526
+ Fe(() => {
1527
+ c(), !ve && y.value.length === 0 && X(), ve = !1;
1528
+ });
1529
+ const We = (C) => {
1530
+ i.value = C;
1531
+ }, $ = (C = !1) => {
1532
+ C && (w.value = 1), X();
1533
+ }, $e = () => {
1534
+ n("reset"), le(), $(!0);
1535
+ };
1536
+ r({
1537
+ pageTotal: f,
1538
+ initSearchParams: le,
1539
+ refresh: $,
1540
+ search: t,
1541
+ table: p,
1542
+ clearSelection: v,
1543
+ toggleRowSelection: k,
1544
+ toggleAllSelection: D,
1545
+ toggleRowExpansion: m,
1546
+ setCurrentRow: P,
1547
+ clearSort: j,
1548
+ clearFilter: O,
1549
+ doLayout: _e,
1550
+ sort: Le,
1551
+ data: y,
1552
+ calcTableHeight: c,
1553
+ selectionList: i
1554
+ });
1555
+ const ye = {};
1556
+ for (const C in g)
1557
+ ye[C] = (F) => g[C]({
1558
+ row: F == null ? void 0 : F.row,
1559
+ index: F == null ? void 0 : F.$index
1560
+ });
1561
+ const be = {};
1562
+ ["action", "action-header", "expand", "append", "empty"].forEach((C) => {
1563
+ l[C] && (be[C] = (F) => l[C]({ ...F || {}, size: void 0 }));
1564
+ });
1565
+ const Se = {};
1566
+ for (const C in h)
1567
+ Se[C] = () => h[C]({ params: t.value });
1568
+ return () => {
1569
+ var C, F, Z, H, Ce, we, Te, xe;
1570
+ return s("section", { class: "m-crud" }, [
1571
+ // Header
1572
+ s("div", { id: `${u}-header`, class: "m-crud-header" }, [
1573
+ ((C = l.header) == null ? void 0 : C.call(l)) || [
1574
+ ((F = l["menu-left"]) == null ? void 0 : F.call(l)) || s("div", { class: "flex items-center" }, [
1575
+ (Z = l["form-menu-top"]) == null ? void 0 : Z.call(l),
1576
+ s("div", { class: "flex items-center" }, [
1577
+ (H = l["form-menu-left"]) == null ? void 0 : H.call(l),
1578
+ s(
1579
+ Me,
1580
+ {
1581
+ modelValue: t.value,
1582
+ "onUpdate:modelValue": (B) => t.value = B,
1583
+ searchColumns: x.value,
1584
+ moreSearchColumns: S.value,
1585
+ ...a,
1586
+ onSearch: () => $(!0),
1587
+ onChange: () => $(!0),
1588
+ onActivated: () => $(!1),
1589
+ onReset: $e
1590
+ },
1591
+ {
1592
+ ...Se,
1593
+ ...d,
1594
+ "form-menu-right": () => {
1595
+ var B;
1596
+ return (B = l["form-menu-right"]) == null ? void 0 : B.call(l, { search: t.value });
1597
+ },
1598
+ "moreSearch-title-right": () => {
1599
+ var B;
1600
+ return (B = l["moreSearch-title-right"]) == null ? void 0 : B.call(l);
1601
+ }
1602
+ }
1603
+ )
1604
+ ])
1605
+ ]),
1606
+ s("div", { class: "flex-1 flex justify-end" }, [
1607
+ (Ce = l["menu-right"]) == null ? void 0 : Ce.call(l)
1608
+ ])
1609
+ ]
1610
+ ]),
1611
+ // Body
1612
+ s(
1613
+ "div",
1614
+ { class: "m-crud-body", style: { height: `calc(100% - ${b.value || "120px"})` } },
1615
+ [
1616
+ ((we = l.table) == null ? void 0 : we.call(l, { data: y.value })) || Ge(
1617
+ s(
1618
+ Ie,
1619
+ {
1620
+ ref: p,
1621
+ height: "100%",
1622
+ columns: T.value,
1623
+ data: y.value,
1624
+ ...a,
1625
+ onSelectionChange: (B) => We(B)
1626
+ },
1627
+ { ...be, ...ye }
1628
+ ),
1629
+ [[mt, o.value]]
1630
+ )
1631
+ ]
1632
+ ),
1633
+ // Footer
1634
+ s(
1635
+ "div",
1636
+ {
1637
+ id: `${u}-footer`,
1638
+ class: [
1639
+ "m-crud-footer",
1640
+ A.value ? "flex-row-reverse" : ""
1641
+ ]
1642
+ },
1643
+ [
1644
+ ((Te = l.footer) == null ? void 0 : Te.call(l)) || [
1645
+ s("div", {}, [(xe = l.batch) == null ? void 0 : xe.call(l, { list: i.value })]),
1646
+ // 与原版 v-show 行为一致:total 为 0 时隐藏但不卸载
1647
+ s(Ue, {
1648
+ style: f.value > 0 ? void 0 : { display: "none" },
1649
+ page: w.value,
1650
+ "onUpdate:page": (B) => w.value = B,
1651
+ limit: E.value,
1652
+ "onUpdate:limit": (B) => E.value = B,
1653
+ pageSizes: R.value,
1654
+ "onUpdate:pageSizes": (B) => R.value = B,
1655
+ total: f.value,
1656
+ ...a,
1657
+ onPagination: X
1658
+ })
1659
+ ]
1660
+ ]
1661
+ )
1662
+ ]);
1663
+ };
1664
+ }
1665
+ }), tn = () => {
1666
+ const e = V(), n = N({
1667
+ get() {
1668
+ var o;
1669
+ return (o = e.value) == null ? void 0 : o.search;
1670
+ },
1671
+ set(o) {
1672
+ e.value.search = o;
1673
+ }
1674
+ }), r = N(() => {
1675
+ var o;
1676
+ return ((o = e.value) == null ? void 0 : o.data) || [];
1677
+ }), a = N(() => {
1678
+ var o;
1679
+ return (o = e.value) == null ? void 0 : o.pageTotal;
1680
+ }), l = N(() => {
1681
+ var o;
1682
+ return (o = e.value) == null ? void 0 : o.selectionList;
1683
+ });
1684
+ return {
1685
+ crudRef: (o) => {
1686
+ e.value = o;
1687
+ },
1688
+ search: n,
1689
+ doLayout: () => {
1690
+ te(() => {
1691
+ var o;
1692
+ (o = e.value) == null || o.calcTableHeight();
1693
+ });
1694
+ },
1695
+ data: r,
1696
+ refresh: () => {
1697
+ var o;
1698
+ (o = e.value) == null || o.refresh();
1699
+ },
1700
+ pageTotal: a,
1701
+ calcHeight: () => {
1702
+ te(() => {
1703
+ var o;
1704
+ (o = e.value) == null || o.calcTableHeight();
1705
+ });
1706
+ },
1707
+ initSearchParams: () => {
1708
+ var o;
1709
+ (o = e.value) == null || o.initSearchParams();
1710
+ },
1711
+ selectionList: l,
1712
+ toggleAllSelection: () => {
1713
+ var o;
1714
+ (o = e.value) == null || o.toggleAllSelection();
1715
+ },
1716
+ toggleRowSelection: (o, f) => {
1717
+ var T;
1718
+ (T = e.value) == null || T.toggleRowSelection(o, f);
1719
+ }
1720
+ };
1721
+ }, qt = [Ht, Ie, Me, fe, Ue, Y, me], Kt = (e) => {
1722
+ qt.forEach((n) => {
1723
+ const r = n.name || n.__name;
1724
+ r && e.component(r, n);
1725
+ });
1726
+ }, nn = {
1727
+ install: Kt
1728
+ };
1729
+ export {
1730
+ me as ColumnSettings,
1731
+ Ht as Crud,
1732
+ Me as Filter,
1733
+ fe as Form,
1734
+ Y as Icon,
1735
+ Ue as Pagination,
1736
+ Ie as Table,
1737
+ en as clearTableConfig,
1738
+ nn as default,
1739
+ Zt as registerTableConfig,
1740
+ tn as useCrud,
1741
+ zt as useEventListener,
1742
+ je as useOpenDialog,
1743
+ Oe as useTableConfig
1744
+ };
1745
+ //# sourceMappingURL=element-crud.es.js.map