@gopowerteam/table-render 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/config/provide.config.d.ts +6 -0
- package/dist/cjs/defines/define-columns.d.ts +2 -0
- package/dist/cjs/defines/define-table-load.d.ts +2 -0
- package/dist/cjs/defines/index.d.ts +2 -0
- package/dist/cjs/hooks/index.d.ts +2 -0
- package/dist/cjs/hooks/use-events.d.ts +26 -0
- package/dist/cjs/hooks/use-export.d.ts +7 -0
- package/dist/cjs/hooks/use-table.d.ts +13 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.d.ts +4 -1
- package/dist/cjs/interfaces/index.d.ts +9 -0
- package/dist/cjs/interfaces/table-column-options.d.ts +39 -0
- package/dist/cjs/interfaces/table-column-render.d.ts +28 -0
- package/dist/cjs/interfaces/table-load-params.d.ts +21 -0
- package/dist/cjs/render/table-column-render.d.ts +30 -0
- package/dist/cjs/render/table-view-render.d.ts +73 -0
- package/dist/cjs/table-columns/button/index.d.ts +26 -0
- package/dist/cjs/table-columns/currency/index.d.ts +9 -0
- package/dist/cjs/table-columns/date/index.d.ts +17 -0
- package/dist/cjs/table-columns/dict/index.d.ts +13 -0
- package/dist/cjs/table-columns/image/index.d.ts +10 -0
- package/dist/cjs/table-columns/index.d.ts +11 -0
- package/dist/cjs/table-columns/phone/index.d.ts +7 -0
- package/dist/cjs/table-columns/render/index.d.ts +5 -0
- package/dist/cjs/table-columns/tag/index.d.ts +8 -0
- package/dist/cjs/table-columns/text/index.d.ts +11 -0
- package/dist/cjs/utils/create-column-render.d.ts +7 -0
- package/dist/cjs/utils/create-table-form.d.ts +3 -0
- package/dist/cjs/utils/create-table-source.d.ts +3 -0
- package/dist/cjs/utils/get-column-value.d.ts +8 -0
- package/dist/cjs/utils/index.d.ts +5 -0
- package/dist/cjs/utils/set-column-value.d.ts +8 -0
- package/dist/cjs/utils/to-px.d.ts +1 -0
- package/dist/es/config/provide.config.d.ts +6 -0
- package/dist/es/defines/define-columns.d.ts +2 -0
- package/dist/es/defines/define-table-load.d.ts +2 -0
- package/dist/es/defines/index.d.ts +2 -0
- package/dist/es/hooks/index.d.ts +2 -0
- package/dist/es/hooks/use-events.d.ts +26 -0
- package/dist/es/hooks/use-export.d.ts +7 -0
- package/dist/es/hooks/use-table.d.ts +13 -0
- package/dist/es/index.d.ts +4 -1
- package/dist/es/index.mjs +494 -53
- package/dist/es/interfaces/index.d.ts +9 -0
- package/dist/es/interfaces/table-column-options.d.ts +39 -0
- package/dist/es/interfaces/table-column-render.d.ts +28 -0
- package/dist/es/interfaces/table-load-params.d.ts +21 -0
- package/dist/es/render/table-column-render.d.ts +30 -0
- package/dist/es/render/table-view-render.d.ts +73 -0
- package/dist/es/table-columns/button/index.d.ts +26 -0
- package/dist/es/table-columns/currency/index.d.ts +9 -0
- package/dist/es/table-columns/date/index.d.ts +17 -0
- package/dist/es/table-columns/dict/index.d.ts +13 -0
- package/dist/es/table-columns/image/index.d.ts +10 -0
- package/dist/es/table-columns/index.d.ts +11 -0
- package/dist/es/table-columns/phone/index.d.ts +7 -0
- package/dist/es/table-columns/render/index.d.ts +5 -0
- package/dist/es/table-columns/tag/index.d.ts +8 -0
- package/dist/es/table-columns/text/index.d.ts +11 -0
- package/dist/es/utils/create-column-render.d.ts +7 -0
- package/dist/es/utils/create-table-form.d.ts +3 -0
- package/dist/es/utils/create-table-source.d.ts +3 -0
- package/dist/es/utils/get-column-value.d.ts +8 -0
- package/dist/es/utils/index.d.ts +5 -0
- package/dist/es/utils/set-column-value.d.ts +8 -0
- package/dist/es/utils/to-px.d.ts +1 -0
- package/dist/style.css +1 -1
- package/package.json +9 -2
- package/dist/cjs/components/table-render.d.ts +0 -10
- package/dist/es/components/table-render.d.ts +0 -10
package/dist/es/index.mjs
CHANGED
|
@@ -1,64 +1,505 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Table as
|
|
3
|
-
|
|
1
|
+
import { ref as w, getCurrentInstance as M, onMounted as $, onUpdated as R, createVNode as c, Fragment as k, createTextVNode as F, defineComponent as E, isVNode as V, provide as P, mergeProps as q } from "vue";
|
|
2
|
+
import { Button as j, Tag as z, Descriptions as A, DescriptionsItem as B, Table as _ } from "@arco-design/web-vue";
|
|
3
|
+
import { FormRender as D } from "@gopowerteam/form-render";
|
|
4
|
+
import { useModal as W, ModalProvider as K } from "@gopowerteam/modal-render";
|
|
5
|
+
function L(e, t, r) {
|
|
6
|
+
const [u, ...a] = (t.index || t.key).split(".").reverse(), l = a.reverse().reduce((n, f) => n == null ? void 0 : n[f], e);
|
|
7
|
+
l[u] = r;
|
|
8
|
+
}
|
|
9
|
+
function N(e) {
|
|
10
|
+
const t = w([]), r = (a) => {
|
|
11
|
+
const l = e.filter((n) => n.formatter);
|
|
12
|
+
return l.length > 0 ? a.map((n) => (l.forEach((f) => {
|
|
13
|
+
f.formatter && L(n, f, f.formatter(n));
|
|
14
|
+
}), n)) : a;
|
|
15
|
+
};
|
|
16
|
+
return [t, (a) => {
|
|
17
|
+
t.value = r(a);
|
|
18
|
+
}];
|
|
19
|
+
}
|
|
20
|
+
function U(e) {
|
|
21
|
+
return e.filter((t) => t.form).map((t) => ({
|
|
22
|
+
key: t.key,
|
|
23
|
+
title: t.title,
|
|
24
|
+
...typeof t.form == "boolean" ? {} : t.form
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
function Ce(e) {
|
|
28
|
+
const t = M(), r = w();
|
|
29
|
+
function u() {
|
|
30
|
+
var l, n;
|
|
31
|
+
const a = (n = (l = t == null ? void 0 : t.proxy) == null ? void 0 : l.$refs) == null ? void 0 : n[e];
|
|
32
|
+
a && (r.value = a);
|
|
33
|
+
}
|
|
34
|
+
return $(u), R(u), r;
|
|
35
|
+
}
|
|
36
|
+
function o(e) {
|
|
37
|
+
return (t, r) => e[t](r);
|
|
38
|
+
}
|
|
39
|
+
const G = Symbol.for("RenderColumnType");
|
|
40
|
+
function s(e, t, r) {
|
|
41
|
+
return t.$type = e, t.$disableColumnMode = r == null ? void 0 : r.disableColumnMode, t.$disableViewMode = r == null ? void 0 : r.disableViewMode, t.$options = (r == null ? void 0 : r.showOverflow) ?? !0, t;
|
|
42
|
+
}
|
|
43
|
+
function h(e, t) {
|
|
44
|
+
return (t.index || t.key).split(".").reduce((r, u) => r == null ? void 0 : r[u], e);
|
|
45
|
+
}
|
|
46
|
+
function H(e) {
|
|
47
|
+
return s("button", (r, u, a) => {
|
|
48
|
+
const l = W(), n = Array.isArray(e) ? e : "buttons" in e ? e.buttons : [e], f = (d, g) => typeof d == "function" ? d(r) : d === void 0 ? g : d;
|
|
49
|
+
async function i(d) {
|
|
50
|
+
await (d.confirm === !0 ? new Promise((b) => {
|
|
51
|
+
l.confirm({
|
|
52
|
+
title: "提示信息",
|
|
53
|
+
content: d.confirmText ?? "您确定要执行该操作?",
|
|
54
|
+
onOk: () => b(!0),
|
|
55
|
+
onCancel: () => b(!1)
|
|
56
|
+
});
|
|
57
|
+
}) : Promise.resolve(!0)) && (d != null && d.onClick) && (await d.onClick(r), d.autoReload && (a != null && a.emits) && (a == null || a.emits("reload")));
|
|
58
|
+
}
|
|
59
|
+
return c(k, null, [n.filter((d) => f(d.visiable, !0)).map((d) => c(j, {
|
|
60
|
+
onClick: () => i(d),
|
|
61
|
+
type: d.type || "text",
|
|
62
|
+
shape: d.shape,
|
|
63
|
+
disabled: f(d.disabled, !1)
|
|
64
|
+
}, {
|
|
65
|
+
icon: d.icon,
|
|
66
|
+
default: () => (typeof d.content == "function" ? d.content(r) : d.content) || ""
|
|
67
|
+
}))]);
|
|
68
|
+
}, {
|
|
69
|
+
disableViewMode: !0
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function T(e) {
|
|
73
|
+
const t = (a) => a.replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g, "$1,"), r = (a) => (parseFloat(a.toString()) / ((e == null ? void 0 : e.scale) || 1)).toFixed((e == null ? void 0 : e.precision) || 2);
|
|
74
|
+
return s("dict", (a, l) => {
|
|
75
|
+
const n = h(a, l);
|
|
76
|
+
return c("div", null, [(e == null ? void 0 : e.prefix) !== void 0 && c("span", null, [e == null ? void 0 : e.prefix]), c("span", {
|
|
77
|
+
class: "currency_value"
|
|
78
|
+
}, [(e == null ? void 0 : e.thousands) === !1 ? r(n) : t(r(n))]), (e == null ? void 0 : e.suffix) !== void 0 && c("span", null, [e == null ? void 0 : e.suffix])]);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
const J = {
|
|
82
|
+
success: "arcoblue",
|
|
83
|
+
warning: "orange",
|
|
84
|
+
error: "red"
|
|
85
|
+
};
|
|
86
|
+
function Q(e) {
|
|
87
|
+
return e instanceof Map ? e : e.dict;
|
|
88
|
+
}
|
|
89
|
+
function X(e) {
|
|
90
|
+
const t = e instanceof Map ? !1 : e.tag;
|
|
91
|
+
return typeof t == "string" ? J[t] : t;
|
|
92
|
+
}
|
|
93
|
+
function Y(e) {
|
|
94
|
+
const t = Q(e), r = X(e);
|
|
95
|
+
return s("dict", (a, l) => {
|
|
96
|
+
const n = h(a, l);
|
|
97
|
+
return r ? c(z, {
|
|
98
|
+
color: r === !0 ? void 0 : r
|
|
99
|
+
}, {
|
|
100
|
+
default: () => [t.get(n) || n]
|
|
101
|
+
}) : c("span", null, [t.get(n) || n]);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function Z(e) {
|
|
105
|
+
function t(a, l) {
|
|
106
|
+
var f;
|
|
107
|
+
const n = (f = document.getElementById(a)) == null ? void 0 : f.getBoundingClientRect();
|
|
108
|
+
if (n) {
|
|
109
|
+
const i = new Image(100, 100);
|
|
110
|
+
i.id = `IMAGE_${a}_PREVIEW`, i.src = l, i.setAttribute("style", ["position:fixed;", `top:${n.top}px;`, `left:${n.left + n.width}px;`, "min-width:400px;", "height:auto;", "z-index:100;"].join("")), document.body.appendChild(i);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function r(a) {
|
|
114
|
+
const l = document.getElementById(`IMAGE_${a}_PREVIEW`);
|
|
115
|
+
l == null || l.remove();
|
|
116
|
+
}
|
|
117
|
+
return s("image", (a, l, n) => {
|
|
118
|
+
const f = h(a, l), i = Math.random().toString(32).slice(2).toUpperCase(), d = {
|
|
119
|
+
width: n != null && n.previewing ? (e == null ? void 0 : e.width) || "auto" : "40px",
|
|
120
|
+
height: n != null && n.previewing && (e == null ? void 0 : e.height) || "auto",
|
|
121
|
+
borderRadius: e == null ? void 0 : e.radius,
|
|
122
|
+
maxWidth: !(e != null && e.height) && !(e != null && e.width) ? "150px" : "auto",
|
|
123
|
+
display: "block",
|
|
124
|
+
margin: "auto",
|
|
125
|
+
objectFit: "contain",
|
|
126
|
+
transform: `rotate(${(e == null ? void 0 : e.rotate) || 0}deg)`,
|
|
127
|
+
cursor: e != null && e.preview ? "pointer" : "unset"
|
|
128
|
+
}, g = `${l.index || l.key}_parsed`;
|
|
129
|
+
if (e != null && e.parse && (e == null || e.parse(f).then((b) => a[g] = b)), e != null && e.parse && !a[g])
|
|
130
|
+
return c("div", null, [F("Loading...")]);
|
|
131
|
+
{
|
|
132
|
+
const b = a[g] || f;
|
|
133
|
+
return c("img", {
|
|
134
|
+
id: i,
|
|
135
|
+
onMouseenter: () => (e == null ? void 0 : e.preview) && !(n != null && n.previewing) && t(i, b),
|
|
136
|
+
onMouseleave: () => (e == null ? void 0 : e.preview) && !(n != null && n.previewing) && r(i),
|
|
137
|
+
src: b,
|
|
138
|
+
style: d
|
|
139
|
+
}, null);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
const p = " ";
|
|
144
|
+
function ee(e) {
|
|
145
|
+
return e == null ? void 0 : e.replace(/(\d{3})\d*(\d{4})/g, "$1****$2");
|
|
146
|
+
}
|
|
147
|
+
function re(e, t) {
|
|
148
|
+
return e == null ? void 0 : e.replace(/\*/g, "M").replace(/\B(?=(?:\S{4})+$)/g, t ?? p).replace(/M/g, "*");
|
|
149
|
+
}
|
|
150
|
+
function te(e) {
|
|
151
|
+
return s("phone", (r, u) => {
|
|
152
|
+
const a = h(r, u), l = re(e != null && e.safe ? ee(a) : a, e == null ? void 0 : e.separator);
|
|
153
|
+
return e != null && e.callable ? c("a", {
|
|
154
|
+
style: "text-decoration:none;",
|
|
155
|
+
href: `tel:${a}`
|
|
156
|
+
}, [l]) : c("span", null, [l]);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function ne(e) {
|
|
160
|
+
return s("render", (r) => e(r), {
|
|
161
|
+
showOverflow: !1
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
function ae(e) {
|
|
165
|
+
return s("tag", (r, u) => {
|
|
166
|
+
const a = h(r, u), l = (e == null ? void 0 : e.textColors) || ["#F87335"], n = (e == null ? void 0 : e.backgroundColors) || ["#FFF4E8"];
|
|
167
|
+
return c("div", {
|
|
168
|
+
style: {
|
|
169
|
+
display: "flex",
|
|
170
|
+
flexWrap: "wrap"
|
|
171
|
+
}
|
|
172
|
+
}, [a.map((f, i) => c("span", {
|
|
173
|
+
style: {
|
|
174
|
+
margin: "2px",
|
|
175
|
+
padding: "2px 5px",
|
|
176
|
+
border: `solid 2px ${(e == null ? void 0 : e.border) || "transparent"}`,
|
|
177
|
+
borderRadius: `${(e == null ? void 0 : e.radius) || 0}px`,
|
|
178
|
+
color: typeof l == "function" ? l(f, i) : l[i % l.length],
|
|
179
|
+
backgroundColor: typeof n == "function" ? n(f, i) : n[i % n.length]
|
|
180
|
+
}
|
|
181
|
+
}, [f]))]);
|
|
182
|
+
}, {
|
|
183
|
+
showOverflow: !1
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
function S(e) {
|
|
187
|
+
if (typeof e == "string")
|
|
188
|
+
return e;
|
|
189
|
+
if (typeof e == "number")
|
|
190
|
+
return `${e}px`;
|
|
191
|
+
}
|
|
192
|
+
function le(e, t, r) {
|
|
193
|
+
var u, a;
|
|
194
|
+
return typeof e == "function" ? (u = e(r)) == null ? void 0 : u.toString() : typeof (e == null ? void 0 : e.content) == "function" ? (a = e == null ? void 0 : e.content(r)) == null ? void 0 : a.toString() : typeof (e == null ? void 0 : e.content) == "string" ? e == null ? void 0 : e.content : h(r, t);
|
|
195
|
+
}
|
|
196
|
+
function ue(e, t) {
|
|
197
|
+
if (typeof e != "function") {
|
|
198
|
+
if (typeof (e == null ? void 0 : e.color) == "function")
|
|
199
|
+
return e == null ? void 0 : e.color(t);
|
|
200
|
+
if (typeof (e == null ? void 0 : e.color) == "string")
|
|
201
|
+
return e == null ? void 0 : e.color;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function de(e, t) {
|
|
205
|
+
if (typeof e != "function")
|
|
206
|
+
return typeof (e == null ? void 0 : e.size) == "function" ? S(e == null ? void 0 : e.size(t)) : S(e == null ? void 0 : e.size);
|
|
207
|
+
}
|
|
208
|
+
function ce(e, t) {
|
|
209
|
+
let r = "";
|
|
210
|
+
const u = ue(e, t), a = de(e, t);
|
|
211
|
+
return u && (r += `color:${u};`), a && (r += `font-size:${a};`), r;
|
|
212
|
+
}
|
|
213
|
+
function fe(e) {
|
|
214
|
+
return s("text", (r, u) => {
|
|
215
|
+
const a = le(e || {}, u, r), l = ce(e || {}, r);
|
|
216
|
+
return c("span", {
|
|
217
|
+
style: l
|
|
218
|
+
}, [a]);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
function ie() {
|
|
222
|
+
return {
|
|
223
|
+
text: fe,
|
|
224
|
+
dict: Y,
|
|
225
|
+
tag: ae,
|
|
226
|
+
render: ne,
|
|
227
|
+
phone: te,
|
|
228
|
+
image: Z,
|
|
229
|
+
currency: T,
|
|
230
|
+
date: T,
|
|
231
|
+
button: H
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function I(e, t) {
|
|
235
|
+
if (!(e != null && e.render))
|
|
236
|
+
return;
|
|
237
|
+
const r = e.render({
|
|
238
|
+
...ie()
|
|
239
|
+
// ...(Table?.$override?.table || {}),
|
|
240
|
+
});
|
|
241
|
+
return {
|
|
242
|
+
render: ({
|
|
243
|
+
record: u
|
|
244
|
+
}) => r(u, e, t),
|
|
245
|
+
[G]: r.$type,
|
|
246
|
+
disableColumnMode: r.$disableColumnMode,
|
|
247
|
+
disableViewMode: r.$disableViewMode,
|
|
248
|
+
showOverflow: r.$showOverflow,
|
|
249
|
+
isRenderColumn: r.$type === "render",
|
|
250
|
+
type: r.$type
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function me(e, t, r) {
|
|
254
|
+
return e.map((u) => ({
|
|
255
|
+
...t || {},
|
|
256
|
+
...u
|
|
257
|
+
})).map((u) => ye(u, r)).filter(Boolean);
|
|
258
|
+
}
|
|
259
|
+
function ye(e, t) {
|
|
260
|
+
const {
|
|
261
|
+
render: r
|
|
262
|
+
} = I(e, {
|
|
263
|
+
previewing: !1,
|
|
264
|
+
emits: t
|
|
265
|
+
}) || {};
|
|
266
|
+
if (!(e.visiable === !1 || typeof e.visiable == "function" && e.visiable() === !1))
|
|
267
|
+
return {
|
|
268
|
+
dataIndex: e.index || e.key,
|
|
269
|
+
title: e.title,
|
|
270
|
+
width: e.width === "auto" ? void 0 : e.width,
|
|
271
|
+
align: e.align ?? "center",
|
|
272
|
+
fixed: e.fixed,
|
|
273
|
+
ellipsis: e.ellipsis ?? !0,
|
|
274
|
+
tooltip: !0,
|
|
275
|
+
...e.extraProps,
|
|
276
|
+
render: r
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
function ge(e) {
|
|
280
|
+
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !V(e);
|
|
281
|
+
}
|
|
282
|
+
const be = /* @__PURE__ */ E({
|
|
283
|
+
props: {
|
|
284
|
+
record: {
|
|
285
|
+
type: Object,
|
|
286
|
+
required: !0
|
|
287
|
+
},
|
|
288
|
+
columns: {
|
|
289
|
+
type: Array,
|
|
290
|
+
required: !0
|
|
291
|
+
},
|
|
292
|
+
minWidth: {
|
|
293
|
+
type: Number,
|
|
294
|
+
required: !1,
|
|
295
|
+
default: 300
|
|
296
|
+
},
|
|
297
|
+
border: {
|
|
298
|
+
type: Boolean,
|
|
299
|
+
default: !0
|
|
300
|
+
},
|
|
301
|
+
exclude: {
|
|
302
|
+
type: Array,
|
|
303
|
+
default: () => []
|
|
304
|
+
},
|
|
305
|
+
layout: {
|
|
306
|
+
type: String,
|
|
307
|
+
required: !1,
|
|
308
|
+
default: "horizontal"
|
|
309
|
+
},
|
|
310
|
+
buttons: {
|
|
311
|
+
type: Array,
|
|
312
|
+
default: () => []
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
setup(e) {
|
|
316
|
+
const t = M(), r = w(0), u = e.columns.map((l) => ({
|
|
317
|
+
options: l,
|
|
318
|
+
renderer: I(l, {
|
|
319
|
+
previewing: !0
|
|
320
|
+
})
|
|
321
|
+
})).filter(({
|
|
322
|
+
options: l
|
|
323
|
+
}) => {
|
|
324
|
+
var n;
|
|
325
|
+
return !((n = e.exclude) != null && n.includes(l.key));
|
|
326
|
+
}).filter(({
|
|
327
|
+
renderer: l
|
|
328
|
+
}) => !(l != null && l.disableViewMode));
|
|
329
|
+
function a() {
|
|
330
|
+
var l;
|
|
331
|
+
if (t) {
|
|
332
|
+
const n = (l = t.proxy) == null ? void 0 : l.$el;
|
|
333
|
+
console.log(n.offsetWidth), r.value = Math.floor(n.offsetWidth / e.minWidth);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return $(() => {
|
|
337
|
+
a();
|
|
338
|
+
}), () => {
|
|
339
|
+
let l;
|
|
340
|
+
return c("div", {
|
|
341
|
+
class: "preview-container"
|
|
342
|
+
}, [c(A, {
|
|
343
|
+
column: r.value,
|
|
344
|
+
bordered: !0,
|
|
345
|
+
align: "left",
|
|
346
|
+
layout: e.layout
|
|
347
|
+
}, ge(l = u.map((n) => c(B, {
|
|
348
|
+
label: n.options.title
|
|
349
|
+
}, {
|
|
350
|
+
default: () => {
|
|
351
|
+
var f, i;
|
|
352
|
+
return [(f = n.renderer) != null && f.render ? (i = n.renderer) == null ? void 0 : i.render({
|
|
353
|
+
record: e.record
|
|
354
|
+
}) : h(e.record, n.options)];
|
|
355
|
+
}
|
|
356
|
+
}))) ? l : {
|
|
357
|
+
default: () => [l]
|
|
358
|
+
})]);
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
}), ve = /* @__PURE__ */ E({
|
|
4
362
|
props: {
|
|
5
|
-
|
|
6
|
-
|
|
363
|
+
// 数据主键
|
|
364
|
+
rowKey: {
|
|
365
|
+
type: String,
|
|
366
|
+
required: !0
|
|
367
|
+
},
|
|
368
|
+
form: {
|
|
369
|
+
type: Object,
|
|
370
|
+
required: !1
|
|
371
|
+
},
|
|
372
|
+
columns: {
|
|
373
|
+
type: Object,
|
|
374
|
+
required: !0
|
|
375
|
+
},
|
|
376
|
+
autoLoad: {
|
|
377
|
+
type: Boolean,
|
|
378
|
+
required: !1,
|
|
379
|
+
default: !0
|
|
380
|
+
},
|
|
381
|
+
loadData: {
|
|
382
|
+
type: Function,
|
|
383
|
+
required: !1
|
|
384
|
+
},
|
|
385
|
+
height: {
|
|
386
|
+
type: Number,
|
|
387
|
+
required: !1
|
|
388
|
+
},
|
|
389
|
+
size: {
|
|
390
|
+
type: String,
|
|
391
|
+
required: !1,
|
|
392
|
+
default: "large"
|
|
393
|
+
},
|
|
394
|
+
columnsOptions: {
|
|
395
|
+
type: Object,
|
|
396
|
+
required: !1
|
|
7
397
|
}
|
|
398
|
+
// 分页配置
|
|
399
|
+
// pagination: {
|
|
400
|
+
// type: Object as PropType<PaginationOptions | boolean>,
|
|
401
|
+
// required: false,
|
|
402
|
+
// },
|
|
8
403
|
},
|
|
404
|
+
expose: ["preview", "export"],
|
|
9
405
|
setup(e) {
|
|
10
|
-
|
|
406
|
+
const t = Math.random().toString(32).slice(2).toUpperCase(), r = w(), u = w(), a = w(), [l, n] = N(e.columns), f = {
|
|
407
|
+
rowKey: e.rowKey,
|
|
408
|
+
size: e.size,
|
|
409
|
+
scroll: {
|
|
410
|
+
x: e.columns.reduce((m, y) => m += typeof y.width != "number" ? Math.max(y.title.length * 16, 80) : y.width, 0),
|
|
411
|
+
y: e.height ?? "100%"
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
P("a", "xxxxasdasdasd");
|
|
415
|
+
const i = e.form || U(e.columns), d = (m) => {
|
|
416
|
+
var x;
|
|
417
|
+
if (!e.loadData)
|
|
418
|
+
return;
|
|
419
|
+
m != null && m.reset;
|
|
420
|
+
const y = {
|
|
421
|
+
...((x = u.value) == null ? void 0 : x.formSource) || {}
|
|
422
|
+
};
|
|
423
|
+
Object.keys(y).forEach((v) => {
|
|
424
|
+
[null, void 0, ""].includes(y[v]) && delete y[v];
|
|
425
|
+
}), e.loadData({
|
|
426
|
+
form: y,
|
|
427
|
+
update: n
|
|
428
|
+
});
|
|
429
|
+
}, g = (m) => {
|
|
430
|
+
const y = l.value.find((x) => x[e.rowKey] === m.key);
|
|
431
|
+
if (!y)
|
|
432
|
+
throw new Error("未找到需要预览的数据");
|
|
433
|
+
a.value.open(be, {
|
|
434
|
+
record: y,
|
|
435
|
+
columns: e.columns
|
|
436
|
+
}, {
|
|
437
|
+
title: m.title || "详情",
|
|
438
|
+
mode: m.mode
|
|
439
|
+
});
|
|
440
|
+
}, C = o({
|
|
441
|
+
reload: d,
|
|
442
|
+
preview: g,
|
|
443
|
+
export: (m) => {
|
|
444
|
+
},
|
|
445
|
+
edit: (m) => {
|
|
446
|
+
}
|
|
447
|
+
}), O = me(e.columns, e.columnsOptions, C);
|
|
448
|
+
return $(() => {
|
|
449
|
+
e.autoLoad && d();
|
|
450
|
+
}), {
|
|
451
|
+
tableId: t,
|
|
452
|
+
tableInstance: r,
|
|
453
|
+
tableSource: l,
|
|
454
|
+
tableOptions: f,
|
|
455
|
+
tableColumns: O,
|
|
456
|
+
tableEvents: C,
|
|
457
|
+
tableForm: i,
|
|
458
|
+
formInstance: u,
|
|
459
|
+
modalInstance: a,
|
|
460
|
+
reload: d,
|
|
461
|
+
preview: g
|
|
462
|
+
};
|
|
11
463
|
},
|
|
12
464
|
render() {
|
|
13
|
-
const e =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
salary: 25e3,
|
|
35
|
-
address: "35 Park Road, London",
|
|
36
|
-
email: "alisa.ross@example.com"
|
|
37
|
-
}, {
|
|
38
|
-
key: "3",
|
|
39
|
-
name: "Kevin Sandra",
|
|
40
|
-
salary: 22e3,
|
|
41
|
-
address: "31 Park Road, London",
|
|
42
|
-
email: "kevin.sandra@example.com"
|
|
43
|
-
}, {
|
|
44
|
-
key: "4",
|
|
45
|
-
name: "Ed Hellen",
|
|
46
|
-
salary: 17e3,
|
|
47
|
-
address: "42 Park Road, London",
|
|
48
|
-
email: "ed.hellen@example.com"
|
|
465
|
+
const e = () => {
|
|
466
|
+
if (this.tableForm)
|
|
467
|
+
return c("div", {
|
|
468
|
+
class: "table-form"
|
|
469
|
+
}, [c(D, {
|
|
470
|
+
form: this.tableForm,
|
|
471
|
+
ref: (r) => this.formInstance = r,
|
|
472
|
+
searchable: !0,
|
|
473
|
+
onSubmit: () => this.tableEvents("reload")
|
|
474
|
+
}, null)]);
|
|
475
|
+
}, t = () => c("div", {
|
|
476
|
+
class: "table-body"
|
|
477
|
+
}, [c(_, q({
|
|
478
|
+
data: this.tableSource,
|
|
479
|
+
columns: this.tableColumns,
|
|
480
|
+
ref: (r) => this.tableInstance = r
|
|
481
|
+
}, this.tableOptions), null)]);
|
|
482
|
+
return c("div", {
|
|
483
|
+
class: "table-render"
|
|
484
|
+
}, [c(K, {
|
|
485
|
+
ref: (r) => this.modalInstance = r
|
|
49
486
|
}, {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
email: "william.smith@example.com"
|
|
55
|
-
}]);
|
|
56
|
-
return o(s, {
|
|
57
|
-
columns: e,
|
|
58
|
-
data: a
|
|
59
|
-
}, null);
|
|
487
|
+
default: () => [c("div", {
|
|
488
|
+
class: "table-render-content"
|
|
489
|
+
}, [e(), t()])]
|
|
490
|
+
})]);
|
|
60
491
|
}
|
|
61
492
|
});
|
|
493
|
+
function Te(e) {
|
|
494
|
+
return e;
|
|
495
|
+
}
|
|
496
|
+
function Se(e) {
|
|
497
|
+
return e;
|
|
498
|
+
}
|
|
62
499
|
export {
|
|
63
|
-
|
|
500
|
+
ve as TableRender,
|
|
501
|
+
Te as defineColumns,
|
|
502
|
+
Se as defineTableLoad,
|
|
503
|
+
o as useEvents,
|
|
504
|
+
Ce as useTable
|
|
64
505
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { FormItemOptions } from '@gopowerteam/form-render';
|
|
2
|
+
import type { TableColumnData } from '@arco-design/web-vue';
|
|
3
|
+
import type { TableColumnRender } from './table-column-render';
|
|
4
|
+
import type { DataRecord } from '.';
|
|
5
|
+
export interface TableColumnPreviewOptions {
|
|
6
|
+
span?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface TableColumnSharedOptions {
|
|
9
|
+
align?: 'left' | 'right' | 'center';
|
|
10
|
+
width?: number;
|
|
11
|
+
ellipsis?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 列配置
|
|
15
|
+
*/
|
|
16
|
+
export interface TableColumnOptions<T> {
|
|
17
|
+
key: string;
|
|
18
|
+
title: string;
|
|
19
|
+
index?: string;
|
|
20
|
+
fixed?: 'left' | 'right';
|
|
21
|
+
align?: 'left' | 'right' | 'center';
|
|
22
|
+
width?: number | 'auto';
|
|
23
|
+
render?: TableColumnRender<T>;
|
|
24
|
+
form?: boolean | Omit<FormItemOptions, 'key' | 'title'>;
|
|
25
|
+
formatter?: DataFormatter<T>;
|
|
26
|
+
ellipsis?: boolean;
|
|
27
|
+
preview?: TableColumnPreviewOptions;
|
|
28
|
+
exportable?: ExportColumnOptions | boolean;
|
|
29
|
+
treeNode?: boolean;
|
|
30
|
+
visiable?: boolean | (() => boolean);
|
|
31
|
+
extraProps?: Partial<Omit<TableColumnData, 'dataIndex' | 'title' | 'fixed' | 'align' | 'width'>>;
|
|
32
|
+
}
|
|
33
|
+
export interface ExportColumnOptions {
|
|
34
|
+
header?: string;
|
|
35
|
+
width?: number;
|
|
36
|
+
content?: (record: DataRecord) => string | number | undefined;
|
|
37
|
+
}
|
|
38
|
+
export type TableColumnsOptions<T = DataRecord> = TableColumnOptions<T>[];
|
|
39
|
+
export type DataFormatter<T> = (record: T) => string | number | Date | undefined;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { EventEmits } from '../hooks';
|
|
2
|
+
import type { TableColumnRenders } from '../table-columns';
|
|
3
|
+
import type { TableColumnOptions } from './table-column-options';
|
|
4
|
+
interface TableColumnRenderResultType {
|
|
5
|
+
$type?: string;
|
|
6
|
+
$disableColumnMode?: boolean;
|
|
7
|
+
$disableViewMode?: boolean;
|
|
8
|
+
$showOverflow?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface TableColumnRenderResult<T> extends TableColumnRenderResultType {
|
|
11
|
+
(record: T, columnOptions: TableColumnOptions<T>, ctx?: {
|
|
12
|
+
previewing?: boolean;
|
|
13
|
+
emits?: EventEmits;
|
|
14
|
+
}): JSX.Element;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Render函数
|
|
18
|
+
*/
|
|
19
|
+
export interface TableColumnRender<T> {
|
|
20
|
+
(render: TableColumnRenderFun<T>): TableColumnRenderResult<T>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Render函数模板
|
|
24
|
+
*/
|
|
25
|
+
type TableColumnRenderFun<T> = ReturnType<typeof TableColumnRenders<T>> & {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface DataRecord {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
}
|
|
4
|
+
export interface DataProp {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* 分页接口
|
|
9
|
+
*/
|
|
10
|
+
export interface PageService {
|
|
11
|
+
page: number;
|
|
12
|
+
size: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 数据加载参数
|
|
16
|
+
*/
|
|
17
|
+
export interface TableLoadParams {
|
|
18
|
+
form: DataRecord;
|
|
19
|
+
page?: PageService;
|
|
20
|
+
update: (data: DataRecord[]) => void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type TableColumnData, type TableData } from '@arco-design/web-vue';
|
|
2
|
+
import type { TableColumnOptions, TableColumnSharedOptions, TableColumnsOptions } from '../interfaces';
|
|
3
|
+
import { RenderColumnType } from '../utils';
|
|
4
|
+
import type { EventEmits } from '../hooks';
|
|
5
|
+
/**
|
|
6
|
+
* 生成Render模板
|
|
7
|
+
* @param render
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function toRenderColumn<T>(options?: TableColumnOptions<T>, context?: {
|
|
11
|
+
previewing?: boolean;
|
|
12
|
+
emits?: EventEmits;
|
|
13
|
+
}): {
|
|
14
|
+
render: ({ record }: {
|
|
15
|
+
record: TableData;
|
|
16
|
+
}) => JSX.Element;
|
|
17
|
+
[RenderColumnType]: string | undefined;
|
|
18
|
+
disableColumnMode: boolean | undefined;
|
|
19
|
+
disableViewMode: boolean | undefined;
|
|
20
|
+
showOverflow: boolean | undefined;
|
|
21
|
+
isRenderColumn: boolean;
|
|
22
|
+
type: string | undefined;
|
|
23
|
+
} | undefined;
|
|
24
|
+
export declare function renderTableColumns(columns: TableColumnsOptions, columnsOptions: TableColumnSharedOptions | undefined, events: EventEmits): TableColumnData[];
|
|
25
|
+
/**
|
|
26
|
+
* 创建表格列
|
|
27
|
+
* @param options
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
export declare function renderTableColumn<T>(options: TableColumnOptions<T>, events: EventEmits): TableColumnData | undefined;
|