vue3-smart-table 0.0.2 → 0.0.4
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/README.md +404 -42
- package/dist/vue3-smart-table.cjs.js +12 -2
- package/dist/vue3-smart-table.css +1 -1
- package/dist/vue3-smart-table.es.js +292 -224
- package/package.json +1 -1
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { ElImage as
|
|
3
|
-
|
|
1
|
+
import { defineComponent as O, ref as A, watch as F, resolveComponent as V, createBlock as _, openBlock as v, mergeProps as x, withKeys as R, withCtx as S, createElementBlock as I, Fragment as J, renderList as L, h as g, computed as z, toRefs as Q, createCommentVNode as Z, unref as s, createTextVNode as q, toDisplayString as T, renderSlot as Y, normalizeProps as ee, resolveDynamicComponent as te, normalizeClass as ne, normalizeStyle as le, resolveDirective as re, withDirectives as oe, createSlots as ie } from "vue";
|
|
2
|
+
import { ElImage as D, ElTag as se, ElMessage as $, ElButton as ae } from "element-plus";
|
|
3
|
+
function C(t, e) {
|
|
4
|
+
if (!(!t || !e))
|
|
5
|
+
return e.split(".").reduce((n, r) => n == null ? void 0 : n[r], t);
|
|
6
|
+
}
|
|
7
|
+
function U(t, e, n) {
|
|
8
|
+
if (!t || !e) return;
|
|
9
|
+
const r = e.split("."), o = r.pop(), l = r.reduce((i, c) => (i[c] || (i[c] = {}), i[c]), t);
|
|
10
|
+
l[o] = n;
|
|
11
|
+
}
|
|
12
|
+
const ce = /* @__PURE__ */ O({
|
|
4
13
|
__name: "input",
|
|
5
14
|
props: {
|
|
6
15
|
row: {},
|
|
@@ -9,29 +18,29 @@ const Q = /* @__PURE__ */ x({
|
|
|
9
18
|
onCellEnter: { type: Function }
|
|
10
19
|
},
|
|
11
20
|
setup(t) {
|
|
12
|
-
const e = t, n =
|
|
13
|
-
|
|
14
|
-
e.row
|
|
21
|
+
const e = t, n = A(C(e.row, e.col.key));
|
|
22
|
+
F(n, (l) => {
|
|
23
|
+
U(e.row, e.col.key, l);
|
|
15
24
|
});
|
|
16
25
|
const r = () => {
|
|
17
|
-
var
|
|
18
|
-
return (
|
|
19
|
-
},
|
|
20
|
-
var
|
|
21
|
-
return (
|
|
26
|
+
var l;
|
|
27
|
+
return (l = e.onCellBlur) == null ? void 0 : l.call(e, e.row, e.col);
|
|
28
|
+
}, o = () => {
|
|
29
|
+
var l;
|
|
30
|
+
return (l = e.onCellEnter) == null ? void 0 : l.call(e, e.row, e.col);
|
|
22
31
|
};
|
|
23
|
-
return (
|
|
24
|
-
const
|
|
25
|
-
return
|
|
32
|
+
return (l, i) => {
|
|
33
|
+
const c = V("el-input");
|
|
34
|
+
return v(), _(c, x({
|
|
26
35
|
modelValue: n.value,
|
|
27
|
-
"onUpdate:modelValue":
|
|
36
|
+
"onUpdate:modelValue": i[0] || (i[0] = (d) => n.value = d)
|
|
28
37
|
}, { placeholder: "", size: "small", clearable: !0, ...t.col.renderProps }, {
|
|
29
38
|
onBlur: r,
|
|
30
|
-
onKeyup:
|
|
39
|
+
onKeyup: R(o, ["enter"])
|
|
31
40
|
}), null, 16, ["modelValue"]);
|
|
32
41
|
};
|
|
33
42
|
}
|
|
34
|
-
}),
|
|
43
|
+
}), ue = /* @__PURE__ */ O({
|
|
35
44
|
__name: "inputNumber",
|
|
36
45
|
props: {
|
|
37
46
|
row: {},
|
|
@@ -41,30 +50,30 @@ const Q = /* @__PURE__ */ x({
|
|
|
41
50
|
onCellEnter: { type: Function }
|
|
42
51
|
},
|
|
43
52
|
setup(t) {
|
|
44
|
-
const e = t, n =
|
|
45
|
-
|
|
46
|
-
var
|
|
47
|
-
e.row
|
|
53
|
+
const e = t, n = A(C(e.row, e.col.key));
|
|
54
|
+
F(n, (l) => {
|
|
55
|
+
var i;
|
|
56
|
+
U(e.row, e.col.key, l), (i = e.onCellChange) == null || i.call(e, e.row, e.col);
|
|
48
57
|
});
|
|
49
58
|
const r = () => {
|
|
50
|
-
var
|
|
51
|
-
return (
|
|
52
|
-
},
|
|
53
|
-
var
|
|
54
|
-
return (
|
|
59
|
+
var l;
|
|
60
|
+
return (l = e.onCellBlur) == null ? void 0 : l.call(e, e.row, e.col);
|
|
61
|
+
}, o = () => {
|
|
62
|
+
var l;
|
|
63
|
+
return (l = e.onCellEnter) == null ? void 0 : l.call(e, e.row, e.col);
|
|
55
64
|
};
|
|
56
|
-
return (
|
|
57
|
-
const
|
|
58
|
-
return
|
|
65
|
+
return (l, i) => {
|
|
66
|
+
const c = V("el-input-number");
|
|
67
|
+
return v(), _(c, x({
|
|
59
68
|
modelValue: n.value,
|
|
60
|
-
"onUpdate:modelValue":
|
|
69
|
+
"onUpdate:modelValue": i[0] || (i[0] = (d) => n.value = d)
|
|
61
70
|
}, { min: 0, max: 99999, controls: !1, size: "small", ...t.col.renderProps }, {
|
|
62
71
|
onBlur: r,
|
|
63
|
-
onKeyup:
|
|
72
|
+
onKeyup: R(o, ["enter"])
|
|
64
73
|
}), null, 16, ["modelValue"]);
|
|
65
74
|
};
|
|
66
75
|
}
|
|
67
|
-
}),
|
|
76
|
+
}), de = /* @__PURE__ */ O({
|
|
68
77
|
__name: "select",
|
|
69
78
|
props: {
|
|
70
79
|
row: {},
|
|
@@ -74,37 +83,37 @@ const Q = /* @__PURE__ */ x({
|
|
|
74
83
|
onCellEnter: { type: Function }
|
|
75
84
|
},
|
|
76
85
|
setup(t) {
|
|
77
|
-
const e = t, n =
|
|
78
|
-
|
|
79
|
-
e.row
|
|
86
|
+
const e = t, n = A(C(e.row, e.col.key));
|
|
87
|
+
F(n, (i) => {
|
|
88
|
+
U(e.row, e.col.key, i);
|
|
80
89
|
});
|
|
81
90
|
const r = () => {
|
|
82
|
-
var
|
|
83
|
-
return (
|
|
91
|
+
var i;
|
|
92
|
+
return (i = e.onCellChange) == null ? void 0 : i.call(e, e.row, e.col);
|
|
93
|
+
}, o = () => {
|
|
94
|
+
var i;
|
|
95
|
+
return (i = e.onCellBlur) == null ? void 0 : i.call(e, e.row, e.col);
|
|
84
96
|
}, l = () => {
|
|
85
|
-
var
|
|
86
|
-
return (
|
|
87
|
-
}, c = () => {
|
|
88
|
-
var o;
|
|
89
|
-
return (o = e.onCellEnter) == null ? void 0 : o.call(e, e.row, e.col);
|
|
97
|
+
var i;
|
|
98
|
+
return (i = e.onCellEnter) == null ? void 0 : i.call(e, e.row, e.col);
|
|
90
99
|
};
|
|
91
|
-
return (
|
|
92
|
-
const
|
|
93
|
-
return
|
|
100
|
+
return (i, c) => {
|
|
101
|
+
const d = V("el-option"), y = V("el-select");
|
|
102
|
+
return v(), _(y, x({
|
|
94
103
|
modelValue: n.value,
|
|
95
|
-
"onUpdate:modelValue":
|
|
104
|
+
"onUpdate:modelValue": c[0] || (c[0] = (h) => n.value = h)
|
|
96
105
|
}, { placeholder: "请选择", size: "small", clearable: !0, ...t.col.renderProps }, {
|
|
97
106
|
onChange: r,
|
|
98
|
-
onBlur:
|
|
99
|
-
onKeyup:
|
|
107
|
+
onBlur: o,
|
|
108
|
+
onKeyup: R(l, ["enter"])
|
|
100
109
|
}), {
|
|
101
|
-
default:
|
|
110
|
+
default: S(() => {
|
|
102
111
|
var h;
|
|
103
112
|
return [
|
|
104
|
-
(
|
|
105
|
-
key:
|
|
106
|
-
label:
|
|
107
|
-
value:
|
|
113
|
+
(v(!0), I(J, null, L(((h = t.col.renderProps) == null ? void 0 : h.options) || [], (u) => (v(), _(d, {
|
|
114
|
+
key: u.value,
|
|
115
|
+
label: u.label,
|
|
116
|
+
value: u.value
|
|
108
117
|
}, null, 8, ["label", "value"]))), 128))
|
|
109
118
|
];
|
|
110
119
|
}),
|
|
@@ -112,53 +121,54 @@ const Q = /* @__PURE__ */ x({
|
|
|
112
121
|
}, 16, ["modelValue"]);
|
|
113
122
|
};
|
|
114
123
|
}
|
|
115
|
-
}),
|
|
124
|
+
}), N = (t) => O({
|
|
116
125
|
props: ["row", "col", "onCellChange", "onCellBlur", "onCellEnter", "onClick"],
|
|
117
126
|
setup(e) {
|
|
118
127
|
return () => g(t, e);
|
|
119
128
|
}
|
|
120
129
|
});
|
|
121
|
-
function
|
|
130
|
+
function ye(t) {
|
|
122
131
|
return typeof t.formatter == "function";
|
|
123
132
|
}
|
|
124
|
-
function
|
|
133
|
+
function me() {
|
|
125
134
|
return {
|
|
126
|
-
input:
|
|
127
|
-
"input-number":
|
|
128
|
-
select:
|
|
135
|
+
input: N(ce),
|
|
136
|
+
"input-number": N(ue),
|
|
137
|
+
select: N(de),
|
|
129
138
|
button: (t) => {
|
|
130
|
-
const e = t.col.renderProps || {};
|
|
131
|
-
return g(
|
|
139
|
+
const e = t.col.renderProps || {}, n = C(t.row, t.col.key);
|
|
140
|
+
return g(ae, {
|
|
132
141
|
type: e.type || "primary",
|
|
133
142
|
...e,
|
|
134
143
|
onClick: () => {
|
|
135
|
-
var
|
|
136
|
-
return (
|
|
144
|
+
var r;
|
|
145
|
+
return (r = t.onClick) == null ? void 0 : r.call(t, t.row, t.col);
|
|
137
146
|
}
|
|
138
|
-
}, () => e.label ||
|
|
147
|
+
}, () => e.label || n);
|
|
139
148
|
},
|
|
140
149
|
link: (t) => {
|
|
141
|
-
const e = t.col.renderProps || {};
|
|
150
|
+
const e = t.col.renderProps || {}, n = C(t.row, t.col.key);
|
|
142
151
|
return g("a", {
|
|
143
152
|
href: e.href || "#",
|
|
144
153
|
target: e.blank ? "_blank" : "_self",
|
|
145
154
|
style: e.style || "color:#409EFF;cursor:pointer;",
|
|
146
|
-
onClick: (
|
|
147
|
-
var
|
|
148
|
-
|
|
155
|
+
onClick: (r) => {
|
|
156
|
+
var o;
|
|
157
|
+
r.preventDefault(), (o = t.onClick) == null || o.call(t, t.row, t.col);
|
|
149
158
|
}
|
|
150
|
-
}, e.label ||
|
|
159
|
+
}, e.label || n);
|
|
151
160
|
},
|
|
152
161
|
html: (t) => {
|
|
153
|
-
var
|
|
162
|
+
var n;
|
|
163
|
+
const e = C(t.row, t.col.key);
|
|
154
164
|
return g("div", {
|
|
155
165
|
class: "line-clamp-2",
|
|
156
|
-
innerHTML:
|
|
157
|
-
...((
|
|
166
|
+
innerHTML: e ?? "",
|
|
167
|
+
...((n = t.col) == null ? void 0 : n.renderProps) || {}
|
|
158
168
|
});
|
|
159
169
|
},
|
|
160
170
|
copy: (t) => {
|
|
161
|
-
const e = t.row
|
|
171
|
+
const e = C(t.row, t.col.key) ?? "";
|
|
162
172
|
return g(
|
|
163
173
|
"div",
|
|
164
174
|
{
|
|
@@ -190,18 +200,18 @@ function ne() {
|
|
|
190
200
|
try {
|
|
191
201
|
if (navigator.clipboard && navigator.clipboard.writeText)
|
|
192
202
|
navigator.clipboard.writeText(e).then(() => {
|
|
193
|
-
|
|
203
|
+
$.success("复制成功");
|
|
194
204
|
}).catch(() => {
|
|
195
|
-
|
|
205
|
+
$.error("复制失败");
|
|
196
206
|
});
|
|
197
207
|
else {
|
|
198
208
|
const n = document.createElement("textarea");
|
|
199
209
|
n.value = e, n.style.position = "fixed", n.style.opacity = "0", document.body.appendChild(n), n.select();
|
|
200
210
|
const r = document.execCommand("copy");
|
|
201
|
-
document.body.removeChild(n), r ?
|
|
211
|
+
document.body.removeChild(n), r ? $.success("复制成功") : $.error("复制失败");
|
|
202
212
|
}
|
|
203
213
|
} catch {
|
|
204
|
-
|
|
214
|
+
$.error("复制失败");
|
|
205
215
|
}
|
|
206
216
|
}
|
|
207
217
|
},
|
|
@@ -212,39 +222,73 @@ function ne() {
|
|
|
212
222
|
);
|
|
213
223
|
},
|
|
214
224
|
img: (t) => {
|
|
215
|
-
var
|
|
216
|
-
const e = t.row
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
225
|
+
var i;
|
|
226
|
+
const e = C(t.row, t.col.key) ?? "", n = ((i = t.col) == null ? void 0 : i.renderProps) || {}, o = e ? Array.isArray(e) ? e.filter((c) => c && typeof c == "string") : [e] : [];
|
|
227
|
+
if (o.length === 0)
|
|
228
|
+
return n.placeholder || "";
|
|
229
|
+
const l = {
|
|
230
|
+
width: n.width || "80px",
|
|
231
|
+
height: n.height || "80px",
|
|
232
|
+
marginRight: o.length > 1 ? "4px" : "0",
|
|
233
|
+
...n.style || {}
|
|
234
|
+
};
|
|
235
|
+
return o.length === 1 ? g(D, {
|
|
236
|
+
src: o[0],
|
|
237
|
+
previewSrcList: n.previewSrcList || o,
|
|
238
|
+
fit: n.fit || "contain",
|
|
239
|
+
style: l,
|
|
222
240
|
...n
|
|
223
|
-
})
|
|
241
|
+
}) : (console.log(n.previewSrcList), g("div", {
|
|
242
|
+
style: "display: flex; align-items: center; position: relative"
|
|
243
|
+
}, [
|
|
244
|
+
// 显示第一张图片,点击可预览所有
|
|
245
|
+
g(D, {
|
|
246
|
+
src: o[0],
|
|
247
|
+
previewSrcList: n.previewSrcList || o,
|
|
248
|
+
fit: n.fit || "contain",
|
|
249
|
+
style: l,
|
|
250
|
+
...n
|
|
251
|
+
}),
|
|
252
|
+
// 如果图片数量大于1,显示剩余图片数量
|
|
253
|
+
o.length > 1 && g("span", {
|
|
254
|
+
style: `
|
|
255
|
+
margin-left: 8px;
|
|
256
|
+
font-size: 12px;
|
|
257
|
+
color: #666;
|
|
258
|
+
background: #f0f0f0;
|
|
259
|
+
padding: 2px 6px;
|
|
260
|
+
border-radius: 2px;
|
|
261
|
+
position: absolute;
|
|
262
|
+
top: 0;
|
|
263
|
+
right: 0;
|
|
264
|
+
`,
|
|
265
|
+
title: `共 ${o.length} 张图片`
|
|
266
|
+
}, `+${o.length - 1}`)
|
|
267
|
+
]));
|
|
224
268
|
},
|
|
225
269
|
dict: (t) => {
|
|
226
|
-
const e = t.row
|
|
270
|
+
const e = C(t.row, t.col.key) ?? "", n = t.col.renderProps || {}, r = n.options ?? [], o = n.showValue ?? !1;
|
|
227
271
|
if (e == null || e === "") return "";
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
{ key:
|
|
231
|
-
{ default: () =>
|
|
272
|
+
const l = Array.isArray(e) ? e.map(String) : [String(e)], i = r.filter((y) => l.includes(String(y.value))), c = l.filter((y) => !r.some((h) => String(h.value) === y)), d = i.map((y, h) => g(
|
|
273
|
+
se,
|
|
274
|
+
{ key: y.value, type: y.listClass, class: y.cssClass, disableTransitions: !0 },
|
|
275
|
+
{ default: () => y.label + " " }
|
|
232
276
|
));
|
|
233
|
-
return
|
|
277
|
+
return o && c.length > 0 && d.push(g("span", {}, c.join(" "))), g("div", {}, d);
|
|
234
278
|
},
|
|
235
279
|
map: (t) => {
|
|
236
280
|
var r;
|
|
237
|
-
const e = t.row
|
|
281
|
+
const e = C(t.row, t.col.key) ?? "", n = ((r = t.col.renderProps) == null ? void 0 : r.options) ?? {};
|
|
238
282
|
return e != null ? n[e] ?? "" : "";
|
|
239
283
|
},
|
|
240
284
|
formatter: (t) => {
|
|
241
|
-
var
|
|
242
|
-
const { col: e, row: n } = t, r =
|
|
243
|
-
return
|
|
285
|
+
var o;
|
|
286
|
+
const { col: e, row: n } = t, r = C(t.row, t.col.key) ?? "";
|
|
287
|
+
return ye(e) ? (o = e.formatter) == null ? void 0 : o.call(e, r, n) : r ?? "";
|
|
244
288
|
},
|
|
245
289
|
icon: (t) => {
|
|
246
|
-
const e = t.row
|
|
247
|
-
return e ? /^https?:\/\//.test(e) ? g(
|
|
290
|
+
const e = C(t.row, t.col.key) ?? "", n = t.col.renderProps || {};
|
|
291
|
+
return e ? /^https?:\/\//.test(e) ? g(D, {
|
|
248
292
|
src: e,
|
|
249
293
|
previewSrcList: [e],
|
|
250
294
|
fit: "contain",
|
|
@@ -263,178 +307,193 @@ function ne() {
|
|
|
263
307
|
}
|
|
264
308
|
};
|
|
265
309
|
}
|
|
266
|
-
function
|
|
267
|
-
const
|
|
268
|
-
if (!
|
|
269
|
-
const
|
|
310
|
+
function pe(t, e = 10, n = []) {
|
|
311
|
+
const o = "*:*:*", l = (a) => {
|
|
312
|
+
if (!a) return !0;
|
|
313
|
+
const p = Array.isArray(a) ? a : [a];
|
|
270
314
|
return n.some(
|
|
271
|
-
(
|
|
315
|
+
(f) => f === o || p.includes(f)
|
|
272
316
|
);
|
|
273
|
-
},
|
|
274
|
-
(
|
|
317
|
+
}, i = z(() => t.some((a) => l(a.permission))), c = z(() => t.filter((p) => l(p.permission)).slice(0, e).reduce(
|
|
318
|
+
(p, f) => p + (f.width ?? 60),
|
|
275
319
|
0
|
|
276
|
-
)),
|
|
277
|
-
(
|
|
320
|
+
)), d = (a, p) => l(a.permission) && (a.visible ? a.visible(p) : !0), y = (a) => t.filter((f) => d(f, a)).slice(0, e).reduce(
|
|
321
|
+
(f, B) => f + (B.width ?? 60),
|
|
278
322
|
0
|
|
279
323
|
);
|
|
280
324
|
return {
|
|
281
|
-
hasAnyButton:
|
|
282
|
-
optWidth:
|
|
283
|
-
hasAnyVisibleButton: (
|
|
284
|
-
(
|
|
325
|
+
hasAnyButton: i,
|
|
326
|
+
optWidth: c,
|
|
327
|
+
hasAnyVisibleButton: (a) => a != null && a.length ? a.some(
|
|
328
|
+
(p) => t.some((f) => d(f, p))
|
|
285
329
|
) : !1,
|
|
286
|
-
getMaxOptWidth: (
|
|
287
|
-
(
|
|
330
|
+
getMaxOptWidth: (a) => a != null && a.length ? a.reduce(
|
|
331
|
+
(p, f) => Math.max(p, y(f)),
|
|
288
332
|
0
|
|
289
|
-
) :
|
|
290
|
-
getVisibleButtons: (
|
|
333
|
+
) : c.value,
|
|
334
|
+
getVisibleButtons: (a) => t.filter((p) => d(p, a)).slice(0, e)
|
|
291
335
|
};
|
|
292
336
|
}
|
|
293
|
-
const
|
|
337
|
+
const fe = ["title"], ge = /* @__PURE__ */ O({
|
|
294
338
|
__name: "index",
|
|
295
339
|
props: {
|
|
296
340
|
col: { type: Object, required: !0 },
|
|
297
|
-
permissions: { type: Array, default: () => [] }
|
|
341
|
+
permissions: { type: Array, default: () => [] },
|
|
342
|
+
pagination: { type: Object, default: () => ({}) }
|
|
298
343
|
},
|
|
299
344
|
emits: ["cellBlur", "cellEnter", "cellChange", "cellClick"],
|
|
300
345
|
setup(t, { emit: e }) {
|
|
301
|
-
const n = t, r = e,
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
346
|
+
const n = t, r = e, o = (m) => {
|
|
347
|
+
var K, w;
|
|
348
|
+
const k = (K = n.pagination) == null ? void 0 : K.page, E = (w = n.pagination) == null ? void 0 : w.size;
|
|
349
|
+
return k && E ? (k - 1) * E + m + 1 : m + 1;
|
|
350
|
+
}, { col: l } = Q(n), i = (m, k) => r("cellChange", m, k), c = (m, k) => r("cellBlur", m, k), d = (m, k) => r("cellEnter", m, k), y = (m, k) => r("cellClick", m, k), h = me(), {
|
|
351
|
+
hasAnyButton: u,
|
|
352
|
+
hasAnyVisibleButton: b,
|
|
353
|
+
optWidth: a,
|
|
354
|
+
getMaxOptWidth: p,
|
|
355
|
+
getVisibleButtons: f
|
|
356
|
+
} = pe(
|
|
308
357
|
l.value.buttons || [],
|
|
309
358
|
l.value.maxbtn ?? 10,
|
|
310
359
|
n.permissions || []
|
|
311
|
-
),
|
|
312
|
-
function
|
|
313
|
-
return !(
|
|
360
|
+
), B = z(() => (l.value.buttons || []).length ? (l.value.__rows || []).length ? b(l.value.__rows || []) : u.value : !1), W = z(() => l.value.__rows ? p(l.value.__rows) : a.value);
|
|
361
|
+
function G(m) {
|
|
362
|
+
return !(m.type === "selection" || m.type === "index" || m.type === "operation" && !B.value || m.visible === !1);
|
|
314
363
|
}
|
|
315
|
-
return (
|
|
316
|
-
const
|
|
317
|
-
return
|
|
364
|
+
return (m, k) => {
|
|
365
|
+
const E = V("el-table-column"), K = V("el-button");
|
|
366
|
+
return s(l).type === "selection" ? (v(), _(E, x({
|
|
318
367
|
key: 0,
|
|
319
368
|
type: "selection"
|
|
320
|
-
},
|
|
369
|
+
}, s(l).columnProps), null, 16)) : s(l).type === "index" ? (v(), _(E, x({
|
|
321
370
|
key: 1,
|
|
322
371
|
type: "index",
|
|
323
|
-
label:
|
|
372
|
+
label: s(l).label || "#",
|
|
324
373
|
align: "center"
|
|
325
|
-
},
|
|
374
|
+
}, s(l).columnProps), {
|
|
375
|
+
default: S(({ $index: w }) => [
|
|
376
|
+
q(T(o(w)), 1)
|
|
377
|
+
]),
|
|
378
|
+
_: 1
|
|
379
|
+
}, 16, ["label"])) : s(l).type === "operation" && B.value ? (v(), _(E, x({
|
|
326
380
|
key: 2,
|
|
327
|
-
label:
|
|
381
|
+
label: s(l).label || "操作",
|
|
328
382
|
align: "center"
|
|
329
383
|
}, {
|
|
330
|
-
...
|
|
331
|
-
width:
|
|
384
|
+
...s(l).columnProps,
|
|
385
|
+
width: W.value
|
|
332
386
|
}), {
|
|
333
|
-
default:
|
|
334
|
-
(
|
|
335
|
-
key:
|
|
336
|
-
type:
|
|
387
|
+
default: S(({ row: w }) => [
|
|
388
|
+
(v(!0), I(J, null, L(s(f)(w), (P) => (v(), _(K, {
|
|
389
|
+
key: P.label,
|
|
390
|
+
type: P.type || "primary",
|
|
337
391
|
link: "",
|
|
338
|
-
onClick: (
|
|
392
|
+
onClick: (M) => P.action(w)
|
|
339
393
|
}, {
|
|
340
|
-
default:
|
|
341
|
-
|
|
394
|
+
default: S(() => [
|
|
395
|
+
q(T(P.label), 1)
|
|
342
396
|
]),
|
|
343
397
|
_: 2
|
|
344
398
|
}, 1032, ["type", "onClick"]))), 128))
|
|
345
399
|
]),
|
|
346
400
|
_: 1
|
|
347
|
-
}, 16, ["label"])) :
|
|
401
|
+
}, 16, ["label"])) : G(s(l)) ? (v(), _(E, x({
|
|
348
402
|
key: 3,
|
|
349
|
-
|
|
350
|
-
label: d(l).label,
|
|
403
|
+
label: s(l).label,
|
|
351
404
|
align: "center"
|
|
352
|
-
},
|
|
353
|
-
default:
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
405
|
+
}, s(l).columnProps || {}), {
|
|
406
|
+
default: S((w) => {
|
|
407
|
+
var P, M, j, H;
|
|
408
|
+
return [
|
|
409
|
+
s(l).render === "slot" && m.$slots[((P = s(l)) == null ? void 0 : P.slot) || s(l).key] ? Y(m.$slots, ((M = s(l)) == null ? void 0 : M.slot) || s(l).key, ee(x({ key: 0 }, w))) : s(l).render && s(h)[s(l).render] ? (v(), _(te(s(h)[s(l).render]), {
|
|
410
|
+
key: 1,
|
|
411
|
+
row: w.row,
|
|
412
|
+
col: s(l),
|
|
413
|
+
onCellChange: i,
|
|
414
|
+
onCellBlur: c,
|
|
415
|
+
onCellEnter: d,
|
|
416
|
+
onClick: y
|
|
417
|
+
}, null, 40, ["row", "col"])) : (v(), I("span", {
|
|
418
|
+
key: 2,
|
|
419
|
+
style: le(((j = s(l).renderProps) == null ? void 0 : j.style) || ""),
|
|
420
|
+
class: ne(((H = s(l).renderProps) == null ? void 0 : H.class) || ""),
|
|
421
|
+
title: s(C)(w.row, s(l).key)
|
|
422
|
+
}, T(s(C)(w.row, s(l).key)), 15, fe))
|
|
423
|
+
];
|
|
424
|
+
}),
|
|
425
|
+
_: 3
|
|
426
|
+
}, 16, ["label"])) : Z("", !0);
|
|
368
427
|
};
|
|
369
428
|
}
|
|
370
|
-
}),
|
|
371
|
-
function
|
|
372
|
-
return `${
|
|
429
|
+
}), he = "table_columns_";
|
|
430
|
+
function ve(t, e) {
|
|
431
|
+
return `${he}${t}_${e}`;
|
|
373
432
|
}
|
|
374
|
-
function
|
|
433
|
+
function X(t, e) {
|
|
375
434
|
if (!(e != null && e.length)) return t;
|
|
376
435
|
const n = new Map(
|
|
377
436
|
e.map((r) => [r.key, r])
|
|
378
437
|
);
|
|
379
438
|
return t.map((r) => {
|
|
380
|
-
const
|
|
381
|
-
return
|
|
439
|
+
const o = n.get(r.key);
|
|
440
|
+
return o ? {
|
|
382
441
|
...r,
|
|
383
|
-
visible: typeof
|
|
442
|
+
visible: typeof o.visible == "boolean" ? o.visible : r.visible
|
|
384
443
|
} : r;
|
|
385
444
|
});
|
|
386
445
|
}
|
|
387
|
-
function
|
|
446
|
+
function Ce(t, e) {
|
|
388
447
|
const {
|
|
389
448
|
pageKey: n,
|
|
390
449
|
userId: r,
|
|
391
|
-
storage:
|
|
392
|
-
} = e || {},
|
|
393
|
-
|
|
450
|
+
storage: o = localStorage
|
|
451
|
+
} = e || {}, i = r ? ve(r, n || "") : null, c = i ? o.getItem(i) : null, d = A(
|
|
452
|
+
X(
|
|
394
453
|
t,
|
|
395
|
-
|
|
454
|
+
c ? JSON.parse(c) : []
|
|
396
455
|
)
|
|
397
456
|
);
|
|
398
|
-
return
|
|
399
|
-
|
|
400
|
-
(
|
|
401
|
-
if (!
|
|
402
|
-
const h =
|
|
403
|
-
key:
|
|
404
|
-
visible:
|
|
405
|
-
columnOpts:
|
|
457
|
+
return F(
|
|
458
|
+
d,
|
|
459
|
+
(y) => {
|
|
460
|
+
if (!i) return;
|
|
461
|
+
const h = y.map((u) => ({
|
|
462
|
+
key: u.key,
|
|
463
|
+
visible: u.visible,
|
|
464
|
+
columnOpts: u.columnOpts
|
|
406
465
|
}));
|
|
407
|
-
|
|
408
|
-
|
|
466
|
+
o.setItem(
|
|
467
|
+
i,
|
|
409
468
|
JSON.stringify(h)
|
|
410
469
|
);
|
|
411
470
|
},
|
|
412
471
|
{ deep: !0 }
|
|
413
472
|
), {
|
|
414
473
|
/** 当前列配置(响应式) */
|
|
415
|
-
columns:
|
|
474
|
+
columns: d,
|
|
416
475
|
/**
|
|
417
476
|
* 主动设置列配置
|
|
418
477
|
* 常用于:列设置弹窗 / 拖拽排序完成
|
|
419
478
|
*/
|
|
420
|
-
setColumns(
|
|
421
|
-
|
|
479
|
+
setColumns(y) {
|
|
480
|
+
d.value = X(
|
|
422
481
|
t,
|
|
423
|
-
|
|
424
|
-
),
|
|
425
|
-
|
|
426
|
-
JSON.stringify(
|
|
482
|
+
y
|
|
483
|
+
), i && o.setItem(
|
|
484
|
+
i,
|
|
485
|
+
JSON.stringify(y)
|
|
427
486
|
);
|
|
428
487
|
},
|
|
429
488
|
/**
|
|
430
489
|
* 重置为默认列配置
|
|
431
490
|
*/
|
|
432
491
|
resetColumns() {
|
|
433
|
-
|
|
492
|
+
d.value = t, i && o.removeItem(i);
|
|
434
493
|
}
|
|
435
494
|
};
|
|
436
495
|
}
|
|
437
|
-
const
|
|
496
|
+
const be = /* @__PURE__ */ O({
|
|
438
497
|
__name: "index",
|
|
439
498
|
props: {
|
|
440
499
|
data: { type: Array, default: () => [] },
|
|
@@ -451,7 +510,8 @@ const ie = /* @__PURE__ */ x({
|
|
|
451
510
|
/** 当前用户标识(可选,用于列缓存) */
|
|
452
511
|
type: [String, Number],
|
|
453
512
|
default: ""
|
|
454
|
-
}
|
|
513
|
+
},
|
|
514
|
+
pagination: { type: Object, default: () => ({}) }
|
|
455
515
|
},
|
|
456
516
|
emits: [
|
|
457
517
|
"update:columns",
|
|
@@ -461,57 +521,65 @@ const ie = /* @__PURE__ */ x({
|
|
|
461
521
|
"cell-click"
|
|
462
522
|
],
|
|
463
523
|
setup(t, { expose: e, emit: n }) {
|
|
464
|
-
const r = t,
|
|
524
|
+
const r = t, o = n, { columns: l } = Ce(r.columns, {
|
|
465
525
|
pageKey: r.pageKey ?? "",
|
|
466
526
|
userId: r.userId ?? ""
|
|
467
527
|
});
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
(
|
|
528
|
+
F(
|
|
529
|
+
l,
|
|
530
|
+
(u) => o("update:columns", u),
|
|
471
531
|
{ deep: !0, immediate: !0 }
|
|
472
532
|
);
|
|
473
|
-
const
|
|
474
|
-
|
|
475
|
-
},
|
|
476
|
-
console.log("enter"),
|
|
477
|
-
},
|
|
478
|
-
|
|
479
|
-
}, h =
|
|
533
|
+
const i = (u, b) => o("cellChange", u, b), c = (u, b) => {
|
|
534
|
+
o("cellBlur", u, b);
|
|
535
|
+
}, d = (u, b) => {
|
|
536
|
+
console.log("enter"), o("cellEnter", u, b);
|
|
537
|
+
}, y = (u, b) => {
|
|
538
|
+
b && o("cell-click", u, b);
|
|
539
|
+
}, h = A();
|
|
480
540
|
return e({
|
|
481
541
|
tableRef: h
|
|
482
|
-
}), (
|
|
483
|
-
const
|
|
484
|
-
return
|
|
542
|
+
}), (u, b) => {
|
|
543
|
+
const a = V("el-table"), p = re("loading");
|
|
544
|
+
return oe((v(), _(a, x({
|
|
485
545
|
ref_key: "tableRef",
|
|
486
546
|
ref: h
|
|
487
|
-
},
|
|
547
|
+
}, u.$attrs, {
|
|
488
548
|
data: t.data,
|
|
489
549
|
"row-key": t.rowKey,
|
|
490
550
|
class: "smart-table"
|
|
491
551
|
}), {
|
|
492
|
-
default:
|
|
493
|
-
(
|
|
494
|
-
key:
|
|
495
|
-
col:
|
|
552
|
+
default: S(() => [
|
|
553
|
+
(v(!0), I(J, null, L(s(l), (f) => (v(), _(ge, {
|
|
554
|
+
key: f.key,
|
|
555
|
+
col: f,
|
|
496
556
|
permissions: t.permissions,
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
557
|
+
pagination: t.pagination,
|
|
558
|
+
onCellChange: i,
|
|
559
|
+
onCellBlur: c,
|
|
560
|
+
onCellEnter: d,
|
|
561
|
+
onCellClick: y
|
|
562
|
+
}, ie({ _: 2 }, [
|
|
563
|
+
L(s(l), (B) => ({
|
|
564
|
+
name: B.key,
|
|
565
|
+
fn: S((W) => [
|
|
566
|
+
Y(u.$slots, B.key, x({ ref_for: !0 }, W), void 0, !0)
|
|
567
|
+
])
|
|
568
|
+
}))
|
|
569
|
+
]), 1032, ["col", "permissions", "pagination"]))), 128))
|
|
502
570
|
]),
|
|
503
|
-
_:
|
|
571
|
+
_: 3
|
|
504
572
|
}, 16, ["data", "row-key"])), [
|
|
505
|
-
[
|
|
573
|
+
[p, t.loading]
|
|
506
574
|
]);
|
|
507
575
|
};
|
|
508
576
|
}
|
|
509
|
-
}),
|
|
577
|
+
}), ke = (t, e) => {
|
|
510
578
|
const n = t.__vccOpts || t;
|
|
511
|
-
for (const [r,
|
|
512
|
-
n[r] =
|
|
579
|
+
for (const [r, o] of e)
|
|
580
|
+
n[r] = o;
|
|
513
581
|
return n;
|
|
514
|
-
},
|
|
582
|
+
}, xe = /* @__PURE__ */ ke(be, [["__scopeId", "data-v-7c94ec39"]]);
|
|
515
583
|
export {
|
|
516
|
-
|
|
584
|
+
xe as SmartTable
|
|
517
585
|
};
|