UNPKG

vxe-table

Version:

A PC-end table component based on Vxe UI, supporting copy-paste, data pivot table, and high-performance virtual list table solution.

97 lines (96 loc) • 2.63 kB
function getTreeNodeLines(isExpandable, depth, linesMask, isFirstRow, isLastRow, showRootLine) { const lines = []; for (let col = 1; col <= depth; col++) { const leftVal = `var(--vxe-ui-table-tree-node-btn-width) + var(--vxe-ui-table-current-tree-node-indent) * ${col - 1}`; const through = (linesMask & 1 << col - 1) !== 0; if (col === 1 && !showRootLine) { continue; } if (col < depth) { if (through) { let top = "0"; let height = "100%"; if (isFirstRow) { top = "50%"; height = "50%"; } else if (isLastRow) { top = "0"; height = "50%"; } lines.push({ type: "v", style: { left: `calc(${leftVal})`, top, height } }); } } else { let vTop = "0"; let vHeight = through ? "100%" : "50%"; if (isFirstRow && isLastRow) { vTop = "50%"; vHeight = "0px"; } else if (isFirstRow) { vTop = "50%"; vHeight = "50%"; } else if (isLastRow) { vTop = "0"; vHeight = "50%"; } if (isExpandable && vHeight !== "0px") { let cutType = "v cut"; if (vTop === "0" && vHeight === "50%") { cutType = "v cut-top"; } else if (vTop === "50%" && vHeight === "50%") { cutType = "v cut-bottom"; } else if (vHeight === "100%") { cutType = "v cut-full"; } lines.push({ type: cutType, style: { left: `calc(${leftVal})`, top: vTop, height: vHeight } }); } else { if (vHeight !== "0px") { lines.push({ type: "v", style: { left: `calc(${leftVal})`, top: vTop, height: vHeight } }); } } if (isExpandable) { lines.push({ type: "h", style: { left: `calc(${leftVal} + var(--vxe-ui-table-tree-node-btn-width) / 2 + 1px)`, top: "50%", width: "calc(var(--vxe-ui-table-current-tree-node-indent) - var(--vxe-ui-table-tree-node-btn-width) - 0.2em)" } }); } else { lines.push({ type: "h", style: { left: `calc(${leftVal})`, top: "50%", width: "calc(var(--vxe-ui-table-current-tree-node-indent) - var(--vxe-ui-table-tree-node-btn-width) / 2 - 0.1em)" } }); } } } return lines; } export { getTreeNodeLines };