解决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();
      });
    },

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

相关推荐
蚰蜒螟8 分钟前
从 pthread_create 到 thread_native_entry:glibc 如何唤醒 Java 线程
java·开发语言
We་ct11 分钟前
LeetCode 300. 最长递增子序列:两种解法从入门到优化
开发语言·前端·javascript·算法·leetcode·typescript
gCode Teacher 格码致知12 分钟前
Python提高: unittest和 pytest的使用方法-由Deepseek产生
开发语言·python·pytest
Johnstons30 分钟前
网络可观测性落地指南:从“出了问题才排查“到“实时感知全网状态“
开发语言·网络·php
️是7836 分钟前
信息奥赛一本通—编程启蒙(3371:【例64.2】 生日相同)
开发语言·c++·算法
Kiling_070437 分钟前
Java Math类核心用法全解析
java·开发语言
jieyucx41 分钟前
Go 语言运算符与控制台输入输出详解
开发语言·后端·golang
Ulyanov1 小时前
《玩转QT Designer Studio:从设计到实战》 QT Designer Studio的定位革命与技术架构
开发语言·python·qt·系统仿真·雷达电子对抗仿真
iiiiyu1 小时前
常用API(StringJoiner类 & Math类 & System类)
java·大数据·开发语言·数据结构·编程语言
Xiu Yan2 小时前
Java 转 C++ 系列:函数对象、谓词和内建函数对象
java·开发语言·c++