UNPKG

@layui/layui-vue

Version:

a component library for Vue 3 base on layui-vue

23 lines (22 loc) 2.57 kB
import { defineComponent as A, inject as k, computed as x, createVNode as s, Fragment as E } from "vue"; import L from "../../../icon/index.js"; import { LAY_TABLE_CONTEXT as O, columnsTypeList as z } from "../../constant.js"; import { isString as B } from "../../../utils/type.js"; const F = A({ name: "LayTableMainTd", inheritAttrs: !1, props: { data: { type: Object, default: () => ({}) }, dataIndex: { type: Number, default: 0 }, column: { type: Object, default: () => ({}) }, columnIndex: { type: Number, default: 0 }, expandSpace: { type: Boolean }, expandIndex: { type: Number, default: 0 }, currentIndentSize: { type: Number, default: 0 } }, emits: ["update:expandKeys"], setup({ data: n, column: a, dataIndex: d, columnIndex: t, expandSpace: y, expandIndex: i, currentIndentSize: C }, { slots: r }) { const { tableProps: o, tableSlots: b, tableEmits: f, expandState: I, commonGetClasses: v, commonGetStylees: w } = k(O), m = (e, c, u, p) => { const l = o.spanMethod(e, c, u, p); return l instanceof Array ? { rowspan: l[0], colspan: l[1] } : l instanceof Object ? l : { rowspan: 1, colspan: 1 }; }, g = (e, { data: c, column: u, dataIndex: p, columnIndex: l }) => B(o[e]) ? o[e] : o[e](c, u, p, l), S = x(() => I.checkExpand(n[o.id])), T = x(() => S.value ? "layui-icon-subtraction" : "layui-icon-addition"), j = (e) => { I.toggleExpand(n[o.id], !S.value), f("expand-change", n, e); }, N = () => { var e; return s(E, null, [y && t === i && s("span", { style: { marginRight: `${C}px` } }, null), y && !n[o.childrenColumnName] && !b.expand && t === i && s("span", { class: "layui-table-cell-expand-icon-spaced" }, null), (b.expand || n[o.childrenColumnName]) && t === i && s(L, { class: "layui-table-cell-expand-icon", type: T.value, onClick: j }, null), (e = r.default) == null ? void 0 : e.call(r)]); }, h = x(() => a.type && z.includes(a.type)); return () => ((e, c, u, p) => { const l = m(e, c, u, p); return l.colspan != 0 || l.rowspan != 0; })(n, a, d, t) && s("td", { class: v(a, g("cellClassName", { data: n, column: a, dataIndex: d, columnIndex: t })), style: w(a, { whiteSpace: a.ellipsisTooltip ? "nowrap" : "normal" }, g("cellStyle", { data: n, column: a, dataIndex: d, columnIndex: t })), colspan: m(n, a, d, t).colspan, rowspan: m(n, a, d, t).rowspan, onDblclick: h.value ? (e) => f("cell-double", n[a.key], e) : void 0 }, [h.value ? s(N, null, null) : s("div", { class: "layui-table-cell-content", style: { textAlign: a.align, justifyContent: a.align } }, [s(N, null, null)])]); } }); export { F as default };