@layui/layui-vue
Version:
a component library for Vue 3 base on layui-vue
21 lines (20 loc) • 2.94 kB
JavaScript
import { defineComponent as V, inject as g, unref as e, openBlock as l, createElementBlock as o, createElementVNode as d, createVNode as n, Fragment as b, renderList as h, createBlock as C, withCtx as f, createTextVNode as D, toDisplayString as N, normalizeStyle as y, createCommentVNode as T } from "vue";
import E from "../../_components/render.js";
import w from "../../checkboxV2/index2.js";
import F from "../../dropdown/index2.js";
import c from "../../icon/index.js";
import { LAY_TABLE_CONTEXT as j } from "../constant.js";
import { useToolBar as M } from "../hooks/useToolbar.js";
import { isValueArray as k } from "../../utils/arrayUtil.js";
const R = { key: 0, class: "layui-table-tool" }, z = { class: "layui-table-tool-temp" }, O = { key: 0, class: "layui-table-tool-self" }, U = ["title"], X = { class: "layui-table-tool-checkbox" }, Y = ["title"], q = ["title"], G = ["title", "onClick"], $ = V({ name: "LayTableToolBar", __name: "TableToolbar", props: { defaultToolbar: { type: [Boolean, Array] }, spanMethod: { type: Function }, hierarchicalColumns: {}, lastLevelAllColumns: {}, tableDataSource: {}, tableRef: {} }, setup(x) {
const B = x, { tableSlots: m } = g(j), { t: p, showToolbars: u, toolbarStyle: r, exportData: _, print: A } = M(B);
return (L, s) => e(k)(e(u)) || e(m).toolbar ? (l(), o("div", R, [d("div", z, [n(e(E), { slots: e(m), render: "toolbar" }, null, 8, ["slots"])]), e(k)(e(u)) ? (l(), o("div", O, [(l(!0), o(b, null, h(e(u), (t, S) => (l(), o(b, { key: S }, [t === "filter" ? (l(), C(F, { key: 0, placement: "bottom-end" }, { content: f(() => [d("div", X, [(l(!0), o(b, null, h(L.hierarchicalColumns[0], (a, i) => (l(), C(w, { key: a.key || a.type || i, "model-value": !a.hide, skin: "primary", disabled: e(k)(a.children), value: i, onChange: () => function(v) {
v.hide = !v.hide;
}(a) }, { default: f(() => [D(N(a.title), 1)]), _: 2 }, 1032, ["model-value", "disabled", "value", "onChange"]))), 128))])]), default: f(() => [d("div", { class: "layui-inline", title: e(p)("table.filter"), "lay-event": "", style: y(e(r)(t)) }, [n(e(c), { type: "layui-icon-slider" })], 12, U)]), _: 2 }, 1024)) : t === "export" ? (l(), o("div", { key: 1, class: "layui-inline", title: e(p)("table.export"), "lay-event": "", style: y(e(r)(t)), onClick: s[0] || (s[0] = (a) => e(_)()) }, [n(e(c), { type: "layui-icon-export" })], 12, Y)) : t === "print" ? (l(), o("div", { key: 2, style: y(e(r)(t)), class: "layui-inline", title: e(p)("table.print"), "lay-event": "", onClick: s[1] || (s[1] = (a) => e(A)()) }, [n(e(c), { type: "layui-icon-print" })], 12, q)) : (l(), o("div", { key: 3, style: y(e(r)(t)), class: "layui-inline", title: t.title, "lay-event": "", onClick: (a) => {
var i;
return (i = t == null ? void 0 : t.onClick) == null ? void 0 : i.call(t);
} }, [n(e(c), { type: t.icon }, null, 8, ["type"])], 12, G))], 64))), 128))])) : T("", !0)])) : T("", !0);
} });
export {
$ as default
};