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