vue3-smart-table 0.0.2 → 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.
@@ -1,6 +1,15 @@
1
- import { defineComponent as x, ref as V, watch as S, resolveComponent as w, createBlock as b, openBlock as f, mergeProps as _, withKeys as M, withCtx as P, createElementBlock as O, Fragment as K, renderList as T, h as g, computed as $, toRefs as U, createCommentVNode as j, unref as d, createTextVNode as D, toDisplayString as N, resolveDynamicComponent as H, resolveDirective as q, withDirectives as X } from "vue";
2
- import { ElImage as L, ElTag as Y, ElMessage as E, ElButton as G } from "element-plus";
3
- const Q = /* @__PURE__ */ x({
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__ */ x({
9
18
  onCellEnter: { type: Function }
10
19
  },
11
20
  setup(t) {
12
- const e = t, n = V(e.row[e.col.key]);
13
- S(n, (c) => {
14
- e.row[e.col.key] = c;
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 c;
18
- return (c = e.onCellBlur) == null ? void 0 : c.call(e, e.row, e.col);
19
- }, l = () => {
20
- var c;
21
- return (c = e.onCellEnter) == null ? void 0 : c.call(e, e.row, e.col);
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 (c, o) => {
24
- const y = w("el-input");
25
- return f(), b(y, _({
26
- modelValue: n.value,
27
- "onUpdate:modelValue": o[0] || (o[0] = (u) => n.value = u)
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: M(l, ["enter"])
39
+ onKeyup: D(n, ["enter"])
31
40
  }), null, 16, ["modelValue"]);
32
41
  };
33
42
  }
34
- }), Z = /* @__PURE__ */ x({
43
+ }), ce = /* @__PURE__ */ V({
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 = V(e.row[e.col.key]);
45
- S(n, (c) => {
53
+ const e = t, l = A(C(e.row, e.col.key));
54
+ F(l, (s) => {
46
55
  var o;
47
- e.row[e.col.key] = c, (o = e.onCellChange) == null || o.call(e, e.row, e.col);
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 c;
51
- return (c = e.onCellBlur) == null ? void 0 : c.call(e, e.row, e.col);
52
- }, l = () => {
53
- var c;
54
- return (c = e.onCellEnter) == null ? void 0 : c.call(e, e.row, e.col);
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 (c, o) => {
57
- const y = w("el-input-number");
58
- return f(), b(y, _({
59
- modelValue: n.value,
60
- "onUpdate:modelValue": o[0] || (o[0] = (u) => n.value = u)
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: M(l, ["enter"])
72
+ onKeyup: D(n, ["enter"])
64
73
  }), null, 16, ["modelValue"]);
65
74
  };
66
75
  }
67
- }), ee = /* @__PURE__ */ x({
76
+ }), ue = /* @__PURE__ */ V({
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 = V(e.row[e.col.key]);
78
- S(n, (o) => {
79
- e.row[e.col.key] = o;
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
- }, l = () => {
93
+ }, n = () => {
85
94
  var o;
86
95
  return (o = e.onCellBlur) == null ? void 0 : o.call(e, e.row, e.col);
87
- }, c = () => {
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, y) => {
92
- const u = w("el-option"), i = w("el-select");
93
- return f(), b(i, _({
94
- modelValue: n.value,
95
- "onUpdate:modelValue": y[0] || (y[0] = (h) => n.value = h)
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: l,
99
- onKeyup: M(c, ["enter"])
107
+ onBlur: n,
108
+ onKeyup: D(s, ["enter"])
100
109
  }), {
101
- default: P(() => {
102
- var h;
110
+ default: S(() => {
111
+ var v;
103
112
  return [
104
- (f(!0), O(K, null, T(((h = t.col.renderProps) == null ? void 0 : h.options) || [], (a) => (f(), b(u, {
105
- key: a.value,
106
- label: a.label,
107
- value: a.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__ */ x({
112
121
  }, 16, ["modelValue"]);
113
122
  };
114
123
  }
115
- }), W = (t) => x({
124
+ }), T = (t) => V({
116
125
  props: ["row", "col", "onCellChange", "onCellBlur", "onCellEnter", "onClick"],
117
126
  setup(e) {
118
- return () => g(t, e);
127
+ return () => f(t, e);
119
128
  }
120
129
  });
121
- function te(t) {
130
+ function de(t) {
122
131
  return typeof t.formatter == "function";
123
132
  }
124
- function ne() {
133
+ function ye() {
125
134
  return {
126
- input: W(Q),
127
- "input-number": W(Z),
128
- select: W(ee),
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 g(G, {
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 n;
136
- return (n = t.onClick) == null ? void 0 : n.call(t, t.row, t.col);
144
+ var r;
145
+ return (r = t.onClick) == null ? void 0 : r.call(t, t.row, t.col);
137
146
  }
138
- }, () => e.label || t.row[t.col.key]);
147
+ }, () => e.label || l);
139
148
  },
140
149
  link: (t) => {
141
- const e = t.col.renderProps || {};
142
- return g("a", {
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: (n) => {
147
- var r;
148
- n.preventDefault(), (r = t.onClick) == null || r.call(t, t.row, t.col);
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 || t.row[t.col.key]);
159
+ }, e.label || l);
151
160
  },
152
161
  html: (t) => {
153
- var e;
154
- return g("div", {
162
+ var l;
163
+ const e = C(t.row, t.col.key);
164
+ return f("div", {
155
165
  class: "line-clamp-2",
156
- innerHTML: t.row[t.col.key] ?? "",
157
- ...((e = t.col) == null ? void 0 : e.renderProps) || {}
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[t.col.key] ?? "";
162
- return g(
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
- g("span", {
179
+ f("span", {
170
180
  class: "copy-text line-clamp-1",
171
181
  style: "padding-right: 20px;"
172
182
  }, e),
173
- g(
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
- E.success("复制成功");
203
+ $.success("复制成功");
194
204
  }).catch(() => {
195
- E.error("复制失败");
205
+ $.error("复制失败");
196
206
  });
197
207
  else {
198
- const n = document.createElement("textarea");
199
- n.value = e, n.style.position = "fixed", n.style.opacity = "0", document.body.appendChild(n), n.select();
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(n), r ? E.success("复制成功") : E.error("复制失败");
211
+ document.body.removeChild(l), r ? $.success("复制成功") : $.error("复制失败");
202
212
  }
203
213
  } catch {
204
- E.error("复制失败");
214
+ $.error("复制失败");
205
215
  }
206
216
  }
207
217
  },
@@ -212,85 +222,119 @@ function ne() {
212
222
  );
213
223
  },
214
224
  img: (t) => {
215
- var r;
216
- const e = t.row[t.col.key] ?? "", n = ((r = t.col) == null ? void 0 : r.renderProps) || {};
217
- return g(L, {
218
- src: e,
219
- previewSrcList: (n == null ? void 0 : n.previewSrcList) ?? (Array.isArray(e) ? e : [e]),
220
- fit: "contain",
221
- style: "width:80px;height:80px",
222
- ...n
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[t.col.key], n = t.col.renderProps || {}, r = n.options ?? [], l = n.showValue ?? !1;
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 c = Array.isArray(e) ? e.map(String) : [String(e)], o = r.filter((i) => c.includes(String(i.value))), y = c.filter((i) => !r.some((h) => String(h.value) === i)), u = o.map((i, h) => g(
229
- Y,
230
- { key: i.value, type: i.listClass, class: i.cssClass, disableTransitions: !0 },
231
- { default: () => i.label + " " }
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 l && y.length > 0 && u.push(g("span", {}, y.join(" "))), g("div", {}, u);
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[t.col.key], n = ((r = t.col.renderProps) == null ? void 0 : r.options) ?? {};
238
- return e != null ? n[e] ?? "" : "";
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 l;
242
- const { col: e, row: n } = t, r = n[e.key];
243
- return te(e) ? (l = e.formatter) == null ? void 0 : l.call(e, r, n) : r ?? "";
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[t.col.key] ?? "", n = t.col.renderProps || {};
247
- return e ? /^https?:\/\//.test(e) ? g(L, {
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
- ...n
253
- }) : /^\s*<svg[\s\S]*<\/svg>\s*$/.test(e) ? g("div", {
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;${n.style || ""}`,
256
- ...n
257
- }) : g("i", {
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;${n.style || ""}`,
261
- ...n
304
+ style: `font-size:20px;${l.style || ""}`,
305
+ ...l
262
306
  }) : "";
263
307
  }
264
308
  };
265
309
  }
266
- function le(t, e = 10, n = []) {
267
- const l = "*:*:*", c = (s) => {
268
- if (!s) return !0;
269
- const m = Array.isArray(s) ? s : [s];
270
- return n.some(
271
- (p) => p === l || m.includes(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 = $(() => t.some((s) => c(s.permission))), y = $(() => t.filter((m) => c(m.permission)).slice(0, e).reduce(
274
- (m, p) => m + (p.width ?? 55),
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
- )), u = (s, m) => c(s.permission) && (s.visible ? s.visible(m) : !0), i = (s) => t.filter((p) => u(p, s)).slice(0, e).reduce(
277
- (p, I) => p + (I.width ?? 55),
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: y,
283
- hasAnyVisibleButton: (s) => s != null && s.length ? s.some(
284
- (m) => t.some((p) => u(p, m))
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: (s) => s != null && s.length ? s.reduce(
287
- (m, p) => Math.max(m, i(p)),
330
+ getMaxOptWidth: (a) => a != null && a.length ? a.reduce(
331
+ (m, p) => Math.max(m, d(p)),
288
332
  0
289
- ) : y.value,
290
- getVisibleButtons: (s) => t.filter((m) => u(m, s)).slice(0, e)
333
+ ) : c.value,
334
+ getVisibleButtons: (a) => t.filter((m) => y(m, a)).slice(0, e)
291
335
  };
292
336
  }
293
- const re = /* @__PURE__ */ x({
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__ */ x({
298
342
  },
299
343
  emits: ["cellBlur", "cellEnter", "cellChange", "cellClick"],
300
344
  setup(t, { emit: e }) {
301
- const n = t, r = e, { col: l } = U(n), c = (v, k) => r("cellChange", v, k), o = (v, k) => r("cellBlur", v, k), y = (v, k) => r("cellEnter", v, k), u = (v, k) => r("cellClick", v, k), i = ne(), {
302
- hasAnyButton: h,
303
- hasAnyVisibleButton: a,
304
- optWidth: C,
305
- getMaxOptWidth: s,
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
- } = le(
308
- l.value.buttons || [],
309
- l.value.maxbtn ?? 10,
310
- n.permissions || []
311
- ), p = $(() => (l.value.buttons || []).length ? (l.value.__rows || []).length ? a(l.value.__rows || []) : h.value : !1), I = $(() => l.value.__rows ? s(l.value.__rows) : C.value);
312
- function z(v) {
313
- return !(v.type === "selection" || v.type === "index" || v.type === "operation" && !p.value || v.visible === !1);
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 (v, k) => {
316
- const A = w("el-table-column"), J = w("el-button");
317
- return d(l).type === "selection" ? (f(), b(A, _({
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
- }, d(l).columnProps), null, 16)) : d(l).type === "index" ? (f(), b(A, _({
364
+ }, i(n).columnProps), null, 16)) : i(n).type === "index" ? (g(), b(K, _({
321
365
  key: 1,
322
366
  type: "index",
323
- label: d(l).label || "#",
367
+ label: i(n).label || "#",
324
368
  align: "center"
325
- }, d(l).columnProps), null, 16, ["label"])) : d(l).type === "operation" && p.value ? (f(), b(A, _({
369
+ }, i(n).columnProps), null, 16, ["label"])) : i(n).type === "operation" && p.value ? (g(), b(K, _({
326
370
  key: 2,
327
- label: d(l).label || "操作",
371
+ label: i(n).label || "操作",
328
372
  align: "center"
329
373
  }, {
330
- ...d(l).columnProps,
331
- width: I.value
374
+ ...i(n).columnProps,
375
+ width: P.value
332
376
  }), {
333
- default: P(({ row: B }) => [
334
- (f(!0), O(K, null, T(d(m)(B), (F) => (f(), b(J, {
335
- key: F.label,
336
- type: F.type || "primary",
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: (ue) => F.action(B)
382
+ onClick: (z) => B.action(x)
339
383
  }, {
340
- default: P(() => [
341
- D(N(F.label), 1)
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"])) : z(d(l)) ? (f(), b(A, _({
391
+ }, 16, ["label"])) : W(i(n)) ? (g(), b(K, _({
348
392
  key: 3,
349
- prop: d(l).key,
350
- label: d(l).label,
393
+ label: i(n).label,
351
394
  align: "center"
352
- }, d(l).columnProps || {}), {
353
- default: P(({ row: B }) => [
354
- d(l).render && d(i)[d(l).render] ? (f(), b(H(d(i)[d(l).render]), {
355
- key: 0,
356
- row: B,
357
- col: d(l),
358
- onCellChange: c,
359
- onCellBlur: o,
360
- onCellEnter: y,
361
- onClick: u
362
- }, null, 40, ["row", "col"])) : (f(), O(K, { key: 1 }, [
363
- D(N(B[d(l).key]), 1)
364
- ], 64))
365
- ]),
366
- _: 1
367
- }, 16, ["prop", "label"])) : j("", !0);
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
- }), oe = "table_columns_";
371
- function ce(t, e) {
372
- return `${oe}${t}_${e}`;
419
+ }), he = "table_columns_";
420
+ function ge(t, e) {
421
+ return `${he}${t}_${e}`;
373
422
  }
374
- function R(t, e) {
423
+ function q(t, e) {
375
424
  if (!(e != null && e.length)) return t;
376
- const n = new Map(
425
+ const l = new Map(
377
426
  e.map((r) => [r.key, r])
378
427
  );
379
428
  return t.map((r) => {
380
- const l = n.get(r.key);
381
- return l ? {
429
+ const n = l.get(r.key);
430
+ return n ? {
382
431
  ...r,
383
- visible: typeof l.visible == "boolean" ? l.visible : r.visible
432
+ visible: typeof n.visible == "boolean" ? n.visible : r.visible
384
433
  } : r;
385
434
  });
386
435
  }
387
- function se(t, e) {
436
+ function ve(t, e) {
388
437
  const {
389
- pageKey: n,
438
+ pageKey: l,
390
439
  userId: r,
391
- storage: l = localStorage
392
- } = e || {}, o = r ? ce(r, n || "") : null, y = o ? l.getItem(o) : null, u = V(
393
- R(
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
- y ? JSON.parse(y) : []
444
+ c ? JSON.parse(c) : []
396
445
  )
397
446
  );
398
- return S(
399
- u,
400
- (i) => {
447
+ return F(
448
+ y,
449
+ (d) => {
401
450
  if (!o) return;
402
- const h = i.map((a) => ({
403
- key: a.key,
404
- visible: a.visible,
405
- columnOpts: a.columnOpts
451
+ const v = d.map((u) => ({
452
+ key: u.key,
453
+ visible: u.visible,
454
+ columnOpts: u.columnOpts
406
455
  }));
407
- l.setItem(
456
+ n.setItem(
408
457
  o,
409
- JSON.stringify(h)
458
+ JSON.stringify(v)
410
459
  );
411
460
  },
412
461
  { deep: !0 }
413
462
  ), {
414
463
  /** 当前列配置(响应式) */
415
- columns: u,
464
+ columns: y,
416
465
  /**
417
466
  * 主动设置列配置
418
467
  * 常用于:列设置弹窗 / 拖拽排序完成
419
468
  */
420
- setColumns(i) {
421
- u.value = R(
469
+ setColumns(d) {
470
+ y.value = q(
422
471
  t,
423
- i
424
- ), o && l.setItem(
472
+ d
473
+ ), o && n.setItem(
425
474
  o,
426
- JSON.stringify(i)
475
+ JSON.stringify(d)
427
476
  );
428
477
  },
429
478
  /**
430
479
  * 重置为默认列配置
431
480
  */
432
481
  resetColumns() {
433
- u.value = t, o && l.removeItem(o);
482
+ y.value = t, o && n.removeItem(o);
434
483
  }
435
484
  };
436
485
  }
437
- const ie = /* @__PURE__ */ x({
486
+ const Ce = /* @__PURE__ */ V({
438
487
  __name: "index",
439
488
  props: {
440
489
  data: { type: Array, default: () => [] },
@@ -460,58 +509,65 @@ const ie = /* @__PURE__ */ x({
460
509
  "cellEnter",
461
510
  "cell-click"
462
511
  ],
463
- setup(t, { expose: e, emit: n }) {
464
- const r = t, l = n, { columns: c } = se(r.columns, {
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
- S(
469
- c,
470
- (a) => l("update:columns", a),
517
+ F(
518
+ s,
519
+ (u) => n("update:columns", u),
471
520
  { deep: !0, immediate: !0 }
472
521
  );
473
- const o = (a, C) => l("cellChange", a, C), y = (a, C) => {
474
- l("cellBlur", a, C);
475
- }, u = (a, C) => {
476
- console.log("enter"), l("cellEnter", a, C);
477
- }, i = (a, C) => {
478
- C && l("cell-click", a, C);
479
- }, h = V();
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: h
482
- }), (a, C) => {
483
- const s = w("el-table"), m = q("loading");
484
- return X((f(), b(s, _({
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: h
487
- }, a.$attrs, {
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: P(() => [
493
- (f(!0), O(K, null, T(d(c), (p) => (f(), b(re, {
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: y,
499
- onCellEnter: u,
500
- onCellClick: i
501
- }, null, 8, ["col", "permissions"]))), 128))
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
- _: 1
559
+ _: 3
504
560
  }, 16, ["data", "row-key"])), [
505
561
  [m, t.loading]
506
562
  ]);
507
563
  };
508
564
  }
509
- }), ae = (t, e) => {
510
- const n = t.__vccOpts || t;
511
- for (const [r, l] of e)
512
- n[r] = l;
513
- return n;
514
- }, me = /* @__PURE__ */ ae(ie, [["__scopeId", "data-v-338b77db"]]);
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
- me as SmartTable
572
+ we as SmartTable
517
573
  };