@chewel611/naive-ui-plus 0.0.30 → 0.0.32
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 +539 -531
- package/dist/index.umd.cjs +1 -1
- package/es/modal/PModal.d.ts +3 -0
- package/es/modal/PModal.vue.js +47 -42
- package/es/modal/index.d.ts +9 -0
- package/es/modal/typing.d.ts +3 -0
- package/es/page/PPage.vue.js +20 -20
- package/es/table/PTable.vue.js +111 -108
- package/es/table/typing.d.ts +2 -2
- package/lib/modal/PModal.d.ts +3 -0
- package/lib/modal/PModal.vue.cjs +1 -1
- package/lib/modal/index.d.ts +9 -0
- package/lib/modal/typing.d.ts +3 -0
- package/lib/page/PPage.vue.cjs +1 -1
- package/lib/table/PTable.vue.cjs +1 -1
- package/lib/table/typing.d.ts +2 -2
- package/package.json +1 -1
package/es/table/PTable.vue.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { useDialog as
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import { PlusSquareOutlined as
|
|
4
|
-
const
|
|
1
|
+
import { useDialog as ne, useMessage as le, NCard as ae, NDataTable as ie, NSpace as se, NTooltip as re, NIcon as f, NDropdown as ce, NButton as de } from "naive-ui";
|
|
2
|
+
import { defineComponent as ue, ref as m, computed as H, unref as d, onMounted as fe, openBlock as C, createBlock as T, withCtx as i, createElementVNode as h, createElementBlock as pe, renderSlot as ge, createCommentVNode as O, createVNode as s, toDisplayString as me, h as r, toRaw as $ } from "vue";
|
|
3
|
+
import { PlusSquareOutlined as he, DeleteOutlined as P, ReloadOutlined as ye, MoreOutlined as ke, EditOutlined as ve } from "@vicons/antd";
|
|
4
|
+
const we = { class: "text-lg font-medium" }, be = { id: "data-content" }, Ce = {
|
|
5
5
|
key: 0,
|
|
6
6
|
class: "rounded-lg bg-gray-50 flex flex-row gap-2 items-center justify-end p-4 mb-4"
|
|
7
|
-
},
|
|
7
|
+
}, xe = /* @__PURE__ */ ue({
|
|
8
8
|
__name: "PTable",
|
|
9
9
|
props: {
|
|
10
10
|
title: {},
|
|
@@ -15,27 +15,28 @@ const ve = { class: "text-lg font-medium" }, we = { id: "data-content" }, be = {
|
|
|
15
15
|
onAdd: {},
|
|
16
16
|
onEdit: {}
|
|
17
17
|
},
|
|
18
|
-
setup(_, { expose:
|
|
19
|
-
const
|
|
18
|
+
setup(_, { expose: I }) {
|
|
19
|
+
const R = m(null), A = ne(), y = le(), k = m(!1), v = m([]), w = m([]), u = m({
|
|
20
20
|
page: 1,
|
|
21
21
|
itemCount: 0,
|
|
22
22
|
pageSize: 10,
|
|
23
23
|
pageSizes: [10, 20, 30, 50],
|
|
24
24
|
showSizePicker: !0,
|
|
25
25
|
onChange: async (e) => {
|
|
26
|
-
|
|
26
|
+
u.value.page = e, await p();
|
|
27
27
|
},
|
|
28
28
|
onUpdatePageSize: async (e) => {
|
|
29
|
-
|
|
29
|
+
u.value.pageSize = e, await p();
|
|
30
30
|
}
|
|
31
|
-
}), l = _,
|
|
31
|
+
}), l = _, M = (e) => {
|
|
32
32
|
const t = (o) => {
|
|
33
33
|
const n = [];
|
|
34
|
-
return e && e.forEach((
|
|
35
|
-
|
|
36
|
-
label:
|
|
37
|
-
key:
|
|
38
|
-
|
|
34
|
+
return e && e.forEach((a) => {
|
|
35
|
+
a.key !== "edit" && a.key !== "delete" && n.push({
|
|
36
|
+
label: a.name,
|
|
37
|
+
key: a.key,
|
|
38
|
+
icon: a.icon && (() => r(f, null, { default: () => r(a.icon) })),
|
|
39
|
+
props: { onClick: () => a.action(o) }
|
|
39
40
|
});
|
|
40
41
|
}), n;
|
|
41
42
|
};
|
|
@@ -49,29 +50,31 @@ const ve = { class: "text-lg font-medium" }, we = { id: "data-content" }, be = {
|
|
|
49
50
|
if (l.onEdit && n.push({
|
|
50
51
|
label: "编辑",
|
|
51
52
|
key: "edit",
|
|
53
|
+
icon: () => r(f, null, { default: () => r(ve) }),
|
|
52
54
|
props: { onClick: async () => await l.onEdit(o) }
|
|
53
55
|
}), l.onDelete && n.push({
|
|
54
56
|
label: "删除",
|
|
55
57
|
key: "delete",
|
|
56
|
-
|
|
58
|
+
icon: () => r(f, null, { default: () => r(P) }),
|
|
59
|
+
props: { onClick: () => W(o) }
|
|
57
60
|
}), n = [...n, ...t(o)], !(n.length <= 0))
|
|
58
|
-
return
|
|
59
|
-
|
|
61
|
+
return r(
|
|
62
|
+
ce,
|
|
60
63
|
{
|
|
61
64
|
options: n,
|
|
62
65
|
placement: "bottom-start"
|
|
63
66
|
},
|
|
64
67
|
{
|
|
65
|
-
default: () =>
|
|
66
|
-
|
|
68
|
+
default: () => r(
|
|
69
|
+
de,
|
|
67
70
|
{ size: "small", type: "primary" },
|
|
68
|
-
{ default: () => ["操作",
|
|
71
|
+
{ default: () => ["操作", r(f, () => r(ke))] }
|
|
69
72
|
)
|
|
70
73
|
}
|
|
71
74
|
);
|
|
72
75
|
}
|
|
73
76
|
};
|
|
74
|
-
},
|
|
77
|
+
}, V = H(() => {
|
|
75
78
|
const e = l.columns.filter((o) => o.key != "action").map((o) => ({
|
|
76
79
|
title: o.title,
|
|
77
80
|
key: o.key,
|
|
@@ -86,13 +89,13 @@ const ve = { class: "text-lg font-medium" }, we = { id: "data-content" }, be = {
|
|
|
86
89
|
return t && t?.length > 0 || l.onEdit || l.onDelete ? [
|
|
87
90
|
{ type: "selection", fixed: "left" },
|
|
88
91
|
...e,
|
|
89
|
-
|
|
92
|
+
M(t)
|
|
90
93
|
] : [{ type: "selection", fixed: "left" }, ...e];
|
|
91
|
-
}),
|
|
94
|
+
}), q = async () => await p(), W = (e) => z([e]), j = () => {
|
|
92
95
|
const e = D();
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
e && e.length > 0 &&
|
|
96
|
+
z(e);
|
|
97
|
+
}, z = (e) => {
|
|
98
|
+
e && e.length > 0 && A.warning({
|
|
96
99
|
title: "警告",
|
|
97
100
|
content: "删除数据不可恢复, 确认删除吗?",
|
|
98
101
|
positiveText: "确定",
|
|
@@ -100,137 +103,137 @@ const ve = { class: "text-lg font-medium" }, we = { id: "data-content" }, be = {
|
|
|
100
103
|
onPositiveClick: async () => {
|
|
101
104
|
if (l.onDelete)
|
|
102
105
|
try {
|
|
103
|
-
await l.onDelete(e) ? (
|
|
106
|
+
await l.onDelete(e) ? (p(), y.success("删除成功")) : y.error("删除失败");
|
|
104
107
|
} catch (t) {
|
|
105
|
-
|
|
108
|
+
y.error(t.message);
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
});
|
|
109
|
-
}, D = () =>
|
|
110
|
-
if (!
|
|
111
|
-
|
|
112
|
+
}, D = () => v.value ? w.value.filter((t) => v.value.includes(t.id)).map((t) => $(t)) : [], F = () => D()[0], K = () => $(w.value), p = async () => {
|
|
113
|
+
if (!k.value) {
|
|
114
|
+
k.value = !0;
|
|
112
115
|
try {
|
|
113
116
|
if (l.onLoad) {
|
|
114
117
|
var { data: e, total: t } = await l.onLoad(
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
u.value.page,
|
|
119
|
+
u.value.pageSize
|
|
117
120
|
);
|
|
118
|
-
|
|
121
|
+
w.value = e, u.value.itemCount = t;
|
|
119
122
|
}
|
|
120
123
|
} catch (o) {
|
|
121
|
-
|
|
124
|
+
y.error(o.message);
|
|
122
125
|
} finally {
|
|
123
|
-
|
|
126
|
+
k.value = !1;
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
|
-
},
|
|
127
|
-
const e =
|
|
129
|
+
}, U = H(() => {
|
|
130
|
+
const e = d(R);
|
|
128
131
|
if (!e) return;
|
|
129
|
-
const t = e?.$el, o = t.querySelector(".n-data-table-thead "), { bottomIncludeBody: n } =
|
|
130
|
-
let
|
|
131
|
-
const
|
|
132
|
+
const t = e?.$el, o = t.querySelector(".n-data-table-thead "), { bottomIncludeBody: n } = Y(o), a = 48;
|
|
133
|
+
let c = 12, b = 24;
|
|
134
|
+
const g = t.querySelector(
|
|
132
135
|
".n-data-table__pagination"
|
|
133
136
|
);
|
|
134
|
-
if (
|
|
135
|
-
const S =
|
|
136
|
-
|
|
137
|
+
if (g) {
|
|
138
|
+
const S = g.offsetHeight;
|
|
139
|
+
c += S || 0;
|
|
137
140
|
} else
|
|
138
|
-
|
|
139
|
-
return n - (
|
|
140
|
-
}),
|
|
141
|
-
const t = document.documentElement, o = t.scrollLeft, n = t.scrollTop,
|
|
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), {
|
|
142
145
|
left: S,
|
|
143
|
-
top:
|
|
144
|
-
width:
|
|
145
|
-
height:
|
|
146
|
-
} =
|
|
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;
|
|
147
150
|
return {
|
|
148
151
|
left: x,
|
|
149
152
|
top: E,
|
|
150
|
-
right:
|
|
151
|
-
bottom:
|
|
152
|
-
rightIncludeBody:
|
|
153
|
-
bottomIncludeBody:
|
|
153
|
+
right: L - J - x,
|
|
154
|
+
bottom: N - Q - E,
|
|
155
|
+
rightIncludeBody: L - x,
|
|
156
|
+
bottomIncludeBody: N - E
|
|
154
157
|
};
|
|
155
158
|
};
|
|
156
|
-
return
|
|
157
|
-
getData:
|
|
158
|
-
getSelectedRow:
|
|
159
|
+
return fe(async () => await p()), I({
|
|
160
|
+
getData: K,
|
|
161
|
+
getSelectedRow: F,
|
|
159
162
|
getSelectedRows: D,
|
|
160
|
-
refreshData:
|
|
163
|
+
refreshData: p,
|
|
161
164
|
resetPage: () => {
|
|
162
|
-
|
|
165
|
+
u.value.page = 1;
|
|
163
166
|
}
|
|
164
167
|
}), (e, t) => {
|
|
165
|
-
const o =
|
|
166
|
-
return
|
|
167
|
-
header:
|
|
168
|
+
const o = re, n = se, a = ie;
|
|
169
|
+
return C(), T(d(ae), { bordered: !1 }, {
|
|
170
|
+
header: i(() => [
|
|
168
171
|
s(n, {
|
|
169
172
|
justify: "space-between",
|
|
170
173
|
align: "center",
|
|
171
174
|
class: "w-full"
|
|
172
175
|
}, {
|
|
173
|
-
default:
|
|
174
|
-
|
|
176
|
+
default: i(() => [
|
|
177
|
+
h("span", we, me(_.title), 1),
|
|
175
178
|
s(n, null, {
|
|
176
|
-
default:
|
|
177
|
-
l.onAdd ? (
|
|
179
|
+
default: i(() => [
|
|
180
|
+
l.onAdd ? (C(), T(o, {
|
|
178
181
|
key: 0,
|
|
179
182
|
trigger: "hover"
|
|
180
183
|
}, {
|
|
181
|
-
trigger:
|
|
182
|
-
s(
|
|
184
|
+
trigger: i(() => [
|
|
185
|
+
s(d(f), {
|
|
183
186
|
size: "18",
|
|
184
187
|
class: "mr-1 cursor-pointer hover:text-blue-600",
|
|
185
188
|
onClick: l.onAdd
|
|
186
189
|
}, {
|
|
187
|
-
default:
|
|
188
|
-
s(
|
|
190
|
+
default: i(() => [
|
|
191
|
+
s(d(he))
|
|
189
192
|
]),
|
|
190
193
|
_: 1
|
|
191
194
|
}, 8, ["onClick"])
|
|
192
195
|
]),
|
|
193
|
-
default:
|
|
194
|
-
t[1] || (t[1] =
|
|
196
|
+
default: i(() => [
|
|
197
|
+
t[1] || (t[1] = h("span", null, "新增", -1))
|
|
195
198
|
]),
|
|
196
199
|
_: 1
|
|
197
|
-
})) :
|
|
198
|
-
l.onDelete ? (
|
|
200
|
+
})) : O("", !0),
|
|
201
|
+
l.onDelete ? (C(), T(o, {
|
|
199
202
|
key: 1,
|
|
200
203
|
trigger: "hover"
|
|
201
204
|
}, {
|
|
202
|
-
trigger:
|
|
203
|
-
s(
|
|
205
|
+
trigger: i(() => [
|
|
206
|
+
s(d(f), {
|
|
204
207
|
size: "18",
|
|
205
208
|
class: "mr-1 cursor-pointer hover:text-blue-600",
|
|
206
|
-
onClick:
|
|
209
|
+
onClick: j
|
|
207
210
|
}, {
|
|
208
|
-
default:
|
|
209
|
-
s(
|
|
211
|
+
default: i(() => [
|
|
212
|
+
s(d(P))
|
|
210
213
|
]),
|
|
211
214
|
_: 1
|
|
212
215
|
})
|
|
213
216
|
]),
|
|
214
|
-
default:
|
|
215
|
-
t[2] || (t[2] =
|
|
217
|
+
default: i(() => [
|
|
218
|
+
t[2] || (t[2] = h("span", null, "删除", -1))
|
|
216
219
|
]),
|
|
217
220
|
_: 1
|
|
218
|
-
})) :
|
|
221
|
+
})) : O("", !0),
|
|
219
222
|
s(o, { trigger: "hover" }, {
|
|
220
|
-
trigger:
|
|
221
|
-
s(
|
|
223
|
+
trigger: i(() => [
|
|
224
|
+
s(d(f), {
|
|
222
225
|
size: "18",
|
|
223
226
|
class: "cursor-pointer hover:text-blue-600",
|
|
224
|
-
onClick:
|
|
227
|
+
onClick: q
|
|
225
228
|
}, {
|
|
226
|
-
default:
|
|
227
|
-
s(
|
|
229
|
+
default: i(() => [
|
|
230
|
+
s(d(ye))
|
|
228
231
|
]),
|
|
229
232
|
_: 1
|
|
230
233
|
})
|
|
231
234
|
]),
|
|
232
|
-
default:
|
|
233
|
-
t[3] || (t[3] =
|
|
235
|
+
default: i(() => [
|
|
236
|
+
t[3] || (t[3] = h("span", null, "刷新", -1))
|
|
234
237
|
]),
|
|
235
238
|
_: 1
|
|
236
239
|
})
|
|
@@ -241,25 +244,25 @@ const ve = { class: "text-lg font-medium" }, we = { id: "data-content" }, be = {
|
|
|
241
244
|
_: 1
|
|
242
245
|
})
|
|
243
246
|
]),
|
|
244
|
-
default:
|
|
245
|
-
|
|
246
|
-
e.$slots.toolbar ? (
|
|
247
|
-
|
|
248
|
-
])) :
|
|
249
|
-
s(
|
|
247
|
+
default: i(() => [
|
|
248
|
+
h("div", be, [
|
|
249
|
+
e.$slots.toolbar ? (C(), pe("div", Ce, [
|
|
250
|
+
ge(e.$slots, "toolbar")
|
|
251
|
+
])) : O("", !0),
|
|
252
|
+
s(a, {
|
|
250
253
|
remote: "",
|
|
251
254
|
ref_key: "$table",
|
|
252
|
-
ref:
|
|
253
|
-
"checked-row-keys":
|
|
254
|
-
"onUpdate:checkedRowKeys": t[0] || (t[0] = (
|
|
255
|
-
"max-height":
|
|
256
|
-
loading:
|
|
255
|
+
ref: R,
|
|
256
|
+
"checked-row-keys": v.value,
|
|
257
|
+
"onUpdate:checkedRowKeys": t[0] || (t[0] = (c) => v.value = c),
|
|
258
|
+
"max-height": U.value,
|
|
259
|
+
loading: k.value,
|
|
257
260
|
bordered: !1,
|
|
258
261
|
"single-line": !1,
|
|
259
|
-
columns:
|
|
260
|
-
data:
|
|
261
|
-
pagination:
|
|
262
|
-
"row-key": (
|
|
262
|
+
columns: V.value,
|
|
263
|
+
data: w.value,
|
|
264
|
+
pagination: u.value,
|
|
265
|
+
"row-key": (c) => c[_.idField]
|
|
263
266
|
}, null, 8, ["checked-row-keys", "max-height", "loading", "columns", "data", "pagination", "row-key"])
|
|
264
267
|
])
|
|
265
268
|
]),
|
|
@@ -269,5 +272,5 @@ const ve = { class: "text-lg font-medium" }, we = { id: "data-content" }, be = {
|
|
|
269
272
|
}
|
|
270
273
|
});
|
|
271
274
|
export {
|
|
272
|
-
|
|
275
|
+
xe as default
|
|
273
276
|
};
|
package/es/table/typing.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { VNodeChild } from 'vue';
|
|
1
|
+
import { VNodeChild, Component } from 'vue';
|
|
2
2
|
export type DataTableColumnActionDefine = {
|
|
3
3
|
name: string;
|
|
4
4
|
key: string;
|
|
5
|
-
icon?:
|
|
5
|
+
icon?: Component;
|
|
6
6
|
action: (row: any) => void;
|
|
7
7
|
};
|
|
8
8
|
export type DataTableColumnDefine = {
|
package/lib/modal/PModal.d.ts
CHANGED
|
@@ -2114,6 +2114,9 @@ declare const __VLS_component: import('vue').DefineComponent<ModalProps, {
|
|
|
2114
2114
|
width: number;
|
|
2115
2115
|
height: number;
|
|
2116
2116
|
saveBtnText: string;
|
|
2117
|
+
cancelBtnText: string;
|
|
2118
|
+
hideCancelBtn: boolean;
|
|
2119
|
+
hideSaveBtn: boolean;
|
|
2117
2120
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
2118
2121
|
$modal: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('vue').ExtractPropTypes<{
|
|
2119
2122
|
draggable: import('vue').PropType<boolean | import('naive-ui/es/modal/src/interface').ModalDraggableOptions>;
|
package/lib/modal/PModal.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 n=require("naive-ui"),e=require("vue"),p=e.defineComponent({__name:"PModal",props:{saveBtnText:{default:"保存"},cancelBtnText:{default:"取消"},hideCancelBtn:{type:Boolean,default:!1},hideSaveBtn:{type:Boolean,default:!1},title:{},width:{default:800},height:{default:500},visible:{type:Boolean},loading:{type:Boolean},onSave:{},onClose:{}},emits:["update:visible","update:loading"],setup(l,{expose:r,emit:c}){const i=n.useMessage(),a=l,o=c,u=async()=>{o("update:loading",!0);try{a.onSave&&await a.onSave()&&s()}catch(t){i.error(t.message)}finally{o("update:loading",!1)}},s=()=>{o("update:visible",!1),o("update:loading",!1)},f=async()=>{try{a.onClose?await a.onClose()&&s():s()}catch(t){i.error(t.message),o("update:loading",!1)}};return r({open:()=>{o("update:visible",!0),o("update:loading",!1)},close:()=>{o("update:visible",!1),o("update:loading",!1)}}),(t,C)=>{const g=n.NText,d=n.NButton,h=n.NSpace;return e.openBlock(),e.createBlock(e.unref(n.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:s}),{header:e.withCtx(()=>[t.$slots.header?e.renderSlot(t.$slots,"header",{key:0}):a.title?(e.openBlock(),e.createBlock(g,{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(()=>[a.hideSaveBtn?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(d,{key:0,type:"primary",loading:l.loading,onClick:u},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(l.saveBtnText),1)]),_:1},8,["loading"])),e.renderSlot(t.$slots,"action-extra",{loading:l.loading}),a.hideCancelBtn?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(d,{key:1,onClick:f,loading:l.loading},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(l.cancelBtnText),1)]),_:1},8,["loading"]))]),_:3})]),_:3},16,["show","style"])}}});exports.default=p;
|
package/lib/modal/index.d.ts
CHANGED
|
@@ -13,6 +13,9 @@ export declare const PModalPlugin: {
|
|
|
13
13
|
width: number;
|
|
14
14
|
height: number;
|
|
15
15
|
saveBtnText: string;
|
|
16
|
+
cancelBtnText: string;
|
|
17
|
+
hideCancelBtn: boolean;
|
|
18
|
+
hideSaveBtn: boolean;
|
|
16
19
|
}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {
|
|
17
20
|
$modal: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('vue').ExtractPropTypes<{
|
|
18
21
|
draggable: import('vue').PropType<boolean | import('naive-ui/es/modal/src/interface').ModalDraggableOptions>;
|
|
@@ -2117,6 +2120,9 @@ export declare const PModalPlugin: {
|
|
|
2117
2120
|
width: number;
|
|
2118
2121
|
height: number;
|
|
2119
2122
|
saveBtnText: string;
|
|
2123
|
+
cancelBtnText: string;
|
|
2124
|
+
hideCancelBtn: boolean;
|
|
2125
|
+
hideSaveBtn: boolean;
|
|
2120
2126
|
}>;
|
|
2121
2127
|
__isFragment?: never;
|
|
2122
2128
|
__isTeleport?: never;
|
|
@@ -2134,6 +2140,9 @@ export declare const PModalPlugin: {
|
|
|
2134
2140
|
width: number;
|
|
2135
2141
|
height: number;
|
|
2136
2142
|
saveBtnText: string;
|
|
2143
|
+
cancelBtnText: string;
|
|
2144
|
+
hideCancelBtn: boolean;
|
|
2145
|
+
hideSaveBtn: boolean;
|
|
2137
2146
|
}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
2138
2147
|
$slots: {
|
|
2139
2148
|
header?(_: {}): any;
|
package/lib/modal/typing.d.ts
CHANGED
package/lib/page/PPage.vue.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("naive-ui"),e=require("vue"),i=require("@vicons/antd"),d={class:"border border-gray-100 rounded-lg"},u={class:"text-xl font-semibold text-gray-800"},p={class:"text-sm text-gray-500 mt-1"},
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("naive-ui"),e=require("vue"),i=require("@vicons/antd"),d={class:"border border-gray-100 rounded-lg"},u={class:"text-xl font-semibold text-gray-800"},p={class:"text-sm text-gray-500 mt-1"},f=e.defineComponent({__name:"PPage",props:{icon:{type:Object,required:!1,default:()=>i.AlertOutlined},title:{type:String,required:!0},subtitle:{type:String,required:!1}},setup(c){const t=c;return(o,m)=>{const a=n.NIcon,s=n.NAvatar,l=n.NSpace,r=n.NCard;return e.openBlock(),e.createElementBlock("div",d,[t.title?(e.openBlock(),e.createBlock(r,{key:0,class:"mb-4",bordered:!1,"content-class":"py-4"},{default:e.withCtx(()=>[e.createVNode(l,{align:"center",justify:"space-between"},{default:e.withCtx(()=>[e.createVNode(l,{align:"center",size:16},{default:e.withCtx(()=>[t.icon?(e.openBlock(),e.createBlock(s,{key:0,size:48,class:"bg-linear-to-br from-blue-500 to-indigo-600"},{default:e.withCtx(()=>[e.createVNode(a,{size:24,component:t.icon,color:"#fff"},null,8,["component"])]),_:1})):e.createCommentVNode("",!0),e.createElementVNode("div",null,[e.createElementVNode("div",u,e.toDisplayString(t.title),1),e.createElementVNode("div",p,e.toDisplayString(t.subtitle??t.title+"主页"),1)])]),_:1})]),_:1})]),_:1})):e.createCommentVNode("",!0),o.$slots.search?(e.openBlock(),e.createBlock(r,{key:1,class:"mb-4","content-class":"flex flex-row gap-2",bordered:!1},{default:e.withCtx(()=>[e.renderSlot(o.$slots,"search")]),_:3})):e.createCommentVNode("",!0),o.$slots.default?(e.openBlock(),e.createBlock(r,{key:2,"content-class":"flex flex-row gap-2 p-0!",bordered:!1},{default:e.withCtx(()=>[e.renderSlot(o.$slots,"default")]),_:3})):e.createCommentVNode("",!0)])}}});exports.default=f;
|
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 a=require("naive-ui"),e=require("vue"),u=require("@vicons/antd"),K={class:"text-lg font-medium"},X={id:"data-content"},Y={key:0,class:"rounded-lg bg-gray-50 flex flex-row gap-2 items-center justify-end p-4 mb-4"},G=e.defineComponent({__name:"PTable",props:{title:{},idField:{default:"id"},columns:{},onLoad:{},onDelete:{},onAdd:{},onEdit:{}},setup(y,{expose:S}){const N=e.ref(null),D=a.useDialog(),g=a.useMessage(),p=e.ref(!1),h=e.ref([]),m=e.ref([]),c=e.ref({page:1,itemCount:0,pageSize:10,pageSizes:[10,20,30,50],showSizePicker:!0,onChange:async t=>{c.value.page=t,await d()},onUpdatePageSize:async t=>{c.value.pageSize=t,await d()}}),i=y,B=t=>{const o=n=>{const l=[];return t&&t.forEach(r=>{r.key!=="edit"&&r.key!=="delete"&&l.push({label:r.name,key:r.key,icon:r.icon&&(()=>e.h(a.NIcon,null,{default:()=>e.h(r.icon)})),props:{onClick:()=>r.action(n)}})}),l};return{title:"操作",key:"actions",width:100,fixed:"right",render:n=>{let l=[];if(i.onEdit&&l.push({label:"编辑",key:"edit",icon:()=>e.h(a.NIcon,null,{default:()=>e.h(u.EditOutlined)}),props:{onClick:async()=>await i.onEdit(n)}}),i.onDelete&&l.push({label:"删除",key:"delete",icon:()=>e.h(a.NIcon,null,{default:()=>e.h(u.DeleteOutlined)}),props:{onClick:()=>R(n)}}),l=[...l,...o(n)],!(l.length<=0))return e.h(a.NDropdown,{options:l,placement:"bottom-start"},{default:()=>e.h(a.NButton,{size:"small",type:"primary"},{default:()=>["操作",e.h(a.NIcon,()=>e.h(u.MoreOutlined))]})})}}},O=e.computed(()=>{const t=i.columns.filter(n=>n.key!="action").map(n=>({title:n.title,key:n.key,width:n.width,fixed:n.fixed??!1,render:n.render,ellipsis:n.ellipsis?{tooltip:!0}:!1})),o=i.columns.reduce((n,l)=>l.key==="action"?l:n,void 0)?.action;return o&&o?.length>0||i.onEdit||i.onDelete?[{type:"selection",fixed:"left"},...t,B(o)]:[{type:"selection",fixed:"left"},...t]}),T=async()=>await d(),R=t=>x([t]),I=()=>{const t=k();x(t)},x=t=>{t&&t.length>0&&D.warning({title:"警告",content:"删除数据不可恢复, 确认删除吗?",positiveText:"确定",negativeText:"取消",onPositiveClick:async()=>{if(i.onDelete)try{await i.onDelete(t)?(d(),g.success("删除成功")):g.error("删除失败")}catch(o){g.error(o.message)}}})},k=()=>h.value?m.value.filter(o=>h.value.includes(o.id)).map(o=>e.toRaw(o)):[],z=()=>k()[0],L=()=>e.toRaw(m.value),d=async()=>{if(!p.value){p.value=!0;try{if(i.onLoad){var{data:t,total:o}=await i.onLoad(c.value.page,c.value.pageSize);m.value=t,c.value.itemCount=o}}catch(n){g.error(n.message)}finally{p.value=!1}}},H=e.computed(()=>{const t=e.unref(N);if(!t)return;const o=t?.$el,n=o.querySelector(".n-data-table-thead "),{bottomIncludeBody:l}=$(n),r=48;let s=12,w=24;const f=o.querySelector(".n-data-table__pagination");if(f){const v=f.offsetHeight;s+=v||0}else s+=28;return l-(r+s+w)}),P=t=>!t||!t.getBoundingClientRect?0:t.getBoundingClientRect(),$=t=>{const o=document.documentElement,n=o.scrollLeft,l=o.scrollTop,r=o.clientLeft,s=o.clientTop,w=window.pageXOffset,f=window.pageYOffset,_=P(t),{left:v,top:q,width:M,height:A}=_,j=(w||n)-(r||0),U=(f||l)-(s||0),W=v+w,F=q+f,C=W-j,b=F-U,V=window.document.documentElement.clientWidth,E=window.document.documentElement.clientHeight;return{left:C,top:b,right:V-M-C,bottom:E-A-b,rightIncludeBody:V-C,bottomIncludeBody:E-b}};return e.onMounted(async()=>await d()),S({getData:L,getSelectedRow:z,getSelectedRows:k,refreshData:d,resetPage:()=>{c.value.page=1}}),(t,o)=>{const n=a.NTooltip,l=a.NSpace,r=a.NDataTable;return e.openBlock(),e.createBlock(e.unref(a.NCard),{bordered:!1},{header:e.withCtx(()=>[e.createVNode(l,{justify:"space-between",align:"center",class:"w-full"},{default:e.withCtx(()=>[e.createElementVNode("span",K,e.toDisplayString(y.title),1),e.createVNode(l,null,{default:e.withCtx(()=>[i.onAdd?(e.openBlock(),e.createBlock(n,{key:0,trigger:"hover"},{trigger:e.withCtx(()=>[e.createVNode(e.unref(a.NIcon),{size:"18",class:"mr-1 cursor-pointer hover:text-blue-600",onClick:i.onAdd},{default:e.withCtx(()=>[e.createVNode(e.unref(u.PlusSquareOutlined))]),_:1},8,["onClick"])]),default:e.withCtx(()=>[o[1]||(o[1]=e.createElementVNode("span",null,"新增",-1))]),_:1})):e.createCommentVNode("",!0),i.onDelete?(e.openBlock(),e.createBlock(n,{key:1,trigger:"hover"},{trigger:e.withCtx(()=>[e.createVNode(e.unref(a.NIcon),{size:"18",class:"mr-1 cursor-pointer hover:text-blue-600",onClick:I},{default:e.withCtx(()=>[e.createVNode(e.unref(u.DeleteOutlined))]),_:1})]),default:e.withCtx(()=>[o[2]||(o[2]=e.createElementVNode("span",null,"删除",-1))]),_:1})):e.createCommentVNode("",!0),e.createVNode(n,{trigger:"hover"},{trigger:e.withCtx(()=>[e.createVNode(e.unref(a.NIcon),{size:"18",class:"cursor-pointer hover:text-blue-600",onClick:T},{default:e.withCtx(()=>[e.createVNode(e.unref(u.ReloadOutlined))]),_:1})]),default:e.withCtx(()=>[o[3]||(o[3]=e.createElementVNode("span",null,"刷新",-1))]),_:1})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createElementVNode("div",X,[t.$slots.toolbar?(e.openBlock(),e.createElementBlock("div",Y,[e.renderSlot(t.$slots,"toolbar")])):e.createCommentVNode("",!0),e.createVNode(r,{remote:"",ref_key:"$table",ref:N,"checked-row-keys":h.value,"onUpdate:checkedRowKeys":o[0]||(o[0]=s=>h.value=s),"max-height":H.value,loading:p.value,bordered:!1,"single-line":!1,columns:O.value,data:m.value,pagination:c.value,"row-key":s=>s[y.idField]},null,8,["checked-row-keys","max-height","loading","columns","data","pagination","row-key"])])]),_:3})}}});exports.default=G;
|
package/lib/table/typing.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { VNodeChild } from 'vue';
|
|
1
|
+
import { VNodeChild, Component } from 'vue';
|
|
2
2
|
export type DataTableColumnActionDefine = {
|
|
3
3
|
name: string;
|
|
4
4
|
key: string;
|
|
5
|
-
icon?:
|
|
5
|
+
icon?: Component;
|
|
6
6
|
action: (row: any) => void;
|
|
7
7
|
};
|
|
8
8
|
export type DataTableColumnDefine = {
|