el-plus-powerful-table
Version:
## [DOCS](https://peng-xiao-shuai.github.io/vite-vue-admin-docs/zh-CN/component_directive/component/powerful-table-doc.html)
116 lines (115 loc) • 3.06 kB
JavaScript
import { deepClone as a } from "../index.mjs";
import { computed as _ } from "vue";
function E(e, t, i) {
var y;
const r = (y = t.tree) == null ? void 0 : y.props;
let s = [];
const f = (l, p, d = a(t.list)) => {
s.length || (s = a(
t
).list.sort((n, c) => (n._cdSort = n[r == null ? void 0 : r.children] ? 1 : 0, c._cdSort = c[r == null ? void 0 : r.children] ? 1 : 0, c._cdSort - n._cdSort)));
const h = d;
if (!l || Array.isArray(l) && !l.length)
return t.list;
const o = L(p);
if (o.filters && o.filtersType === "select" || o.type === "switch")
g(
r,
s,
(n) => {
const c = n;
return l.some((F) => {
var w;
switch (o.type) {
case "tag": {
const S = (w = typeof c[o.prop] == "string" ? c[o.prop].split(",") : c[o.prop]) == null ? void 0 : w.map((O) => String(O));
return S == null ? void 0 : S.includes(String(F));
}
default:
return c[o.prop] == F;
}
});
},
h
);
else if (o.filtersType === "date") {
const n = l;
g(
r,
s,
(c) => A(
c[o.prop],
n[0],
n[1]
),
h
);
} else
g(
r,
s,
(n) => String(
n[o.prop] || ""
).includes(String(l)),
h
);
return h;
}, u = _(
() => (l) => L(l)
);
return {
handleHeaderFilterChange: (l, p) => {
var o;
let d = [];
const h = (o = i.value) == null ? void 0 : o.filter(
(n) => n.state.value.length
);
if (h != null && h.length) {
if (typeof u.value(p).customFilter == "function") {
new Promise((n) => {
u.value(p).customFilter(l, p, n);
}).then((n) => {
e.tableLists = n;
});
return;
}
h.forEach((n) => {
d = f(n.state.value, n.header, d), e.tableLists = d;
});
} else
e.tableLists = t.list;
},
getPropObj: u
};
}
const g = (e, t, i, r) => {
t && t.length && t.forEach((s) => {
const f = a(s);
f[e.children] && f[e.children].length ? (f[e.children] = [], D(i(s), r, f), g(
e,
s[e.children],
i,
i(s) ? r[r.length - 1][e.children] : r
)) : D(i(s), r, f);
});
}, D = (e, t, i) => {
e && (t.length && t.map((s) => JSON.stringify(s)).some((s) => s.replace(/,"_cdSort":\d/, "").includes(JSON.stringify(i).replace(/,"_cdSort":\d/, ""))) || t.push(i));
}, L = (e) => {
let t = { prop: "" };
if (!Array.isArray(e.props))
return t = e.props, t;
if (e.props.length === 1)
t = e.props[0];
else if (e.props.length > 1) {
const i = e.props.find((r) => r.filterItem);
t = i || e.props[0];
}
return t;
}, A = (e, t, i) => {
const r = new Date(e), s = new Date(t), f = new Date(i);
return r >= s && r <= f;
};
export {
E as useFilters
};
//# sourceMappingURL=useFilters.mjs.map