UNPKG

@layui/layui-vue

Version:

a component library for Vue 3 base on layui-vue

23 lines (22 loc) 2.46 kB
import u from "../../_components/render.js"; import y from "../../checkboxV2/index2.js"; import f from "../../dropdown/index2.js"; import i from "../../icon/index.js"; import h from "../../space/index2.js"; import { defineComponent as d, inject as v, h as e } from "vue"; import { LAY_TABLE_CONTEXT as C } from "../constant.js"; import { useToolBar as k } from "../hooks/useToolbar.js"; import { isValueArray as m } from "../../utils/arrayUtil.js"; import { clsPrefix as r } from "../../utils/common.js"; const T = d({ name: "ToolbarItem", props: { resetParams: { required: !0, type: Object }, toolbar: { required: !0, type: [String, Object] } }, setup: (l) => () => { const { toolbar: t, resetParams: { t: o, exportData: s, hierarchicalColumns: n, print: p } } = l; return t === "filter" ? e(f, { placement: "bottom-end" }, { default: () => e("div", { class: r("table-toolbar-item"), title: o("table.filter") }, e(i, { type: r("icon-slider") })), content: () => e("div", { class: r("table-tool-checkbox") }, n[0].map((a, c) => e(y, { skin: "primary", key: a.key || a.type || c, value: c, modelValue: !a.hide, disabled: m(a.children), onChange: () => function(b) { b.hide = !b.hide; }(a) }, () => a.title))) }) : t === "export" ? e("div", { title: o("table.export"), class: r("table-toolbar-item"), onClick: s }, e(i, { type: r("icon-export") })) : t === "print" ? e("div", { title: o("table.print"), class: r("table-toolbar-item"), onClick: p }, e(i, { type: r("icon-print") })) : t != null && t.render ? t.render() : e("div", { title: t.title, class: r("table-toolbar-item"), onClick: t.onClick }, e(i, { type: t.icon })); } }), D = d({ name: "TableToolbar", props: { defaultToolbar: { required: !0, type: [Array, Boolean] }, hierarchicalColumns: { required: !0, type: Array }, spanMethod: { required: !0, type: Function }, lastLevelAllColumns: { required: !0, type: Array }, tableDataSource: { required: !0, type: Array }, tableRef: { required: !0, type: [Object, null] } }, setup(l) { const { tableSlots: t } = v(C), { showToolbars: o, ...s } = k(l); return () => m(o.value) || t.toolbar ? e("div", { class: r("table-tool") }, [e("div", { class: r("table-tool-temp") }, [e(u, { slots: t, render: "toolbar" })]), m(o.value) && e("div", { class: r("table-tool-self") }, e(h, () => o.value.map((n, p) => e(T, { toolbar: n, key: p, resetParams: { ...s, hierarchicalColumns: l.hierarchicalColumns } }))))]) : null; } }); export { D as default };