ling-yun-custom-components 0.0.76 → 0.0.77
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/es/PaginationTable.mjs
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { w as Ee } from "./chunks/index.bCzIhWFw.js";
|
|
2
|
-
import { useSlots as ke, computed as m, ref as v, watch as
|
|
3
|
-
import { ElButton as
|
|
4
|
-
import { emitsMap as
|
|
5
|
-
import { _ as
|
|
6
|
-
import { cloneDeep as
|
|
7
|
-
import { _ as
|
|
8
|
-
import './assets/PaginationTable.css';const
|
|
2
|
+
import { useSlots as ke, computed as m, ref as v, watch as ue, onMounted as ze, nextTick as Pe, createElementBlock as E, openBlock as S, createElementVNode as y, createCommentVNode as k, unref as p, renderSlot as I, Fragment as Ne, createBlock as oe, withCtx as j, createTextVNode as de, toDisplayString as Ae, createVNode as U, createSlots as We, renderList as De, normalizeProps as Ie, guardReactiveProps as je, mergeProps as Oe, h as H } from "vue";
|
|
3
|
+
import { ElButton as re, ElAutoResizer as qe, ElTableV2 as Ke, ElCheckbox as $e } from "element-plus";
|
|
4
|
+
import { emitsMap as ce, paginationConfig as Fe, calculateScale as Ve } from "color-star-custom-methods";
|
|
5
|
+
import { _ as Le } from "./chunks/layout.BOupEsmd.js";
|
|
6
|
+
import { cloneDeep as Me } from "lodash";
|
|
7
|
+
import { _ as _e } from "./chunks/_plugin-vue_export-helper.CHgC5LLL.js";
|
|
8
|
+
import './assets/PaginationTable.css';const Ue = { class: "flex h-full flex-col" }, He = {
|
|
9
9
|
class: "w-full flex justify-between overflow-hidden",
|
|
10
10
|
style: { height: "auto" }
|
|
11
|
-
},
|
|
11
|
+
}, Ge = {
|
|
12
12
|
key: 0,
|
|
13
13
|
class: "flex-1 overflow-hidden"
|
|
14
|
-
},
|
|
14
|
+
}, Je = {
|
|
15
15
|
class: "flex",
|
|
16
16
|
style: { width: "auto", gap: "10px" }
|
|
17
|
-
},
|
|
17
|
+
}, Qe = {
|
|
18
18
|
key: 1,
|
|
19
19
|
class: "flex items-center mg-b-18"
|
|
20
|
-
},
|
|
20
|
+
}, Xe = { class: "fz-12 text-74798c" }, Ye = { class: "btn-group mg-l-12" }, Ze = { class: "w-full flex-1 overflow-hidden flex flex-col" }, et = { class: "flex-1 overflow-hidden TABLE-AREA" }, tt = {
|
|
21
21
|
key: 0,
|
|
22
22
|
class: "flex justify-end mg-t-20",
|
|
23
23
|
style: { height: "auto" }
|
|
24
|
-
},
|
|
24
|
+
}, lt = /* @__PURE__ */ Object.assign({
|
|
25
25
|
name: "PaginationTable"
|
|
26
26
|
}, {
|
|
27
27
|
__name: "layout",
|
|
@@ -104,20 +104,20 @@ import './assets/PaginationTable.css';const Me = { class: "flex h-full flex-col"
|
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
106
|
emits: [
|
|
107
|
-
|
|
107
|
+
ce.paginationChange,
|
|
108
108
|
"updateTableData",
|
|
109
109
|
"handleTableSelect",
|
|
110
110
|
"handleBatchDelete",
|
|
111
111
|
"updateSortState",
|
|
112
112
|
"endReached"
|
|
113
113
|
],
|
|
114
|
-
setup(c, { expose:
|
|
115
|
-
const b =
|
|
114
|
+
setup(c, { expose: fe, emit: he }) {
|
|
115
|
+
const b = he, u = c, O = ke(), z = m(() => typeof u.requestFn == "function"), r = m({
|
|
116
116
|
get: () => z.value ? x.value : u.tableData,
|
|
117
117
|
set: (e) => {
|
|
118
118
|
z.value ? x.value = e : b("updateTableData", e);
|
|
119
119
|
}
|
|
120
|
-
}),
|
|
120
|
+
}), q = v(0), ve = m(() => z.value ? q.value : u.total), w = m({
|
|
121
121
|
get: () => u.sortState,
|
|
122
122
|
set: (e) => {
|
|
123
123
|
b("updateSortState", e);
|
|
@@ -126,12 +126,12 @@ import './assets/PaginationTable.css';const Me = { class: "flex h-full flex-col"
|
|
|
126
126
|
w.value[e] = t, r.value = r.value.reverse();
|
|
127
127
|
}, ge = (e) => {
|
|
128
128
|
b("endReached", e);
|
|
129
|
-
}, x = v([]), h = m(() => u.pageMapping.pageNum),
|
|
129
|
+
}, x = v([]), h = m(() => u.pageMapping.pageNum), K = m(() => u.pageMapping.pageSize), $ = {
|
|
130
130
|
[h.value]: 1,
|
|
131
|
-
[
|
|
131
|
+
[K.value]: 20
|
|
132
132
|
}, d = v({
|
|
133
|
-
|
|
134
|
-
}), g = v([]), i = v([]),
|
|
133
|
+
...$
|
|
134
|
+
}), g = v([]), i = v([]), G = v([]), C = v({}), J = m(() => me(C.value));
|
|
135
135
|
function me(e) {
|
|
136
136
|
const t = /* @__PURE__ */ new Set();
|
|
137
137
|
for (const l in e)
|
|
@@ -140,7 +140,7 @@ import './assets/PaginationTable.css';const Me = { class: "flex h-full flex-col"
|
|
|
140
140
|
});
|
|
141
141
|
return t;
|
|
142
142
|
}
|
|
143
|
-
const
|
|
143
|
+
const Q = ({ value: e, intermediate: t = !1, onChange: l }) => H($e, {
|
|
144
144
|
onChange: l,
|
|
145
145
|
modelValue: e,
|
|
146
146
|
indeterminate: t
|
|
@@ -153,46 +153,46 @@ import './assets/PaginationTable.css';const Me = { class: "flex h-full flex-col"
|
|
|
153
153
|
};
|
|
154
154
|
l(e.children);
|
|
155
155
|
}
|
|
156
|
-
e.parentId &&
|
|
157
|
-
},
|
|
158
|
-
const t =
|
|
156
|
+
e.parentId && X(e.parentId), Z(), R();
|
|
157
|
+
}, X = (e) => {
|
|
158
|
+
const t = Y(r.value, e);
|
|
159
159
|
if (!t) return;
|
|
160
160
|
const l = t.children.every((a) => a.selected);
|
|
161
|
-
l && !t.selected ? (t.selected = !0, i.value.some((a) => a.id === t.id) || i.value.push(t)) : !l && t.selected && (t.selected = !1, i.value = i.value.filter(({ id: a }) => a !== t.id)), t.parentId &&
|
|
162
|
-
},
|
|
161
|
+
l && !t.selected ? (t.selected = !0, i.value.some((a) => a.id === t.id) || i.value.push(t)) : !l && t.selected && (t.selected = !1, i.value = i.value.filter(({ id: a }) => a !== t.id)), t.parentId && X(t.parentId);
|
|
162
|
+
}, Y = (e, t) => {
|
|
163
163
|
for (const l of e) {
|
|
164
164
|
if (l.id === t) return l;
|
|
165
165
|
if (l.children) {
|
|
166
|
-
const a =
|
|
166
|
+
const a = Y(l.children, t);
|
|
167
167
|
if (a) return a;
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
return null;
|
|
171
171
|
};
|
|
172
|
-
function
|
|
173
|
-
C.value[d.value[h.value]] =
|
|
172
|
+
function Z() {
|
|
173
|
+
C.value[d.value[h.value]] = ee(
|
|
174
174
|
r.value
|
|
175
175
|
);
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function ee(e) {
|
|
178
178
|
let t = [];
|
|
179
179
|
return e.forEach((l) => {
|
|
180
|
-
l.selected && t.push(l), l.children && l.children.length > 0 && (t = t.concat(
|
|
180
|
+
l.selected && t.push(l), l.children && l.children.length > 0 && (t = t.concat(ee(l.children)));
|
|
181
181
|
}), t;
|
|
182
182
|
}
|
|
183
|
-
function
|
|
184
|
-
e.selected = t, e.children && e.children.length > 0 && e.children.forEach((l) =>
|
|
183
|
+
function F(e, t) {
|
|
184
|
+
e.selected = t, e.children && e.children.length > 0 && e.children.forEach((l) => F(l, t));
|
|
185
185
|
}
|
|
186
186
|
const ye = (e) => {
|
|
187
|
-
const t = r.value.map((l) => (
|
|
188
|
-
return r.value = [...t],
|
|
187
|
+
const t = r.value.map((l) => (F(l, e), l));
|
|
188
|
+
return r.value = [...t], Z(), i.value = e ? [...Object.values(C.value).flat()] : [], R(), [...i.value];
|
|
189
189
|
}, be = () => {
|
|
190
190
|
g.value.unshift({
|
|
191
191
|
key: "selection",
|
|
192
192
|
width: 50,
|
|
193
193
|
cellRenderer: (e) => {
|
|
194
194
|
const { rowData: t } = e, a = t.children && t.children.length > 0 ? xe(t) : !1;
|
|
195
|
-
return H(
|
|
195
|
+
return H(Q, {
|
|
196
196
|
value: t.selected,
|
|
197
197
|
intermediate: a,
|
|
198
198
|
onChange: (s) => Se(t, s)
|
|
@@ -200,10 +200,10 @@ import './assets/PaginationTable.css';const Me = { class: "flex h-full flex-col"
|
|
|
200
200
|
},
|
|
201
201
|
headerCellRenderer: () => {
|
|
202
202
|
const e = p(r), t = e.every((a) => {
|
|
203
|
-
const s = a.selected, o =
|
|
203
|
+
const s = a.selected, o = te(a);
|
|
204
204
|
return s && o;
|
|
205
|
-
}), l = e.some((a) => a.selected ||
|
|
206
|
-
return H(
|
|
205
|
+
}), l = e.some((a) => a.selected || le(a));
|
|
206
|
+
return H(Q, {
|
|
207
207
|
value: t,
|
|
208
208
|
intermediate: l && !t,
|
|
209
209
|
// 目前是当前页全选就是全选状态,也就是每页的全选状态单独的
|
|
@@ -217,28 +217,28 @@ import './assets/PaginationTable.css';const Me = { class: "flex h-full flex-col"
|
|
|
217
217
|
const t = e.children.filter((l) => l.selected).length;
|
|
218
218
|
return t > 0 && t < e.children.length;
|
|
219
219
|
};
|
|
220
|
+
function te(e) {
|
|
221
|
+
return e.children?.length ? !!e.selected && e.children.every(te) : !!e.selected;
|
|
222
|
+
}
|
|
220
223
|
function le(e) {
|
|
221
|
-
return e.
|
|
224
|
+
return e.selected ? !0 : e.children?.some(le) || !1;
|
|
222
225
|
}
|
|
223
226
|
function ae(e) {
|
|
224
|
-
return e.selected ? !0 : e.children?.some(ae) || !1;
|
|
225
|
-
}
|
|
226
|
-
function ne(e) {
|
|
227
227
|
return e.map((t) => {
|
|
228
228
|
const l = { ...t, selected: !1 };
|
|
229
|
-
return l.children && (l.children =
|
|
229
|
+
return l.children && (l.children = ae(l.children)), l;
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
232
|
const B = v(!1), Ce = () => {
|
|
233
233
|
B.value = !0, be();
|
|
234
|
-
},
|
|
235
|
-
B.value = !1, i.value = [], r.value = r.value.map((e) => (
|
|
234
|
+
}, V = () => {
|
|
235
|
+
B.value = !1, i.value = [], r.value = r.value.map((e) => (F(e, !1), e)), C.value = {}, x.value = ae(x.value), g.value.shift(), R();
|
|
236
236
|
}, we = () => {
|
|
237
237
|
b("handleBatchDelete", {
|
|
238
238
|
selectedRows: Object.values(C.value).flat(),
|
|
239
239
|
// getAllSelectedNodes(finalTableData.value)
|
|
240
240
|
cb: () => {
|
|
241
|
-
|
|
241
|
+
V(), R();
|
|
242
242
|
}
|
|
243
243
|
});
|
|
244
244
|
}, Be = () => {
|
|
@@ -259,24 +259,24 @@ import './assets/PaginationTable.css';const Me = { class: "flex h-full flex-col"
|
|
|
259
259
|
...u.params,
|
|
260
260
|
...d.value
|
|
261
261
|
}).then((e) => {
|
|
262
|
-
x.value =
|
|
262
|
+
x.value = L(
|
|
263
263
|
e?.data[u.tableDataKey],
|
|
264
264
|
d.value[h.value],
|
|
265
|
-
|
|
266
|
-
) || [],
|
|
267
|
-
}) : (x.value =
|
|
265
|
+
J.value
|
|
266
|
+
) || [], q.value = e?.data?.total;
|
|
267
|
+
}) : (x.value = L(
|
|
268
268
|
u.tableData,
|
|
269
269
|
d.value[h.value],
|
|
270
|
-
|
|
271
|
-
),
|
|
270
|
+
J.value
|
|
271
|
+
), q.value = u.total);
|
|
272
272
|
};
|
|
273
|
-
function
|
|
273
|
+
function L(e, t, l, a = !1) {
|
|
274
274
|
return e.map((s) => {
|
|
275
275
|
const o = l.has(s.id) || a, f = {
|
|
276
276
|
...s,
|
|
277
277
|
selected: o
|
|
278
278
|
};
|
|
279
|
-
return f.children && (f.children =
|
|
279
|
+
return f.children && (f.children = L(
|
|
280
280
|
f.children,
|
|
281
281
|
t,
|
|
282
282
|
l,
|
|
@@ -286,116 +286,116 @@ import './assets/PaginationTable.css';const Me = { class: "flex h-full flex-col"
|
|
|
286
286
|
});
|
|
287
287
|
}
|
|
288
288
|
const Re = () => {
|
|
289
|
-
d.value[h.value] =
|
|
289
|
+
d.value[h.value] = $[h.value], T();
|
|
290
290
|
}, Te = () => {
|
|
291
|
-
d.value = {
|
|
292
|
-
},
|
|
293
|
-
e === "size" && (d.value[h.value] = 1), T(), b(
|
|
294
|
-
}, P = v(0),
|
|
295
|
-
let e = P.value, t =
|
|
291
|
+
d.value = { ...$ }, T();
|
|
292
|
+
}, ne = (e) => {
|
|
293
|
+
e === "size" && (d.value[h.value] = 1), T(), b(ce.paginationChange, d.value);
|
|
294
|
+
}, P = v(0), N = () => {
|
|
295
|
+
let e = P.value, t = Me(u.columns);
|
|
296
296
|
const l = 1 / Ve(), a = t.filter((n) => n.fixedWidth), s = t.filter((n) => !n.fixedWidth);
|
|
297
297
|
let o = 0;
|
|
298
298
|
a.forEach((n) => {
|
|
299
299
|
n.width && (o += n.width);
|
|
300
300
|
});
|
|
301
|
-
let f = e - o,
|
|
301
|
+
let f = e - o, M = 0;
|
|
302
302
|
s.forEach((n) => {
|
|
303
|
-
n.width && (
|
|
303
|
+
n.width && (M += n.width);
|
|
304
304
|
});
|
|
305
|
-
const
|
|
306
|
-
if (t.forEach((n,
|
|
307
|
-
let
|
|
305
|
+
const ie = [];
|
|
306
|
+
if (t.forEach((n, A) => {
|
|
307
|
+
let W;
|
|
308
308
|
if (n.fixedWidth)
|
|
309
|
-
|
|
310
|
-
else if (n.width &&
|
|
311
|
-
const
|
|
312
|
-
|
|
309
|
+
W = n.width || 100;
|
|
310
|
+
else if (n.width && M > 0) {
|
|
311
|
+
const D = n.width / M, _ = f * D;
|
|
312
|
+
W = Math.max(_, n.width);
|
|
313
313
|
} else {
|
|
314
|
-
const
|
|
315
|
-
|
|
314
|
+
const D = s.filter((_) => !_.width);
|
|
315
|
+
W = D.length > 0 ? f / D.length : f / s.length;
|
|
316
316
|
}
|
|
317
|
-
|
|
318
|
-
}), t = t.map((n,
|
|
319
|
-
const n = g.value.find((
|
|
317
|
+
ie.push(W);
|
|
318
|
+
}), t = t.map((n, A) => (n.width = ie[A] * l, w.value && Object.keys(w.value).length && w.value[n.key] && (n.sortable = !0), n)), B.value) {
|
|
319
|
+
const n = g.value.find((A) => A.key === "selection");
|
|
320
320
|
n && (g.value = [n, ...t]);
|
|
321
321
|
} else
|
|
322
322
|
g.value = [...t];
|
|
323
323
|
};
|
|
324
|
-
|
|
324
|
+
ue(
|
|
325
325
|
() => B.value,
|
|
326
326
|
() => {
|
|
327
|
-
|
|
327
|
+
N();
|
|
328
328
|
}
|
|
329
|
-
),
|
|
329
|
+
), ue(
|
|
330
330
|
() => u.tableDomWidth,
|
|
331
331
|
(e) => {
|
|
332
|
-
e && (P.value = e,
|
|
332
|
+
e && (P.value = e, N());
|
|
333
333
|
}
|
|
334
334
|
);
|
|
335
|
-
const
|
|
336
|
-
P.value = document.querySelector(".TABLE-AREA").getBoundingClientRect().width,
|
|
335
|
+
const se = () => {
|
|
336
|
+
P.value = document.querySelector(".TABLE-AREA").getBoundingClientRect().width, N();
|
|
337
337
|
};
|
|
338
338
|
return ze(() => {
|
|
339
|
-
T(), g.value = u.columns, P.value = document.querySelector(".TABLE-AREA").getBoundingClientRect().width,
|
|
340
|
-
|
|
341
|
-
}), window.addEventListener("resize",
|
|
342
|
-
}),
|
|
339
|
+
T(), g.value = u.columns, P.value = document.querySelector(".TABLE-AREA").getBoundingClientRect().width, Pe(() => {
|
|
340
|
+
N();
|
|
341
|
+
}), window.addEventListener("resize", se);
|
|
342
|
+
}), fe({
|
|
343
343
|
getTableList: T,
|
|
344
344
|
search: Re,
|
|
345
345
|
reset: Te,
|
|
346
346
|
initBatchSelect: Be,
|
|
347
|
-
handleCancelSelect:
|
|
348
|
-
handleResize:
|
|
349
|
-
}), (e, t) => (S(), E("div",
|
|
350
|
-
y("div",
|
|
351
|
-
p(
|
|
352
|
-
|
|
347
|
+
handleCancelSelect: V,
|
|
348
|
+
handleResize: se
|
|
349
|
+
}), (e, t) => (S(), E("div", Ue, [
|
|
350
|
+
y("div", He, [
|
|
351
|
+
p(O)["filter-left"] ? (S(), E("div", Ge, [
|
|
352
|
+
I(e.$slots, "filter-left", {}, void 0, !0)
|
|
353
353
|
])) : k("", !0),
|
|
354
|
-
y("div",
|
|
355
|
-
c.hasBatchSelect && r.value.length ? (S(), E(
|
|
356
|
-
B.value ? (S(), E("div",
|
|
357
|
-
y("div",
|
|
354
|
+
y("div", Je, [
|
|
355
|
+
c.hasBatchSelect && r.value.length ? (S(), E(Ne, { key: 0 }, [
|
|
356
|
+
B.value ? (S(), E("div", Qe, [
|
|
357
|
+
y("div", Xe, "已选" + Ae(i.value.length) + "条数据", 1),
|
|
358
358
|
y("div", {
|
|
359
359
|
class: "fz-12 text-3b64ff mg-l-4 pointer",
|
|
360
|
-
onClick:
|
|
360
|
+
onClick: V
|
|
361
361
|
}, "取消选择"),
|
|
362
|
-
|
|
363
|
-
y("div",
|
|
364
|
-
U(p(
|
|
362
|
+
I(e.$slots, "btn-group", {}, () => [
|
|
363
|
+
y("div", Ye, [
|
|
364
|
+
U(p(re), {
|
|
365
365
|
type: "danger",
|
|
366
366
|
onClick: we,
|
|
367
367
|
disabled: !i.value.length
|
|
368
368
|
}, {
|
|
369
|
-
default:
|
|
370
|
-
|
|
369
|
+
default: j(() => [...t[6] || (t[6] = [
|
|
370
|
+
de(" 删除 ", -1)
|
|
371
371
|
])]),
|
|
372
372
|
_: 1
|
|
373
373
|
}, 8, ["disabled"])
|
|
374
374
|
])
|
|
375
375
|
], !0)
|
|
376
|
-
])) : (S(),
|
|
376
|
+
])) : (S(), oe(p(re), {
|
|
377
377
|
key: 0,
|
|
378
378
|
disabled: c.disableBatchSelect,
|
|
379
379
|
title: c.disableBatchSelect ? c.disableBatchSelectText : "",
|
|
380
380
|
type: "default",
|
|
381
381
|
onClick: Ce
|
|
382
382
|
}, {
|
|
383
|
-
default:
|
|
384
|
-
|
|
383
|
+
default: j(() => [...t[5] || (t[5] = [
|
|
384
|
+
de(" 批量选择 ", -1)
|
|
385
385
|
])]),
|
|
386
386
|
_: 1
|
|
387
387
|
}, 8, ["disabled", "title"]))
|
|
388
388
|
], 64)) : k("", !0),
|
|
389
|
-
p(
|
|
389
|
+
p(O)["filter-right"] ? I(e.$slots, "filter-right", { key: 1 }, void 0, !0) : k("", !0)
|
|
390
390
|
])
|
|
391
391
|
]),
|
|
392
|
-
y("div",
|
|
393
|
-
y("div",
|
|
394
|
-
U(p(
|
|
395
|
-
default:
|
|
396
|
-
U(p(
|
|
397
|
-
"expanded-row-keys":
|
|
398
|
-
"onUpdate:expandedRowKeys": t[0] || (t[0] = (s) =>
|
|
392
|
+
y("div", Ze, [
|
|
393
|
+
y("div", et, [
|
|
394
|
+
U(p(qe), null, {
|
|
395
|
+
default: j(({ width: l, height: a }) => [
|
|
396
|
+
U(p(Ke), {
|
|
397
|
+
"expanded-row-keys": G.value,
|
|
398
|
+
"onUpdate:expandedRowKeys": t[0] || (t[0] = (s) => G.value = s),
|
|
399
399
|
"expand-column-key": c.expandColumnKey,
|
|
400
400
|
columns: g.value,
|
|
401
401
|
data: r.value,
|
|
@@ -406,10 +406,10 @@ import './assets/PaginationTable.css';const Me = { class: "flex h-full flex-col"
|
|
|
406
406
|
onEndReached: ge,
|
|
407
407
|
onColumnSort: pe
|
|
408
408
|
}, We({ _: 2 }, [
|
|
409
|
-
De(p(
|
|
409
|
+
De(p(O), (s, o) => ({
|
|
410
410
|
name: o,
|
|
411
|
-
fn:
|
|
412
|
-
|
|
411
|
+
fn: j((f) => [
|
|
412
|
+
I(e.$slots, o, Ie(je(f)), void 0, !0)
|
|
413
413
|
])
|
|
414
414
|
}))
|
|
415
415
|
]), 1032, ["expanded-row-keys", "expand-column-key", "columns", "data", "width", "height", "sort-state"])
|
|
@@ -417,25 +417,26 @@ import './assets/PaginationTable.css';const Me = { class: "flex h-full flex-col"
|
|
|
417
417
|
_: 3
|
|
418
418
|
})
|
|
419
419
|
]),
|
|
420
|
-
c.isPagination
|
|
421
|
-
c.isPagination ? (S(),
|
|
420
|
+
c.isPagination ? (S(), E("div", tt, [
|
|
421
|
+
c.isPagination ? (S(), oe(Le, Oe({
|
|
422
422
|
key: 0,
|
|
423
423
|
"current-page": d.value[h.value],
|
|
424
424
|
"onUpdate:currentPage": t[1] || (t[1] = (l) => d.value[h.value] = l),
|
|
425
|
-
"page-size": d.value[
|
|
426
|
-
"onUpdate:pageSize": t[2] || (t[2] = (l) => d.value[
|
|
425
|
+
"page-size": d.value[K.value],
|
|
426
|
+
"onUpdate:pageSize": t[2] || (t[2] = (l) => d.value[K.value] = l),
|
|
427
427
|
"page-sizes": c.pagination.pageSizes,
|
|
428
428
|
layout: c.pagination.layout,
|
|
429
|
-
total:
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
429
|
+
total: ve.value
|
|
430
|
+
}, e.$attrs, {
|
|
431
|
+
onSizeChange: t[3] || (t[3] = (l) => ne("size")),
|
|
432
|
+
onCurrentChange: t[4] || (t[4] = (l) => ne("page"))
|
|
433
|
+
}), null, 16, ["current-page", "page-size", "page-sizes", "layout", "total"])) : k("", !0)
|
|
433
434
|
])) : k("", !0)
|
|
434
435
|
])
|
|
435
436
|
]));
|
|
436
437
|
}
|
|
437
|
-
}),
|
|
438
|
+
}), at = /* @__PURE__ */ _e(lt, [["__scopeId", "data-v-7c948317"]]), ct = Ee(at);
|
|
438
439
|
export {
|
|
439
|
-
|
|
440
|
-
|
|
440
|
+
ct as PaginationTable,
|
|
441
|
+
ct as default
|
|
441
442
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[data-v-
|
|
1
|
+
[data-v-7c948317] .el-table-v2__header-cell-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
package/lib/PaginationTable.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./assets/PaginationTable.css');const pe=require("./chunks/index.CkihWzK6.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./assets/PaginationTable.css');const pe=require("./chunks/index.CkihWzK6.js"),t=require("vue"),B=require("element-plus"),P=require("color-star-custom-methods"),ge=require("./chunks/layout.DbtiD7D3.js"),me=require("lodash"),Se=require("./chunks/_plugin-vue_export-helper.BHFhmbuH.js"),ye={class:"flex h-full flex-col"},be={class:"w-full flex justify-between overflow-hidden",style:{height:"auto"}},Ce={key:0,class:"flex-1 overflow-hidden"},xe={class:"flex",style:{width:"auto",gap:"10px"}},Be={key:1,class:"flex items-center mg-b-18"},Ee={class:"fz-12 text-74798c"},ke={class:"btn-group mg-l-12"},we={class:"w-full flex-1 overflow-hidden flex flex-col"},Ne={class:"flex-1 overflow-hidden TABLE-AREA"},Te={key:0,class:"flex justify-end mg-t-20",style:{height:"auto"}},Re=Object.assign({name:"PaginationTable"},{__name:"layout",props:{isPagination:{type:Boolean,default:!0},disableBatchSelect:{type:Boolean,default:!1},disableBatchSelectText:{type:String,default:""},total:{type:Number,default:0},tableData:{type:Array,default:()=>[]},pagination:{type:Object,default:()=>P.paginationConfig},params:{type:Object,default:()=>{}},requestFn:{type:Function},columns:{type:Array,default:()=>[]},hasBatchSelect:{type:Boolean,default:!1},expandColumnKey:{type:String,default:""},tableDataKey:{type:String,default:"list"},tableDomWidth:{type:Number,default:0},pageMapping:{type:Object,default:()=>({pageSize:"pageSize",pageNum:"pageNum"})},sortState:{type:Object,default:()=>{}}},emits:[P.emitsMap.paginationChange,"updateTableData","handleTableSelect","handleBatchDelete","updateSortState","endReached"],setup(f,{expose:ee,emit:te}){const g=te,i=f,V=t.useSlots(),E=t.computed(()=>typeof i.requestFn=="function"),d=t.computed({get:()=>E.value?m.value:i.tableData,set:e=>{E.value?m.value=e:g("updateTableData",e)}}),z=t.ref(0),le=t.computed(()=>E.value?z.value:i.total),y=t.computed({get:()=>i.sortState,set:e=>{g("updateSortState",e)}}),ae=({key:e,order:l})=>{y.value[e]=l,d.value=d.value.reverse()},ne=e=>{g("endReached",e)},m=t.ref([]),v=t.computed(()=>i.pageMapping.pageNum),A=t.computed(()=>i.pageMapping.pageSize),q={[v.value]:1,[A.value]:20},c=t.ref({...q}),p=t.ref([]),u=t.ref([]),M=t.ref([]),S=t.ref({}),K=t.computed(()=>oe(S.value));function oe(e){const l=new Set;for(const a in e)e.hasOwnProperty(a)&&e[a].forEach(n=>{l.add(n.id)});return l}const _=({value:e,intermediate:l=!1,onChange:a})=>t.h(B.ElCheckbox,{onChange:a,modelValue:e,indeterminate:l}),se=(e,l)=>{if(e.selected=l,l?u.value.some(a=>a.id===e.id)||u.value.push(e):u.value=u.value.filter(({id:a})=>a!==e.id),e.children&&e.children.length>0){const a=n=>{n.forEach(s=>{s.selected=l,l?u.value.some(r=>r.id===s.id)||u.value.push(s):u.value=u.value.filter(({id:r})=>r!==s.id),s.children&&s.children.length>0&&a(s.children)})};a(e.children)}e.parentId&&F(e.parentId),L(),C()},F=e=>{const l=$(d.value,e);if(!l)return;const a=l.children.every(n=>n.selected);a&&!l.selected?(l.selected=!0,u.value.some(n=>n.id===l.id)||u.value.push(l)):!a&&l.selected&&(l.selected=!1,u.value=u.value.filter(({id:n})=>n!==l.id)),l.parentId&&F(l.parentId)},$=(e,l)=>{for(const a of e){if(a.id===l)return a;if(a.children){const n=$(a.children,l);if(n)return n}}return null};function L(){S.value[c.value[v.value]]=U(d.value)}function U(e){let l=[];return e.forEach(a=>{a.selected&&l.push(a),a.children&&a.children.length>0&&(l=l.concat(U(a.children)))}),l}function W(e,l){e.selected=l,e.children&&e.children.length>0&&e.children.forEach(a=>W(a,l))}const ue=e=>{const l=d.value.map(a=>(W(a,e),a));return d.value=[...l],L(),u.value=e?[...Object.values(S.value).flat()]:[],C(),[...u.value]},ie=()=>{p.value.unshift({key:"selection",width:50,cellRenderer:e=>{const{rowData:l}=e,n=l.children&&l.children.length>0?re(l):!1;return t.h(_,{value:l.selected,intermediate:n,onChange:s=>se(l,s)})},headerCellRenderer:()=>{const e=t.unref(d),l=e.every(n=>{const s=n.selected,r=H(n);return s&&r}),a=e.some(n=>n.selected||G(n));return t.h(_,{value:l,intermediate:a&&!l,onChange:ue})}})},re=e=>{if(!e.children||e.children.length===0)return!1;const l=e.children.filter(a=>a.selected).length;return l>0&&l<e.children.length};function H(e){return e.children?.length?!!e.selected&&e.children.every(H):!!e.selected}function G(e){return e.selected?!0:e.children?.some(G)||!1}function J(e){return e.map(l=>{const a={...l,selected:!1};return a.children&&(a.children=J(a.children)),a})}const b=t.ref(!1),ce=()=>{b.value=!0,ie()},D=()=>{b.value=!1,u.value=[],d.value=d.value.map(e=>(W(e,!1),e)),S.value={},m.value=J(m.value),p.value.shift(),C()},de=()=>{g("handleBatchDelete",{selectedRows:Object.values(S.value).flat(),cb:()=>{D(),C()}})},fe=()=>{u.value=[],C()};function C(){const e=Object.values(S.value).flat();g("handleTableSelect",{originNodeData:u.value,allSelectedNodes:e,selectedSubNodes:e.filter(l=>!l.children)})}const x=()=>{E.value?i.requestFn({...i.params,...c.value}).then(e=>{m.value=j(e?.data[i.tableDataKey],c.value[v.value],K.value)||[],z.value=e?.data?.total}):(m.value=j(i.tableData,c.value[v.value],K.value),z.value=i.total)};function j(e,l,a,n=!1){return e.map(s=>{const r=a.has(s.id)||n,h={...s,selected:r};return h.children&&(h.children=j(h.children,l,a,r)),h})}const he=()=>{c.value[v.value]=q[v.value],x()},ve=()=>{c.value={...q},x()},Q=e=>{e==="size"&&(c.value[v.value]=1),x(),g(P.emitsMap.paginationChange,c.value)},k=t.ref(0),w=()=>{let e=k.value,l=me.cloneDeep(i.columns);const a=1/P.calculateScale(),n=l.filter(o=>o.fixedWidth),s=l.filter(o=>!o.fixedWidth);let r=0;n.forEach(o=>{o.width&&(r+=o.width)});let h=e-r,I=0;s.forEach(o=>{o.width&&(I+=o.width)});const Y=[];if(l.forEach((o,N)=>{let T;if(o.fixedWidth)T=o.width||100;else if(o.width&&I>0){const R=o.width/I,O=h*R;T=Math.max(O,o.width)}else{const R=s.filter(O=>!O.width);T=R.length>0?h/R.length:h/s.length}Y.push(T)}),l=l.map((o,N)=>(o.width=Y[N]*a,y.value&&Object.keys(y.value).length&&y.value[o.key]&&(o.sortable=!0),o)),b.value){const o=p.value.find(N=>N.key==="selection");o&&(p.value=[o,...l])}else p.value=[...l]};t.watch(()=>b.value,()=>{w()}),t.watch(()=>i.tableDomWidth,e=>{e&&(k.value=e,w())});const X=()=>{k.value=document.querySelector(".TABLE-AREA").getBoundingClientRect().width,w()};return t.onMounted(()=>{x(),p.value=i.columns,k.value=document.querySelector(".TABLE-AREA").getBoundingClientRect().width,t.nextTick(()=>{w()}),window.addEventListener("resize",X)}),ee({getTableList:x,search:he,reset:ve,initBatchSelect:fe,handleCancelSelect:D,handleResize:X}),(e,l)=>(t.openBlock(),t.createElementBlock("div",ye,[t.createElementVNode("div",be,[t.unref(V)["filter-left"]?(t.openBlock(),t.createElementBlock("div",Ce,[t.renderSlot(e.$slots,"filter-left",{},void 0,!0)])):t.createCommentVNode("",!0),t.createElementVNode("div",xe,[f.hasBatchSelect&&d.value.length?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[b.value?(t.openBlock(),t.createElementBlock("div",Be,[t.createElementVNode("div",Ee,"已选"+t.toDisplayString(u.value.length)+"条数据",1),t.createElementVNode("div",{class:"fz-12 text-3b64ff mg-l-4 pointer",onClick:D},"取消选择"),t.renderSlot(e.$slots,"btn-group",{},()=>[t.createElementVNode("div",ke,[t.createVNode(t.unref(B.ElButton),{type:"danger",onClick:de,disabled:!u.value.length},{default:t.withCtx(()=>[...l[6]||(l[6]=[t.createTextVNode(" 删除 ",-1)])]),_:1},8,["disabled"])])],!0)])):(t.openBlock(),t.createBlock(t.unref(B.ElButton),{key:0,disabled:f.disableBatchSelect,title:f.disableBatchSelect?f.disableBatchSelectText:"",type:"default",onClick:ce},{default:t.withCtx(()=>[...l[5]||(l[5]=[t.createTextVNode(" 批量选择 ",-1)])]),_:1},8,["disabled","title"]))],64)):t.createCommentVNode("",!0),t.unref(V)["filter-right"]?t.renderSlot(e.$slots,"filter-right",{key:1},void 0,!0):t.createCommentVNode("",!0)])]),t.createElementVNode("div",we,[t.createElementVNode("div",Ne,[t.createVNode(t.unref(B.ElAutoResizer),null,{default:t.withCtx(({width:a,height:n})=>[t.createVNode(t.unref(B.ElTableV2),{"expanded-row-keys":M.value,"onUpdate:expandedRowKeys":l[0]||(l[0]=s=>M.value=s),"expand-column-key":f.expandColumnKey,columns:p.value,data:d.value,width:a,height:n,fixed:"","sort-state":y.value,onEndReached:ne,onColumnSort:ae},t.createSlots({_:2},[t.renderList(t.unref(V),(s,r)=>({name:r,fn:t.withCtx(h=>[t.renderSlot(e.$slots,r,t.normalizeProps(t.guardReactiveProps(h)),void 0,!0)])}))]),1032,["expanded-row-keys","expand-column-key","columns","data","width","height","sort-state"])]),_:3})]),f.isPagination?(t.openBlock(),t.createElementBlock("div",Te,[f.isPagination?(t.openBlock(),t.createBlock(ge._sfc_main,t.mergeProps({key:0,"current-page":c.value[v.value],"onUpdate:currentPage":l[1]||(l[1]=a=>c.value[v.value]=a),"page-size":c.value[A.value],"onUpdate:pageSize":l[2]||(l[2]=a=>c.value[A.value]=a),"page-sizes":f.pagination.pageSizes,layout:f.pagination.layout,total:le.value},e.$attrs,{onSizeChange:l[3]||(l[3]=a=>Q("size")),onCurrentChange:l[4]||(l[4]=a=>Q("page"))}),null,16,["current-page","page-size","page-sizes","layout","total"])):t.createCommentVNode("",!0)])):t.createCommentVNode("",!0)])]))}}),Pe=Se._export_sfc(Re,[["__scopeId","data-v-7c948317"]]),Z=pe.withInstall(Pe);exports.PaginationTable=Z;exports.default=Z;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[data-v-
|
|
1
|
+
[data-v-7c948317] .el-table-v2__header-cell-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|