UNPKG

vxe-pc-ui

Version:
61 lines (60 loc) 1.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.calcTreeLine = calcTreeLine; exports.deNodeValue = deNodeValue; exports.enNodeValue = enNodeValue; var _xeUtils = _interopRequireDefault(require("xe-utils")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } function enNodeValue(nodeid) { return _xeUtils.default.eqNull(nodeid) ? '' : encodeURIComponent(`${nodeid}`); } function deNodeValue(nodeid) { return nodeid ? decodeURIComponent(`${nodeid}`) : nodeid; } function countTreeExpand($xeTree, prevNode) { let count = 1; if (!prevNode) { return count; } const props = $xeTree.props; const { transform } = props; const reactData = $xeTree.reactData; const { updateExpandedFlag } = reactData; const internalData = $xeTree.internalData; const { treeExpandedMaps } = internalData; const { computeChildrenField, computeMapChildrenField } = $xeTree.getComputeMaps(); const childrenField = computeChildrenField.value; const mapChildrenField = computeMapChildrenField.value; const nodeChildren = prevNode[transform ? mapChildrenField : childrenField]; if (nodeChildren && updateExpandedFlag && treeExpandedMaps[$xeTree.getNodeId(prevNode)]) { for (let index = 0; index < nodeChildren.length; index++) { count += countTreeExpand($xeTree, nodeChildren[index]); } } return count; } function calcTreeLine($xeTree, node, prevNode) { const internalData = $xeTree.internalData; const { scrollYStore } = internalData; const { rowHeight } = scrollYStore; let expandSize = 1; if (prevNode) { expandSize = countTreeExpand($xeTree, prevNode); } return (rowHeight || 28) * expandSize - (prevNode ? 1 : 12); }