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.
@@ -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 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 = V(e.row[e.col.key]);
13
- S(n, (c) => {
14
- e.row[e.col.key] = c;
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 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 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 (c, o) => {
24
- const y = w("el-input");
25
- return f(), b(y, _({
32
+ return (l, i) => {
33
+ const c = V("el-input");
34
+ return v(), _(c, x({
26
35
  modelValue: n.value,
27
- "onUpdate:modelValue": o[0] || (o[0] = (u) => n.value = u)
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: M(l, ["enter"])
39
+ onKeyup: R(o, ["enter"])
31
40
  }), null, 16, ["modelValue"]);
32
41
  };
33
42
  }
34
- }), Z = /* @__PURE__ */ x({
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 = V(e.row[e.col.key]);
45
- S(n, (c) => {
46
- var o;
47
- e.row[e.col.key] = c, (o = e.onCellChange) == null || o.call(e, e.row, e.col);
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 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 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 (c, o) => {
57
- const y = w("el-input-number");
58
- return f(), b(y, _({
65
+ return (l, i) => {
66
+ const c = V("el-input-number");
67
+ return v(), _(c, x({
59
68
  modelValue: n.value,
60
- "onUpdate:modelValue": o[0] || (o[0] = (u) => n.value = u)
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: M(l, ["enter"])
72
+ onKeyup: R(o, ["enter"])
64
73
  }), null, 16, ["modelValue"]);
65
74
  };
66
75
  }
67
- }), ee = /* @__PURE__ */ x({
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 = V(e.row[e.col.key]);
78
- S(n, (o) => {
79
- e.row[e.col.key] = o;
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 o;
83
- return (o = e.onCellChange) == null ? void 0 : o.call(e, e.row, e.col);
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 o;
86
- return (o = e.onCellBlur) == null ? void 0 : o.call(e, e.row, e.col);
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 (o, y) => {
92
- const u = w("el-option"), i = w("el-select");
93
- return f(), b(i, _({
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": y[0] || (y[0] = (h) => n.value = h)
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: l,
99
- onKeyup: M(c, ["enter"])
107
+ onBlur: o,
108
+ onKeyup: R(l, ["enter"])
100
109
  }), {
101
- default: P(() => {
110
+ default: S(() => {
102
111
  var h;
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
+ (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
- }), W = (t) => x({
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 te(t) {
130
+ function ye(t) {
122
131
  return typeof t.formatter == "function";
123
132
  }
124
- function ne() {
133
+ function me() {
125
134
  return {
126
- input: W(Q),
127
- "input-number": W(Z),
128
- select: W(ee),
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(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 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 || 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: (n) => {
147
- var r;
148
- n.preventDefault(), (r = t.onClick) == null || r.call(t, t.row, t.col);
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 || t.row[t.col.key]);
159
+ }, e.label || n);
151
160
  },
152
161
  html: (t) => {
153
- var e;
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: t.row[t.col.key] ?? "",
157
- ...((e = t.col) == null ? void 0 : e.renderProps) || {}
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[t.col.key] ?? "";
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
- E.success("复制成功");
203
+ $.success("复制成功");
194
204
  }).catch(() => {
195
- E.error("复制失败");
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 ? E.success("复制成功") : E.error("复制失败");
211
+ document.body.removeChild(n), r ? $.success("复制成功") : $.error("复制失败");
202
212
  }
203
213
  } catch {
204
- E.error("复制失败");
214
+ $.error("复制失败");
205
215
  }
206
216
  }
207
217
  },
@@ -212,39 +222,73 @@ 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",
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[t.col.key], n = t.col.renderProps || {}, r = n.options ?? [], l = n.showValue ?? !1;
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 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 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 l && y.length > 0 && u.push(g("span", {}, y.join(" "))), g("div", {}, u);
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[t.col.key], n = ((r = t.col.renderProps) == null ? void 0 : r.options) ?? {};
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 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 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[t.col.key] ?? "", n = t.col.renderProps || {};
247
- return e ? /^https?:\/\//.test(e) ? g(L, {
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 le(t, e = 10, n = []) {
267
- const l = "*:*:*", c = (s) => {
268
- if (!s) return !0;
269
- const m = Array.isArray(s) ? s : [s];
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
- (p) => p === l || m.includes(p)
315
+ (f) => f === o || p.includes(f)
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
+ }, 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
- )), 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
+ )), 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: o,
282
- optWidth: y,
283
- hasAnyVisibleButton: (s) => s != null && s.length ? s.some(
284
- (m) => t.some((p) => u(p, m))
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: (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
+ (p, f) => Math.max(p, y(f)),
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((p) => d(p, a)).slice(0, e)
291
335
  };
292
336
  }
293
- const re = /* @__PURE__ */ x({
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, { 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,
306
- getVisibleButtons: m
307
- } = le(
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
- ), 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);
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 (v, k) => {
316
- const A = w("el-table-column"), J = w("el-button");
317
- return d(l).type === "selection" ? (f(), b(A, _({
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
- }, d(l).columnProps), null, 16)) : d(l).type === "index" ? (f(), b(A, _({
369
+ }, s(l).columnProps), null, 16)) : s(l).type === "index" ? (v(), _(E, x({
321
370
  key: 1,
322
371
  type: "index",
323
- label: d(l).label || "#",
372
+ label: s(l).label || "#",
324
373
  align: "center"
325
- }, d(l).columnProps), null, 16, ["label"])) : d(l).type === "operation" && p.value ? (f(), b(A, _({
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: d(l).label || "操作",
381
+ label: s(l).label || "操作",
328
382
  align: "center"
329
383
  }, {
330
- ...d(l).columnProps,
331
- width: I.value
384
+ ...s(l).columnProps,
385
+ width: W.value
332
386
  }), {
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",
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: (ue) => F.action(B)
392
+ onClick: (M) => P.action(w)
339
393
  }, {
340
- default: P(() => [
341
- D(N(F.label), 1)
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"])) : z(d(l)) ? (f(), b(A, _({
401
+ }, 16, ["label"])) : G(s(l)) ? (v(), _(E, x({
348
402
  key: 3,
349
- prop: d(l).key,
350
- label: d(l).label,
403
+ label: s(l).label,
351
404
  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);
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
- }), oe = "table_columns_";
371
- function ce(t, e) {
372
- return `${oe}${t}_${e}`;
429
+ }), he = "table_columns_";
430
+ function ve(t, e) {
431
+ return `${he}${t}_${e}`;
373
432
  }
374
- function R(t, e) {
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 l = n.get(r.key);
381
- return l ? {
439
+ const o = n.get(r.key);
440
+ return o ? {
382
441
  ...r,
383
- visible: typeof l.visible == "boolean" ? l.visible : r.visible
442
+ visible: typeof o.visible == "boolean" ? o.visible : r.visible
384
443
  } : r;
385
444
  });
386
445
  }
387
- function se(t, e) {
446
+ function Ce(t, e) {
388
447
  const {
389
448
  pageKey: n,
390
449
  userId: r,
391
- storage: l = localStorage
392
- } = e || {}, o = r ? ce(r, n || "") : null, y = o ? l.getItem(o) : null, u = V(
393
- R(
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
- y ? JSON.parse(y) : []
454
+ c ? JSON.parse(c) : []
396
455
  )
397
456
  );
398
- return S(
399
- u,
400
- (i) => {
401
- if (!o) return;
402
- const h = i.map((a) => ({
403
- key: a.key,
404
- visible: a.visible,
405
- columnOpts: a.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
- l.setItem(
408
- o,
466
+ o.setItem(
467
+ i,
409
468
  JSON.stringify(h)
410
469
  );
411
470
  },
412
471
  { deep: !0 }
413
472
  ), {
414
473
  /** 当前列配置(响应式) */
415
- columns: u,
474
+ columns: d,
416
475
  /**
417
476
  * 主动设置列配置
418
477
  * 常用于:列设置弹窗 / 拖拽排序完成
419
478
  */
420
- setColumns(i) {
421
- u.value = R(
479
+ setColumns(y) {
480
+ d.value = X(
422
481
  t,
423
- i
424
- ), o && l.setItem(
425
- o,
426
- JSON.stringify(i)
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
- u.value = t, o && l.removeItem(o);
492
+ d.value = t, i && o.removeItem(i);
434
493
  }
435
494
  };
436
495
  }
437
- const ie = /* @__PURE__ */ x({
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, l = n, { columns: c } = se(r.columns, {
524
+ const r = t, o = n, { columns: l } = Ce(r.columns, {
465
525
  pageKey: r.pageKey ?? "",
466
526
  userId: r.userId ?? ""
467
527
  });
468
- S(
469
- c,
470
- (a) => l("update:columns", a),
528
+ F(
529
+ l,
530
+ (u) => o("update:columns", u),
471
531
  { deep: !0, immediate: !0 }
472
532
  );
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();
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
- }), (a, C) => {
483
- const s = w("el-table"), m = q("loading");
484
- return X((f(), b(s, _({
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
- }, a.$attrs, {
547
+ }, u.$attrs, {
488
548
  data: t.data,
489
549
  "row-key": t.rowKey,
490
550
  class: "smart-table"
491
551
  }), {
492
- default: P(() => [
493
- (f(!0), O(K, null, T(d(c), (p) => (f(), b(re, {
494
- key: p.key,
495
- col: p,
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
- onCellChange: o,
498
- onCellBlur: y,
499
- onCellEnter: u,
500
- onCellClick: i
501
- }, null, 8, ["col", "permissions"]))), 128))
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
- _: 1
571
+ _: 3
504
572
  }, 16, ["data", "row-key"])), [
505
- [m, t.loading]
573
+ [p, t.loading]
506
574
  ]);
507
575
  };
508
576
  }
509
- }), ae = (t, e) => {
577
+ }), ke = (t, e) => {
510
578
  const n = t.__vccOpts || t;
511
- for (const [r, l] of e)
512
- n[r] = l;
579
+ for (const [r, o] of e)
580
+ n[r] = o;
513
581
  return n;
514
- }, me = /* @__PURE__ */ ae(ie, [["__scopeId", "data-v-338b77db"]]);
582
+ }, xe = /* @__PURE__ */ ke(be, [["__scopeId", "data-v-7c94ec39"]]);
515
583
  export {
516
- me as SmartTable
584
+ xe as SmartTable
517
585
  };