行业知识
vue2点击左侧的树节点(el-tree)定位到对应右侧树形表格(el-table)的位置,树形表格懒加载
2026-11-28 15:39:43
来源:互联网转载
左侧树代码
{{ node.label }} 右侧树形表格代码
js代码
data: function () { return { defaultProps: { children: "childrenList", label: function (data, node) { return data.name; } }, treeData: [], detailsList: [], lazy: true //开启懒加载 }},methods: {// 点击分项定位到右边表格位置 handleNodeClick(data) { // 首先获取所有的行row的高度 const rowHeightList = []; //存放所有元素的高度 const temp = document.getElementsByClassName("el-table__row"); for (let i = 0; i { for (let x of dataList) { number++ // 判断分项是否存在,存在则进行定位操作 if (x.quotaName == data.firstQuotaName) { // itemRow = x; rowIndex = number - 1; break; } if (x.children) { fn(x.children); } } }; fn(this.detailsList); let totalHeight = 0; //求出选中行之前的的高度之和,需要注意的是,当前行的高度不能包含进去 for (let index = 0; index { if (itemChildren.detailId == detailId) { if (itemChildren.children) { itemChildren.children.forEach(itemOld=>{ childrenList.forEach(itemNew=>{ if ((itemOld.detailId == itemNew.detailId) && itemOld.children) { itemNew.children = itemOld.children } }) }) } itemChildren.children = childrenList } else { getMenu(itemChildren); } }); } } this.detailsList.forEach(item=>{ getMenu(item); }) },} el-table左键双击单元格编辑内容(输入框输入计算公式可直接得出结果),右键单击展示操作菜单,可编辑单元格高亮展示
下一篇:个人小店怎么搭建服务器?