@chewel611/naive-ui-plus 0.0.29 → 0.0.30
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 +771 -897
- package/dist/index.umd.cjs +1 -1
- package/es/modal/PModal.d.ts +0 -1
- package/es/modal/PModal.vue.js +31 -32
- package/es/modal/index.d.ts +0 -3
- package/es/modal/typing.d.ts +0 -1
- package/es/table/PTable.d.ts +0 -8
- package/es/table/PTable.vue.js +146 -267
- package/es/table/index.d.ts +0 -20
- package/es/table/typing.d.ts +3 -11
- package/lib/modal/PModal.d.ts +0 -1
- package/lib/modal/PModal.vue.cjs +1 -1
- package/lib/modal/index.d.ts +0 -3
- package/lib/modal/typing.d.ts +0 -1
- package/lib/table/PTable.d.ts +0 -8
- package/lib/table/PTable.vue.cjs +1 -1
- package/lib/table/index.d.ts +0 -20
- package/lib/table/typing.d.ts +3 -11
- package/package.json +1 -1
- package/es/utils/helper.js +0 -9
- package/lib/utils/helper.cjs +0 -1
package/es/table/PTable.vue.js
CHANGED
|
@@ -1,273 +1,236 @@
|
|
|
1
|
-
import { useDialog as
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import { PlusSquareOutlined as
|
|
4
|
-
|
|
5
|
-
import { cloneDeep as ze } from "lodash";
|
|
6
|
-
const Le = { class: "text-lg font-medium" }, _e = { id: "data-content" }, He = {
|
|
1
|
+
import { useDialog as oe, useMessage as ne, NCard as le, NDataTable as ae, NSpace as ie, NTooltip as se, NIcon as w, NDropdown as re, NButton as ce } from "naive-ui";
|
|
2
|
+
import { defineComponent as de, ref as p, computed as H, unref as c, onMounted as ue, openBlock as b, createBlock as T, withCtx as a, createElementVNode as g, createElementBlock as fe, renderSlot as pe, createCommentVNode as R, createVNode as s, toDisplayString as ge, h as C, toRaw as $ } from "vue";
|
|
3
|
+
import { PlusSquareOutlined as me, DeleteOutlined as he, ReloadOutlined as ye, MoreOutlined as ke } from "@vicons/antd";
|
|
4
|
+
const ve = { class: "text-lg font-medium" }, we = { id: "data-content" }, be = {
|
|
7
5
|
key: 0,
|
|
8
6
|
class: "rounded-lg bg-gray-50 flex flex-row gap-2 items-center justify-end p-4 mb-4"
|
|
9
|
-
},
|
|
7
|
+
}, Se = /* @__PURE__ */ de({
|
|
10
8
|
__name: "PTable",
|
|
11
9
|
props: {
|
|
12
10
|
title: {},
|
|
13
11
|
idField: { default: "id" },
|
|
14
|
-
item: { default: {} },
|
|
15
12
|
columns: {},
|
|
16
|
-
modalWidth: { default: 800 },
|
|
17
|
-
hiddenAdd: { type: Boolean, default: !1 },
|
|
18
|
-
hiddenEdit: { type: Boolean, default: !1 },
|
|
19
|
-
hiddenDelete: { type: Boolean, default: !1 },
|
|
20
13
|
onLoad: {},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
onSave: {},
|
|
25
|
-
onDelete: {}
|
|
14
|
+
onDelete: {},
|
|
15
|
+
onAdd: {},
|
|
16
|
+
onEdit: {}
|
|
26
17
|
},
|
|
27
|
-
setup(
|
|
28
|
-
const
|
|
18
|
+
setup(_, { expose: P }) {
|
|
19
|
+
const z = p(null), I = oe(), m = ne(), h = p(!1), y = p([]), k = p([]), d = p({
|
|
29
20
|
page: 1,
|
|
30
21
|
itemCount: 0,
|
|
31
22
|
pageSize: 10,
|
|
32
23
|
pageSizes: [10, 20, 30, 50],
|
|
33
24
|
showSizePicker: !0,
|
|
34
25
|
onChange: async (e) => {
|
|
35
|
-
|
|
26
|
+
d.value.page = e, await u();
|
|
36
27
|
},
|
|
37
28
|
onUpdatePageSize: async (e) => {
|
|
38
|
-
|
|
29
|
+
d.value.pageSize = e, await u();
|
|
39
30
|
}
|
|
40
|
-
}),
|
|
41
|
-
const t = (
|
|
42
|
-
const
|
|
43
|
-
return e && e.forEach((
|
|
44
|
-
|
|
45
|
-
label:
|
|
46
|
-
key:
|
|
47
|
-
props: { onClick: () =>
|
|
31
|
+
}), l = _, A = (e) => {
|
|
32
|
+
const t = (o) => {
|
|
33
|
+
const n = [];
|
|
34
|
+
return e && e.forEach((i) => {
|
|
35
|
+
i.key !== "edit" && i.key !== "delete" && n.push({
|
|
36
|
+
label: i.name,
|
|
37
|
+
key: i.key,
|
|
38
|
+
props: { onClick: () => i.action(o) }
|
|
48
39
|
});
|
|
49
|
-
}),
|
|
40
|
+
}), n;
|
|
50
41
|
};
|
|
51
42
|
return {
|
|
52
43
|
title: "操作",
|
|
53
44
|
key: "actions",
|
|
54
45
|
width: 100,
|
|
55
46
|
fixed: "right",
|
|
56
|
-
render: (
|
|
57
|
-
let
|
|
58
|
-
if (
|
|
47
|
+
render: (o) => {
|
|
48
|
+
let n = [];
|
|
49
|
+
if (l.onEdit && n.push({
|
|
59
50
|
label: "编辑",
|
|
60
51
|
key: "edit",
|
|
61
|
-
props: { onClick: () =>
|
|
62
|
-
}),
|
|
52
|
+
props: { onClick: async () => await l.onEdit(o) }
|
|
53
|
+
}), l.onDelete && n.push({
|
|
63
54
|
label: "删除",
|
|
64
55
|
key: "delete",
|
|
65
|
-
props: { onClick: () =>
|
|
66
|
-
}),
|
|
67
|
-
return
|
|
68
|
-
|
|
56
|
+
props: { onClick: () => q(o) }
|
|
57
|
+
}), n = [...n, ...t(o)], !(n.length <= 0))
|
|
58
|
+
return C(
|
|
59
|
+
re,
|
|
69
60
|
{
|
|
70
|
-
options:
|
|
61
|
+
options: n,
|
|
71
62
|
placement: "bottom-start"
|
|
72
63
|
},
|
|
73
64
|
{
|
|
74
|
-
default: () =>
|
|
75
|
-
|
|
65
|
+
default: () => C(
|
|
66
|
+
ce,
|
|
76
67
|
{ size: "small", type: "primary" },
|
|
77
|
-
{ default: () => ["操作",
|
|
68
|
+
{ default: () => ["操作", C(w, () => C(ke))] }
|
|
78
69
|
)
|
|
79
70
|
}
|
|
80
71
|
);
|
|
81
72
|
}
|
|
82
73
|
};
|
|
83
|
-
},
|
|
84
|
-
const e =
|
|
85
|
-
title:
|
|
86
|
-
key:
|
|
87
|
-
width:
|
|
88
|
-
fixed:
|
|
89
|
-
render:
|
|
90
|
-
ellipsis:
|
|
91
|
-
})), t =
|
|
92
|
-
(
|
|
74
|
+
}, M = H(() => {
|
|
75
|
+
const e = l.columns.filter((o) => o.key != "action").map((o) => ({
|
|
76
|
+
title: o.title,
|
|
77
|
+
key: o.key,
|
|
78
|
+
width: o.width,
|
|
79
|
+
fixed: o.fixed ?? !1,
|
|
80
|
+
render: o.render,
|
|
81
|
+
ellipsis: o.ellipsis ? { tooltip: !0 } : !1
|
|
82
|
+
})), t = l.columns.reduce(
|
|
83
|
+
(o, n) => n.key === "action" ? n : o,
|
|
93
84
|
void 0
|
|
94
85
|
)?.action;
|
|
95
|
-
return t && t?.length > 0 ||
|
|
86
|
+
return t && t?.length > 0 || l.onEdit || l.onDelete ? [
|
|
96
87
|
{ type: "selection", fixed: "left" },
|
|
97
88
|
...e,
|
|
98
|
-
|
|
89
|
+
A(t)
|
|
99
90
|
] : [{ type: "selection", fixed: "left" }, ...e];
|
|
100
|
-
}),
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const e = R();
|
|
106
|
-
A(e);
|
|
107
|
-
}, A = (e) => {
|
|
108
|
-
e && e.length > 0 && J.warning({
|
|
91
|
+
}), V = async () => await u(), q = (e) => B([e]), W = () => {
|
|
92
|
+
const e = D();
|
|
93
|
+
B(e);
|
|
94
|
+
}, B = (e) => {
|
|
95
|
+
e && e.length > 0 && I.warning({
|
|
109
96
|
title: "警告",
|
|
110
97
|
content: "删除数据不可恢复, 确认删除吗?",
|
|
111
98
|
positiveText: "确定",
|
|
112
99
|
negativeText: "取消",
|
|
113
100
|
onPositiveClick: async () => {
|
|
114
|
-
if (
|
|
101
|
+
if (l.onDelete)
|
|
115
102
|
try {
|
|
116
|
-
await
|
|
103
|
+
await l.onDelete(e) ? (u(), m.success("删除成功")) : m.error("删除失败");
|
|
117
104
|
} catch (t) {
|
|
118
|
-
|
|
105
|
+
m.error(t.message);
|
|
119
106
|
}
|
|
120
107
|
}
|
|
121
108
|
});
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
g.value = ze(e), F(g.value, async () => {
|
|
126
|
-
o.onGet && (g.value = await o.onGet(e[o.idField])), Object.assign(o.item, g.value);
|
|
127
|
-
});
|
|
128
|
-
}, V = async () => {
|
|
129
|
-
if (o.onSave)
|
|
130
|
-
try {
|
|
131
|
-
x.value = !0, (h.value ? await o.onSave(void 0, y(o.item)) : await o.onSave(g.value[o.idField], y(o.item))) && (B(), await m());
|
|
132
|
-
} catch (e) {
|
|
133
|
-
w.error(e.message);
|
|
134
|
-
} finally {
|
|
135
|
-
x.value = !1;
|
|
136
|
-
}
|
|
137
|
-
}, F = async (e, t) => {
|
|
138
|
-
o.onOpenModal?.(e), await t?.(), e ? (h.value = !1, b.value = !0) : (b.value = !1, h.value = !0);
|
|
139
|
-
}, B = () => {
|
|
140
|
-
g.value = null, Re(o.item), Object.assign(o.item, { ...y(W.value) }), o.onCloseModal?.(o.item), h.value = !1, b.value = !1;
|
|
141
|
-
}, R = () => O.value ? E.value.filter((t) => O.value.includes(t.id)).map((t) => y(t)) : [], ae = () => R()[0], se = () => y(E.value), m = async () => {
|
|
142
|
-
if (!M.value) {
|
|
143
|
-
M.value = !0;
|
|
109
|
+
}, D = () => y.value ? k.value.filter((t) => y.value.includes(t.id)).map((t) => $(t)) : [], j = () => D()[0], F = () => $(k.value), u = async () => {
|
|
110
|
+
if (!h.value) {
|
|
111
|
+
h.value = !0;
|
|
144
112
|
try {
|
|
145
|
-
if (
|
|
146
|
-
var { data: e, total: t } = await
|
|
147
|
-
|
|
148
|
-
|
|
113
|
+
if (l.onLoad) {
|
|
114
|
+
var { data: e, total: t } = await l.onLoad(
|
|
115
|
+
d.value.page,
|
|
116
|
+
d.value.pageSize
|
|
149
117
|
);
|
|
150
|
-
|
|
118
|
+
k.value = e, d.value.itemCount = t;
|
|
151
119
|
}
|
|
152
|
-
} catch (
|
|
153
|
-
|
|
120
|
+
} catch (o) {
|
|
121
|
+
m.error(o.message);
|
|
154
122
|
} finally {
|
|
155
|
-
|
|
123
|
+
h.value = !1;
|
|
156
124
|
}
|
|
157
125
|
}
|
|
158
|
-
},
|
|
159
|
-
const e =
|
|
126
|
+
}, K = H(() => {
|
|
127
|
+
const e = c(z);
|
|
160
128
|
if (!e) return;
|
|
161
|
-
const t = e?.$el,
|
|
162
|
-
let
|
|
163
|
-
const
|
|
129
|
+
const t = e?.$el, o = t.querySelector(".n-data-table-thead "), { bottomIncludeBody: n } = X(o), i = 48;
|
|
130
|
+
let r = 12, v = 24;
|
|
131
|
+
const f = t.querySelector(
|
|
164
132
|
".n-data-table__pagination"
|
|
165
133
|
);
|
|
166
|
-
if (
|
|
167
|
-
const
|
|
168
|
-
|
|
134
|
+
if (f) {
|
|
135
|
+
const S = f.offsetHeight;
|
|
136
|
+
r += S || 0;
|
|
169
137
|
} else
|
|
170
|
-
|
|
171
|
-
return
|
|
172
|
-
}),
|
|
173
|
-
const t = document.documentElement,
|
|
174
|
-
left:
|
|
175
|
-
top:
|
|
176
|
-
width:
|
|
177
|
-
height:
|
|
178
|
-
} =
|
|
138
|
+
r += 28;
|
|
139
|
+
return n - (i + r + v);
|
|
140
|
+
}), U = (e) => !e || !e.getBoundingClientRect ? 0 : e.getBoundingClientRect(), X = (e) => {
|
|
141
|
+
const t = document.documentElement, o = t.scrollLeft, n = t.scrollTop, i = t.clientLeft, r = t.clientTop, v = window.pageXOffset, f = window.pageYOffset, L = U(e), {
|
|
142
|
+
left: S,
|
|
143
|
+
top: Y,
|
|
144
|
+
width: G,
|
|
145
|
+
height: J
|
|
146
|
+
} = L, Q = (v || o) - (i || 0), Z = (f || n) - (r || 0), ee = S + v, te = Y + f, x = ee - Q, E = te - Z, N = window.document.documentElement.clientWidth, O = window.document.documentElement.clientHeight;
|
|
179
147
|
return {
|
|
180
|
-
left:
|
|
181
|
-
top:
|
|
182
|
-
right:
|
|
183
|
-
bottom:
|
|
184
|
-
rightIncludeBody:
|
|
185
|
-
bottomIncludeBody:
|
|
148
|
+
left: x,
|
|
149
|
+
top: E,
|
|
150
|
+
right: N - G - x,
|
|
151
|
+
bottom: O - J - E,
|
|
152
|
+
rightIncludeBody: N - x,
|
|
153
|
+
bottomIncludeBody: O - E
|
|
186
154
|
};
|
|
187
|
-
}, ce = () => {
|
|
188
|
-
W.value = { ...y(o.item) };
|
|
189
155
|
};
|
|
190
|
-
return
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
getSelectedRows: R,
|
|
196
|
-
closeModal: B,
|
|
197
|
-
refreshData: m,
|
|
156
|
+
return ue(async () => await u()), P({
|
|
157
|
+
getData: F,
|
|
158
|
+
getSelectedRow: j,
|
|
159
|
+
getSelectedRows: D,
|
|
160
|
+
refreshData: u,
|
|
198
161
|
resetPage: () => {
|
|
199
|
-
|
|
162
|
+
d.value.page = 1;
|
|
200
163
|
}
|
|
201
164
|
}), (e, t) => {
|
|
202
|
-
const
|
|
203
|
-
return
|
|
204
|
-
header:
|
|
205
|
-
s(
|
|
165
|
+
const o = se, n = ie, i = ae;
|
|
166
|
+
return b(), T(c(le), { bordered: !1 }, {
|
|
167
|
+
header: a(() => [
|
|
168
|
+
s(n, {
|
|
206
169
|
justify: "space-between",
|
|
207
170
|
align: "center",
|
|
208
171
|
class: "w-full"
|
|
209
172
|
}, {
|
|
210
|
-
default:
|
|
211
|
-
|
|
212
|
-
s(
|
|
213
|
-
default:
|
|
214
|
-
|
|
173
|
+
default: a(() => [
|
|
174
|
+
g("span", ve, ge(_.title), 1),
|
|
175
|
+
s(n, null, {
|
|
176
|
+
default: a(() => [
|
|
177
|
+
l.onAdd ? (b(), T(o, {
|
|
215
178
|
key: 0,
|
|
216
179
|
trigger: "hover"
|
|
217
180
|
}, {
|
|
218
|
-
trigger:
|
|
219
|
-
s(
|
|
181
|
+
trigger: a(() => [
|
|
182
|
+
s(c(w), {
|
|
220
183
|
size: "18",
|
|
221
184
|
class: "mr-1 cursor-pointer hover:text-blue-600",
|
|
222
|
-
onClick:
|
|
185
|
+
onClick: l.onAdd
|
|
223
186
|
}, {
|
|
224
|
-
default:
|
|
225
|
-
s(
|
|
187
|
+
default: a(() => [
|
|
188
|
+
s(c(me))
|
|
226
189
|
]),
|
|
227
190
|
_: 1
|
|
228
|
-
})
|
|
191
|
+
}, 8, ["onClick"])
|
|
229
192
|
]),
|
|
230
|
-
default:
|
|
231
|
-
t[
|
|
193
|
+
default: a(() => [
|
|
194
|
+
t[1] || (t[1] = g("span", null, "新增", -1))
|
|
232
195
|
]),
|
|
233
196
|
_: 1
|
|
234
|
-
})),
|
|
235
|
-
|
|
197
|
+
})) : R("", !0),
|
|
198
|
+
l.onDelete ? (b(), T(o, {
|
|
236
199
|
key: 1,
|
|
237
200
|
trigger: "hover"
|
|
238
201
|
}, {
|
|
239
|
-
trigger:
|
|
240
|
-
s(
|
|
202
|
+
trigger: a(() => [
|
|
203
|
+
s(c(w), {
|
|
241
204
|
size: "18",
|
|
242
205
|
class: "mr-1 cursor-pointer hover:text-blue-600",
|
|
243
|
-
onClick:
|
|
206
|
+
onClick: W
|
|
244
207
|
}, {
|
|
245
|
-
default:
|
|
246
|
-
s(
|
|
208
|
+
default: a(() => [
|
|
209
|
+
s(c(he))
|
|
247
210
|
]),
|
|
248
211
|
_: 1
|
|
249
212
|
})
|
|
250
213
|
]),
|
|
251
|
-
default:
|
|
252
|
-
t[
|
|
214
|
+
default: a(() => [
|
|
215
|
+
t[2] || (t[2] = g("span", null, "删除", -1))
|
|
253
216
|
]),
|
|
254
217
|
_: 1
|
|
255
|
-
})),
|
|
256
|
-
s(
|
|
257
|
-
trigger:
|
|
258
|
-
s(
|
|
218
|
+
})) : R("", !0),
|
|
219
|
+
s(o, { trigger: "hover" }, {
|
|
220
|
+
trigger: a(() => [
|
|
221
|
+
s(c(w), {
|
|
259
222
|
size: "18",
|
|
260
223
|
class: "cursor-pointer hover:text-blue-600",
|
|
261
|
-
onClick:
|
|
224
|
+
onClick: V
|
|
262
225
|
}, {
|
|
263
|
-
default:
|
|
264
|
-
s(
|
|
226
|
+
default: a(() => [
|
|
227
|
+
s(c(ye))
|
|
265
228
|
]),
|
|
266
229
|
_: 1
|
|
267
230
|
})
|
|
268
231
|
]),
|
|
269
|
-
default:
|
|
270
|
-
t[
|
|
232
|
+
default: a(() => [
|
|
233
|
+
t[3] || (t[3] = g("span", null, "刷新", -1))
|
|
271
234
|
]),
|
|
272
235
|
_: 1
|
|
273
236
|
})
|
|
@@ -278,110 +241,26 @@ const Le = { class: "text-lg font-medium" }, _e = { id: "data-content" }, He = {
|
|
|
278
241
|
_: 1
|
|
279
242
|
})
|
|
280
243
|
]),
|
|
281
|
-
default:
|
|
282
|
-
|
|
283
|
-
e.$slots.toolbar ? (
|
|
284
|
-
|
|
285
|
-
])) :
|
|
286
|
-
s(
|
|
244
|
+
default: a(() => [
|
|
245
|
+
g("div", we, [
|
|
246
|
+
e.$slots.toolbar ? (b(), fe("div", be, [
|
|
247
|
+
pe(e.$slots, "toolbar")
|
|
248
|
+
])) : R("", !0),
|
|
249
|
+
s(i, {
|
|
287
250
|
remote: "",
|
|
288
251
|
ref_key: "$table",
|
|
289
|
-
ref:
|
|
290
|
-
"checked-row-keys":
|
|
291
|
-
"onUpdate:checkedRowKeys": t[0] || (t[0] = (
|
|
292
|
-
"max-height":
|
|
293
|
-
loading:
|
|
252
|
+
ref: z,
|
|
253
|
+
"checked-row-keys": y.value,
|
|
254
|
+
"onUpdate:checkedRowKeys": t[0] || (t[0] = (r) => y.value = r),
|
|
255
|
+
"max-height": K.value,
|
|
256
|
+
loading: h.value,
|
|
294
257
|
bordered: !1,
|
|
295
258
|
"single-line": !1,
|
|
296
|
-
columns:
|
|
297
|
-
data:
|
|
298
|
-
pagination:
|
|
299
|
-
"row-key": (
|
|
300
|
-
}, null, 8, ["checked-row-keys", "max-height", "loading", "columns", "data", "pagination", "row-key"])
|
|
301
|
-
e.$slots.addModal ? (v(), j("div", je, [
|
|
302
|
-
s(u, {
|
|
303
|
-
title: "新增",
|
|
304
|
-
preset: "card",
|
|
305
|
-
show: h.value,
|
|
306
|
-
"onUpdate:show": t[1] || (t[1] = (i) => h.value = i),
|
|
307
|
-
"header-class": "bg-gray-50",
|
|
308
|
-
closable: !1,
|
|
309
|
-
"close-on-esc": !1,
|
|
310
|
-
"mask-closable": !1,
|
|
311
|
-
draggable: !0,
|
|
312
|
-
style: X({ width: `${f.modalWidth}px` })
|
|
313
|
-
}, {
|
|
314
|
-
action: n(() => [
|
|
315
|
-
s(a, { justify: "end" }, {
|
|
316
|
-
default: n(() => [
|
|
317
|
-
s(d(C), {
|
|
318
|
-
type: "primary",
|
|
319
|
-
loading: x.value,
|
|
320
|
-
onClick: V
|
|
321
|
-
}, {
|
|
322
|
-
default: n(() => [...t[6] || (t[6] = [
|
|
323
|
-
$("保存", -1)
|
|
324
|
-
])]),
|
|
325
|
-
_: 1
|
|
326
|
-
}, 8, ["loading"]),
|
|
327
|
-
s(d(C), { onClick: B }, {
|
|
328
|
-
default: n(() => [...t[7] || (t[7] = [
|
|
329
|
-
$("取消", -1)
|
|
330
|
-
])]),
|
|
331
|
-
_: 1
|
|
332
|
-
})
|
|
333
|
-
]),
|
|
334
|
-
_: 1
|
|
335
|
-
})
|
|
336
|
-
]),
|
|
337
|
-
default: n(() => [
|
|
338
|
-
I(e.$slots, "addModal")
|
|
339
|
-
]),
|
|
340
|
-
_: 3
|
|
341
|
-
}, 8, ["show", "style"])
|
|
342
|
-
])) : D("", !0),
|
|
343
|
-
e.$slots.editModal ? (v(), j("div", Ie, [
|
|
344
|
-
s(u, {
|
|
345
|
-
title: "编辑",
|
|
346
|
-
show: b.value,
|
|
347
|
-
"onUpdate:show": t[2] || (t[2] = (i) => b.value = i),
|
|
348
|
-
preset: "card",
|
|
349
|
-
"header-class": "bg-gray-50",
|
|
350
|
-
closable: !1,
|
|
351
|
-
"close-on-esc": !1,
|
|
352
|
-
"mask-closable": !1,
|
|
353
|
-
draggable: !0,
|
|
354
|
-
style: X({ width: `${f.modalWidth}px` })
|
|
355
|
-
}, {
|
|
356
|
-
action: n(() => [
|
|
357
|
-
s(a, { justify: "end" }, {
|
|
358
|
-
default: n(() => [
|
|
359
|
-
s(d(C), {
|
|
360
|
-
type: "primary",
|
|
361
|
-
loading: x.value,
|
|
362
|
-
onClick: V
|
|
363
|
-
}, {
|
|
364
|
-
default: n(() => [...t[8] || (t[8] = [
|
|
365
|
-
$("保存", -1)
|
|
366
|
-
])]),
|
|
367
|
-
_: 1
|
|
368
|
-
}, 8, ["loading"]),
|
|
369
|
-
s(d(C), { onClick: B }, {
|
|
370
|
-
default: n(() => [...t[9] || (t[9] = [
|
|
371
|
-
$("取消", -1)
|
|
372
|
-
])]),
|
|
373
|
-
_: 1
|
|
374
|
-
})
|
|
375
|
-
]),
|
|
376
|
-
_: 1
|
|
377
|
-
})
|
|
378
|
-
]),
|
|
379
|
-
default: n(() => [
|
|
380
|
-
I(e.$slots, "editModal")
|
|
381
|
-
]),
|
|
382
|
-
_: 3
|
|
383
|
-
}, 8, ["show", "style"])
|
|
384
|
-
])) : D("", !0)
|
|
259
|
+
columns: M.value,
|
|
260
|
+
data: k.value,
|
|
261
|
+
pagination: d.value,
|
|
262
|
+
"row-key": (r) => r[_.idField]
|
|
263
|
+
}, null, 8, ["checked-row-keys", "max-height", "loading", "columns", "data", "pagination", "row-key"])
|
|
385
264
|
])
|
|
386
265
|
]),
|
|
387
266
|
_: 3
|
|
@@ -390,5 +269,5 @@ const Le = { class: "text-lg font-medium" }, _e = { id: "data-content" }, He = {
|
|
|
390
269
|
}
|
|
391
270
|
});
|
|
392
271
|
export {
|
|
393
|
-
|
|
272
|
+
Se as default
|
|
394
273
|
};
|
package/es/table/index.d.ts
CHANGED
|
@@ -4,16 +4,10 @@ export declare const PTablePlugin: {
|
|
|
4
4
|
refreshData: () => Promise<void>;
|
|
5
5
|
getData: <T>() => T[];
|
|
6
6
|
getSelectedRows: <T>() => T[];
|
|
7
|
-
closeModal: () => void;
|
|
8
7
|
resetPage: () => void;
|
|
9
8
|
getSelectedRow: <T>() => T;
|
|
10
9
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').PublicProps, {
|
|
11
10
|
idField: string;
|
|
12
|
-
item: any;
|
|
13
|
-
modalWidth: number;
|
|
14
|
-
hiddenAdd: boolean;
|
|
15
|
-
hiddenEdit: boolean;
|
|
16
|
-
hiddenDelete: boolean;
|
|
17
11
|
}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {
|
|
18
12
|
$table: unknown;
|
|
19
13
|
}, any, import('vue').ComponentProvideOptions, {
|
|
@@ -27,16 +21,10 @@ export declare const PTablePlugin: {
|
|
|
27
21
|
refreshData: () => Promise<void>;
|
|
28
22
|
getData: <T>() => T[];
|
|
29
23
|
getSelectedRows: <T>() => T[];
|
|
30
|
-
closeModal: () => void;
|
|
31
24
|
resetPage: () => void;
|
|
32
25
|
getSelectedRow: <T>() => T;
|
|
33
26
|
}, {}, {}, {}, {
|
|
34
27
|
idField: string;
|
|
35
|
-
item: any;
|
|
36
|
-
modalWidth: number;
|
|
37
|
-
hiddenAdd: boolean;
|
|
38
|
-
hiddenEdit: boolean;
|
|
39
|
-
hiddenDelete: boolean;
|
|
40
28
|
}>;
|
|
41
29
|
__isFragment?: never;
|
|
42
30
|
__isTeleport?: never;
|
|
@@ -45,20 +33,12 @@ export declare const PTablePlugin: {
|
|
|
45
33
|
refreshData: () => Promise<void>;
|
|
46
34
|
getData: <T>() => T[];
|
|
47
35
|
getSelectedRows: <T>() => T[];
|
|
48
|
-
closeModal: () => void;
|
|
49
36
|
resetPage: () => void;
|
|
50
37
|
getSelectedRow: <T>() => T;
|
|
51
38
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {
|
|
52
39
|
idField: string;
|
|
53
|
-
item: any;
|
|
54
|
-
modalWidth: number;
|
|
55
|
-
hiddenAdd: boolean;
|
|
56
|
-
hiddenEdit: boolean;
|
|
57
|
-
hiddenDelete: boolean;
|
|
58
40
|
}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
59
41
|
$slots: {
|
|
60
42
|
toolbar?(_: {}): any;
|
|
61
|
-
addModal?(_: {}): any;
|
|
62
|
-
editModal?(_: {}): any;
|
|
63
43
|
};
|
|
64
44
|
}) & import('vue').Plugin;
|
package/es/table/typing.d.ts
CHANGED
|
@@ -17,27 +17,19 @@ export type DataTableColumnDefine = {
|
|
|
17
17
|
export type DataTableProps = {
|
|
18
18
|
title?: string;
|
|
19
19
|
idField?: string;
|
|
20
|
-
item?: any;
|
|
21
20
|
columns: DataTableColumnDefine[];
|
|
22
|
-
modalWidth?: number;
|
|
23
|
-
hiddenAdd?: boolean;
|
|
24
|
-
hiddenEdit?: boolean;
|
|
25
|
-
hiddenDelete?: boolean;
|
|
26
21
|
onLoad: (page: number, pageSize: number) => Promise<{
|
|
27
22
|
data: any[];
|
|
28
23
|
total: number;
|
|
29
24
|
}>;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
onSave?: (id?: string | number, row?: any) => Promise<boolean> | boolean;
|
|
34
|
-
onDelete?: (rows: any[]) => Promise<boolean> | boolean;
|
|
25
|
+
onDelete?: (rows: any[]) => Promise<boolean>;
|
|
26
|
+
onAdd?: () => Promise<void>;
|
|
27
|
+
onEdit?: (row: any) => Promise<void>;
|
|
35
28
|
};
|
|
36
29
|
export type DataTableMethods = {
|
|
37
30
|
refreshData: () => Promise<void>;
|
|
38
31
|
getData: <T>() => T[];
|
|
39
32
|
getSelectedRows: <T>() => T[];
|
|
40
|
-
closeModal: () => void;
|
|
41
33
|
resetPage: () => void;
|
|
42
34
|
getSelectedRow: <T>() => T;
|
|
43
35
|
};
|
package/lib/modal/PModal.d.ts
CHANGED
|
@@ -2113,7 +2113,6 @@ declare const __VLS_component: import('vue').DefineComponent<ModalProps, {
|
|
|
2113
2113
|
}>, {
|
|
2114
2114
|
width: number;
|
|
2115
2115
|
height: number;
|
|
2116
|
-
closable: boolean;
|
|
2117
2116
|
saveBtnText: string;
|
|
2118
2117
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
2119
2118
|
$modal: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('vue').ExtractPropTypes<{
|
package/lib/modal/PModal.vue.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("naive-ui"),e=require("vue"),m=e.defineComponent({__name:"PModal",props:{saveBtnText:{default:"保存"},
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("naive-ui"),e=require("vue"),m=e.defineComponent({__name:"PModal",props:{saveBtnText:{default:"保存"},title:{},width:{default:800},height:{default:500},visible:{type:Boolean},loading:{type:Boolean},onSave:{},onClose:{}},emits:["update:visible","update:loading"],setup(l,{expose:c,emit:u}){const i=s.useMessage(),a=l,o=u,f=async()=>{o("update:loading",!0);try{a.onSave&&await a.onSave()&&n()}catch(t){i.error(t.message)}finally{o("update:loading",!1)}},n=()=>{o("update:visible",!1),o("update:loading",!1)},g=async()=>{try{a.onClose?await a.onClose()&&n():n()}catch(t){i.error(t.message),o("update:loading",!1)}};return c({open:()=>{o("update:visible",!0),o("update:loading",!1)},close:()=>{o("update:visible",!1),o("update:loading",!1)}}),(t,d)=>{const p=s.NText,r=s.NButton,h=s.NSpace;return e.openBlock(),e.createBlock(e.unref(s.NModal),e.mergeProps({ref:"$modal",preset:"card"},t.$attrs,{"header-class":"bg-gray-50",show:a.visible,draggable:!0,closable:!1,"close-on-esc":!1,"mask-closable":!1,bordered:!1,style:{width:`${a.width}px`},onClose:n}),{header:e.withCtx(()=>[t.$slots.header?e.renderSlot(t.$slots,"header",{key:0}):a.title?(e.openBlock(),e.createBlock(p,{key:1},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(l.title),1)]),_:1})):e.createCommentVNode("",!0)]),"header-extra":e.withCtx(()=>[e.renderSlot(t.$slots,"header-extra")]),default:e.withCtx(()=>[e.createElementVNode("div",{class:"overflow-y-auto overflow-hidden mt-5",style:e.normalizeStyle({maxHeight:`${a.height}px`})},[e.renderSlot(t.$slots,"default")],4)]),footer:e.withCtx(()=>[e.renderSlot(t.$slots,"footer")]),action:e.withCtx(()=>[e.createVNode(h,{justify:"end"},{default:e.withCtx(()=>[e.createVNode(r,{type:"primary",loading:l.loading,onClick:f},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(l.saveBtnText),1)]),_:1},8,["loading"]),e.renderSlot(t.$slots,"action-extra",{loading:l.loading}),e.createVNode(r,{onClick:g,loading:l.loading},{default:e.withCtx(()=>[...d[0]||(d[0]=[e.createTextVNode("取消",-1)])]),_:1},8,["loading"])]),_:3})]),_:3},16,["show","style"])}}});exports.default=m;
|