@done-coding/admin-core 0.1.1-alpha.2 → 0.1.1-alpha.3

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.
@@ -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 p = /* @__PURE__ */ t(o, [["__scopeId", "data-v-643017c3"]]);
4
+ const m = /* @__PURE__ */ t(o, [["__scopeId", "data-v-f0f7753c"]]);
5
5
  export {
6
- p as default
6
+ m as default
7
7
  };
@@ -1,19 +1,20 @@
1
- import { ElTable as ue, ElTableColumn as fe, ElEmpty as ge, ElPagination as pe } from "element-plus/es";
1
+ import { ElTable as pe, ElTableColumn as ge, ElEmpty as ce, ElPagination as de } 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 de, useCssVars as ce, useModel as he, useAttrs as me, ref as g, shallowRef as ve, inject as ye, computed as d, onMounted as be, onActivated as Ce, watch as c, openBlock as l, createElementBlock as y, unref as s, createBlock as b, withCtx as C, createVNode as R, mergeProps as p, createCommentVNode as Se, Fragment as E, renderList as _e, createSlots as Ee, renderSlot as V, resolveDynamicComponent as $, createTextVNode as P, toDisplayString as Y, withDirectives as Te, createElementVNode as we, isRef as F, vShow as xe, mergeModels as G } from "vue";
7
+ import { defineComponent as me, useCssVars as he, useModel as ve, useAttrs as ye, ref as u, computed as g, shallowRef as be, inject as Ce, onMounted as Se, onActivated as _e, watch as d, openBlock as s, createElementBlock as y, unref as n, createBlock as b, withCtx as C, createVNode as I, mergeProps as c, createCommentVNode as Ee, Fragment as T, renderList as xe, createSlots as Te, renderSlot as $, resolveDynamicComponent as Y, createTextVNode as R, toDisplayString as q, withDirectives as we, createElementVNode as Pe, isRef as F, vShow as Ie, mergeModels as G } from "vue";
8
8
  import U from "lodash/cloneDeep";
