当前位置: 首页 > article >正文

el-table合并行

需求:

1、”用户任务“中的”代码“需要按照升序进行排列;
2、”用户任务“中连续的”会签“是共用一个序号,并且序号进行合并

效果

在这里插入图片描述

解决方法

列表排序一般是前端传值,后端进行排序。由于后端返回的表格列表没有 序号indexNum 这个字段,我是自己做的一个处理去进行添加,方便后续相同序号的合并

--ListTable.ts--
// 获取表格列表以及添加序号indexNum
  search(resetPaging: boolean) {
    if (resetPaging) {
      this.paging.page = 1;
    }
    let params = this.buildFilter();
    let loading = this.$loading(ConstantMgr.loadingOption);
    UserTaskInsApi.query(params)
      .then((res) => {
        if (res.success) {
          let dataList = res.data!;
          this.index = 1;
          this.tempIndex = 0;
          dataList.forEach((item: any, index) => {
            if (index === 0) {
              item.indexNum = this.index;
              this.tempIndex = this.index;
              this.index++;
              this.temp = item;
            } else {
              if (item.bpmUserTaskDefinitionId !== this.temp.bpmUserTaskDefinitionId) {
                item.indexNum = this.index;
                this.tempIndex = this.index;
                this.index++;
              } else {
                item.indexNum = this.tempIndex;
              }
            }
            // this.index++;
            this.temp = item;
          });
          this.records = dataList;
          console.log('records=>', this.records);
        }
      })
      .catch((err) => {
        this.$message.error(err.message);
      })
      .finally(() => {
        loading.close();
      });
  }

// 相同序号进行合并
  onMergeLines(records) {
    this.spanArr = [];
    this.position = 0;
    records.forEach((item, index) => {
      if (index === 0) {
        this.spanArr.push(1);
        this.position = 0;
      } else {
        if (records[index].indexNum === records[index - 1].indexNum) {
          this.spanArr[this.position] += 1; // 合并行
          this.spanArr.push(0);
        } else {
          this.spanArr.push(1);
          this.position = index;
        }
      }
    });
  }
  objectSpanMethod({ row, column, rowIndex, columnIndex }) {
    if (columnIndex === 0) { // 如果是第一列也就是序号那列就进行合并
      const _row = this.spanArr[rowIndex];
      const _col = _row > 0 ? 1 : 0;
      return {
        rowspan: _row,
        colspan: _col,
      };
    }
  }



--ListTable.vue--

 <el-table  :data="records" :span-method="objectSpanMethod" ……>
     ……
  </el-table>

推荐资料 :https://element.eleme.cn/#/zh-CN


http://www.kler.cn/news/149834.html

相关文章:

  • SecureCRT -- 使用说明
  • 【Apifox】测试工具自动编写接口文档
  • ubuntu系统进入休眠后cuda初始化报错
  • 【Redis基础】Redis基本的全局命令
  • 一文详解Python中常用数据类型
  • render函数举例
  • vue中下载文件后无法打开的坑
  • Linux 下命令行启动与关闭WebLogic的相关服务
  • PPP/INS紧组合代码学习
  • uniapp设置手机通知权限以及uniapp-push2.0推送
  • 【迅搜04】索引配置(一)加载配置文件以及服务端配置
  • SpringBoot : ch09 整合Redis
  • 解析javascript数组方法 find 和 filter 有何区别
  • Android 11.0 默认开启USB调试功能
  • 【C++】内存管理(new与delete)
  • android开发:安卓13Wifi和热点查看与设置功能
  • 【Java Spring】SpringBoot 五大类注解
  • 使用elasticsearch-head插件修改elasticsearch数据
  • [UGUI]Unity背包系统制作详细步骤
  • 【古月居《ros入门21讲》学习笔记】15_ROS中的坐标系管理系统
  • 王者农药小游戏
  • MySQL 索引类型
  • html实现计算器源码
  • linux 账号管理实例一,stdin,passwd复习
  • 力扣105. 从前序与中序遍历序列构造二叉树
  • 虹科方案 | 如何破解CAN与车载以太网之间数据传输和协议转换的难题?
  • 树与二叉树堆:链式二叉树的实现
  • 手机 IOS 软件 IPA 签名下载安装详情图文教程
  • 第七节HarmonyOS UIAbility生命周期以及启动模式
  • 基于SpringBoot的图书管理系统