@layui/layui-vue
Version:
a component library for Vue 3 base on layui-vue
22 lines (21 loc) • 5.77 kB
JavaScript
import { defineComponent as R, inject as O, computed as y, resolveComponent as X, openBlock as d, createElementBlock as s, Fragment as i, createElementVNode as N, normalizeStyle as Y, normalizeClass as v, withModifiers as _, unref as t, renderList as M, createBlock as o, withCtx as c, mergeProps as p, createCommentVNode as x, createTextVNode as V, toDisplayString as k, createVNode as w } from "vue";
import $ from "../../../checkboxV2/index2.js";
import D from "../../../tooltip/index2.js";
import q from "../../../radio/index2.js";
import I from "../../../_components/render.js";
import f from "./TableMainTd.js";
import { LAY_TABLE_CONTEXT as G, columnsTypeList as H } from "../../constant.js";
const J = { key: 1 }, Q = { key: 0, class: "layui-table-cell-expand" }, U = ["colspan"], le = R({ name: "LayTableMain", __name: "TableMain", props: { id: {}, index: {}, data: {}, page: {}, columns: {}, indentSize: {}, currentIndentSize: {}, expandSpace: { type: Boolean }, expandIndex: {}, cellStyle: { type: [String, Function], default: "" }, cellClassName: { type: [String, Function], default: "" }, rowStyle: {}, rowClassName: {}, spanMethod: {}, defaultExpandAll: { type: Boolean }, getCheckboxProps: {}, getRadioProps: {}, childrenColumnName: { default: "children" } }, setup(E) {
const { tableEmits: S, tableSlots: u, selectedState: m, expandState: P } = O(G), n = E, g = y(() => P.checkExpand(n.data[n.id])), B = (e, l) => typeof n.rowClassName == "string" ? n.rowClassName : n.rowClassName(e, l), A = y(() => n.currentIndentSize + n.indentSize), L = y(() => n.getRadioProps(n.data, n.index)), F = y(() => n.getCheckboxProps(n.data, n.index));
return (e, l) => {
const K = X("LayTableMain");
return d(), s(i, null, [N("tr", { style: Y([(C = e.data, h = e.index, typeof n.rowStyle == "string" ? n.rowStyle : n.rowStyle(C, h))]), class: v([B(e.data, e.index)]), onClick: l[2] || (l[2] = _((a) => t(S)("row", e.data, a), ["stop"])), onDblclick: l[3] || (l[3] = (a) => t(S)("row-double", e.data, a)), onContextmenu: l[4] || (l[4] = _((a) => t(S)("row-contextmenu", e.data, a), ["stop"])) }, [(d(!0), s(i, null, M(e.columns, (a, r) => (d(), s(i, { key: a.key || a.type }, [a.type && t(H).includes(a.type) ? (d(), o(t(f), { key: 0, class: v(`layui-table-cell-${a.type}`), data: e.data, column: a, dataIndex: e.index, columnIndex: r, expandSpace: e.expandSpace, expandIndex: e.expandIndex, currentIndentSize: e.currentIndentSize }, { default: c(() => {
var z, b, T;
return [a.type === "radio" ? (d(), o(q, p({ key: 0, modelValue: t(m).tableSelectedKey.value, onChange: l[0] || (l[0] = () => t(m).toggleSelected(e.data[e.id])) }, L.value, { value: e.data[e.id] }), null, 16, ["modelValue", "value"])) : x("", !0), a.type === "checkbox" ? (d(), o($, p({ key: 1, modelValue: t(m).tableMSelectedKeys.includes(e.data[e.id]), onChange: l[1] || (l[1] = (j) => t(m).toggleMSelected(e.data, j)) }, F.value, { value: e.data[e.id], skin: "primary" }), null, 16, ["modelValue", "value"])) : x("", !0), a.type === "number" ? (d(), s(i, { key: 2 }, [V(k((z = e.page) != null && z.current ? (((b = e.page) == null ? void 0 : b.current) - 1) * ((T = e.page) == null ? void 0 : T.limit) + e.index + 1 : e.index + 1), 1)], 64)) : x("", !0)];
}), _: 2 }, 1032, ["class", "data", "column", "dataIndex", "columnIndex", "expandSpace", "expandIndex", "currentIndentSize"])) : (d(), s(i, { key: 1 }, [a.customSlot ? (d(), o(t(f), { key: 0, data: e.data, column: a, dataIndex: e.index, columnIndex: r, expandSpace: e.expandSpace, expandIndex: e.expandIndex, currentIndentSize: e.currentIndentSize }, { default: c(() => [a.ellipsisTooltip ? (d(), o(D, p({ key: 0, isAutoShow: !0, isDark: a.ellipsisTooltipTheme === "dark" }, a.ellipsisTooltipProps), { content: c(() => [w(t(I), { row: e.data, data: e.data, column: a, rowIndex: e.index, columnIndex: r, render: a.customSlot, slots: t(u) }, null, 8, ["row", "data", "column", "rowIndex", "columnIndex", "render", "slots"])]), default: c(() => [w(t(I), { row: e.data, data: e.data, column: a, rowIndex: e.index, columnIndex: r, render: a.customSlot, slots: t(u) }, null, 8, ["row", "data", "column", "rowIndex", "columnIndex", "render", "slots"])]), _: 2 }, 1040, ["isDark"])) : (d(), o(t(I), { key: 1, row: e.data, data: e.data, column: a, rowIndex: e.index, columnIndex: r, render: a.customSlot, slots: t(u) }, null, 8, ["row", "data", "column", "rowIndex", "columnIndex", "render", "slots"]))]), _: 2 }, 1032, ["data", "column", "dataIndex", "columnIndex", "expandSpace", "expandIndex", "currentIndentSize"])) : (d(), o(t(f), { key: 1, data: e.data, column: a, dataIndex: e.index, columnIndex: r, expandSpace: e.expandSpace, expandIndex: e.expandIndex, currentIndentSize: e.currentIndentSize }, { default: c(() => [a.ellipsisTooltip ? (d(), o(D, p({ key: 0, isDark: a.ellipsisTooltipTheme === "dark", isAutoShow: !0 }, a.ellipsisTooltipProps, { content: e.data[a.key] }), { default: c(() => [V(k(e.data[a.key]), 1)]), _: 2 }, 1040, ["isDark", "content"])) : (d(), s("span", J, k(e.data[a.key]), 1))]), _: 2 }, 1032, ["data", "column", "dataIndex", "columnIndex", "expandSpace", "expandIndex", "currentIndentSize"]))], 64))], 64))), 128))], 38), t(u).expand && g.value ? (d(), s("tr", Q, [N("td", { class: "layui-table-cell", colspan: e.columns.length }, [w(t(I), { slots: t(u), render: "expand", data: e.data, row: e.data }, null, 8, ["slots", "data", "row"])], 8, U)])) : x("", !0), e.data[e.childrenColumnName] && g.value ? (d(!0), s(i, { key: 1 }, M(e.data[e.childrenColumnName], (a, r) => (d(), o(K, p({ key: a[e.id] }, n, { index: r, data: a, "current-indent-size": A.value }), null, 16, ["index", "data", "current-indent-size"]))), 128)) : x("", !0)], 64);
var C, h;
};
} });
export {
le as default
};