9
- import q from "lodash/omit";
10
- import D from "lodash/set";
11
- import W 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 T } from "../../config/list-model.mjs";
16
- const Oe = { class: "table-main" }, ze = { class: "table-main-pagination" }, Ue = /* @__PURE__ */ de({
9
+ import D from "lodash/omit";
10
+ import W from "lodash/set";
11
+ import Z from "lodash/get";
12
+ import Re from "./TableToolbar.vue.mjs";
13
+ import ke from "../display/WatchSize.vue.mjs";
14
+ import { pickExportColumns as ze } from "../../utils/export.mjs";
15
+ import { BODY_CONTENT_VIEWPORT_HEIGHT as He } from "../../inject/key.mjs";
16
+ import { APP_API_LIST_MODEL_KEY_CONFIG as w } from "../../config/list-model.mjs";
17
+ const Ne = { class: "table-main" }, Oe = { class: "table-main-pagination" }, Ze = /* @__PURE__ */ me({
17
18
  __name: "TableMain",
18
19
  props: /* @__PURE__ */ G({
19
20
  showPager: { type: Boolean, default: !0 },
@@ -37,180 +38,197 @@ const Oe = { class: "table-main" }, ze = { class: "table-main-pagination" }, Ue
37
38
  isAutoRefreshModifiers: {}
38
39
  }),
39
40
  emits: /* @__PURE__ */ G(["pageChange", "pageSizeChange", "dataChange", "loadingChange", "pageInfoChange"], ["update:isAutoRefresh"]),
40
- setup(u, { expose: Z, emit: Q }) {
41
- ce((e) => ({
42
- v4c03ff8f: e.headerColor
41
+ setup(f, { expose: Q, emit: X }) {
42
+ he((e) => ({
43
+ v16a9ca77: e.headerColor
43
44
  }));
44
- const a = u, h = Q, O = he(u, "isAutoRefresh"), X = me(), w = g([]), x = g(0), i = g(0), o = g(1), m = g(!1), I = g(!1), z = g(0), ee = (e) => {
45
- z.value = e;
46
- }, H = ve(), te = ye(
47
- Pe,
45
+ const o = f, m = X, k = ve(f, "isAutoRefresh"), ee = ye(), S = u([]), _ = u(0), i = u(0), l = u(1), h = u(!1), P = u(!1), z = u([]), te = g(() => ({
46
+ columns: ze(o.columns),
47
+ selectedList: z.value,
48
+ currentPageList: S.value,
49
+ api: o.api,
50
+ query: o.query || {},
51
+ total: _.value,
52
+ hasSelection: o.columns.some((e) => e.type === "selection")
53
+ })), H = u(0), oe = (e) => {
54
+ H.value = e;
55
+ }, N = be(), re = Ce(
56
+ He,
48
57
  500
49
- ), N = d(() => a.showPager ? 35 : 0), k = d(() => {
50
- var n, _;
51
- if (a.showToolbar === !1) return !1;
52
- const e = (n = a.toolbar) == null ? void 0 : n.leftFeatures, t = (_ = a.toolbar) == null ? void 0 : _.rightFeatures;
58
+ ), O = g(() => o.showPager ? 35 : 0), A = g(() => {
59
+ var a, x;
60
+ if (o.showToolbar === !1) return !1;
61
+ const e = (a = o.toolbar) == null ? void 0 : a.leftFeatures, t = (x = o.toolbar) == null ? void 0 : x.rightFeatures;
53
62
  return e === void 0 || e.length > 0 || t === void 0 || t.length > 0;
54
- }), A = d(
55
- () => k.value ? z.value : 0
56
- ), re = d(() => {
57
- const { maxHeight: e, refine: t } = a;
63
+ }), L = g(
64
+ () => A.value ? H.value : 0
65
+ ), ae = g(() => {
66
+ const { maxHeight: e, refine: t } = o;
58
67
  return e ? Math.max(
59
- e - N.value - A.value,
68
+ e - O.value - L.value,
60
69
  200
61
70
  ) : t ? Math.max(
62
- te.value - N.value - A.value - a.refineReduceHeight,
71
+ re.value - O.value - L.value - o.refineReduceHeight,
63
72
  200
64
73
  ) : void 0;
65
- }), S = d(() => {
66
- const e = U(a.query || {});
67
- return D(e, T.PAGE_SIZE_KEY, i.value), D(
74
+ }), E = g(() => {
75
+ const e = U(o.query || {});
76
+ return W(e, w.PAGE_SIZE_KEY, i.value), W(
68
77
  e,
69
- T.CURRENT_PAGE_KEY,
70
- o.value
78
+ w.CURRENT_PAGE_KEY,
79
+ l.value
71
80
  ), e;
72
- }), ae = d(() => ({
73
- ...a.tableProps,
74
- ...X
75
- })), K = (e, t = !0) => {
76
- const n = JSON.stringify(e) === JSON.stringify(S.value);
77
- return !n && t && console.warn(
81
+ }), ne = g(() => {
82
+ var t;
83
+ const e = (t = o.tableProps) == null ? void 0 : t.onSelectionChange;
84
+ return {
85
+ ...o.tableProps,
86
+ ...ee,
87
+ /** 合并内部选中存储与外部 onSelectionChange */
88
+ onSelectionChange: (a) => {
89
+ z.value = a, e == null || e(a);
90
+ }
91
+ };
92
+ }), K = (e, t = !0) => {
93
+ const a = JSON.stringify(e) === JSON.stringify(E.value);
94
+ return !a && t && console.warn(
78
95
  `同一地方 并发请求 参数冰花 当前不是最新的参数 丢弃结果 ${JSON.stringify(
79
96
  e
80
- )} => ${JSON.stringify(S.value)}`
81
- ), n;
97
+ )} => ${JSON.stringify(E.value)}`
98
+ ), a;
82
99
  }, j = (e = !1) => {
83
100
  if (!i.value) return;
84
- m.value ? console.warn("请求并发") : m.value = !0, e || (I.value = !0);
85
- const t = U(S.value);
86
- return a.api(t).then((n) => {
87
- K(t, !1) && (w.value = W(
88
- n,
89
- T.LIST_KEY
90
- ), x.value = W(
91
- n,
92
- T.TOTAL_KEY
93
- ), h("pageInfoChange", {
101
+ h.value ? console.warn("请求并发") : h.value = !0, e || (P.value = !0);
102
+ const t = U(E.value);
103
+ return o.api(t).then((a) => {
104
+ K(t, !1) && (S.value = Z(
105
+ a,
106
+ w.LIST_KEY
107
+ ), _.value = Z(
108
+ a,
109
+ w.TOTAL_KEY
110
+ ), m("pageInfoChange", {
94
111
  pageSize: i.value,
95
- currentPage: o.value,
96
- total: x.value
112
+ currentPage: l.value,
113
+ total: _.value
97
114
  }));
98
115
  }).finally(() => {
99
- K(t) && (m.value = !1, I.value = !1);
116
+ K(t) && (h.value = !1, P.value = !1);
100
117
  });
101
118
  }, B = async (e = !1) => {
102
119
  var t;
103
120
  return (t = j(e)) == null ? void 0 : t.catch(() => {
104
121
  });
105
- }, oe = async (e = !1) => {
106
- if (o.value === 1)
122
+ }, le = async (e = !1) => {
123
+ if (l.value === 1)
107
124
  return B(e);
108
- o.value = 1;
109
- }, ne = (e) => e, v = {
125
+ l.value = 1;
126
+ }, se = (e) => e, v = {
110
127
  refresh: B,
111
- reload: oe,
112
- getTableInstance: () => H.value
113
- }, L = (e, t = []) => ({
114
- ...q(e, ["render", "headerRender"].concat(t)),
115
- injectInfo: a.injectInfo || {},
128
+ reload: le,
129
+ getTableInstance: () => N.value
130
+ }, M = (e, t = []) => ({
131
+ ...D(e, ["render", "headerRender"].concat(t)),
132
+ injectInfo: o.injectInfo || {},
116
133
  exposeInfo: v
117
- }), M = (e) => ({
118
- ...q(e, ["render", "headerRender"]),
119
- injectInfo: a.injectInfo || {},
134
+ }), J = (e) => ({
135
+ ...D(e, ["render", "headerRender"]),
136
+ injectInfo: o.injectInfo || {},
120
137
  exposeInfo: v
121
138
  });
122
- Z(v);
123
- const le = (e) => {
124
- i.value = e, o.value = 1;
125
- }, J = (e) => !e || e === "expand";
126
- return be(() => {
127
- i.value = a.pageSizeInit, Ce(() => {
139
+ Q(v);
140
+ const ie = (e) => {
141
+ i.value = e, l.value = 1;
142
+ }, V = (e) => !e || e === "expand";
143
+ return Se(() => {
144
+ i.value = o.pageSizeInit, _e(() => {
128
145
  v.refresh();
129
146
  });
130
- }), c(w, (e) => {
131
- h("dataChange", e);
132
- }), c(
133
- () => a.query,
147
+ }), d(S, (e) => {
148
+ m("dataChange", e);
149
+ }), d(
150
+ () => o.query,
134
151
  (e, t) => {
135
- JSON.stringify(e) !== JSON.stringify(t) && (o.value = 1);
152
+ JSON.stringify(e) !== JSON.stringify(t) && (l.value = 1);
136
153
  }
137
- ), c(
138
- S,
154
+ ), d(
155
+ E,
139
156
  (e, t) => {
140
157
  JSON.stringify(e) !== JSON.stringify(t) && j();
141
158
  },
142
159
  {
143
160
  immediate: !0
144
161
  }
145
- ), c(I, (e) => {
146
- h("loadingChange", e);
147
- }), c(i, (e) => {
148
- h("pageSizeChange", e);
149
- }), c(o, (e) => {
150
- h("pageChange", e);
162
+ ), d(P, (e) => {
163
+ m("loadingChange", e);
164
+ }), d(i, (e) => {
165
+ m("pageSizeChange", e);
166
+ }), d(l, (e) => {
167
+ m("pageChange", e);
151
168
  }), (e, t) => {
152
- const n = fe, _ = ge, se = ue, ie = pe;
153
- return l(), y("div", Oe, [
154
- s(k) ? (l(), b(s(Re), {
169
+ const a = ge, x = ce, ue = pe, fe = de;
170
+ return s(), y("div", Ne, [
171
+ n(A) ? (s(), b(n(ke), {
155
172
  key: 0,
156
- onHeightChange: ee
173
+ onHeightChange: oe
157
174
  }, {
158
175
  default: C(() => [
159
- R(Ie, p({
160
- "is-auto-refresh": O.value,
161
- "onUpdate:isAutoRefresh": t[0] || (t[0] = (r) => O.value = r),
176
+ I(Re, c({
177
+ "is-auto-refresh": k.value,
178
+ "onUpdate:isAutoRefresh": t[0] || (t[0] = (r) => k.value = r),
162
179
  tableExpose: v,
163
- loading: s(m)
164
- }, a.toolbar), null, 16, ["is-auto-refresh", "loading"])
180
+ loading: n(h),
181
+ exportContext: n(te)
182
+ }, o.toolbar), null, 16, ["is-auto-refresh", "loading", "exportContext"])
165
183
  ]),
166
184
  _: 1
167
- })) : Se("", !0),
168
- R(se, p({
185
+ })) : Ee("", !0),
186
+ I(ue, c({
169
187
  ref_key: "elTable",
170
- ref: H,
188
+ ref: N,
171
189
  class: "table-main-table",
172
190
  stripe: "",
173
191
  border: "",
174
192
  highlightCurrentRow: ""
175
- }, s(ae), {
176
- maxHeight: s(re),
177
- data: s(w),
178
- rowKey: ne(u.rowKey)
193
+ }, n(ne), {
194
+ maxHeight: n(ae),
195
+ data: n(S),
196
+ rowKey: se(f.rowKey)
179
197
  }), {
180
198
  empty: C(() => [
181
- s(m) ? (l(), y(E, { key: 0 }, [
182
- P("加载中...")
183
- ], 64)) : (l(), b(_, { key: 1 }))
199
+ n(h) ? (s(), y(T, { key: 0 }, [
200
+ R("加载中...")
201
+ ], 64)) : (s(), b(x, { key: 1 }))
184
202
  ]),
185
203
  default: C(() => [
186
- (l(!0), y(E, null, _e(u.columns, (r) => (l(), b(n, p({
204
+ (s(!0), y(T, null, xe(f.columns, (r) => (s(), b(a, c({
187
205
  key: r.columnKey || r.prop
188
- }, { ref_for: !0 }, r), Ee({ _: 2 }, [
189
- J(r.type) ? {
206
+ }, { ref_for: !0 }, r), Te({ _: 2 }, [
207
+ V(r.type) ? {
190
208
  name: "default",
191
- fn: C((f) => [
192
- V(e.$slots, r.prop, p({ ref_for: !0 }, L(f)), () => [
193
- r.render ? (l(), b($(r.render), p({
209
+ fn: C((p) => [
210
+ $(e.$slots, r.prop, c({ ref_for: !0 }, M(p)), () => [
211
+ r.render ? (s(), b(Y(r.render), c({
194
212
  key: 0,
195
213
  ref_for: !0
196
- }, L(f, ["$index"]), {
197
- _index: f.$index
198
- }), null, 16, ["_index"])) : (l(), y(E, { key: 1 }, [
199
- P(Y(f.row[r.prop]), 1)
214
+ }, M(p, ["$index"]), {
215
+ _index: p.$index
216
+ }), null, 16, ["_index"])) : (s(), y(T, { key: 1 }, [
217
+ R(q(p.row[r.prop]), 1)
200
218
  ], 64))
201
219
  ], !0)
202
220
  ]),
203
221
  key: "0"
204
222
  } : void 0,
205
- J(r.type) ? {
223
+ V(r.type) ? {
206
224
  name: "header",
207
- fn: C((f) => [
208
- V(e.$slots, `header-${r.prop}`, p({ ref_for: !0 }, M(f)), () => [
209
- r.headerRender ? (l(), b($(r.headerRender), p({
225
+ fn: C((p) => [
226
+ $(e.$slots, `header-${r.prop}`, c({ ref_for: !0 }, J(p)), () => [
227
+ r.headerRender ? (s(), b(Y(r.headerRender), c({
210
228
  key: 0,
211
229
  ref_for: !0
212
- }, M(f)), null, 16)) : (l(), y(E, { key: 1 }, [
213
- P(Y(r.label), 1)
230
+ }, J(p)), null, 16)) : (s(), y(T, { key: 1 }, [
231
+ R(q(r.label), 1)
214
232
  ], 64))
215
233
  ], !0)
216
234
  ]),
@@ -220,26 +238,26 @@ const Oe = { class: "table-main" }, ze = { class: "table-main-pagination" }, Ue
220
238
  ]),
221
239
  _: 3
222
240
  }, 16, ["maxHeight", "data", "rowKey"]),
223
- Te(we("div", ze, [
224
- R(ie, {
225
- "current-page": s(o),
226
- "onUpdate:currentPage": t[1] || (t[1] = (r) => F(o) ? o.value = r : null),
227
- "page-size": s(i),
241
+ we(Pe("div", Oe, [
242
+ I(fe, {
243
+ "current-page": n(l),
244
+ "onUpdate:currentPage": t[1] || (t[1] = (r) => F(l) ? l.value = r : null),
245
+ "page-size": n(i),
228
246
  "onUpdate:pageSize": t[2] || (t[2] = (r) => F(i) ? i.value = r : null),
229
- "page-sizes": u.pageSizeOptions,
247
+ "page-sizes": f.pageSizeOptions,
230
248
  size: "small",
231
249
  background: "",
232
- layout: u.pageLayout,
233
- total: s(x),
234
- onSizeChange: le
250
+ layout: f.pageLayout,
251
+ total: n(_),
252
+ onSizeChange: ie
235
253
  }, null, 8, ["current-page", "page-size", "page-sizes", "layout", "total"])
236
254
  ], 512), [
237
- [xe, u.showPager]
255
+ [Ie, f.showPager]
238
256
  ])
239
257
  ]);
240
258
  };
241
259
  }
242
260
  });
243
261
  export {
244
- Ue as default
262
+ Ze as default
245
263
  };
@@ -1,7 +1,7 @@
1
1
  import o from "./TableToolbar.vue2.mjs";
2
2
  /* empty css */
3
- import a from "../../_virtual/_plugin-vue_export-helper.mjs";
4
- const m = /* @__PURE__ */ a(o, [["__scopeId", "data-v-60e049ad"]]);
3
+ import r from "../../_virtual/_plugin-vue_export-helper.mjs";
4
+ const p = /* @__PURE__ */ r(o, [["__scopeId", "data-v-760501d0"]]);
5
5
  export {
6
- m as default
6
+ p as default
7
7
  };
@@ -1,75 +1,126 @@
1
- import { ElDropdown as k, ElButton as B, ElIcon as D, ElDropdownMenu as I, ElDropdownItem as V } from "element-plus/es";
1
+ import { ElDropdown as _, ElButton as D, ElIcon as V, ElDropdownMenu as T, ElDropdownItem as $ } 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 C, useModel as M, computed as f, ref as E, watch as N, openBlock as u, createElementBlock as z, createElementVNode as g, createBlock as p, withCtx as o, createVNode as l, createTextVNode as d, unref as w, createCommentVNode as c, normalizeClass as T, mergeModels as U } from "vue";
9
- import { ArrowDown as $, Refresh as j } from "@element-plus/icons-vue";
10
- import q from "../misc/AutoRefresh.vue.mjs";
11
- const G = { class: "table-toolbar" }, H = { class: "table-toolbar-left" }, J = { class: "table-toolbar-right" }, ee = /* @__PURE__ */ C({
8
+ import { defineComponent as L, useModel as N, computed as b, ref as y, watch as z, openBlock as f, createElementBlock as P, createElementVNode as F, createBlock as h, withCtx as r, createVNode as n, createTextVNode as v, unref as B, createCommentVNode as w, normalizeClass as S, mergeModels as U } from "vue";
9
+ import { ElMessageBox as X, ElMessage as q } from "element-plus";
10
+ import { ArrowDown as O, Refresh as j } from "@element-plus/icons-vue";
11
+ import G from "../misc/AutoRefresh.vue.mjs";
12
+ import { countAll as H, fetchListAll as k } from "../../helpers/list-helper.mjs";
13
+ import { EXPORT_MAX_LIMIT as c, exportCSV as J } from "../../utils/export.mjs";
14
+ const K = { class: "table-toolbar" }, Q = { class: "table-toolbar-left" }, W = { class: "table-toolbar-right" }, me = /* @__PURE__ */ L({
12
15
  __name: "TableToolbar",
13
16
  props: /* @__PURE__ */ U({
14
- leftFeatures: {},
15
- rightFeatures: {},
17
+ leftFeatures: { default: () => ["export"] },
18
+ rightFeatures: { default: () => ["refresh", "autoRefresh"] },
16
19
  refreshInterval: { default: 30 },
20
+ exportByFe: { type: Boolean, default: !0 },
17
21
  exportFn: {},
18
22
  tableExpose: {},
19
- loading: { type: Boolean }
23
+ loading: { type: Boolean },
24
+ exportContext: {}
20
25
  }, {
21
26
  isAutoRefresh: { type: Boolean },
22
27
  isAutoRefreshModifiers: {}
23
28
  }),
24
29
  emits: ["update:isAutoRefresh"],
25
- setup(n) {
26
- const t = n, v = M(n, "isAutoRefresh"), x = f(
27
- () => t.leftFeatures === void 0 || t.leftFeatures.includes("export")
28
- ), F = f(
30
+ setup(u) {
31
+ const t = u, g = N(u, "isAutoRefresh"), R = b(() => {
32
+ var o;
33
+ return (o = t.leftFeatures) == null ? void 0 : o.includes("export");
34
+ }), A = b(
29
35
  () => t.rightFeatures === void 0 || t.rightFeatures.includes("refresh")
30
- ), _ = f(
36
+ ), C = b(
31
37
  () => t.rightFeatures === void 0 || t.rightFeatures.includes("autoRefresh")
32
- ), i = E(30);
33
- N(
38
+ ), E = y(30);
39
+ z(
34
40
  () => t.refreshInterval,
35
- (a) => {
36
- i.value = a;
41
+ (o) => {
42
+ E.value = o;
37
43
  },
38
44
  { immediate: !0 }
39
45
  );
40
- const r = E(!1), R = (a) => {
41
- r.value || !t.exportFn || (r.value = !0, t.exportFn(a).catch(() => {
46
+ const p = y(!1), M = async (o) => {
47
+ const { columns: e, selectedList: a, currentPageList: x, api: s, query: m } = t.exportContext;
48
+ let i;
49
+ switch (o) {
50
+ case "selected":
51
+ i = a;
52
+ break;
53
+ case "current":
54
+ i = x;
55
+ break;
56
+ case "all":
57
+ try {
58
+ const l = await H(s, m);
59
+ if (l > c) {
60
+ try {
61
+ await X.confirm(
62
+ `数据量超过 ${c} 条(共 ${l} 条),是否只导出前 ${c} 条?`,
63
+ "提示",
64
+ {
65
+ confirmButtonText: "导出",
66
+ cancelButtonText: "取消",
67
+ type: "warning"
68
+ }
69
+ );
70
+ } catch {
71
+ return;
72
+ }
73
+ i = await k(s, m, { limit: c });
74
+ } else
75
+ i = await k(s, m, { limit: c });
76
+ } catch (l) {
77
+ q.error(`导出失败:${(l == null ? void 0 : l.message) || (l == null ? void 0 : l.toString())}`);
78
+ return;
79
+ }
80
+ break;
81
+ }
82
+ const d = `${document.title}-${Date.now()}`;
83
+ J({ columns: e, list: i, filename: d });
84
+ }, I = (o) => {
85
+ var a;
86
+ if (p.value) return;
87
+ p.value = !0;
88
+ const e = t.exportByFe ? M(o) : (a = t.exportFn) == null ? void 0 : a.call(t, o);
89
+ Promise.resolve(e).catch(() => {
42
90
  }).finally(() => {
43
- r.value = !1;
44
- }));
91
+ p.value = !1;
92
+ });
45
93
  };
46
- return (a, e) => {
47
- const h = D, b = B, m = V, y = I, A = k;
48
- return u(), z("div", G, [
49
- g("div", H, [
50
- x.value ? (u(), p(A, {
94
+ return (o, e) => {
95
+ const a = V, x = D, s = $, m = T, i = _;
96
+ return f(), P("div", K, [
97
+ F("div", Q, [
98
+ R.value ? (f(), h(i, {
51
99
  key: 0,
52
- disabled: r.value,
53
- onCommand: R
100
+ disabled: !u.exportContext.total,
101
+ onCommand: I
54
102
  }, {
55
- dropdown: o(() => [
56
- l(y, null, {
57
- default: o(() => [
58
- l(m, { command: "selected" }, {
59
- default: o(() => [...e[4] || (e[4] = [
60
- d("导出选择", -1)
103
+ dropdown: r(() => [
104
+ n(m, null, {
105
+ default: r(() => [
106
+ u.exportContext.hasSelection ? (f(), h(s, {
107
+ key: 0,
108
+ command: "selected"
109
+ }, {
110
+ default: r(() => [...e[4] || (e[4] = [
111
+ v(" 导出选择 ", -1)
61
112
  ])]),
62
113
  _: 1
63
- }),
64
- l(m, { command: "current" }, {
65
- default: o(() => [...e[5] || (e[5] = [
66
- d("导出本页", -1)
114
+ })) : w("", !0),
115
+ n(s, { command: "current" }, {
116
+ default: r(() => [...e[5] || (e[5] = [
117
+ v("导出本页", -1)
67
118
  ])]),
68
119
  _: 1
69
120
  }),
70
- l(m, { command: "all" }, {
71
- default: o(() => [...e[6] || (e[6] = [
72
- d("导出全部", -1)
121
+ n(s, { command: "all" }, {
122
+ default: r(() => [...e[6] || (e[6] = [
123
+ v("导出全部", -1)
73
124
  ])]),
74
125
  _: 1
75
126
  })
@@ -77,17 +128,17 @@ const G = { class: "table-toolbar" }, H = { class: "table-toolbar-left" }, J = {
77
128
  _: 1
78
129
  })
79
130
  ]),
80
- default: o(() => [
81
- l(b, {
131
+ default: r(() => [
132
+ n(x, {
82
133
  size: "small",
83
134
  type: "primary",
84
- loading: r.value
135
+ loading: p.value
85
136
  }, {
86
- default: o(() => [
87
- e[3] || (e[3] = d(" 导出 ", -1)),
88
- l(h, null, {
89
- default: o(() => [
90
- l(w($))
137
+ default: r(() => [
138
+ e[3] || (e[3] = v(" 导出 ", -1)),
139
+ n(a, null, {
140
+ default: r(() => [
141
+ n(B(O))
91
142
  ]),
92
143
  _: 1
93
144
  })
@@ -96,41 +147,41 @@ const G = { class: "table-toolbar" }, H = { class: "table-toolbar-left" }, J = {
96
147
  }, 8, ["loading"])
97
148
  ]),
98
149
  _: 1
99
- }, 8, ["disabled"])) : c("", !0)
150
+ }, 8, ["disabled"])) : w("", !0)
100
151
  ]),
101
- g("div", J, [
102
- _.value ? (u(), p(q, {
152
+ F("div", W, [
153
+ C.value ? (f(), h(G, {
103
154
  key: 0,
104
- modelValue: v.value,
105
- "onUpdate:modelValue": e[0] || (e[0] = (s) => v.value = s),
106
- interval: i.value,
107
- "onUpdate:interval": e[1] || (e[1] = (s) => i.value = s),
155
+ modelValue: g.value,
156
+ "onUpdate:modelValue": e[0] || (e[0] = (d) => g.value = d),
157
+ interval: E.value,
158
+ "onUpdate:interval": e[1] || (e[1] = (d) => E.value = d),
108
159
  refreshFn: t.tableExpose.refresh,
109
- enabled: !n.loading
110
- }, null, 8, ["modelValue", "interval", "refreshFn", "enabled"])) : c("", !0),
111
- F.value ? (u(), p(b, {
160
+ enabled: !u.loading
161
+ }, null, 8, ["modelValue", "interval", "refreshFn", "enabled"])) : w("", !0),
162
+ A.value ? (f(), h(x, {
112
163
  key: 1,
113
164
  size: "small",
114
165
  circle: "",
115
- onClick: e[2] || (e[2] = (s) => t.tableExpose.refresh())
166
+ onClick: e[2] || (e[2] = (d) => t.tableExpose.refresh())
116
167
  }, {
117
- default: o(() => [
118
- l(h, {
119
- class: T({ "table-toolbar-icon--rotating": n.loading })
168
+ default: r(() => [
169
+ n(a, {
170
+ class: S({ "table-toolbar-icon--rotating": u.loading })
120
171
  }, {
121
- default: o(() => [
122
- l(w(j))
172
+ default: r(() => [
173
+ n(B(j))
123
174
  ]),
124
175
  _: 1
125
176
  }, 8, ["class"])
126
177
  ]),
127
178
  _: 1
128
- })) : c("", !0)
179
+ })) : w("", !0)
129
180
  ])
130
181
  ]);
131
182
  };
132
183
  }
133
184
  });
134
185
  export {
135
- ee as default
186
+ me as default
136
187
  };
@@ -1,61 +1,57 @@
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;
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 n = 1;
9
+ let c = 1;
10
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;
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(a) {
25
- return async (c) => {
26
- const e = c.page;
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: r } = e;
30
- if (!r || r <= 0)
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(a))
34
- t = a;
29
+ if (Array.isArray(r))
30
+ t = r;
35
31
  else {
36
- const o = a();
37
- if (o instanceof Promise) {
38
- const l = await o;
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 = o;
39
+ t = s;
44
40
  }
45
- const n = (i - 1) * r, s = n + r;
41
+ const c = (i - 1) * a, o = c + a;
46
42
  return {
47
- items: t.slice(n, s),
43
+ items: t.slice(c, o),
48
44
  page: {
49
45
  totalRecord: t.length,
50
- pageSize: r,
51
- totalPage: Math.ceil(t.length / r)
46
+ pageSize: a,
47
+ totalPage: Math.ceil(t.length / a)
52
48
  }
53
49
  };
54
50
  };
55
51
  }
56
- function h(a, c) {
57
- return a({
58
- ...c,
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
  }
package/es/index.mjs CHANGED
@@ -5,41 +5,42 @@ import { miscInstall as a } from "./components/misc/index.mjs";
5
5
  import { modalInstall as m } from "./components/modal/index.mjs";
6
6
  import { tableInstall as f } from "./components/table/index.mjs";
7
7
  import { listPageInstall as s } from "./components/list-page/index.mjs";
8
- import { default as F } from "./components/modal/DetailModal.vue.mjs";
9
- import { default as E } from "./components/form/FormDateTimeRange.vue.mjs";
8
+ import { default as T } from "./components/modal/DetailModal.vue.mjs";
9
+ import { default as g } from "./components/form/FormDateTimeRange.vue.mjs";
10
10
  import { default as R } from "./components/form/FormMain.vue.mjs";
11
11
  import { default as C } from "./components/form/FormRadio.vue.mjs";
12
- import { default as S } from "./components/form/FormRadioGroup.vue.mjs";
13
- import { default as D } from "./components/form/FormSelect.vue.mjs";
14
- import { default as P } from "./components/form/FormTree.vue.mjs";
12
+ import { default as L } from "./components/form/FormRadioGroup.vue.mjs";
13
+ import { default as S } from "./components/form/FormSelect.vue.mjs";
14
+ import { default as D } from "./components/form/FormTree.vue.mjs";
15
15
  import { default as h } from "./components/form/FormVerifyCode.vue.mjs";
16
- import { default as G } from "./components/menu/MenuItemSub.vue.mjs";
17
- import { default as w } from "./components/menu/MenuTree.vue.mjs";
16
+ import { default as N } from "./components/menu/MenuItemSub.vue.mjs";
17
+ import { default as V } from "./components/menu/MenuTree.vue.mjs";
18
18
  import { default as v } from "./components/display/TabsMain.vue.mjs";
19
19
  import { default as H } from "./components/misc/TriggerAutoImport.vue.mjs";
20
20
  import { default as W } from "./components/display/WatchSize.vue.mjs";
21
21
  import { APP_API_LIST_MODEL_KEY_CONFIG as B } from "./config/list-model.mjs";
22
- import { default as Q } from "./components/misc/AutoRefresh.vue.mjs";
23
- import { BODY_CONTENT_VIEWPORT_HEIGHT as k } from "./inject/key.mjs";
24
- import { default as J } from "./components/modal/ConfirmModal.vue.mjs";
25
- import { FORM_CONFIG_SELECT_ALL_VALUE as Z, getConfirmPasswordRule as $, passwordRule as ee, setFormComponentType as te } from "./helpers/form.mjs";
26
- import { FORM_ITEM_CHANGE_LOADING as re, generateFormData as ae, getBlurSubmit as me, getChangeSubmit as fe, getEnterSubmit as se, getPlaceholder as le, getVModelSugar as ue, parseFormData as ie, setInputComponent as pe, setSelectComponent as ne, stringifyFormData as xe, swiftFormItemConfig as de } from "./components/form/utils.mjs";
27
- import { default as ce } from "./components/form/FormSearch.vue.mjs";
22
+ import { default as Y } from "./components/misc/AutoRefresh.vue.mjs";
23
+ import { BODY_CONTENT_VIEWPORT_HEIGHT as Q } from "./inject/key.mjs";
24
+ import { default as q } from "./components/modal/ConfirmModal.vue.mjs";
25
+ import { EXPORT_MAX_LIMIT as Z, OPERATE_COLUMN_PROP as $, exportCSV as ee, pickExportColumns as te } from "./utils/export.mjs";
26
+ import { FORM_CONFIG_SELECT_ALL_VALUE as re, getConfirmPasswordRule as ae, passwordRule as me, setFormComponentType as fe } from "./helpers/form.mjs";
27
+ import { FORM_ITEM_CHANGE_LOADING as le, generateFormData as ue, getBlurSubmit as pe, getChangeSubmit as ie, getEnterSubmit as ne, getPlaceholder as xe, getVModelSugar as de, parseFormData as Ie, setInputComponent as ce, setSelectComponent as Ee, stringifyFormData as Te, swiftFormItemConfig as _e } from "./components/form/utils.mjs";
28
+ import { default as Me } from "./components/form/FormSearch.vue.mjs";
28
29
  import { default as Fe } from "./components/form/FormVerifyImage.vue.mjs";
29
- import { default as Ee } from "./components/list-page/ListPage.vue.mjs";
30
- import { ROUTE_MODULE_LEVEL as Re, TabsMainReplaceQueryKey as _e } from "./config/route.mjs";
31
- import { default as Ae } from "./components/table/TableMain.vue.mjs";
32
- import { countAll as Le, createListApi as De, fetchListAll as Oe } from "./helpers/list-helper.mjs";
33
- import { createGenerateRouteMetaRawTree as be } from "./helpers/route.mjs";
34
- import { createStorageWithNamespace as ye } from "./helpers/storage.mjs";
35
- import { createUseState as Ne } from "./helpers/state.mjs";
36
- import { flatRouteMetaResolveRaw as Ve, getRoutePermissionKey as ve } from "./utils/router.mjs";
37
- import { getId as He } from "./utils/id.mjs";
38
- import { timeCountDown as We } from "./utils/time.mjs";
39
- import { useActivated as Be, useActivatedEvent as Ye, useActivatedExec as Qe } from "./hooks/activated.mjs";
40
- import { useFeelSize as ke } from "./hooks/feel-size.mjs";
41
- import { useMenusDataDispatch as Je } from "./hooks/menus-dispatch.mjs";
42
- import { useTimeout as Ze } from "./hooks/timeout.mjs";
30
+ import { default as Ae } from "./components/list-page/ListPage.vue.mjs";
31
+ import { ROUTE_MODULE_LEVEL as Oe, TabsMainReplaceQueryKey as Se } from "./config/route.mjs";
32
+ import { default as De } from "./components/table/TableMain.vue.mjs";
33
+ import { countAll as he, createListApi as ye, fetchListAll as Ne } from "./helpers/list-helper.mjs";
34
+ import { createGenerateRouteMetaRawTree as Ve } from "./helpers/route.mjs";
35
+ import { createStorageWithNamespace as ve } from "./helpers/storage.mjs";
36
+ import { createUseState as He } from "./helpers/state.mjs";
37
+ import { flatRouteMetaResolveRaw as We, getRoutePermissionKey as ze } from "./utils/router.mjs";
38
+ import { getId as Xe } from "./utils/id.mjs";
39
+ import { timeCountDown as ke } from "./utils/time.mjs";
40
+ import { useActivated as je, useActivatedEvent as qe, useActivatedExec as Je } from "./hooks/activated.mjs";
41
+ import { useFeelSize as $e } from "./hooks/feel-size.mjs";
42
+ import { useMenusDataDispatch as tt } from "./hooks/menus-dispatch.mjs";
43
+ import { useTimeout as rt } from "./hooks/timeout.mjs";
43
44
  const I = {
44
45
  install(e) {
45
46
  e.use(t), e.use(o), e.use(r), e.use(a), e.use(m), e.use(f), e.use(s);
@@ -47,66 +48,70 @@ const I = {
47
48
  };
48
49
  export {
49
50
  B as APP_API_LIST_MODEL_KEY_CONFIG,
50
- Q as AutoRefresh,
51
- k as BODY_CONTENT_VIEWPORT_HEIGHT,
52
- J as ConfirmModal,
53
- F as DetailModal,
54
- Z as FORM_CONFIG_SELECT_ALL_VALUE,
55
- re as FORM_ITEM_CHANGE_LOADING,
56
- E as FormDateTimeRange,
51
+ Y as AutoRefresh,
52
+ Q as BODY_CONTENT_VIEWPORT_HEIGHT,
53
+ q as ConfirmModal,
54
+ T as DetailModal,
55
+ Z as EXPORT_MAX_LIMIT,
56
+ re as FORM_CONFIG_SELECT_ALL_VALUE,
57
+ le as FORM_ITEM_CHANGE_LOADING,
58
+ g as FormDateTimeRange,
57
59
  R as FormMain,
58
60
  C as FormRadio,
59
- S as FormRadioGroup,
60
- ce as FormSearch,
61
- D as FormSelect,
62
- P as FormTree,
61
+ L as FormRadioGroup,
62
+ Me as FormSearch,
63
+ S as FormSelect,
64
+ D as FormTree,
63
65
  h as FormVerifyCode,
64
66
  Fe as FormVerifyImage,
65
- Ee as ListPage,
66
- G as MenuItemSub,
67
- w as MenuTree,
68
- Re as ROUTE_MODULE_LEVEL,
69
- Ae as TableMain,
67
+ Ae as ListPage,
68
+ N as MenuItemSub,
69
+ V as MenuTree,
70
+ $ as OPERATE_COLUMN_PROP,
71
+ Oe as ROUTE_MODULE_LEVEL,
72
+ De as TableMain,
70
73
  v as TabsMain,
71
- _e as TabsMainReplaceQueryKey,
74
+ Se as TabsMainReplaceQueryKey,
72
75
  H as TriggerAutoImport,
73
76
  W as WatchSize,
74
- Le as countAll,
75
- be as createGenerateRouteMetaRawTree,
76
- De as createListApi,
77
- ye as createStorageWithNamespace,
78
- Ne as createUseState,
77
+ he as countAll,
78
+ Ve as createGenerateRouteMetaRawTree,
79
+ ye as createListApi,
80
+ ve as createStorageWithNamespace,
81
+ He as createUseState,
79
82
  r as displayInstall,
80
- Oe as fetchListAll,
81
- Ve as flatRouteMetaResolveRaw,
83
+ ee as exportCSV,
84
+ Ne as fetchListAll,
85
+ We as flatRouteMetaResolveRaw,
82
86
  t as formInstall,
83
- ae as generateFormData,
84
- me as getBlurSubmit,
85
- fe as getChangeSubmit,
86
- $ as getConfirmPasswordRule,
87
- se as getEnterSubmit,
88
- He as getId,
89
- le as getPlaceholder,
90
- ve as getRoutePermissionKey,
91
- ue as getVModelSugar,
87
+ ue as generateFormData,
88
+ pe as getBlurSubmit,
89
+ ie as getChangeSubmit,
90
+ ae as getConfirmPasswordRule,
91
+ ne as getEnterSubmit,
92
+ Xe as getId,
93
+ xe as getPlaceholder,
94
+ ze as getRoutePermissionKey,
95
+ de as getVModelSugar,
92
96
  I as installComponents,
93
97
  s as listPageInstall,
94
98
  o as menuInstall,
95
99
  a as miscInstall,
96
100
  m as modalInstall,
97
- ie as parseFormData,
98
- ee as passwordRule,
99
- te as setFormComponentType,
100
- pe as setInputComponent,
101
- ne as setSelectComponent,
102
- xe as stringifyFormData,
103
- de as swiftFormItemConfig,
101
+ Ie as parseFormData,
102
+ me as passwordRule,
103
+ te as pickExportColumns,
104
+ fe as setFormComponentType,
105
+ ce as setInputComponent,
106
+ Ee as setSelectComponent,
107
+ Te as stringifyFormData,
108
+ _e as swiftFormItemConfig,
104
109
  f as tableInstall,
105
- We as timeCountDown,
106
- Be as useActivated,
107
- Ye as useActivatedEvent,
108
- Qe as useActivatedExec,
109
- ke as useFeelSize,
110
- Je as useMenusDataDispatch,
111
- Ze as useTimeout
110
+ ke as timeCountDown,
111
+ je as useActivated,
112
+ qe as useActivatedEvent,
113
+ Je as useActivatedExec,
114
+ $e as useFeelSize,
115
+ tt as useMenusDataDispatch,
116
+ rt as useTimeout
112
117
  };
package/es/style.css CHANGED
@@ -1 +1 @@
1
- .form-item-tip[data-v-e889a0ed]{text-align:left;line-height:1.5;font-size:12px}.form-search_show[data-v-8896356d]{margin-bottom:10px}.form-search .btn-box[data-v-8896356d]{padding-left:20px}.form-search[data-v-8896356d] .el-col{padding-left:14px}.form-verify-image[data-v-a4baf877] .el-input__suffix-inner *{margin:0}.form-verify-image-suffix[data-v-a4baf877]{position:absolute;height:100%;border-radius:var(--el-input-border-radius, var(--el-border-radius-base));top:50%;transform:translateY(-50%);overflow:hidden;cursor:pointer}.form-verify-image-suffix-main[data-v-a4baf877]{position:absolute;left:0;top:0;width:100%;height:100%;background-color:#f4f4f4}.auto-refresh[data-v-9d78ca06]{display:flex;align-items:center;gap:8px}.auto-refresh-label[data-v-9d78ca06]{font-size:13px;color:var(--el-text-color-regular)}.auto-refresh-interval[data-v-9d78ca06]{width:80px}.confirm-dialog .content[data-v-2f0c870e]{overflow-x:hidden;overflow-y:auto;max-height:calc(100vh - 200px)}.confirm-dialog .btn[data-v-2f0c870e]{width:150px;height:40px;border-radius:4px}.confirm-dialog .main[data-v-2f0c870e]{position:relative;text-align:center}.confirm-dialog .main .close-box[data-v-2f0c870e]{position:absolute;top:0;right:0;cursor:pointer;z-index:2}.confirm-dialog .main .shim[data-v-2f0c870e]{position:relative;z-index:1}.confirm-dialog .main .shim .title[data-v-2f0c870e]{font-size:18px;font-weight:500}.confirm-dialog .main .shim .content[data-v-2f0c870e]{font-size:16px;margin-top:15px}.confirm-dialog .main .shim .footer[data-v-2f0c870e]{display:flex;justify-content:center;align-items:center;padding-top:5px}.confirm-dialog .main .shim .footer>.btn[data-v-2f0c870e]:not(:last-child){margin-right:30px}.confirm-dialog .main .shim .footer[reverse=true][data-v-2f0c870e]{flex-direction:row-reverse}.confirm-dialog .main .shim .footer[reverse=true]>.btn[data-v-2f0c870e]:not(:last-child){margin-right:0;margin-left:30px}.confirm-dialog .el-dialog__header,.confirm-dialog .el-dialog__body{padding:0;background-color:transparent}.table-toolbar[data-v-60e049ad]{display:flex;justify-content:space-between;align-items:center;padding-bottom:8px;gap:20px}.table-toolbar-left[data-v-60e049ad],.table-toolbar-right[data-v-60e049ad]{display:flex;align-items:center;gap:10px}.table-toolbar-icon--rotating[data-v-60e049ad]{animation:table-toolbar-rotating-60e049ad 1s linear infinite}@keyframes table-toolbar-rotating-60e049ad{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.table-main-table[data-v-643017c3]{--el-table-header-bg-color: var(--v4c03ff8f)}.table-main-pagination[data-v-643017c3]{margin-top:10px;display:flex;justify-content:flex-end}.list-page[data-v-182577bf]{min-height:var(--ad28a056)}.list-page-header[data-v-182577bf],.list-page-operation[data-v-182577bf]{margin-bottom:10px}.list-page[data-v-182577bf] .el-loading-mask{left:-10px;top:-10px;right:-10px;bottom:-10px}
1
+ .form-item-tip[data-v-e889a0ed]{text-align:left;line-height:1.5;font-size:12px}.form-search_show[data-v-8896356d]{margin-bottom:10px}.form-search .btn-box[data-v-8896356d]{padding-left:20px}.form-search[data-v-8896356d] .el-col{padding-left:14px}.form-verify-image[data-v-a4baf877] .el-input__suffix-inner *{margin:0}.form-verify-image-suffix[data-v-a4baf877]{position:absolute;height:100%;border-radius:var(--el-input-border-radius, var(--el-border-radius-base));top:50%;transform:translateY(-50%);overflow:hidden;cursor:pointer}.form-verify-image-suffix-main[data-v-a4baf877]{position:absolute;left:0;top:0;width:100%;height:100%;background-color:#f4f4f4}.auto-refresh[data-v-9d78ca06]{display:flex;align-items:center;gap:8px}.auto-refresh-label[data-v-9d78ca06]{font-size:13px;color:var(--el-text-color-regular)}.auto-refresh-interval[data-v-9d78ca06]{width:80px}.confirm-dialog .content[data-v-2f0c870e]{overflow-x:hidden;overflow-y:auto;max-height:calc(100vh - 200px)}.confirm-dialog .btn[data-v-2f0c870e]{width:150px;height:40px;border-radius:4px}.confirm-dialog .main[data-v-2f0c870e]{position:relative;text-align:center}.confirm-dialog .main .close-box[data-v-2f0c870e]{position:absolute;top:0;right:0;cursor:pointer;z-index:2}.confirm-dialog .main .shim[data-v-2f0c870e]{position:relative;z-index:1}.confirm-dialog .main .shim .title[data-v-2f0c870e]{font-size:18px;font-weight:500}.confirm-dialog .main .shim .content[data-v-2f0c870e]{font-size:16px;margin-top:15px}.confirm-dialog .main .shim .footer[data-v-2f0c870e]{display:flex;justify-content:center;align-items:center;padding-top:5px}.confirm-dialog .main .shim .footer>.btn[data-v-2f0c870e]:not(:last-child){margin-right:30px}.confirm-dialog .main .shim .footer[reverse=true][data-v-2f0c870e]{flex-direction:row-reverse}.confirm-dialog .main .shim .footer[reverse=true]>.btn[data-v-2f0c870e]:not(:last-child){margin-right:0;margin-left:30px}.confirm-dialog .el-dialog__header,.confirm-dialog .el-dialog__body{padding:0;background-color:transparent}.table-toolbar[data-v-760501d0]{display:flex;justify-content:space-between;align-items:center;padding-bottom:8px;gap:20px}.table-toolbar-left[data-v-760501d0],.table-toolbar-right[data-v-760501d0]{display:flex;align-items:center;gap:10px}.table-toolbar-icon--rotating[data-v-760501d0]{animation:table-toolbar-rotating-760501d0 1s linear infinite}@keyframes table-toolbar-rotating-760501d0{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.table-main-table[data-v-f0f7753c]{--el-table-header-bg-color: var(--v16a9ca77)}.table-main-pagination[data-v-f0f7753c]{margin-top:10px;display:flex;justify-content:flex-end}.list-page[data-v-182577bf]{min-height:var(--ad28a056)}.list-page-header[data-v-182577bf],.list-page-operation[data-v-182577bf]{margin-bottom:10px}.list-page[data-v-182577bf] .el-loading-mask{left:-10px;top:-10px;right:-10px;bottom:-10px}
@@ -0,0 +1,23 @@
1
+ const f = "OPERATE", E = 1e4, O = (t) => t.filter((e) => !(!e.prop || e.prop === f || e.type && e.type !== "default")).map((e) => ({
2
+ prop: e.prop,
3
+ label: e.label
4
+ })), b = "\uFEFF", R = ({
5
+ columns: t,
6
+ list: e,
7
+ filename: p = "导出数据"
8
+ }) => {
9
+ const c = t.map((n) => n.label).join(","), s = e.map(
10
+ (n) => t.map((u) => {
11
+ const i = n[u.prop] ?? "";
12
+ return `"${String(i).replace(/"/g, '""')}"`;
13
+ }).join(",")
14
+ ), a = b + [c, ...s].join(`
15
+ `), l = new Blob([a], { type: "text/csv;charset=utf-8;" }), o = URL.createObjectURL(l), r = document.createElement("a");
16
+ r.href = o, r.download = `${p}.csv`, r.click(), URL.revokeObjectURL(o);
17
+ };
18
+ export {
19
+ E as EXPORT_MAX_LIMIT,
20
+ f as OPERATE_COLUMN_PROP,
21
+ R as exportCSV,
22
+ O as pickExportColumns
23
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/admin-core",
3
- "version": "0.1.1-alpha.2",
3
+ "version": "0.1.1-alpha.3",
4
4
  "description": "后台管理核心",
5
5
  "private": false,
6
6
  "main": "lib/index.cjs",
@@ -77,5 +77,5 @@
77
77
  "node": ">=18.0.0",
78
78
  "pnpm": ">=9.0.0"
79
79
  },
80
- "gitHead": "ab2bb3cbded6a375d254e49281d93383534afabe"
80
+ "gitHead": "53e17b4c1d1e64d8b48e85207fc7680109e75809"
81
81
  }
@@ -1,4 +1,4 @@
1
- import { ExportType, TableMainInstance } from './types';
1
+ import { ExportType, TableExportContext, TableMainInstance, TableToolbarLeftFeature, TableToolbarRightFeature } from './types';
2
2
 
3
3
  declare const _default: import('vue').DefineComponent<globalThis.ExtractPropTypes<{
4
4
  isAutoRefresh: import('vue').PropType<boolean>;
@@ -8,14 +8,20 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
8
8
  };
9
9
  leftFeatures: {
10
10
  type: globalThis.PropType<"export"[]>;
11
+ default: () => TableToolbarLeftFeature[];
11
12
  };
12
13
  rightFeatures: {
13
- type: globalThis.PropType<import('./types').TableToolbarRightFeature[]>;
14
+ type: globalThis.PropType<TableToolbarRightFeature[]>;
15
+ default: () => TableToolbarRightFeature[];
14
16
  };
15
17
  refreshInterval: {
16
18
  type: globalThis.PropType<number>;
17
19
  default: number;
18
20
  };
21
+ exportByFe: {
22
+ type: globalThis.PropType<boolean>;
23
+ default: boolean;
24
+ };
19
25
  exportFn: {
20
26
  type: globalThis.PropType<(type: ExportType) => Promise<unknown>>;
21
27
  };
@@ -23,6 +29,10 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
23
29
  type: globalThis.PropType<TableMainInstance>;
24
30
  required: true;
25
31
  };
32
+ exportContext: {
33
+ type: globalThis.PropType<TableExportContext>;
34
+ required: true;
35
+ };
26
36
  }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<globalThis.ExtractPropTypes<{
27
37
  isAutoRefresh: import('vue').PropType<boolean>;
28
38
  loading: {
@@ -31,14 +41,20 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
31
41
  };
32
42
  leftFeatures: {
33
43
  type: globalThis.PropType<"export"[]>;
44
+ default: () => TableToolbarLeftFeature[];
34
45
  };
35
46
  rightFeatures: {
36
- type: globalThis.PropType<import('./types').TableToolbarRightFeature[]>;
47
+ type: globalThis.PropType<TableToolbarRightFeature[]>;
48
+ default: () => TableToolbarRightFeature[];
37
49
  };
38
50
  refreshInterval: {
39
51
  type: globalThis.PropType<number>;
40
52
  default: number;
41
53
  };
54
+ exportByFe: {
55
+ type: globalThis.PropType<boolean>;
56
+ default: boolean;
57
+ };
42
58
  exportFn: {
43
59
  type: globalThis.PropType<(type: ExportType) => Promise<unknown>>;
44
60
  };
@@ -46,7 +62,14 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
46
62
  type: globalThis.PropType<TableMainInstance>;
47
63
  required: true;
48
64
  };
65
+ exportContext: {
66
+ type: globalThis.PropType<TableExportContext>;
67
+ required: true;
68
+ };
49
69
  }>> & Readonly<{}>, {
70
+ leftFeatures: TableToolbarLeftFeature[];
71
+ rightFeatures: TableToolbarRightFeature[];
50
72
  refreshInterval: number;
73
+ exportByFe: boolean;
51
74
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
52
75
  export default _default;
@@ -30,6 +30,23 @@ export type ExportType = "selected" | "current" | "all";
30
30
  export type TableToolbarLeftFeature = "export";
31
31
  /** toolbar 右侧功能 */
32
32
  export type TableToolbarRightFeature = "refresh" | "autoRefresh";
33
+ /** TableMain 传给 toolbar 的导出上下文 */
34
+ export interface TableExportContext {
35
+ /** 可导出列 */
36
+ columns: Pick<ElTableColumnProps, "prop" | "label">[];
37
+ /** 选中行数据 */
38
+ selectedList: Record<string, any>[];
39
+ /** 当前页数据 */
40
+ currentPageList: Record<string, any>[];
41
+ /** 分页 API */
42
+ api: TableMainProps<any, any, any>["api"];
43
+ /** 静态查询参数 */
44
+ query: Record<string, any>;
45
+ /** 当前数据总数 */
46
+ total: number;
47
+ /** 是否包含 selection 列 */
48
+ hasSelection: boolean;
49
+ }
33
50
  /** toolbar 可配置项(通过 TableMain 的 toolbar prop 传入) */
34
51
  export interface TableToolbarConfig {
35
52
  /**
@@ -46,7 +63,13 @@ export interface TableToolbarConfig {
46
63
  rightFeatures?: TableToolbarRightFeature[];
47
64
  /** 自动刷新默认间隔(秒),默认 30 */
48
65
  refreshInterval?: number;
49
- /** 导出方法。传入导出类型,返回 Promise */
66
+ /**
67
+ * 是否由前端导出,默认 true。
68
+ * - true:toolbar 内部调 fetchListAll + exportCSV 完成导出
69
+ * - false:走 exportFn 回调
70
+ */
71
+ exportByFe?: boolean;
72
+ /** 导出方法。传入导出类型,返回 Promise。exportByFe 为 false 时必传 */
50
73
  exportFn?: (type: ExportType) => Promise<unknown>;
51
74
  }
52
75
  /** 表格列默认作用域 */
@@ -0,0 +1,23 @@
1
+ import { ElTableColumnProps } from '../components/table/types';
2
+
3
+ /** 操作列标记 prop。消费方以此值标记操作列,导出时自动过滤 */
4
+ export declare const OPERATE_COLUMN_PROP = "OPERATE";
5
+ /** 前端导出最大行数 */
6
+ export declare const EXPORT_MAX_LIMIT = 10000;
7
+ /** 导出列:从 ElTableColumnProps 中提取 prop、label、type */
8
+ export type ExportColumn = Pick<ElTableColumnProps, "prop" | "label" | "type">;
9
+ /** 导出参数 */
10
+ export interface ExportOptions {
11
+ columns: ExportColumn[];
12
+ list: Record<string, any>[];
13
+ filename?: string;
14
+ }
15
+ /**
16
+ * 从表格列配置中提取可导出列
17
+ * ---
18
+ * 过滤规则:排除 type 为 selection / index / expand 的列(除 default 外均排除),
19
+ * 排除 prop 为 OPERATE_COLUMN_PROP 的列,排除无 prop 的列
20
+ */
21
+ export declare const pickExportColumns: <T extends Record<string, any>>(columns: ElTableColumnProps<T>[]) => ExportColumn[];
22
+ /** 导出 CSV 文件 */
23
+ export declare const exportCSV: ({ columns, list, filename, }: ExportOptions) => void;
@@ -1,3 +1,4 @@
1
1
  export * from './time';
2
2
  export * from './id';
3
3
  export * from './router';
4
+ export * from './export';