@chewel611/naive-ui-plus 0.0.48 → 0.0.50
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/dist/index.js +798 -773
- package/dist/index.umd.cjs +1 -1
- package/es/application/index.js +1 -1
- package/es/error/index.js +4 -4
- package/es/iframe/index.js +1 -1
- package/es/languages/index.js +4 -4
- package/es/layout/index.js +3 -3
- package/es/modal/index.js +2 -2
- package/es/oidc/index.js +2 -2
- package/es/page/index.js +1 -1
- package/es/redirect/index.js +2 -2
- package/es/table/PTable.vue.js +175 -164
- package/es/table/index.js +2 -2
- package/es/table/typing.d.ts +5 -0
- package/es/utils/helper.d.ts +9 -0
- package/es/utils/helper.js +20 -0
- package/es/utils/install.d.ts +1 -1
- package/es/utils/install.js +5 -5
- package/lib/application/index.cjs +1 -1
- package/lib/error/index.cjs +1 -1
- package/lib/iframe/index.cjs +1 -1
- package/lib/languages/index.cjs +1 -1
- package/lib/layout/index.cjs +1 -1
- package/lib/modal/index.cjs +1 -1
- package/lib/oidc/index.cjs +1 -1
- package/lib/page/index.cjs +1 -1
- package/lib/redirect/index.cjs +1 -1
- package/lib/table/PTable.vue.cjs +1 -1
- package/lib/table/index.cjs +1 -1
- package/lib/table/typing.d.ts +5 -0
- package/lib/utils/helper.cjs +1 -0
- package/lib/utils/helper.d.ts +9 -0
- package/lib/utils/install.cjs +1 -1
- package/lib/utils/install.d.ts +1 -1
- package/package.json +103 -102
package/es/table/PTable.vue.js
CHANGED
|
@@ -1,239 +1,250 @@
|
|
|
1
|
-
import { useDialog as
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { useDialog as X, useMessage as Y, NCard as Z, NDataTable as ee, NSpace as te, NTooltip as ne, NIcon as m, NDropdown as oe, NButton as ae } from "naive-ui";
|
|
2
|
+
import { defineComponent as ie, ref as u, computed as E, watch as se, unref as c, onMounted as le, openBlock as C, createBlock as z, withCtx as i, createElementVNode as g, createElementBlock as re, renderSlot as ue, createCommentVNode as N, createVNode as s, toDisplayString as ce, h as l, toRaw as H } from "vue";
|
|
3
|
+
import { getViewportOffset as de } from "../utils/helper.js";
|
|
4
|
+
import { PlusSquareOutlined as fe, DeleteOutlined as A, ReloadOutlined as me, MoreOutlined as pe, EditOutlined as ge } from "@vicons/antd";
|
|
5
|
+
const he = { class: "text-lg font-medium" }, ve = { id: "data-content" }, ye = {
|
|
5
6
|
key: 0,
|
|
6
7
|
class: "rounded-lg bg-gray-50 flex flex-row gap-2 items-center justify-end p-4 mb-4"
|
|
7
|
-
},
|
|
8
|
+
}, _e = /* @__PURE__ */ ie({
|
|
8
9
|
__name: "PTable",
|
|
9
10
|
props: {
|
|
10
11
|
title: {},
|
|
11
12
|
idField: { default: "id" },
|
|
13
|
+
addPermission: {},
|
|
14
|
+
editPermission: {},
|
|
15
|
+
deletePermission: {},
|
|
12
16
|
columns: {},
|
|
13
17
|
onLoad: {},
|
|
14
18
|
onDelete: {},
|
|
15
19
|
onAdd: {},
|
|
16
|
-
onEdit: {}
|
|
20
|
+
onEdit: {},
|
|
21
|
+
onCheckPermission: {}
|
|
17
22
|
},
|
|
18
|
-
setup(
|
|
19
|
-
const
|
|
23
|
+
setup(P, { expose: T }) {
|
|
24
|
+
const B = u(null), L = X(), h = Y(), v = u(!1), y = u([]), k = u([]), x = u(!1), _ = u(!1), w = u(!1), D = u({}), R = E(
|
|
25
|
+
() => _.value || w.value || Object.keys(D.value).length > 0
|
|
26
|
+
), a = P, b = async (e) => !e || !a.onCheckPermission ? !0 : await a.onCheckPermission(e) ?? !1;
|
|
27
|
+
se(
|
|
28
|
+
a,
|
|
29
|
+
async () => {
|
|
30
|
+
x.value = !!a.onAdd && await b(a.addPermission), _.value = !!a.onEdit && await b(a.editPermission), w.value = !!a.onDelete && await b(a.deletePermission);
|
|
31
|
+
const e = a.columns.find(
|
|
32
|
+
(t) => t.key === "action"
|
|
33
|
+
);
|
|
34
|
+
if (e && e.action)
|
|
35
|
+
for (const t of e.action) {
|
|
36
|
+
if (!t.permission) continue;
|
|
37
|
+
const n = await b(
|
|
38
|
+
t.permission.toLowerCase()
|
|
39
|
+
);
|
|
40
|
+
n && (D.value[t.permission] = n);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{ immediate: !0 }
|
|
44
|
+
);
|
|
45
|
+
const M = E(() => {
|
|
46
|
+
const e = [{ type: "selection", fixed: "left" }], t = [];
|
|
47
|
+
return a.columns.forEach((n) => {
|
|
48
|
+
if (n.key !== "action") {
|
|
49
|
+
e.push({
|
|
50
|
+
title: n.title,
|
|
51
|
+
key: n.key,
|
|
52
|
+
width: n.width,
|
|
53
|
+
fixed: n.fixed ?? !1,
|
|
54
|
+
render: n.render,
|
|
55
|
+
ellipsis: n.ellipsis ? { tooltip: !0 } : !1
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
!n.action || n.action.length <= 0 || !R.value || t.push({
|
|
60
|
+
title: "操作",
|
|
61
|
+
key: "actions",
|
|
62
|
+
width: 100,
|
|
63
|
+
fixed: "right",
|
|
64
|
+
render: (o) => {
|
|
65
|
+
const r = [];
|
|
66
|
+
if (j(r, o), q(r, o), I(r, o, n.action), !(r.length <= 0))
|
|
67
|
+
return l(
|
|
68
|
+
oe,
|
|
69
|
+
{
|
|
70
|
+
options: r,
|
|
71
|
+
placement: "bottom-start"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
default: () => l(
|
|
75
|
+
ae,
|
|
76
|
+
{ size: "small", type: "primary" },
|
|
77
|
+
{ default: () => ["操作", l(m, () => l(pe))] }
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}), [...e, ...R.value ? t : []];
|
|
84
|
+
}), d = u({
|
|
20
85
|
page: 1,
|
|
21
86
|
itemCount: 0,
|
|
22
87
|
pageSize: 10,
|
|
23
88
|
pageSizes: [10, 20, 30, 50],
|
|
24
89
|
showSizePicker: !0,
|
|
25
90
|
onChange: async (e) => {
|
|
26
|
-
|
|
91
|
+
d.value.page = e, await p();
|
|
27
92
|
},
|
|
28
93
|
onUpdatePageSize: async (e) => {
|
|
29
|
-
|
|
94
|
+
d.value.pageSize = e, await p();
|
|
30
95
|
}
|
|
31
|
-
}),
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
96
|
+
}), V = E(() => {
|
|
97
|
+
const e = c(B);
|
|
98
|
+
if (!e) return;
|
|
99
|
+
const t = e?.$el, n = t.querySelector(".n-data-table-thead "), { bottomIncludeBody: o } = de(n), r = 48;
|
|
100
|
+
let f = 12, Q = 25;
|
|
101
|
+
const $ = t.querySelector(
|
|
102
|
+
".n-data-table__pagination"
|
|
103
|
+
);
|
|
104
|
+
if ($) {
|
|
105
|
+
const W = $.offsetHeight;
|
|
106
|
+
f += W || 0;
|
|
107
|
+
} else
|
|
108
|
+
f += 28;
|
|
109
|
+
return o - (r + f + Q);
|
|
110
|
+
}), j = async (e, t) => {
|
|
111
|
+
_.value && e.push({
|
|
112
|
+
label: "编辑",
|
|
113
|
+
key: "edit",
|
|
114
|
+
icon: () => l(m, null, { default: () => l(ge) }),
|
|
115
|
+
props: { onClick: async () => await a.onEdit(t) }
|
|
116
|
+
});
|
|
117
|
+
}, q = async (e, t) => {
|
|
118
|
+
w.value && e.push({
|
|
119
|
+
label: "删除",
|
|
120
|
+
key: "delete",
|
|
121
|
+
icon: () => l(m, null, { default: () => l(A) }),
|
|
122
|
+
props: { onClick: () => K(t) }
|
|
123
|
+
});
|
|
124
|
+
}, I = (e, t, n) => {
|
|
125
|
+
if (n)
|
|
126
|
+
for (const o of n) {
|
|
127
|
+
if (o.key === "edit" || o.key === "delete" || !o.permission || !D.value[o.permission])
|
|
128
|
+
return;
|
|
129
|
+
e.push({
|
|
130
|
+
label: o.name,
|
|
131
|
+
key: o.key,
|
|
132
|
+
icon: o.icon && (() => l(m, null, { default: () => l(o.icon) })),
|
|
133
|
+
props: { onClick: () => o.action(t) }
|
|
40
134
|
});
|
|
41
|
-
}), n;
|
|
42
|
-
};
|
|
43
|
-
return {
|
|
44
|
-
title: "操作",
|
|
45
|
-
key: "actions",
|
|
46
|
-
width: 100,
|
|
47
|
-
fixed: "right",
|
|
48
|
-
render: (o) => {
|
|
49
|
-
let n = [];
|
|
50
|
-
if (l.onEdit && n.push({
|
|
51
|
-
label: "编辑",
|
|
52
|
-
key: "edit",
|
|
53
|
-
icon: () => r(f, null, { default: () => r(ve) }),
|
|
54
|
-
props: { onClick: async () => await l.onEdit(o) }
|
|
55
|
-
}), l.onDelete && n.push({
|
|
56
|
-
label: "删除",
|
|
57
|
-
key: "delete",
|
|
58
|
-
icon: () => r(f, null, { default: () => r(P) }),
|
|
59
|
-
props: { onClick: () => W(o) }
|
|
60
|
-
}), n = [...n, ...t(o)], !(n.length <= 0))
|
|
61
|
-
return r(
|
|
62
|
-
ce,
|
|
63
|
-
{
|
|
64
|
-
options: n,
|
|
65
|
-
placement: "bottom-start"
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
default: () => r(
|
|
69
|
-
de,
|
|
70
|
-
{ size: "small", type: "primary" },
|
|
71
|
-
{ default: () => ["操作", r(f, () => r(ke))] }
|
|
72
|
-
)
|
|
73
|
-
}
|
|
74
|
-
);
|
|
75
135
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
width: o.width,
|
|
82
|
-
fixed: o.fixed ?? !1,
|
|
83
|
-
render: o.render,
|
|
84
|
-
ellipsis: o.ellipsis ? { tooltip: !0 } : !1
|
|
85
|
-
})), t = l.columns.reduce(
|
|
86
|
-
(o, n) => n.key === "action" ? n : o,
|
|
87
|
-
void 0
|
|
88
|
-
)?.action;
|
|
89
|
-
return t && t?.length > 0 || l.onEdit || l.onDelete ? [
|
|
90
|
-
{ type: "selection", fixed: "left" },
|
|
91
|
-
...e,
|
|
92
|
-
M(t)
|
|
93
|
-
] : [{ type: "selection", fixed: "left" }, ...e];
|
|
94
|
-
}), q = async () => await p(), W = (e) => z([e]), j = () => {
|
|
95
|
-
const e = D();
|
|
96
|
-
z(e);
|
|
97
|
-
}, z = (e) => {
|
|
98
|
-
e && e.length > 0 && A.warning({
|
|
136
|
+
}, F = async () => await p(), K = (e) => O([e]), U = () => {
|
|
137
|
+
const e = S();
|
|
138
|
+
O(e);
|
|
139
|
+
}, O = (e) => {
|
|
140
|
+
!e || e.length === 0 || L.warning({
|
|
99
141
|
title: "警告",
|
|
100
142
|
content: "删除数据不可恢复, 确认删除吗?",
|
|
101
143
|
positiveText: "确定",
|
|
102
144
|
negativeText: "取消",
|
|
103
145
|
onPositiveClick: async () => {
|
|
104
|
-
if (
|
|
146
|
+
if (a.onDelete)
|
|
105
147
|
try {
|
|
106
|
-
await
|
|
148
|
+
await a.onDelete(e) ? (p(), h.success("删除成功")) : h.error("删除失败");
|
|
107
149
|
} catch (t) {
|
|
108
|
-
|
|
150
|
+
h.error(t.message);
|
|
109
151
|
}
|
|
110
152
|
}
|
|
111
153
|
});
|
|
112
|
-
},
|
|
113
|
-
if (!
|
|
114
|
-
|
|
154
|
+
}, p = async () => {
|
|
155
|
+
if (a.onLoad && !v.value) {
|
|
156
|
+
v.value = !0;
|
|
115
157
|
try {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
} catch (o) {
|
|
124
|
-
y.error(o.message);
|
|
158
|
+
var { items: e, totalCount: t } = await a.onLoad(
|
|
159
|
+
d.value.page,
|
|
160
|
+
d.value.pageSize
|
|
161
|
+
);
|
|
162
|
+
k.value = e, d.value.itemCount = t;
|
|
163
|
+
} catch (n) {
|
|
164
|
+
h.error(n.message);
|
|
125
165
|
} finally {
|
|
126
|
-
|
|
166
|
+
v.value = !1;
|
|
127
167
|
}
|
|
128
168
|
}
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const g = t.querySelector(
|
|
135
|
-
".n-data-table__pagination"
|
|
136
|
-
);
|
|
137
|
-
if (g) {
|
|
138
|
-
const S = g.offsetHeight;
|
|
139
|
-
c += S || 0;
|
|
140
|
-
} else
|
|
141
|
-
c += 28;
|
|
142
|
-
return n - (a + c + b);
|
|
143
|
-
}), X = (e) => !e || !e.getBoundingClientRect ? 0 : e.getBoundingClientRect(), Y = (e) => {
|
|
144
|
-
const t = document.documentElement, o = t.scrollLeft, n = t.scrollTop, a = t.clientLeft, c = t.clientTop, b = window.pageXOffset, g = window.pageYOffset, B = X(e), {
|
|
145
|
-
left: S,
|
|
146
|
-
top: G,
|
|
147
|
-
width: J,
|
|
148
|
-
height: Q
|
|
149
|
-
} = B, Z = (b || o) - (a || 0), ee = (g || n) - (c || 0), te = S + b, oe = G + g, x = te - Z, E = oe - ee, L = window.document.documentElement.clientWidth, N = window.document.documentElement.clientHeight;
|
|
150
|
-
return {
|
|
151
|
-
left: x,
|
|
152
|
-
top: E,
|
|
153
|
-
right: L - J - x,
|
|
154
|
-
bottom: N - Q - E,
|
|
155
|
-
rightIncludeBody: L - x,
|
|
156
|
-
bottomIncludeBody: N - E
|
|
157
|
-
};
|
|
158
|
-
};
|
|
159
|
-
return fe(async () => await p()), I({
|
|
160
|
-
getData: K,
|
|
161
|
-
getSelectedRow: F,
|
|
162
|
-
getSelectedRows: D,
|
|
169
|
+
}, S = () => y.value ? k.value.filter((e) => y.value.includes(e.id)).map((e) => H(e)) : [], G = () => S()[0], J = () => H(k.value);
|
|
170
|
+
return le(async () => await p()), T({
|
|
171
|
+
getData: J,
|
|
172
|
+
getSelectedRow: G,
|
|
173
|
+
getSelectedRows: S,
|
|
163
174
|
refreshData: p,
|
|
164
175
|
resetPage: () => {
|
|
165
|
-
|
|
176
|
+
d.value.page = 1;
|
|
166
177
|
}
|
|
167
178
|
}), (e, t) => {
|
|
168
|
-
const
|
|
169
|
-
return C(),
|
|
179
|
+
const n = ne, o = te, r = ee;
|
|
180
|
+
return C(), z(c(Z), { bordered: !1 }, {
|
|
170
181
|
header: i(() => [
|
|
171
|
-
s(
|
|
182
|
+
s(o, {
|
|
172
183
|
justify: "space-between",
|
|
173
184
|
align: "center",
|
|
174
185
|
class: "w-full"
|
|
175
186
|
}, {
|
|
176
187
|
default: i(() => [
|
|
177
|
-
|
|
178
|
-
s(
|
|
188
|
+
g("span", he, ce(P.title), 1),
|
|
189
|
+
s(o, null, {
|
|
179
190
|
default: i(() => [
|
|
180
|
-
|
|
191
|
+
x.value ? (C(), z(n, {
|
|
181
192
|
key: 0,
|
|
182
193
|
trigger: "hover"
|
|
183
194
|
}, {
|
|
184
195
|
trigger: i(() => [
|
|
185
|
-
s(
|
|
196
|
+
s(c(m), {
|
|
186
197
|
size: "18",
|
|
187
198
|
class: "mr-1 cursor-pointer hover:text-blue-600",
|
|
188
|
-
onClick:
|
|
199
|
+
onClick: a.onAdd
|
|
189
200
|
}, {
|
|
190
201
|
default: i(() => [
|
|
191
|
-
s(
|
|
202
|
+
s(c(fe))
|
|
192
203
|
]),
|
|
193
204
|
_: 1
|
|
194
205
|
}, 8, ["onClick"])
|
|
195
206
|
]),
|
|
196
207
|
default: i(() => [
|
|
197
|
-
t[1] || (t[1] =
|
|
208
|
+
t[1] || (t[1] = g("span", null, "新增", -1))
|
|
198
209
|
]),
|
|
199
210
|
_: 1
|
|
200
|
-
})) :
|
|
201
|
-
|
|
211
|
+
})) : N("", !0),
|
|
212
|
+
w.value ? (C(), z(n, {
|
|
202
213
|
key: 1,
|
|
203
214
|
trigger: "hover"
|
|
204
215
|
}, {
|
|
205
216
|
trigger: i(() => [
|
|
206
|
-
s(
|
|
217
|
+
s(c(m), {
|
|
207
218
|
size: "18",
|
|
208
219
|
class: "mr-1 cursor-pointer hover:text-blue-600",
|
|
209
|
-
onClick:
|
|
220
|
+
onClick: U
|
|
210
221
|
}, {
|
|
211
222
|
default: i(() => [
|
|
212
|
-
s(
|
|
223
|
+
s(c(A))
|
|
213
224
|
]),
|
|
214
225
|
_: 1
|
|
215
226
|
})
|
|
216
227
|
]),
|
|
217
228
|
default: i(() => [
|
|
218
|
-
t[2] || (t[2] =
|
|
229
|
+
t[2] || (t[2] = g("span", null, "删除", -1))
|
|
219
230
|
]),
|
|
220
231
|
_: 1
|
|
221
|
-
})) :
|
|
222
|
-
s(
|
|
232
|
+
})) : N("", !0),
|
|
233
|
+
s(n, { trigger: "hover" }, {
|
|
223
234
|
trigger: i(() => [
|
|
224
|
-
s(
|
|
235
|
+
s(c(m), {
|
|
225
236
|
size: "18",
|
|
226
237
|
class: "cursor-pointer hover:text-blue-600",
|
|
227
|
-
onClick:
|
|
238
|
+
onClick: F
|
|
228
239
|
}, {
|
|
229
240
|
default: i(() => [
|
|
230
|
-
s(
|
|
241
|
+
s(c(me))
|
|
231
242
|
]),
|
|
232
243
|
_: 1
|
|
233
244
|
})
|
|
234
245
|
]),
|
|
235
246
|
default: i(() => [
|
|
236
|
-
t[3] || (t[3] =
|
|
247
|
+
t[3] || (t[3] = g("span", null, "刷新", -1))
|
|
237
248
|
]),
|
|
238
249
|
_: 1
|
|
239
250
|
})
|
|
@@ -245,24 +256,24 @@ const we = { class: "text-lg font-medium" }, be = { id: "data-content" }, Ce = {
|
|
|
245
256
|
})
|
|
246
257
|
]),
|
|
247
258
|
default: i(() => [
|
|
248
|
-
|
|
249
|
-
e.$slots.toolbar ? (C(),
|
|
250
|
-
|
|
251
|
-
])) :
|
|
252
|
-
s(
|
|
259
|
+
g("div", ve, [
|
|
260
|
+
e.$slots.toolbar ? (C(), re("div", ye, [
|
|
261
|
+
ue(e.$slots, "toolbar")
|
|
262
|
+
])) : N("", !0),
|
|
263
|
+
s(r, {
|
|
253
264
|
remote: "",
|
|
254
265
|
ref_key: "$table",
|
|
255
|
-
ref:
|
|
256
|
-
"checked-row-keys":
|
|
257
|
-
"onUpdate:checkedRowKeys": t[0] || (t[0] = (
|
|
258
|
-
"max-height":
|
|
259
|
-
loading:
|
|
266
|
+
ref: B,
|
|
267
|
+
"checked-row-keys": y.value,
|
|
268
|
+
"onUpdate:checkedRowKeys": t[0] || (t[0] = (f) => y.value = f),
|
|
269
|
+
"max-height": V.value,
|
|
270
|
+
loading: v.value,
|
|
260
271
|
bordered: !1,
|
|
261
272
|
"single-line": !1,
|
|
262
|
-
columns:
|
|
263
|
-
data:
|
|
264
|
-
pagination:
|
|
265
|
-
"row-key": (
|
|
273
|
+
columns: M.value,
|
|
274
|
+
data: k.value,
|
|
275
|
+
pagination: d.value,
|
|
276
|
+
"row-key": (f) => f[P.idField]
|
|
266
277
|
}, null, 8, ["checked-row-keys", "max-height", "loading", "columns", "data", "pagination", "row-key"])
|
|
267
278
|
])
|
|
268
279
|
]),
|
|
@@ -272,5 +283,5 @@ const we = { class: "text-lg font-medium" }, be = { id: "data-content" }, Ce = {
|
|
|
272
283
|
}
|
|
273
284
|
});
|
|
274
285
|
export {
|
|
275
|
-
|
|
286
|
+
_e as default
|
|
276
287
|
};
|
package/es/table/index.js
CHANGED
package/es/table/typing.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export type DataTableColumnActionDefine = {
|
|
|
3
3
|
name: string;
|
|
4
4
|
key: string;
|
|
5
5
|
icon?: Component;
|
|
6
|
+
permission?: string;
|
|
6
7
|
action: (row: any) => void;
|
|
7
8
|
};
|
|
8
9
|
export type DataTableColumnDefine = {
|
|
@@ -17,6 +18,9 @@ export type DataTableColumnDefine = {
|
|
|
17
18
|
export type DataTableProps = {
|
|
18
19
|
title?: string;
|
|
19
20
|
idField?: string;
|
|
21
|
+
addPermission?: string;
|
|
22
|
+
editPermission?: string;
|
|
23
|
+
deletePermission?: string;
|
|
20
24
|
columns: DataTableColumnDefine[];
|
|
21
25
|
onLoad: (page: number, pageSize: number) => Promise<{
|
|
22
26
|
items: any[];
|
|
@@ -25,6 +29,7 @@ export type DataTableProps = {
|
|
|
25
29
|
onDelete?: (rows: any[]) => Promise<boolean>;
|
|
26
30
|
onAdd?: () => Promise<void>;
|
|
27
31
|
onEdit?: (row: any) => Promise<void>;
|
|
32
|
+
onCheckPermission?: (value?: string) => Promise<boolean>;
|
|
28
33
|
};
|
|
29
34
|
export type DataTableMethods = {
|
|
30
35
|
refreshData: () => Promise<void>;
|
package/es/utils/helper.d.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
1
|
export declare const resetObject: (obj: Record<string, any>) => void;
|
|
2
|
+
export declare const getBoundingClientRect: (element: Element) => DOMRect | number;
|
|
3
|
+
export declare const getViewportOffset: (element: Element) => {
|
|
4
|
+
left: number;
|
|
5
|
+
top: number;
|
|
6
|
+
right: number;
|
|
7
|
+
bottom: number;
|
|
8
|
+
rightIncludeBody: number;
|
|
9
|
+
bottomIncludeBody: number;
|
|
10
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const O = (t) => !t || !t.getBoundingClientRect ? 0 : t.getBoundingClientRect(), a = (t) => {
|
|
2
|
+
const o = document.documentElement, d = o.scrollLeft, f = o.scrollTop, r = o.clientLeft, g = o.clientTop, c = window.pageXOffset, i = window.pageYOffset, p = O(t), {
|
|
3
|
+
left: u,
|
|
4
|
+
top: h,
|
|
5
|
+
width: w,
|
|
6
|
+
height: m
|
|
7
|
+
} = p, L = (c || d) - (r || 0), T = (i || f) - (g || 0), B = u + c, C = h + i, e = B - L, n = C - T, s = window.document.documentElement.clientWidth, l = window.document.documentElement.clientHeight;
|
|
8
|
+
return {
|
|
9
|
+
left: e,
|
|
10
|
+
top: n,
|
|
11
|
+
right: s - w - e,
|
|
12
|
+
bottom: l - m - n,
|
|
13
|
+
rightIncludeBody: s - e,
|
|
14
|
+
bottomIncludeBody: l - n
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
O as getBoundingClientRect,
|
|
19
|
+
a as getViewportOffset
|
|
20
|
+
};
|
package/es/utils/install.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Plugin, Component } from 'vue';
|
|
2
|
-
export declare const withInstall: <T extends Component>(comp: T) => T & Plugin;
|
|
2
|
+
export declare const withInstall: <T extends Component>(name: string, comp: T) => T & Plugin;
|
package/es/utils/install.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
return
|
|
4
|
-
|
|
1
|
+
const s = (t, n) => {
|
|
2
|
+
const l = n;
|
|
3
|
+
return l.install = function(o) {
|
|
4
|
+
o.component(t, n);
|
|
5
5
|
}, n;
|
|
6
6
|
};
|
|
7
7
|
export {
|
|
8
|
-
|
|
8
|
+
s as withInstall
|
|
9
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../utils/install.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../utils/install.cjs"),i=require("./PApplication.vue.cjs"),e=t.withInstall("PApplication",i.default);exports.PApplicationPlugin=e;
|
package/lib/error/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../utils/install.cjs"),l=require("./P500.vue.cjs"),n=require("./P404.vue.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../utils/install.cjs"),l=require("./P500.vue.cjs"),n=require("./P404.vue.cjs"),P=require("./P403.vue.cjs"),e=t.withInstall("P500",l.default),i=t.withInstall("P404",n.default),u=t.withInstall("P403",P.default);exports.P403Plugin=u;exports.P404Plugin=i;exports.P500Plugin=e;
|
package/lib/iframe/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils/install.cjs"),t=require("./PIframe.vue.cjs"),r=e.withInstall(t.default);exports.PIframePlugin=r;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils/install.cjs"),t=require("./PIframe.vue.cjs"),r=e.withInstall("PIframe",t.default);exports.PIframePlugin=r;
|
package/lib/languages/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils/install.cjs"),t=require("./PLanguage.vue.cjs"),u=e.withInstall(t.default);exports.PLanguagePlugin=u;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils/install.cjs"),t=require("./PLanguage.vue.cjs"),u=e.withInstall("PLanguage",t.default);exports.PLanguagePlugin=u;
|
package/lib/layout/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./PLayout.vue.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./PLayout.vue.cjs"),o=require("./PEmptyLayout.vue.cjs"),t=require("../utils/install.cjs"),a=t.withInstall("PEmptyLayout",o.default),e=t.withInstall("PLayout",u.default);exports.PEmptyLayoutPlugin=a;exports.PLayoutPlugin=e;
|
package/lib/modal/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./PModal.vue.cjs"),t=require("../utils/install.cjs"),l=t.withInstall(e.default);exports.PModalPlugin=l;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./PModal.vue.cjs"),t=require("../utils/install.cjs"),l=t.withInstall("PModal",e.default);exports.PModalPlugin=l;
|
package/lib/oidc/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../utils/install.cjs"),t=require("./POidc.vue.cjs"),e=i.withInstall("POidc",t.default);exports.POidcPlugin=e;
|
package/lib/page/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./PPage.vue.cjs"),t=require("../utils/install.cjs"),u=t.withInstall(e.default);exports.PPagePlugin=u;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./PPage.vue.cjs"),t=require("../utils/install.cjs"),u=t.withInstall("PPage",e.default);exports.PPagePlugin=u;
|
package/lib/redirect/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils/install.cjs"),t=require("./PRedirect.vue.cjs"),i=e.withInstall(t.default);exports.PRedirectPlugin=i;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils/install.cjs"),t=require("./PRedirect.vue.cjs"),i=e.withInstall("PRedirect",t.default);exports.PRedirectPlugin=i;
|
package/lib/table/PTable.vue.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("naive-ui"),e=require("vue"),A=require("../utils/helper.cjs"),d=require("@vicons/antd"),j={class:"text-lg font-medium"},L={id:"data-content"},U={key:0,class:"rounded-lg bg-gray-50 flex flex-row gap-2 items-center justify-end p-4 mb-4"},F=e.defineComponent({__name:"PTable",props:{title:{},idField:{default:"id"},addPermission:{},editPermission:{},deletePermission:{},columns:{},onLoad:{},onDelete:{},onAdd:{},onEdit:{},onCheckPermission:{}},setup(y,{expose:V}){const N=e.ref(null),D=l.useDialog(),f=l.useMessage(),h=e.ref(!1),m=e.ref([]),p=e.ref([]),b=e.ref(!1),w=e.ref(!1),g=e.ref(!1),k=e.ref({}),P=e.computed(()=>w.value||g.value||Object.keys(k.value).length>0),i=y,v=async t=>!t||!i.onCheckPermission?!0:await i.onCheckPermission(t)??!1;e.watch(i,async()=>{b.value=!!i.onAdd&&await v(i.addPermission),w.value=!!i.onEdit&&await v(i.editPermission),g.value=!!i.onDelete&&await v(i.deletePermission);const t=i.columns.find(n=>n.key==="action");if(t&&t.action)for(const n of t.action){if(!n.permission)continue;const o=await v(n.permission.toLowerCase());o&&(k.value[n.permission]=o)}},{immediate:!0});const E=e.computed(()=>{const t=[{type:"selection",fixed:"left"}],n=[];return i.columns.forEach(o=>{if(o.key!=="action"){t.push({title:o.title,key:o.key,width:o.width,fixed:o.fixed??!1,render:o.render,ellipsis:o.ellipsis?{tooltip:!0}:!1});return}!o.action||o.action.length<=0||!P.value||n.push({title:"操作",key:"actions",width:100,fixed:"right",render:a=>{const s=[];if(B(s,a),z(s,a),I(s,a,o.action),!(s.length<=0))return e.h(l.NDropdown,{options:s,placement:"bottom-start"},{default:()=>e.h(l.NButton,{size:"small",type:"primary"},{default:()=>["操作",e.h(l.NIcon,()=>e.h(d.MoreOutlined))]})})}})}),[...t,...P.value?n:[]]}),r=e.ref({page:1,itemCount:0,pageSize:10,pageSizes:[10,20,30,50],showSizePicker:!0,onChange:async t=>{r.value.page=t,await u()},onUpdatePageSize:async t=>{r.value.pageSize=t,await u()}}),S=e.computed(()=>{const t=e.unref(N);if(!t)return;const n=t?.$el,o=n.querySelector(".n-data-table-thead "),{bottomIncludeBody:a}=A.getViewportOffset(o),s=48;let c=12,M=25;const x=n.querySelector(".n-data-table__pagination");if(x){const T=x.offsetHeight;c+=T||0}else c+=28;return a-(s+c+M)}),B=async(t,n)=>{w.value&&t.push({label:"编辑",key:"edit",icon:()=>e.h(l.NIcon,null,{default:()=>e.h(d.EditOutlined)}),props:{onClick:async()=>await i.onEdit(n)}})},z=async(t,n)=>{g.value&&t.push({label:"删除",key:"delete",icon:()=>e.h(l.NIcon,null,{default:()=>e.h(d.DeleteOutlined)}),props:{onClick:()=>R(n)}})},I=(t,n,o)=>{if(o)for(const a of o){if(a.key==="edit"||a.key==="delete"||!a.permission||!k.value[a.permission])return;t.push({label:a.name,key:a.key,icon:a.icon&&(()=>e.h(l.NIcon,null,{default:()=>e.h(a.icon)})),props:{onClick:()=>a.action(n)}})}},O=async()=>await u(),R=t=>_([t]),q=()=>{const t=C();_(t)},_=t=>{!t||t.length===0||D.warning({title:"警告",content:"删除数据不可恢复, 确认删除吗?",positiveText:"确定",negativeText:"取消",onPositiveClick:async()=>{if(i.onDelete)try{await i.onDelete(t)?(u(),f.success("删除成功")):f.error("删除失败")}catch(n){f.error(n.message)}}})},u=async()=>{if(i.onLoad&&!h.value){h.value=!0;try{var{items:t,totalCount:n}=await i.onLoad(r.value.page,r.value.pageSize);p.value=t,r.value.itemCount=n}catch(o){f.error(o.message)}finally{h.value=!1}}},C=()=>m.value?p.value.filter(t=>m.value.includes(t.id)).map(t=>e.toRaw(t)):[],$=()=>C()[0],H=()=>e.toRaw(p.value);return e.onMounted(async()=>await u()),V({getData:H,getSelectedRow:$,getSelectedRows:C,refreshData:u,resetPage:()=>{r.value.page=1}}),(t,n)=>{const o=l.NTooltip,a=l.NSpace,s=l.NDataTable;return e.openBlock(),e.createBlock(e.unref(l.NCard),{bordered:!1},{header:e.withCtx(()=>[e.createVNode(a,{justify:"space-between",align:"center",class:"w-full"},{default:e.withCtx(()=>[e.createElementVNode("span",j,e.toDisplayString(y.title),1),e.createVNode(a,null,{default:e.withCtx(()=>[b.value?(e.openBlock(),e.createBlock(o,{key:0,trigger:"hover"},{trigger:e.withCtx(()=>[e.createVNode(e.unref(l.NIcon),{size:"18",class:"mr-1 cursor-pointer hover:text-blue-600",onClick:i.onAdd},{default:e.withCtx(()=>[e.createVNode(e.unref(d.PlusSquareOutlined))]),_:1},8,["onClick"])]),default:e.withCtx(()=>[n[1]||(n[1]=e.createElementVNode("span",null,"新增",-1))]),_:1})):e.createCommentVNode("",!0),g.value?(e.openBlock(),e.createBlock(o,{key:1,trigger:"hover"},{trigger:e.withCtx(()=>[e.createVNode(e.unref(l.NIcon),{size:"18",class:"mr-1 cursor-pointer hover:text-blue-600",onClick:q},{default:e.withCtx(()=>[e.createVNode(e.unref(d.DeleteOutlined))]),_:1})]),default:e.withCtx(()=>[n[2]||(n[2]=e.createElementVNode("span",null,"删除",-1))]),_:1})):e.createCommentVNode("",!0),e.createVNode(o,{trigger:"hover"},{trigger:e.withCtx(()=>[e.createVNode(e.unref(l.NIcon),{size:"18",class:"cursor-pointer hover:text-blue-600",onClick:O},{default:e.withCtx(()=>[e.createVNode(e.unref(d.ReloadOutlined))]),_:1})]),default:e.withCtx(()=>[n[3]||(n[3]=e.createElementVNode("span",null,"刷新",-1))]),_:1})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createElementVNode("div",L,[t.$slots.toolbar?(e.openBlock(),e.createElementBlock("div",U,[e.renderSlot(t.$slots,"toolbar")])):e.createCommentVNode("",!0),e.createVNode(s,{remote:"",ref_key:"$table",ref:N,"checked-row-keys":m.value,"onUpdate:checkedRowKeys":n[0]||(n[0]=c=>m.value=c),"max-height":S.value,loading:h.value,bordered:!1,"single-line":!1,columns:E.value,data:p.value,pagination:r.value,"row-key":c=>c[y.idField]},null,8,["checked-row-keys","max-height","loading","columns","data","pagination","row-key"])])]),_:3})}}});exports.default=F;
|
package/lib/table/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./PTable.vue.cjs"),t=require("../utils/install.cjs"),l=t.withInstall(e.default);exports.PTablePlugin=l;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./PTable.vue.cjs"),t=require("../utils/install.cjs"),l=t.withInstall("PTable",e.default);exports.PTablePlugin=l;
|