@done-coding/admin-core 0.1.1-alpha.2 → 0.1.1-alpha.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.
- package/es/components/form/FormDatePicker.vue.mjs +7 -0
- package/es/components/form/FormDatePicker.vue2.mjs +50 -0
- package/es/components/form/index.mjs +19 -19
- package/es/components/form/utils.mjs +82 -61
- package/es/components/misc/ActionButton.vue.mjs +52 -0
- package/es/components/misc/ActionButton.vue2.mjs +4 -0
- package/es/components/misc/ActionButtonDanger.vue.mjs +32 -0
- package/es/components/misc/ActionButtonDanger.vue2.mjs +4 -0
- package/es/components/misc/ActionButtonWarn.vue.mjs +32 -0
- package/es/components/misc/ActionButtonWarn.vue2.mjs +4 -0
- package/es/components/misc/index.mjs +21 -9
- package/es/components/table/TableMain.vue.mjs +1 -1
- package/es/components/table/TableMain.vue2.mjs +148 -133
- package/es/components/table/TableToolbar.vue.mjs +3 -3
- package/es/components/table/TableToolbar.vue2.mjs +154 -70
- package/es/components/table/ToolbarButtons.vue.mjs +49 -0
- package/es/components/table/ToolbarButtons.vue2.mjs +4 -0
- package/es/helpers/list-helper.mjs +29 -33
- package/es/index.mjs +104 -92
- package/es/style.css +1 -1
- package/es/utils/export.mjs +23 -0
- package/package.json +2 -2
- package/types/components/form/{FormDateTimeRange.vue.d.ts → FormDatePicker.vue.d.ts} +2 -2
- package/types/components/form/index.d.ts +2 -2
- package/types/components/form/utils.d.ts +3 -1
- package/types/components/misc/ActionButton.vue.d.ts +24 -0
- package/types/components/misc/ActionButtonDanger.vue.d.ts +19 -0
- package/types/components/misc/ActionButtonWarn.vue.d.ts +19 -0
- package/types/components/misc/index.d.ts +4 -1
- package/types/components/table/TableToolbar.vue.d.ts +66 -9
- package/types/components/table/ToolbarButtons.vue.d.ts +19 -0
- package/types/components/table/types.d.ts +64 -17
- package/types/utils/export.d.ts +30 -0
- package/types/utils/index.d.ts +1 -0
- package/es/components/form/FormDateTimeRange.vue.mjs +0 -46
- package/es/components/form/FormDateTimeRange.vue2.mjs +0 -4
|
@@ -1,75 +1,149 @@
|
|
|
1
|
-
import { ElDropdown as
|
|
1
|
+
import { ElDropdown as V, ElButton as $, ElIcon as F, ElDropdownMenu as S, ElDropdownItem as z } from "element-plus/es";
|
|
2
2
|
import "element-plus/es/components/base/style/css";
|
|
3
3
|
import "element-plus/es/components/dropdown/style/css";
|
|
4
4
|
import "element-plus/es/components/dropdown-menu/style/css";
|
|
5
5
|
import "element-plus/es/components/dropdown-item/style/css";
|
|
6
6
|
import "element-plus/es/components/button/style/css";
|
|
7
7
|
import "element-plus/es/components/icon/style/css";
|
|
8
|
-
import { defineComponent as
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
|
|
8
|
+
import { defineComponent as L, useModel as P, computed as v, ref as y, watch as N, withDirectives as U, openBlock as c, createElementBlock as X, createElementVNode as R, createBlock as p, withCtx as n, createVNode as r, createTextVNode as h, unref as A, createCommentVNode as g, normalizeClass as q, vShow as O, mergeModels as j } from "vue";
|
|
9
|
+
import { ElMessageBox as G, ElMessage as H } from "element-plus";
|
|
10
|
+
import { ArrowDown as J, Refresh as K } from "@element-plus/icons-vue";
|
|
11
|
+
import Q from "../misc/AutoRefresh.vue.mjs";
|
|
12
|
+
import k from "./ToolbarButtons.vue.mjs";
|
|
13
|
+
import { countAll as W, fetchListAll as M } from "../../helpers/list-helper.mjs";
|
|
14
|
+
import { EXPORT_MAX_LIMIT as f, exportCSV as Y } from "../../utils/export.mjs";
|
|
15
|
+
const Z = { class: "table-toolbar" }, _ = { class: "table-toolbar-left" }, ee = { class: "table-toolbar-right" }, pe = /* @__PURE__ */ L({
|
|
12
16
|
__name: "TableToolbar",
|
|
13
|
-
props: /* @__PURE__ */
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
props: /* @__PURE__ */ j({
|
|
18
|
+
showRefresh: { type: Boolean, default: !0 },
|
|
19
|
+
showAutoRefresh: { type: Boolean, default: !0 },
|
|
16
20
|
refreshInterval: { default: 30 },
|
|
21
|
+
exportByFe: { type: Boolean, default: !0 },
|
|
17
22
|
exportFn: {},
|
|
23
|
+
exportColumns: {},
|
|
24
|
+
leftExtraButtons: {},
|
|
25
|
+
rightExtraButtons: {},
|
|
18
26
|
tableExpose: {},
|
|
19
|
-
loading: { type: Boolean }
|
|
27
|
+
loading: { type: Boolean },
|
|
28
|
+
exportContext: {},
|
|
29
|
+
currentPage: {},
|
|
30
|
+
pageSize: {}
|
|
20
31
|
}, {
|
|
21
32
|
isAutoRefresh: { type: Boolean },
|
|
22
33
|
isAutoRefreshModifiers: {}
|
|
23
34
|
}),
|
|
24
35
|
emits: ["update:isAutoRefresh"],
|
|
25
|
-
setup(
|
|
26
|
-
const t =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
setup(l) {
|
|
37
|
+
const t = l, w = P(l, "isAutoRefresh"), B = v(() => {
|
|
38
|
+
var o;
|
|
39
|
+
return !!((o = t.exportColumns) != null && o.length);
|
|
40
|
+
}), C = v(() => ({
|
|
41
|
+
tableExpose: t.tableExpose,
|
|
42
|
+
loading: t.loading,
|
|
43
|
+
exportContext: t.exportContext,
|
|
44
|
+
selectedList: t.exportContext.selectedList,
|
|
45
|
+
pagination: {
|
|
46
|
+
currentPage: t.currentPage,
|
|
47
|
+
pageSize: t.pageSize,
|
|
48
|
+
total: t.exportContext.total
|
|
49
|
+
}
|
|
50
|
+
})), D = v(
|
|
51
|
+
() => {
|
|
52
|
+
var o, e;
|
|
53
|
+
return [
|
|
54
|
+
B.value,
|
|
55
|
+
t.showAutoRefresh,
|
|
56
|
+
t.showRefresh,
|
|
57
|
+
(o = t.leftExtraButtons) == null ? void 0 : o.length,
|
|
58
|
+
(e = t.rightExtraButtons) == null ? void 0 : e.length
|
|
59
|
+
].filter(Boolean).length;
|
|
60
|
+
}
|
|
61
|
+
), E = y(30);
|
|
33
62
|
N(
|
|
34
63
|
() => t.refreshInterval,
|
|
35
|
-
(
|
|
36
|
-
|
|
64
|
+
(o) => {
|
|
65
|
+
E.value = o;
|
|
37
66
|
},
|
|
38
67
|
{ immediate: !0 }
|
|
39
68
|
);
|
|
40
|
-
const
|
|
41
|
-
|
|
69
|
+
const x = y(!1), I = async (o) => {
|
|
70
|
+
const { selectedList: e, currentPageList: s, api: d, query: i } = t.exportContext, b = t.exportColumns;
|
|
71
|
+
let u;
|
|
72
|
+
switch (o) {
|
|
73
|
+
case "selected":
|
|
74
|
+
u = e;
|
|
75
|
+
break;
|
|
76
|
+
case "current":
|
|
77
|
+
u = s;
|
|
78
|
+
break;
|
|
79
|
+
case "all":
|
|
80
|
+
try {
|
|
81
|
+
const a = await W(d, i);
|
|
82
|
+
if (a > f) {
|
|
83
|
+
try {
|
|
84
|
+
await G.confirm(
|
|
85
|
+
`数据量超过 ${f} 条(共 ${a} 条),是否只导出前 ${f} 条?`,
|
|
86
|
+
"提示",
|
|
87
|
+
{
|
|
88
|
+
confirmButtonText: "导出",
|
|
89
|
+
cancelButtonText: "取消",
|
|
90
|
+
type: "warning"
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
} catch {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
u = await M(d, i, { limit: f });
|
|
97
|
+
} else
|
|
98
|
+
u = await M(d, i, { limit: f });
|
|
99
|
+
} catch (a) {
|
|
100
|
+
H.error(`导出失败:${(a == null ? void 0 : a.message) || (a == null ? void 0 : a.toString())}`);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
const m = `${document.title}-${Date.now()}`;
|
|
106
|
+
Y({ columns: b, list: u, filename: m });
|
|
107
|
+
}, T = (o) => {
|
|
108
|
+
var s;
|
|
109
|
+
if (x.value) return;
|
|
110
|
+
x.value = !0;
|
|
111
|
+
const e = t.exportByFe ? I(o) : (s = t.exportFn) == null ? void 0 : s.call(t, o);
|
|
112
|
+
Promise.resolve(e).catch(() => {
|
|
42
113
|
}).finally(() => {
|
|
43
|
-
|
|
44
|
-
})
|
|
114
|
+
x.value = !1;
|
|
115
|
+
});
|
|
45
116
|
};
|
|
46
|
-
return (
|
|
47
|
-
const
|
|
48
|
-
return
|
|
49
|
-
|
|
50
|
-
|
|
117
|
+
return (o, e) => {
|
|
118
|
+
const s = F, d = $, i = z, b = S, u = V;
|
|
119
|
+
return U((c(), X("div", Z, [
|
|
120
|
+
R("div", _, [
|
|
121
|
+
B.value ? (c(), p(u, {
|
|
51
122
|
key: 0,
|
|
52
|
-
disabled:
|
|
53
|
-
onCommand:
|
|
123
|
+
disabled: !l.exportContext.total,
|
|
124
|
+
onCommand: T
|
|
54
125
|
}, {
|
|
55
|
-
dropdown:
|
|
56
|
-
|
|
57
|
-
default:
|
|
58
|
-
l(
|
|
59
|
-
|
|
60
|
-
|
|
126
|
+
dropdown: n(() => [
|
|
127
|
+
r(b, null, {
|
|
128
|
+
default: n(() => [
|
|
129
|
+
l.exportContext.hasSelection ? (c(), p(i, {
|
|
130
|
+
key: 0,
|
|
131
|
+
command: "selected"
|
|
132
|
+
}, {
|
|
133
|
+
default: n(() => [...e[4] || (e[4] = [
|
|
134
|
+
h(" 导出选择 ", -1)
|
|
61
135
|
])]),
|
|
62
136
|
_: 1
|
|
63
|
-
}),
|
|
64
|
-
|
|
65
|
-
default:
|
|
66
|
-
|
|
137
|
+
})) : g("", !0),
|
|
138
|
+
r(i, { command: "current" }, {
|
|
139
|
+
default: n(() => [...e[5] || (e[5] = [
|
|
140
|
+
h("导出本页", -1)
|
|
67
141
|
])]),
|
|
68
142
|
_: 1
|
|
69
143
|
}),
|
|
70
|
-
|
|
71
|
-
default:
|
|
72
|
-
|
|
144
|
+
r(i, { command: "all" }, {
|
|
145
|
+
default: n(() => [...e[6] || (e[6] = [
|
|
146
|
+
h("导出全部", -1)
|
|
73
147
|
])]),
|
|
74
148
|
_: 1
|
|
75
149
|
})
|
|
@@ -77,17 +151,17 @@ const G = { class: "table-toolbar" }, H = { class: "table-toolbar-left" }, J = {
|
|
|
77
151
|
_: 1
|
|
78
152
|
})
|
|
79
153
|
]),
|
|
80
|
-
default:
|
|
81
|
-
|
|
154
|
+
default: n(() => [
|
|
155
|
+
r(d, {
|
|
82
156
|
size: "small",
|
|
83
157
|
type: "primary",
|
|
84
|
-
loading:
|
|
158
|
+
loading: x.value
|
|
85
159
|
}, {
|
|
86
|
-
default:
|
|
87
|
-
e[3] || (e[3] =
|
|
88
|
-
|
|
89
|
-
default:
|
|
90
|
-
|
|
160
|
+
default: n(() => [
|
|
161
|
+
e[3] || (e[3] = h(" 导出 ", -1)),
|
|
162
|
+
r(s, null, {
|
|
163
|
+
default: n(() => [
|
|
164
|
+
r(A(J))
|
|
91
165
|
]),
|
|
92
166
|
_: 1
|
|
93
167
|
})
|
|
@@ -96,41 +170,51 @@ const G = { class: "table-toolbar" }, H = { class: "table-toolbar-left" }, J = {
|
|
|
96
170
|
}, 8, ["loading"])
|
|
97
171
|
]),
|
|
98
172
|
_: 1
|
|
99
|
-
}, 8, ["disabled"])) :
|
|
173
|
+
}, 8, ["disabled"])) : g("", !0),
|
|
174
|
+
r(k, {
|
|
175
|
+
buttons: l.leftExtraButtons,
|
|
176
|
+
ctx: C.value
|
|
177
|
+
}, null, 8, ["buttons", "ctx"])
|
|
100
178
|
]),
|
|
101
|
-
|
|
102
|
-
|
|
179
|
+
R("div", ee, [
|
|
180
|
+
r(k, {
|
|
181
|
+
buttons: l.rightExtraButtons,
|
|
182
|
+
ctx: C.value
|
|
183
|
+
}, null, 8, ["buttons", "ctx"]),
|
|
184
|
+
l.showAutoRefresh ? (c(), p(Q, {
|
|
103
185
|
key: 0,
|
|
104
|
-
modelValue:
|
|
105
|
-
"onUpdate:modelValue": e[0] || (e[0] = (
|
|
106
|
-
interval:
|
|
107
|
-
"onUpdate:interval": e[1] || (e[1] = (
|
|
108
|
-
refreshFn:
|
|
109
|
-
enabled: !
|
|
110
|
-
}, null, 8, ["modelValue", "interval", "refreshFn", "enabled"])) :
|
|
111
|
-
|
|
186
|
+
modelValue: w.value,
|
|
187
|
+
"onUpdate:modelValue": e[0] || (e[0] = (m) => w.value = m),
|
|
188
|
+
interval: E.value,
|
|
189
|
+
"onUpdate:interval": e[1] || (e[1] = (m) => E.value = m),
|
|
190
|
+
refreshFn: l.tableExpose.refresh,
|
|
191
|
+
enabled: !l.loading
|
|
192
|
+
}, null, 8, ["modelValue", "interval", "refreshFn", "enabled"])) : g("", !0),
|
|
193
|
+
l.showRefresh ? (c(), p(d, {
|
|
112
194
|
key: 1,
|
|
113
195
|
size: "small",
|
|
114
196
|
circle: "",
|
|
115
|
-
onClick: e[2] || (e[2] = (
|
|
197
|
+
onClick: e[2] || (e[2] = (m) => l.tableExpose.refresh())
|
|
116
198
|
}, {
|
|
117
|
-
default:
|
|
118
|
-
|
|
119
|
-
class:
|
|
199
|
+
default: n(() => [
|
|
200
|
+
r(s, {
|
|
201
|
+
class: q({ "table-toolbar-icon--rotating": l.loading })
|
|
120
202
|
}, {
|
|
121
|
-
default:
|
|
122
|
-
|
|
203
|
+
default: n(() => [
|
|
204
|
+
r(A(K))
|
|
123
205
|
]),
|
|
124
206
|
_: 1
|
|
125
207
|
}, 8, ["class"])
|
|
126
208
|
]),
|
|
127
209
|
_: 1
|
|
128
|
-
})) :
|
|
210
|
+
})) : g("", !0)
|
|
129
211
|
])
|
|
212
|
+
], 512)), [
|
|
213
|
+
[O, D.value]
|
|
130
214
|
]);
|
|
131
215
|
};
|
|
132
216
|
}
|
|
133
217
|
});
|
|
134
218
|
export {
|
|
135
|
-
|
|
219
|
+
pe as default
|
|
136
220
|
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ElButton as p } from "element-plus/es";
|
|
2
|
+
import "element-plus/es/components/base/style/css";
|
|
3
|
+
import "element-plus/es/components/button/style/css";
|
|
4
|
+
import { defineComponent as y, openBlock as t, createElementBlock as r, Fragment as n, renderList as d, createBlock as c, resolveDynamicComponent as u, unref as x, mergeProps as l, withCtx as m, createTextVNode as i, toDisplayString as f } from "vue";
|
|
5
|
+
import B from "../misc/ActionButton.vue.mjs";
|
|
6
|
+
const A = /* @__PURE__ */ y({
|
|
7
|
+
__name: "ToolbarButtons",
|
|
8
|
+
props: {
|
|
9
|
+
buttons: {},
|
|
10
|
+
ctx: {}
|
|
11
|
+
},
|
|
12
|
+
setup(o) {
|
|
13
|
+
const s = B;
|
|
14
|
+
return (_, R) => {
|
|
15
|
+
const k = p;
|
|
16
|
+
return t(!0), r(n, null, d(o.buttons, (e) => {
|
|
17
|
+
var a;
|
|
18
|
+
return t(), r(n, {
|
|
19
|
+
key: e.key
|
|
20
|
+
}, [
|
|
21
|
+
e.actionButtonProps ? (t(), c(u(x(s)), l({
|
|
22
|
+
key: 0,
|
|
23
|
+
ref_for: !0
|
|
24
|
+
}, e.actionButtonProps(o.ctx)), {
|
|
25
|
+
default: m(() => [
|
|
26
|
+
e.btnRender ? (t(), c(u(() => e.btnRender(o.ctx)), { key: 0 })) : (t(), r(n, { key: 1 }, [
|
|
27
|
+
i(f(e.label), 1)
|
|
28
|
+
], 64))
|
|
29
|
+
]),
|
|
30
|
+
_: 2
|
|
31
|
+
}, 1040)) : (t(), c(k, l({
|
|
32
|
+
key: 1,
|
|
33
|
+
ref_for: !0
|
|
34
|
+
}, (a = e.props) == null ? void 0 : a.call(e, o.ctx)), {
|
|
35
|
+
default: m(() => [
|
|
36
|
+
e.btnRender ? (t(), c(u(() => e.btnRender(o.ctx)), { key: 0 })) : (t(), r(n, { key: 1 }, [
|
|
37
|
+
i(f(e.label), 1)
|
|
38
|
+
], 64))
|
|
39
|
+
]),
|
|
40
|
+
_: 2
|
|
41
|
+
}, 1040))
|
|
42
|
+
], 64);
|
|
43
|
+
}), 128);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
export {
|
|
48
|
+
A as default
|
|
49
|
+
};
|
|
@@ -1,61 +1,57 @@
|
|
|
1
|
-
async function A(
|
|
2
|
-
var
|
|
3
|
-
const i = (e == null ? void 0 : e.pageSize) ?? 200,
|
|
1
|
+
async function A(r, n, e) {
|
|
2
|
+
var o;
|
|
3
|
+
const i = (e == null ? void 0 : e.pageSize) ?? 200, a = (e == null ? void 0 : e.limit) ?? 1e4;
|
|
4
4
|
if (i < 1 || i > 1e3)
|
|
5
5
|
throw new Error(
|
|
6
6
|
`fetchListAll: pageSize 必须在 [1, 1000] 范围内(实际 ${i})`
|
|
7
7
|
);
|
|
8
8
|
const t = [];
|
|
9
|
-
let
|
|
9
|
+
let c = 1;
|
|
10
10
|
for (; ; ) {
|
|
11
|
-
const
|
|
12
|
-
...
|
|
13
|
-
page: { page:
|
|
14
|
-
}, l = await
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
`fetchListAll 超出上限 ${r}(实际 totalRecord=${g}),请手动分页或质疑工具适用性`
|
|
18
|
-
);
|
|
19
|
-
if (t.push(...p), p.length < i || t.length >= g) break;
|
|
20
|
-
n += 1;
|
|
11
|
+
const s = {
|
|
12
|
+
...n,
|
|
13
|
+
page: { page: c, pageSize: i }
|
|
14
|
+
}, l = await r(s), g = l.items, p = ((o = l.page) == null ? void 0 : o.totalRecord) ?? 0;
|
|
15
|
+
if (t.push(...g), t.length >= a || g.length < i || t.length >= p) break;
|
|
16
|
+
c += 1;
|
|
21
17
|
}
|
|
22
|
-
return t;
|
|
18
|
+
return t.slice(0, a);
|
|
23
19
|
}
|
|
24
|
-
function f(
|
|
25
|
-
return async (
|
|
26
|
-
const e =
|
|
20
|
+
function f(r) {
|
|
21
|
+
return async (n) => {
|
|
22
|
+
const e = n.page;
|
|
27
23
|
if (!e)
|
|
28
24
|
throw new Error("createListApi: params.page 必填(含 page / pageSize)");
|
|
29
|
-
const { page: i, pageSize:
|
|
30
|
-
if (!
|
|
25
|
+
const { page: i, pageSize: a } = e;
|
|
26
|
+
if (!a || a <= 0)
|
|
31
27
|
throw new Error("createListApi: pageSize 必须 > 0");
|
|
32
28
|
let t;
|
|
33
|
-
if (Array.isArray(
|
|
34
|
-
t =
|
|
29
|
+
if (Array.isArray(r))
|
|
30
|
+
t = r;
|
|
35
31
|
else {
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
const l = await
|
|
32
|
+
const s = r();
|
|
33
|
+
if (s instanceof Promise) {
|
|
34
|
+
const l = await s;
|
|
39
35
|
if (!Array.isArray(l))
|
|
40
36
|
throw new Error("createListApi: 异步 source 返回值必须为数组");
|
|
41
37
|
t = l;
|
|
42
38
|
} else
|
|
43
|
-
t =
|
|
39
|
+
t = s;
|
|
44
40
|
}
|
|
45
|
-
const
|
|
41
|
+
const c = (i - 1) * a, o = c + a;
|
|
46
42
|
return {
|
|
47
|
-
items: t.slice(
|
|
43
|
+
items: t.slice(c, o),
|
|
48
44
|
page: {
|
|
49
45
|
totalRecord: t.length,
|
|
50
|
-
pageSize:
|
|
51
|
-
totalPage: Math.ceil(t.length /
|
|
46
|
+
pageSize: a,
|
|
47
|
+
totalPage: Math.ceil(t.length / a)
|
|
52
48
|
}
|
|
53
49
|
};
|
|
54
50
|
};
|
|
55
51
|
}
|
|
56
|
-
function h(
|
|
57
|
-
return
|
|
58
|
-
...
|
|
52
|
+
function h(r, n) {
|
|
53
|
+
return r({
|
|
54
|
+
...n,
|
|
59
55
|
page: { page: 1, pageSize: 1 }
|
|
60
56
|
}).then((e) => e.page.totalRecord);
|
|
61
57
|
}
|