@done-coding/admin-core 0.0.1-alpha.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/form/FormMain.vue.mjs +65 -61
- package/es/components/form/FormSearch.vue2.mjs +24 -23
- package/es/components/list-page/ListPage.vue.mjs +1 -1
- package/es/components/list-page/ListPage.vue2.mjs +105 -93
- package/es/components/modal/DetailModal.vue.mjs +31 -29
- package/es/components/table/TableMain.vue.mjs +2 -2
- package/es/components/table/TableMain.vue2.mjs +154 -117
- package/es/components/table/TableToolbar.vue.mjs +7 -0
- package/es/components/table/TableToolbar.vue2.mjs +95 -0
- package/es/helpers/list-helper.mjs +66 -0
- package/es/hooks/timeout.mjs +21 -0
- package/es/index.mjs +43 -37
- package/es/style.css +1 -1
- package/package.json +3 -3
- package/types/components/form/FormMain.vue.d.ts +3 -0
- package/types/components/form/types.d.ts +1 -0
- package/types/components/list-page/ListPage.vue.d.ts +18 -2
- package/types/components/modal/types.d.ts +2 -0
- package/types/components/table/TableMain.vue.d.ts +13 -1
- package/types/components/table/TableToolbar.vue.d.ts +43 -0
- package/types/components/table/types.d.ts +18 -0
- package/types/helpers/index.d.ts +2 -0
- package/types/helpers/list-helper.d.ts +36 -0
- package/types/helpers/types.d.ts +15 -0
- package/types/hooks/index.d.ts +1 -0
- package/types/hooks/timeout.d.ts +7 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { defineComponent as g, ref as A, computed as
|
|
4
|
-
import { stringifyFormData as
|
|
5
|
-
const
|
|
1
|
+
import y from "./ConfirmModal.vue.mjs";
|
|
2
|
+
import p from "../form/FormMain.vue.mjs";
|
|
3
|
+
import { defineComponent as g, ref as A, computed as l, watch as C, openBlock as M, createBlock as x, unref as s, withCtx as D, createVNode as b, mergeProps as k } from "vue";
|
|
4
|
+
import { stringifyFormData as v } from "../form/utils.mjs";
|
|
5
|
+
const B = "80px", $ = /* @__PURE__ */ g({
|
|
6
6
|
__name: "DetailModal",
|
|
7
7
|
props: {
|
|
8
8
|
data: {},
|
|
@@ -14,48 +14,50 @@ const v = "80px", W = /* @__PURE__ */ g({
|
|
|
14
14
|
editApi: {},
|
|
15
15
|
modalWidth: { default: 600 },
|
|
16
16
|
formLayout: { default: () => ({ span: 24 }) },
|
|
17
|
-
formProps: {}
|
|
17
|
+
formProps: {},
|
|
18
|
+
formRowGutter: {}
|
|
18
19
|
},
|
|
19
20
|
emits: ["update:show", "afterAdd", "afterEdit"],
|
|
20
|
-
setup(e, { emit:
|
|
21
|
-
const t = e,
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
var
|
|
25
|
-
return (
|
|
21
|
+
setup(e, { emit: f }) {
|
|
22
|
+
const t = e, r = f, d = A(), m = l(() => t.data), c = l(() => `${t.type === "add" ? "新增" : "编辑"}${t.subTitle || ""}`), u = (a) => {
|
|
23
|
+
r("update:show", a);
|
|
24
|
+
}, w = () => {
|
|
25
|
+
var a;
|
|
26
|
+
return (a = d.value) == null ? void 0 : a.validate().then(async () => {
|
|
26
27
|
var i, n;
|
|
27
|
-
const
|
|
28
|
-
console.log("confirm",
|
|
28
|
+
const o = v(t.data, t.list);
|
|
29
|
+
console.log("confirm", o), t.type === "add" ? (await ((i = t.addApi) == null ? void 0 : i.call(t, o)), r("afterAdd", o)) : (await ((n = t.editApi) == null ? void 0 : n.call(t, o)), r("afterEdit", o));
|
|
29
30
|
});
|
|
30
|
-
},
|
|
31
|
+
}, h = () => {
|
|
31
32
|
console.log("cancel");
|
|
32
33
|
};
|
|
33
34
|
return C(
|
|
34
35
|
() => t.show,
|
|
35
|
-
(
|
|
36
|
-
var
|
|
37
|
-
|
|
36
|
+
(a) => {
|
|
37
|
+
var o;
|
|
38
|
+
a || (o = d.value) == null || o.clearValidate();
|
|
38
39
|
}
|
|
39
|
-
), (
|
|
40
|
-
const i =
|
|
40
|
+
), (a, o) => {
|
|
41
|
+
const i = p, n = y;
|
|
41
42
|
return M(), x(n, {
|
|
42
|
-
title: s(
|
|
43
|
+
title: s(c),
|
|
43
44
|
show: e.show,
|
|
44
|
-
onConfirm:
|
|
45
|
-
onCancel:
|
|
45
|
+
onConfirm: w,
|
|
46
|
+
onCancel: h,
|
|
46
47
|
useLoading: "",
|
|
47
48
|
width: e.modalWidth,
|
|
48
49
|
"onUpdate:show": u
|
|
49
50
|
}, {
|
|
50
51
|
default: D(() => [
|
|
51
|
-
|
|
52
|
+
b(i, k({
|
|
52
53
|
ref_key: "formMain",
|
|
53
|
-
ref:
|
|
54
|
+
ref: d,
|
|
54
55
|
list: e.list,
|
|
55
|
-
data: s(
|
|
56
|
+
data: s(m),
|
|
56
57
|
layout: e.formLayout,
|
|
57
|
-
labelWidth:
|
|
58
|
-
|
|
58
|
+
labelWidth: B,
|
|
59
|
+
"row-gutter": e.formRowGutter
|
|
60
|
+
}, e.formProps), null, 16, ["list", "data", "layout", "row-gutter"])
|
|
59
61
|
]),
|
|
60
62
|
_: 1
|
|
61
63
|
}, 8, ["title", "show", "width"]);
|
|
@@ -63,5 +65,5 @@ const v = "80px", W = /* @__PURE__ */ g({
|
|
|
63
65
|
}
|
|
64
66
|
});
|
|
65
67
|
export {
|
|
66
|
-
|
|
68
|
+
$ as default
|
|
67
69
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import o from "./TableMain.vue2.mjs";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import t from "../../_virtual/_plugin-vue_export-helper.mjs";
|
|
4
|
-
const
|
|
4
|
+
const p = /* @__PURE__ */ t(o, [["__scopeId", "data-v-08dc9d04"]]);
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
p as default
|
|
7
7
|
};
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
import { ElTable as
|
|
1
|
+
import { ElTable as ue, ElTableColumn as fe, ElEmpty as ge, ElPagination as pe } from "element-plus/es";
|
|
2
2
|
import "element-plus/es/components/base/style/css";
|
|
3
3
|
import "element-plus/es/components/pagination/style/css";
|
|
4
4
|
import "element-plus/es/components/table/style/css";
|
|
5
5
|
import "element-plus/es/components/empty/style/css";
|
|
6
6
|
import "element-plus/es/components/table-column/style/css";
|
|
7
|
-
import { defineComponent as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
|
|
7
|
+
import { defineComponent as de, useCssVars as ce, useModel as me, useAttrs as he, ref as g, shallowRef as ve, inject as ye, computed as d, onMounted as be, onActivated as Ce, watch as c, openBlock as n, createElementBlock as y, unref as l, createBlock as b, withCtx as C, createVNode as I, mergeProps as p, createCommentVNode as Se, Fragment as _, renderList as _e, createSlots as Ee, renderSlot as J, resolveDynamicComponent as V, createTextVNode as R, toDisplayString as $, withDirectives as Te, createElementVNode as we, isRef as Y, vShow as xe, mergeModels as G } from "vue";
|
|
8
|
+
import U from "lodash/cloneDeep";
|
|
9
|
+
import q from "lodash/omit";
|
|
10
|
+
import D from "lodash/set";
|
|
11
|
+
import F from "lodash/get";
|
|
12
|
+
import Ie from "./TableToolbar.vue.mjs";
|
|
13
|
+
import Re from "../display/WatchSize.vue.mjs";
|
|
14
|
+
import { BODY_CONTENT_VIEWPORT_HEIGHT as Pe } from "../../inject/key.mjs";
|
|
15
|
+
import { APP_API_LIST_MODEL_KEY_CONFIG as E } from "../../config/list-model.mjs";
|
|
16
|
+
const Oe = { class: "table-main" }, ze = { class: "table-main-pagination" }, qe = /* @__PURE__ */ de({
|
|
15
17
|
__name: "TableMain",
|
|
16
|
-
props: {
|
|
18
|
+
props: /* @__PURE__ */ G({
|
|
17
19
|
showPager: { type: Boolean, default: !0 },
|
|
20
|
+
showToolbar: { type: Boolean, default: !0 },
|
|
21
|
+
toolbar: {},
|
|
18
22
|
query: {},
|
|
19
23
|
pageSizeInit: { default: 20 },
|
|
20
24
|
pageSizeOptions: { default: () => [10, 20, 30, 40] },
|
|
@@ -28,148 +32,181 @@ const Se = { class: "table-main" }, Ee = { class: "table-main-pagination" }, Ke
|
|
|
28
32
|
refine: { type: Boolean, default: !0 },
|
|
29
33
|
refineReduceHeight: { default: 0 },
|
|
30
34
|
injectInfo: {}
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
}, {
|
|
36
|
+
isAutoRefresh: { type: Boolean },
|
|
37
|
+
isAutoRefreshModifiers: {}
|
|
38
|
+
}),
|
|
39
|
+
emits: /* @__PURE__ */ G(["pageChange", "pageSizeChange", "dataChange", "loadingChange", "pageInfoChange"], ["update:isAutoRefresh"]),
|
|
40
|
+
setup(s, { expose: W, emit: Z }) {
|
|
41
|
+
ce((e) => ({
|
|
42
|
+
v1961e86c: e.headerColor
|
|
36
43
|
}));
|
|
37
|
-
const
|
|
38
|
-
|
|
44
|
+
const a = s, m = Z, P = me(s, "isAutoRefresh"), Q = he(), T = g([]), w = g(0), i = g(0), o = g(1), h = g(!1), x = g(!1), O = g(0), X = (e) => {
|
|
45
|
+
O.value = e;
|
|
46
|
+
}, z = ve(), ee = ye(
|
|
47
|
+
Pe,
|
|
39
48
|
500
|
|
40
|
-
),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
), H = d(() => a.showPager ? 35 : 0), N = d(() => {
|
|
50
|
+
var t;
|
|
51
|
+
if (a.showToolbar === !1) return !1;
|
|
52
|
+
const e = (t = a.toolbar) == null ? void 0 : t.features;
|
|
53
|
+
return e === void 0 || e.length > 0;
|
|
54
|
+
}), k = d(
|
|
55
|
+
() => N.value ? O.value : 0
|
|
56
|
+
), te = d(() => {
|
|
57
|
+
const { maxHeight: e, refine: t } = a;
|
|
58
|
+
return e ? Math.max(
|
|
59
|
+
e - H.value - k.value,
|
|
60
|
+
200
|
|
61
|
+
) : t ? Math.max(
|
|
62
|
+
ee.value - H.value - k.value - a.refineReduceHeight,
|
|
44
63
|
200
|
|
45
64
|
) : void 0;
|
|
46
|
-
}),
|
|
47
|
-
const e =
|
|
48
|
-
return
|
|
65
|
+
}), S = d(() => {
|
|
66
|
+
const e = U(a.query || {});
|
|
67
|
+
return D(e, E.PAGE_SIZE_KEY, i.value), D(
|
|
49
68
|
e,
|
|
50
|
-
|
|
51
|
-
|
|
69
|
+
E.CURRENT_PAGE_KEY,
|
|
70
|
+
o.value
|
|
52
71
|
), e;
|
|
53
|
-
}),
|
|
54
|
-
...
|
|
55
|
-
...
|
|
56
|
-
})),
|
|
57
|
-
const
|
|
58
|
-
return !
|
|
72
|
+
}), re = d(() => ({
|
|
73
|
+
...a.tableProps,
|
|
74
|
+
...Q
|
|
75
|
+
})), A = (e, t = !0) => {
|
|
76
|
+
const u = JSON.stringify(e) === JSON.stringify(S.value);
|
|
77
|
+
return !u && t && console.warn(
|
|
59
78
|
`同一地方 并发请求 参数冰花 当前不是最新的参数 丢弃结果 ${JSON.stringify(
|
|
60
79
|
e
|
|
61
|
-
)} => ${JSON.stringify(
|
|
62
|
-
),
|
|
63
|
-
},
|
|
80
|
+
)} => ${JSON.stringify(S.value)}`
|
|
81
|
+
), u;
|
|
82
|
+
}, K = (e = !1) => {
|
|
64
83
|
if (!i.value) return;
|
|
65
84
|
h.value ? console.warn("请求并发") : h.value = !0, e || (x.value = !0);
|
|
66
|
-
const t =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
),
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
)
|
|
85
|
+
const t = U(S.value);
|
|
86
|
+
a.api(t).then((u) => {
|
|
87
|
+
A(t, !1) && (T.value = F(
|
|
88
|
+
u,
|
|
89
|
+
E.LIST_KEY
|
|
90
|
+
), w.value = F(
|
|
91
|
+
u,
|
|
92
|
+
E.TOTAL_KEY
|
|
93
|
+
), m("pageInfoChange", {
|
|
94
|
+
pageSize: i.value,
|
|
95
|
+
currentPage: o.value,
|
|
96
|
+
total: w.value
|
|
97
|
+
}));
|
|
75
98
|
}).finally(() => {
|
|
76
|
-
|
|
99
|
+
A(t) && (h.value = !1, x.value = !1);
|
|
77
100
|
});
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
},
|
|
83
|
-
refresh:
|
|
84
|
-
reload:
|
|
85
|
-
getTableInstance: () =>
|
|
86
|
-
},
|
|
87
|
-
...
|
|
88
|
-
injectInfo:
|
|
101
|
+
}, j = (e = !1) => {
|
|
102
|
+
K(e);
|
|
103
|
+
}, ae = (e = !1) => {
|
|
104
|
+
o.value === 1 ? j(e) : o.value = 1;
|
|
105
|
+
}, oe = (e) => e, v = {
|
|
106
|
+
refresh: j,
|
|
107
|
+
reload: ae,
|
|
108
|
+
getTableInstance: () => z.value
|
|
109
|
+
}, B = (e, t = []) => ({
|
|
110
|
+
...q(e, ["render", "headerRender"].concat(t)),
|
|
111
|
+
injectInfo: a.injectInfo || {},
|
|
89
112
|
exposeInfo: v
|
|
90
|
-
}),
|
|
91
|
-
...
|
|
92
|
-
injectInfo:
|
|
113
|
+
}), L = (e) => ({
|
|
114
|
+
...q(e, ["render", "headerRender"]),
|
|
115
|
+
injectInfo: a.injectInfo || {},
|
|
93
116
|
exposeInfo: v
|
|
94
117
|
});
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
i.value = e,
|
|
98
|
-
},
|
|
99
|
-
return
|
|
100
|
-
i.value =
|
|
118
|
+
W(v);
|
|
119
|
+
const ne = (e) => {
|
|
120
|
+
i.value = e, o.value = 1;
|
|
121
|
+
}, M = (e) => !e || e === "expand";
|
|
122
|
+
return be(() => {
|
|
123
|
+
i.value = a.pageSizeInit, Ce(() => {
|
|
101
124
|
v.refresh();
|
|
102
125
|
});
|
|
103
|
-
}),
|
|
126
|
+
}), c(T, (e) => {
|
|
104
127
|
m("dataChange", e);
|
|
105
|
-
}),
|
|
106
|
-
() =>
|
|
128
|
+
}), c(
|
|
129
|
+
() => a.query,
|
|
107
130
|
(e, t) => {
|
|
108
|
-
JSON.stringify(e) !== JSON.stringify(t) && (
|
|
131
|
+
JSON.stringify(e) !== JSON.stringify(t) && (o.value = 1);
|
|
109
132
|
}
|
|
110
|
-
),
|
|
111
|
-
|
|
133
|
+
), c(
|
|
134
|
+
S,
|
|
112
135
|
(e, t) => {
|
|
113
|
-
JSON.stringify(e) !== JSON.stringify(t) &&
|
|
136
|
+
JSON.stringify(e) !== JSON.stringify(t) && K();
|
|
114
137
|
},
|
|
115
138
|
{
|
|
116
139
|
immediate: !0
|
|
117
140
|
}
|
|
118
|
-
),
|
|
141
|
+
), c(x, (e) => {
|
|
119
142
|
m("loadingChange", e);
|
|
120
|
-
}),
|
|
143
|
+
}), c(i, (e) => {
|
|
121
144
|
m("pageSizeChange", e);
|
|
122
|
-
}),
|
|
145
|
+
}), c(o, (e) => {
|
|
123
146
|
m("pageChange", e);
|
|
124
147
|
}), (e, t) => {
|
|
125
|
-
const
|
|
126
|
-
return
|
|
127
|
-
|
|
148
|
+
const u = fe, le = ge, ie = ue, se = pe;
|
|
149
|
+
return n(), y("div", Oe, [
|
|
150
|
+
l(N) ? (n(), b(l(Re), {
|
|
151
|
+
key: 0,
|
|
152
|
+
onHeightChange: X
|
|
153
|
+
}, {
|
|
154
|
+
default: C(() => [
|
|
155
|
+
I(Ie, p({
|
|
156
|
+
"is-auto-refresh": P.value,
|
|
157
|
+
"onUpdate:isAutoRefresh": t[0] || (t[0] = (r) => P.value = r),
|
|
158
|
+
tableExpose: v,
|
|
159
|
+
loading: l(h)
|
|
160
|
+
}, a.toolbar), null, 16, ["is-auto-refresh", "loading"])
|
|
161
|
+
]),
|
|
162
|
+
_: 1
|
|
163
|
+
})) : Se("", !0),
|
|
164
|
+
I(ie, p({
|
|
128
165
|
ref_key: "elTable",
|
|
129
|
-
ref:
|
|
166
|
+
ref: z,
|
|
130
167
|
class: "table-main-table",
|
|
131
168
|
stripe: "",
|
|
132
169
|
border: "",
|
|
133
170
|
highlightCurrentRow: ""
|
|
134
|
-
},
|
|
135
|
-
maxHeight:
|
|
136
|
-
data:
|
|
137
|
-
rowKey:
|
|
171
|
+
}, l(re), {
|
|
172
|
+
maxHeight: l(te),
|
|
173
|
+
data: l(T),
|
|
174
|
+
rowKey: oe(s.rowKey)
|
|
138
175
|
}), {
|
|
139
|
-
empty:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
], 64)) : (
|
|
176
|
+
empty: C(() => [
|
|
177
|
+
l(h) ? (n(), y(_, { key: 0 }, [
|
|
178
|
+
R("加载中...")
|
|
179
|
+
], 64)) : (n(), b(le, { key: 1 }))
|
|
143
180
|
]),
|
|
144
|
-
default:
|
|
145
|
-
(
|
|
181
|
+
default: C(() => [
|
|
182
|
+
(n(!0), y(_, null, _e(s.columns, (r) => (n(), b(u, p({
|
|
146
183
|
key: r.columnKey || r.prop
|
|
147
|
-
}, { ref_for: !0 }, r),
|
|
148
|
-
|
|
184
|
+
}, { ref_for: !0 }, r), Ee({ _: 2 }, [
|
|
185
|
+
M(r.type) ? {
|
|
149
186
|
name: "default",
|
|
150
|
-
fn:
|
|
151
|
-
|
|
152
|
-
r.render ? (
|
|
187
|
+
fn: C((f) => [
|
|
188
|
+
J(e.$slots, r.prop, p({ ref_for: !0 }, B(f)), () => [
|
|
189
|
+
r.render ? (n(), b(V(r.render), p({
|
|
153
190
|
key: 0,
|
|
154
191
|
ref_for: !0
|
|
155
|
-
},
|
|
156
|
-
_index:
|
|
157
|
-
}), null, 16, ["_index"])) : (
|
|
158
|
-
|
|
192
|
+
}, B(f, ["$index"]), {
|
|
193
|
+
_index: f.$index
|
|
194
|
+
}), null, 16, ["_index"])) : (n(), y(_, { key: 1 }, [
|
|
195
|
+
R($(f.row[r.prop]), 1)
|
|
159
196
|
], 64))
|
|
160
197
|
], !0)
|
|
161
198
|
]),
|
|
162
199
|
key: "0"
|
|
163
200
|
} : void 0,
|
|
164
|
-
|
|
201
|
+
M(r.type) ? {
|
|
165
202
|
name: "header",
|
|
166
|
-
fn:
|
|
167
|
-
|
|
168
|
-
r.headerRender ? (
|
|
203
|
+
fn: C((f) => [
|
|
204
|
+
J(e.$slots, `header-${r.prop}`, p({ ref_for: !0 }, L(f)), () => [
|
|
205
|
+
r.headerRender ? (n(), b(V(r.headerRender), p({
|
|
169
206
|
key: 0,
|
|
170
207
|
ref_for: !0
|
|
171
|
-
},
|
|
172
|
-
|
|
208
|
+
}, L(f)), null, 16)) : (n(), y(_, { key: 1 }, [
|
|
209
|
+
R($(r.label), 1)
|
|
173
210
|
], 64))
|
|
174
211
|
], !0)
|
|
175
212
|
]),
|
|
@@ -179,26 +216,26 @@ const Se = { class: "table-main" }, Ee = { class: "table-main-pagination" }, Ke
|
|
|
179
216
|
]),
|
|
180
217
|
_: 3
|
|
181
218
|
}, 16, ["maxHeight", "data", "rowKey"]),
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
"current-page":
|
|
185
|
-
"onUpdate:currentPage": t[
|
|
186
|
-
"page-size":
|
|
187
|
-
"onUpdate:pageSize": t[
|
|
188
|
-
"page-sizes":
|
|
189
|
-
|
|
219
|
+
Te(we("div", ze, [
|
|
220
|
+
I(se, {
|
|
221
|
+
"current-page": l(o),
|
|
222
|
+
"onUpdate:currentPage": t[1] || (t[1] = (r) => Y(o) ? o.value = r : null),
|
|
223
|
+
"page-size": l(i),
|
|
224
|
+
"onUpdate:pageSize": t[2] || (t[2] = (r) => Y(i) ? i.value = r : null),
|
|
225
|
+
"page-sizes": s.pageSizeOptions,
|
|
226
|
+
size: "small",
|
|
190
227
|
background: "",
|
|
191
|
-
layout:
|
|
192
|
-
total:
|
|
193
|
-
onSizeChange:
|
|
228
|
+
layout: s.pageLayout,
|
|
229
|
+
total: l(w),
|
|
230
|
+
onSizeChange: ne
|
|
194
231
|
}, null, 8, ["current-page", "page-size", "page-sizes", "layout", "total"])
|
|
195
232
|
], 512), [
|
|
196
|
-
[
|
|
233
|
+
[xe, s.showPager]
|
|
197
234
|
])
|
|
198
235
|
]);
|
|
199
236
|
};
|
|
200
237
|
}
|
|
201
238
|
});
|
|
202
239
|
export {
|
|
203
|
-
|
|
240
|
+
qe as default
|
|
204
241
|
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ElInputNumber as g, ElSwitch as w, ElButton as y, ElIcon as C } from "element-plus/es";
|
|
2
|
+
import "element-plus/es/components/base/style/css";
|
|
3
|
+
import "element-plus/es/components/button/style/css";
|
|
4
|
+
import "element-plus/es/components/icon/style/css";
|
|
5
|
+
import "element-plus/es/components/switch/style/css";
|
|
6
|
+
import "element-plus/es/components/input-number/style/css";
|
|
7
|
+
import { defineComponent as M, useModel as N, computed as p, ref as T, watch as i, openBlock as a, createElementBlock as h, createElementVNode as m, Fragment as z, createVNode as f, isRef as S, unref as v, createCommentVNode as c, createBlock as b, withCtx as E, normalizeClass as U, mergeModels as F } from "vue";
|
|
8
|
+
import { Refresh as j } from "@element-plus/icons-vue";
|
|
9
|
+
import { useTimeout as q } from "../../hooks/timeout.mjs";
|
|
10
|
+
import { useActivatedExec as D } from "../../hooks/activated.mjs";
|
|
11
|
+
const G = { class: "table-toolbar" }, H = { class: "table-toolbar-right" }, $ = /* @__PURE__ */ M({
|
|
12
|
+
__name: "TableToolbar",
|
|
13
|
+
props: /* @__PURE__ */ F({
|
|
14
|
+
features: { default: () => ["refresh", "autoRefresh"] },
|
|
15
|
+
refreshInterval: { default: 30 },
|
|
16
|
+
tableExpose: {},
|
|
17
|
+
loading: { type: Boolean }
|
|
18
|
+
}, {
|
|
19
|
+
isAutoRefresh: { type: Boolean },
|
|
20
|
+
isAutoRefreshModifiers: {}
|
|
21
|
+
}),
|
|
22
|
+
emits: ["update:isAutoRefresh"],
|
|
23
|
+
setup(n) {
|
|
24
|
+
const e = n, t = N(n, "isAutoRefresh"), R = p(
|
|
25
|
+
() => e.features === void 0 || e.features.includes("refresh")
|
|
26
|
+
), d = p(
|
|
27
|
+
() => e.features === void 0 || e.features.includes("autoRefresh")
|
|
28
|
+
), l = T(30);
|
|
29
|
+
i(
|
|
30
|
+
() => e.refreshInterval,
|
|
31
|
+
(r) => {
|
|
32
|
+
l.value = r;
|
|
33
|
+
},
|
|
34
|
+
{ immediate: !0 }
|
|
35
|
+
);
|
|
36
|
+
const [x, V] = q(), s = () => {
|
|
37
|
+
x(() => {
|
|
38
|
+
e.tableExpose.refresh(), t.value && s();
|
|
39
|
+
}, l.value * 1e3);
|
|
40
|
+
}, _ = () => {
|
|
41
|
+
e.tableExpose.refresh(), t.value && s();
|
|
42
|
+
};
|
|
43
|
+
return i(t, (r) => {
|
|
44
|
+
r ? s() : V();
|
|
45
|
+
}), i(l, () => {
|
|
46
|
+
t.value && s();
|
|
47
|
+
}), D(() => {
|
|
48
|
+
t.value && (e.tableExpose.refresh(), s());
|
|
49
|
+
}), (r, o) => {
|
|
50
|
+
const k = g, A = w, B = C, I = y;
|
|
51
|
+
return a(), h("div", G, [
|
|
52
|
+
m("div", H, [
|
|
53
|
+
d.value && t.value ? (a(), h(z, { key: 0 }, [
|
|
54
|
+
o[2] || (o[2] = m("span", { class: "table-toolbar-label" }, "刷新间隔", -1)),
|
|
55
|
+
f(k, {
|
|
56
|
+
modelValue: v(l),
|
|
57
|
+
"onUpdate:modelValue": o[0] || (o[0] = (u) => S(l) ? l.value = u : null),
|
|
58
|
+
min: 1,
|
|
59
|
+
step: 5,
|
|
60
|
+
size: "small",
|
|
61
|
+
class: "table-toolbar-interval"
|
|
62
|
+
}, null, 8, ["modelValue"]),
|
|
63
|
+
o[3] || (o[3] = m("span", { class: "table-toolbar-label" }, "秒", -1))
|
|
64
|
+
], 64)) : c("", !0),
|
|
65
|
+
d.value ? (a(), b(A, {
|
|
66
|
+
key: 1,
|
|
67
|
+
modelValue: t.value,
|
|
68
|
+
"onUpdate:modelValue": o[1] || (o[1] = (u) => t.value = u),
|
|
69
|
+
"active-text": "自动刷新"
|
|
70
|
+
}, null, 8, ["modelValue"])) : c("", !0),
|
|
71
|
+
R.value ? (a(), b(I, {
|
|
72
|
+
key: 2,
|
|
73
|
+
circle: "",
|
|
74
|
+
onClick: _
|
|
75
|
+
}, {
|
|
76
|
+
default: E(() => [
|
|
77
|
+
f(B, {
|
|
78
|
+
class: U({ "table-toolbar-icon--rotating": n.loading })
|
|
79
|
+
}, {
|
|
80
|
+
default: E(() => [
|
|
81
|
+
f(v(j))
|
|
82
|
+
]),
|
|
83
|
+
_: 1
|
|
84
|
+
}, 8, ["class"])
|
|
85
|
+
]),
|
|
86
|
+
_: 1
|
|
87
|
+
})) : c("", !0)
|
|
88
|
+
])
|
|
89
|
+
]);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
export {
|
|
94
|
+
$ as default
|
|
95
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
async function A(a, c, e) {
|
|
2
|
+
var s;
|
|
3
|
+
const i = (e == null ? void 0 : e.pageSize) ?? 200, r = (e == null ? void 0 : e.limit) ?? 1e4;
|
|
4
|
+
if (i < 1 || i > 1e3)
|
|
5
|
+
throw new Error(
|
|
6
|
+
`fetchListAll: pageSize 必须在 [1, 1000] 范围内(实际 ${i})`
|
|
7
|
+
);
|
|
8
|
+
const t = [];
|
|
9
|
+
let n = 1;
|
|
10
|
+
for (; ; ) {
|
|
11
|
+
const o = {
|
|
12
|
+
...c,
|
|
13
|
+
page: { page: n, pageSize: i }
|
|
14
|
+
}, l = await a(o), p = l.items, g = ((s = l.page) == null ? void 0 : s.totalRecord) ?? 0;
|
|
15
|
+
if (n === 1 && g > r)
|
|
16
|
+
throw new Error(
|
|
17
|
+
`fetchListAll 超出上限 ${r}(实际 totalRecord=${g}),请手动分页或质疑工具适用性`
|
|
18
|
+
);
|
|
19
|
+
if (t.push(...p), p.length < i || t.length >= g) break;
|
|
20
|
+
n += 1;
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
}
|
|
24
|
+
function f(a) {
|
|
25
|
+
return async (c) => {
|
|
26
|
+
const e = c.page;
|
|
27
|
+
if (!e)
|
|
28
|
+
throw new Error("createListApi: params.page 必填(含 page / pageSize)");
|
|
29
|
+
const { page: i, pageSize: r } = e;
|
|
30
|
+
if (!r || r <= 0)
|
|
31
|
+
throw new Error("createListApi: pageSize 必须 > 0");
|
|
32
|
+
let t;
|
|
33
|
+
if (Array.isArray(a))
|
|
34
|
+
t = a;
|
|
35
|
+
else {
|
|
36
|
+
const o = a();
|
|
37
|
+
if (o instanceof Promise) {
|
|
38
|
+
const l = await o;
|
|
39
|
+
if (!Array.isArray(l))
|
|
40
|
+
throw new Error("createListApi: 异步 source 返回值必须为数组");
|
|
41
|
+
t = l;
|
|
42
|
+
} else
|
|
43
|
+
t = o;
|
|
44
|
+
}
|
|
45
|
+
const n = (i - 1) * r, s = n + r;
|
|
46
|
+
return {
|
|
47
|
+
items: t.slice(n, s),
|
|
48
|
+
page: {
|
|
49
|
+
totalRecord: t.length,
|
|
50
|
+
pageSize: r,
|
|
51
|
+
totalPage: Math.ceil(t.length / r)
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function h(a, c) {
|
|
57
|
+
return a({
|
|
58
|
+
...c,
|
|
59
|
+
page: { page: 1, pageSize: 1 }
|
|
60
|
+
}).then((e) => e.page.totalRecord);
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
h as countAll,
|
|
64
|
+
f as createListApi,
|
|
65
|
+
A as fetchListAll
|
|
66
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ref as c, onBeforeUnmount as n, watch as s } from "vue";
|
|
2
|
+
import { useActivated as v } from "./activated.mjs";
|
|
3
|
+
const l = (o = !0) => {
|
|
4
|
+
const { isActivated: r } = v(), e = c(void 0), t = () => {
|
|
5
|
+
e.value !== null && e.value !== void 0 && (clearTimeout(e.value), e.value = void 0);
|
|
6
|
+
}, u = (i, m) => {
|
|
7
|
+
t(), e.value = setTimeout(i, m);
|
|
8
|
+
};
|
|
9
|
+
return o && n(t), s(
|
|
10
|
+
r,
|
|
11
|
+
(i) => {
|
|
12
|
+
i || o && t();
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
immediate: !0
|
|
16
|
+
}
|
|
17
|
+
), [u, t];
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
l as useTimeout
|
|
21
|
+
};
|