解决objectSpanMethod与expand共存时展开后表格错位问题

1、增加@expand-change="expandHeight"---手动增加高度

2、单列合并('department')

复制代码
 expandHeight(row, expanded) {
      this.$nextTick(() => {
        const rowIndex = this.tableData.findIndex(
          (item) => item.userKey === row.userKey
        );
        if (rowIndex === -1 || !this.spanObj.department) return;

        let realIndex = rowIndex;
        for (let i = rowIndex; i >= 0; i--) {
          if (this.spanObj.department[i] > 0) {
            realIndex = i;
            break;
          }
        }

        const isExpanding = expanded.some(
          (item) => item.userKey === row.userKey
        );

        const newDept = [...this.spanObj.department];
        if (isExpanding) {
          newDept[realIndex] += 1;
        } else {
          newDept[realIndex] -= 1;
        }

        this.spanObj.department = newDept;

        this.$refs.oneRef.doLayout();
      });
    },

3、多列合并('department' ,'group' )

复制代码
    expandHeight(row, expanded) {
      this.$nextTick(() => {
        const rowIndex = this.tableData.findIndex(
          (item) => item.userKey === row.userKey
        );
        if (rowIndex === -1 || !this.spanObj.department || !this.spanObj.group)
          return;

        let deptIndex = rowIndex;
        for (let i = rowIndex; i >= 0; i--) {
          if (this.spanObj.department[i] > 0) {
            deptIndex = i;
            break;
          }
        }

        let groupIndex = rowIndex;
        for (let i = rowIndex; i >= 0; i--) {
          if (this.spanObj.group[i] > 0) {
            groupIndex = i;
            break;
          }
        }

        const isExpanding = expanded.some(
          (item) => item.userKey === row.userKey
        );

        const newDept = [...this.spanObj.department];
        const newGroup = [...this.spanObj.group];

        if (isExpanding) {
          newDept[deptIndex] += 1;
          newGroup[groupIndex] += 1;
        } else {
          newDept[deptIndex] -= 1;
          newGroup[groupIndex] -= 1;
        }

        this.spanObj.department = newDept;
        this.spanObj.group = newGroup;

        this.$refs.oneRef.doLayout();
      });
    },

解决思路:展开某行时候 手动在合并的列中 增加一个高度,其他代码看上一篇

相关推荐
xiangxiongfly91517 小时前
Vue3 动态加载静态资源
前端·javascript·vue.js
克里斯蒂亚诺更新18 小时前
ruoyi切换新版本初始化需要修改的地方
前端·javascript·vue.js
特种加菲猫18 小时前
二叉搜索树:数据世界的“快速寻路指南”
开发语言·c++
特种加菲猫18 小时前
STL关联容器:Set/Multiset与Map/Multimap详解
开发语言·c++
我滴老baby18 小时前
0基础速通Python+AI|2026热门轻量化玩法全攻略:从入门到实战,3天搞定AI应用开发
开发语言·人工智能·python
一个天蝎座 白勺 程序猿18 小时前
Python(29)Python生成器函数深度解析:asyncio事件循环的底层实现与异步编程实战
开发语言·python
2zcode18 小时前
原创文档:基于MATLAB的线性预测编码变声器系统
开发语言·matlab·语音识别
七夜zippoe18 小时前
Python RESTful API设计终极指南:从理论到企业级实战
开发语言·python·http·pandas·restful api
lly20240618 小时前
Highcharts 配置说明
开发语言
车位涂鸦18 小时前
在线浏览“秀人网合集”的新思路:30 行 Python 把封面图链接秒变本地可点图库
开发语言·python