@done-coding/admin-core 0.1.1-alpha.1 → 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.
- package/es/components/list-page/ListPage.vue.mjs +2 -2
- package/es/components/list-page/ListPage.vue2.mjs +97 -84
- package/es/components/misc/AutoRefresh.vue.mjs +2 -2
- package/es/components/misc/AutoRefresh.vue2.mjs +32 -30
- package/es/components/table/TableMain.vue.mjs +2 -2
- package/es/components/table/TableMain.vue2.mjs +152 -134
- package/es/components/table/TableToolbar.vue.mjs +2 -2
- package/es/components/table/TableToolbar.vue2.mjs +157 -39
- package/es/helpers/list-helper.mjs +29 -33
- package/es/index.mjs +79 -74
- package/es/style.css +1 -1
- package/es/utils/export.mjs +23 -0
- package/package.json +2 -2
- package/types/components/list-page/ListPage.vue.d.ts +2 -0
- package/types/components/list-page/types.d.ts +2 -0
- package/types/components/table/TableToolbar.vue.d.ts +40 -8
- package/types/components/table/types.d.ts +42 -8
- package/types/utils/export.d.ts +23 -0
- package/types/utils/index.d.ts +1 -0
|
@@ -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
|
}
|
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
|
|
9
|
-
import { default as
|
|
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
|
|
13
|
-
import { default as
|
|
14
|
-
import { default as
|
|
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
|
|
17
|
-
import { default as
|
|
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
|
|
23
|
-
import { BODY_CONTENT_VIEWPORT_HEIGHT as
|
|
24
|
-
import { default as
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
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
|
|
30
|
-
import { ROUTE_MODULE_LEVEL as
|
|
31
|
-
import { default as
|
|
32
|
-
import { countAll as
|
|
33
|
-
import { createGenerateRouteMetaRawTree as
|
|
34
|
-
import { createStorageWithNamespace as
|
|
35
|
-
import { createUseState as
|
|
36
|
-
import { flatRouteMetaResolveRaw as
|
|
37
|
-
import { getId as
|
|
38
|
-
import { timeCountDown as
|
|
39
|
-
import { useActivated as
|
|
40
|
-
import { useFeelSize as
|
|
41
|
-
import { useMenusDataDispatch as
|
|
42
|
-
import { useTimeout as
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
Z as
|
|
55
|
-
re as
|
|
56
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
74
|
+
Se as TabsMainReplaceQueryKey,
|
|
72
75
|
H as TriggerAutoImport,
|
|
73
76
|
W as WatchSize,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
81
|
-
|
|
83
|
+
ee as exportCSV,
|
|
84
|
+
Ne as fetchListAll,
|
|
85
|
+
We as flatRouteMetaResolveRaw,
|
|
82
86
|
t as formInstall,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
te as
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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-
|
|
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.
|
|
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": "
|
|
80
|
+
"gitHead": "53e17b4c1d1e64d8b48e85207fc7680109e75809"
|
|
81
81
|
}
|
|
@@ -16,6 +16,7 @@ declare const _default: <T extends Record<string, any>, PO extends Record<string
|
|
|
16
16
|
tableMainProps?: Partial<Omit<import('../table').TableMainProps<T, import('../form').ExcludeNeverProperties<import('../form').ExtractFormStringifyRawFromObject<PO, SO>> & SQ, ListPageInnerInjectInfo<PO, F>>, import('./types').TableMainOptionsKey | import('./types').TableMainRewriteKey>> | undefined;
|
|
17
17
|
} & {
|
|
18
18
|
showOperation?: boolean;
|
|
19
|
+
showHeader?: boolean;
|
|
19
20
|
list?: FormItemConfigList<PO, SO> | undefined;
|
|
20
21
|
api: (params: import('../table').TableApiParams<import('../form').ExcludeNeverProperties<import('../form').ExtractFormStringifyRawFromObject<PO, SO>> & SQ>) => Promise<import('../table').TableApiResult<T>>;
|
|
21
22
|
query?: SQ | undefined;
|
|
@@ -41,6 +42,7 @@ declare const _default: <T extends Record<string, any>, PO extends Record<string
|
|
|
41
42
|
injectInfo: ListPageInnerInjectInfo<PO, F>;
|
|
42
43
|
exposeInfo: TableMainInstance;
|
|
43
44
|
}) => any>> & {
|
|
45
|
+
header?(_: {}): any;
|
|
44
46
|
operation?(_: {}): any;
|
|
45
47
|
}>;
|
|
46
48
|
emit: {
|
|
@@ -26,6 +26,8 @@ F extends Record<string, any>> = Partial<Pick<FormSearchProps<PO, SO, {}>, FormS
|
|
|
26
26
|
} & {
|
|
27
27
|
/** 是否展示操作区 */
|
|
28
28
|
showOperation?: boolean;
|
|
29
|
+
/** 是否展示头部区 */
|
|
30
|
+
showHeader?: boolean;
|
|
29
31
|
list?: FormItemConfigList<PO, SO>;
|
|
30
32
|
/** api */
|
|
31
33
|
api: (params: TableApiParams<ExtractFormStringifyFromObject<PO, SO> & SQ>) => Promise<TableApiResult<T>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { 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>;
|
|
@@ -6,38 +6,70 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
|
|
|
6
6
|
type: globalThis.PropType<boolean>;
|
|
7
7
|
required: true;
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
type: globalThis.PropType<
|
|
11
|
-
default: () =>
|
|
9
|
+
leftFeatures: {
|
|
10
|
+
type: globalThis.PropType<"export"[]>;
|
|
11
|
+
default: () => TableToolbarLeftFeature[];
|
|
12
|
+
};
|
|
13
|
+
rightFeatures: {
|
|
14
|
+
type: globalThis.PropType<TableToolbarRightFeature[]>;
|
|
15
|
+
default: () => TableToolbarRightFeature[];
|
|
12
16
|
};
|
|
13
17
|
refreshInterval: {
|
|
14
18
|
type: globalThis.PropType<number>;
|
|
15
19
|
default: number;
|
|
16
20
|
};
|
|
21
|
+
exportByFe: {
|
|
22
|
+
type: globalThis.PropType<boolean>;
|
|
23
|
+
default: boolean;
|
|
24
|
+
};
|
|
25
|
+
exportFn: {
|
|
26
|
+
type: globalThis.PropType<(type: ExportType) => Promise<unknown>>;
|
|
27
|
+
};
|
|
17
28
|
tableExpose: {
|
|
18
29
|
type: globalThis.PropType<TableMainInstance>;
|
|
19
30
|
required: true;
|
|
20
31
|
};
|
|
32
|
+
exportContext: {
|
|
33
|
+
type: globalThis.PropType<TableExportContext>;
|
|
34
|
+
required: true;
|
|
35
|
+
};
|
|
21
36
|
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<globalThis.ExtractPropTypes<{
|
|
22
37
|
isAutoRefresh: import('vue').PropType<boolean>;
|
|
23
38
|
loading: {
|
|
24
39
|
type: globalThis.PropType<boolean>;
|
|
25
40
|
required: true;
|
|
26
41
|
};
|
|
27
|
-
|
|
28
|
-
type: globalThis.PropType<
|
|
29
|
-
default: () =>
|
|
42
|
+
leftFeatures: {
|
|
43
|
+
type: globalThis.PropType<"export"[]>;
|
|
44
|
+
default: () => TableToolbarLeftFeature[];
|
|
45
|
+
};
|
|
46
|
+
rightFeatures: {
|
|
47
|
+
type: globalThis.PropType<TableToolbarRightFeature[]>;
|
|
48
|
+
default: () => TableToolbarRightFeature[];
|
|
30
49
|
};
|
|
31
50
|
refreshInterval: {
|
|
32
51
|
type: globalThis.PropType<number>;
|
|
33
52
|
default: number;
|
|
34
53
|
};
|
|
54
|
+
exportByFe: {
|
|
55
|
+
type: globalThis.PropType<boolean>;
|
|
56
|
+
default: boolean;
|
|
57
|
+
};
|
|
58
|
+
exportFn: {
|
|
59
|
+
type: globalThis.PropType<(type: ExportType) => Promise<unknown>>;
|
|
60
|
+
};
|
|
35
61
|
tableExpose: {
|
|
36
62
|
type: globalThis.PropType<TableMainInstance>;
|
|
37
63
|
required: true;
|
|
38
64
|
};
|
|
65
|
+
exportContext: {
|
|
66
|
+
type: globalThis.PropType<TableExportContext>;
|
|
67
|
+
required: true;
|
|
68
|
+
};
|
|
39
69
|
}>> & Readonly<{}>, {
|
|
40
|
-
|
|
70
|
+
leftFeatures: TableToolbarLeftFeature[];
|
|
71
|
+
rightFeatures: TableToolbarRightFeature[];
|
|
41
72
|
refreshInterval: number;
|
|
73
|
+
exportByFe: boolean;
|
|
42
74
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
43
75
|
export default _default;
|
|
@@ -24,19 +24,53 @@ export interface TableMainInstance {
|
|
|
24
24
|
reload: (slice?: boolean) => Promise<unknown>;
|
|
25
25
|
getTableInstance: () => TableInstance | undefined;
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
export type
|
|
27
|
+
/** 导出类型 */
|
|
28
|
+
export type ExportType = "selected" | "current" | "all";
|
|
29
|
+
/** toolbar 左侧功能 */
|
|
30
|
+
export type TableToolbarLeftFeature = "export";
|
|
31
|
+
/** toolbar 右侧功能 */
|
|
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
|
+
}
|
|
29
50
|
/** toolbar 可配置项(通过 TableMain 的 toolbar prop 传入) */
|
|
30
51
|
export interface TableToolbarConfig {
|
|
31
52
|
/**
|
|
32
|
-
*
|
|
33
|
-
* - undefined
|
|
34
|
-
* - []
|
|
35
|
-
|
|
53
|
+
* 左侧功能列表。
|
|
54
|
+
* - undefined(默认):显示所有左侧功能
|
|
55
|
+
* - [](空数组):不渲染左侧功能
|
|
56
|
+
*/
|
|
57
|
+
leftFeatures?: TableToolbarLeftFeature[];
|
|
58
|
+
/**
|
|
59
|
+
* 右侧功能列表。
|
|
60
|
+
* - undefined(默认):显示所有右侧功能
|
|
61
|
+
* - [](空数组):不渲染右侧功能
|
|
36
62
|
*/
|
|
37
|
-
|
|
63
|
+
rightFeatures?: TableToolbarRightFeature[];
|
|
38
64
|
/** 自动刷新默认间隔(秒),默认 30 */
|
|
39
65
|
refreshInterval?: number;
|
|
66
|
+
/**
|
|
67
|
+
* 是否由前端导出,默认 true。
|
|
68
|
+
* - true:toolbar 内部调 fetchListAll + exportCSV 完成导出
|
|
69
|
+
* - false:走 exportFn 回调
|
|
70
|
+
*/
|
|
71
|
+
exportByFe?: boolean;
|
|
72
|
+
/** 导出方法。传入导出类型,返回 Promise。exportByFe 为 false 时必传 */
|
|
73
|
+
exportFn?: (type: ExportType) => Promise<unknown>;
|
|
40
74
|
}
|
|
41
75
|
/** 表格列默认作用域 */
|
|
42
76
|
export interface TableColumnDefaultScope<T extends Record<string, any>, F extends Record<string, any>> {
|
|
@@ -82,7 +116,7 @@ SQ extends Record<string, any>,
|
|
|
82
116
|
F extends Record<string, any>> {
|
|
83
117
|
/** 展示分页器 */
|
|
84
118
|
showPager?: boolean;
|
|
85
|
-
/** 是否显示 toolbar(顶层开关,默认 true,优先级高于 toolbar.
|
|
119
|
+
/** 是否显示 toolbar(顶层开关,默认 true,优先级高于 toolbar.leftFeatures / rightFeatures) */
|
|
86
120
|
showToolbar?: boolean;
|
|
87
121
|
/** toolbar 配置 */
|
|
88
122
|
toolbar?: TableToolbarConfig;
|
|
@@ -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;
|
package/types/utils/index.d.ts
CHANGED