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

table表格实现多行合并效果实现

vue-ant table表格实现多行合并

效果如图:
请添加图片描述

<template>
	<a-table
      :columns="columns"
      :data-source="data"
      bordered
      size="middle"
      :scroll="{ x: 'calc(200px + 50%)' }"
      :pagination="false"
    >
      <template #bodyCell="{ column, record }">
        <template v-if="column.dataIndex === 'action'">
          <span @click="toProjectPage(record.id)" style="color: #1677ff; cursor: pointer">
            查看详情
          </span>
        </template>
      </template>
    </a-table>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { h } from 'vue';


const columns = ref([]);
const data = ref([]); 
const totals = ref({});
const list = ref<any>([]);

onMounted(async () => {
  getDataDetail();
});

const toProjectPage = params => {
};

/** 获取数据明细列表数据 */
const getDataDetail = async () => {
  let columnsRes: any = [
    {
      title: '时间',
      dataIndex: 'name',
      align: 'center',
      width: 120,
      customCell: (_, index) => {
        if (index === 0) {
          return { rowSpan: 9 }; // 当前单元格与上一行的单元格合并,不再渲染
        } else {
          return { rowSpan: 0 };
        }
      },
    },
    {
      title: '二列',
      dataIndex: 'app_id',
      align: 'center',
      width: 120,
    },
    {
      title: '三列',
      dataIndex: 'state_id',
      align: 'center',
      width: 120,
    },
    {
      title: '四列',
      dataIndex: 'model_name',
      align: 'center',
      width: 120,
    },
    {
      title: '五列',
      dataIndex: 'person',
      align: 'center',
      width: 120,
    },
    {
      title: '六列',
      dataIndex: 'cost_sum',
      align: 'center',
      width: 120,
    },
    {
      title: '七列',
      dataIndex: 'invoke_sum',
      align: 'center',
      width: 120,
    },
    {
      title: '八列',
      dataIndex: 'external_sum',
      align: 'center',
      width: 120,
    },
    {
      title: '操作',
      dataIndex: 'action',
      align: 'center',
      width: 120,
    },
  ];
  let totalsArr: any = {};
  let dataRes: any = [
    {
      name: 'XXX1',
      app_id: 111,
      state_id: 11111,
      model_name: '3333',
      person: '9999',
      cost_sum: 1867,
      invoke_sum: 98989,
      external_sum: 9877,
    },
    {
      name: 'XXX2',
      app_id: 111,
      state_id: 11111,
      model_name: '3333',
      person: '9999',
      cost_sum: 1867,
      invoke_sum: 98989,
      external_sum: 9877,
    },
    {
      name: 'XXX3',
      app_id: 111,
      state_id: 11111,
      model_name: '3333',
      person: '9999',
      cost_sum: 1867,
      invoke_sum: 98989,
      external_sum: 9877,
    },
    {
      name: 'XXX5',
      app_id: 111,
      state_id: 11111,
      model_name: '3333',
      person: '9999',
      cost_sum: 1867,
      invoke_sum: 98989,
      external_sum: 9877,
    },
    {
      name: 'XXX6',
      app_id: 111,
      state_id: 11111,
      model_name: '3333',
      person: '9999',
      cost_sum: 1867,
      invoke_sum: 98989,
      external_sum: 9877,
    },
  ];
  columns.value = columnsRes;
  data.value = dataRes;
  totals.value = totalsArr;
  list.value = columnsRes.slice(1);
};
</script>

<style scoped lang="less">
:deep(.ant-table-thead > tr > th) {
  color: #fff !important;
  background: #1677ff !important;
  border-radius: 0 !important;
  text-align: center !important;
}
:deep(.ant-table-tbody > tr > td) {
  text-align: center !important;
}

.tabel-area {
  padding: 10px 20px 0;
  .filter-area {
    display: flex;
    align-items: center;
    .search-btn {
      margin-left: 20px;
    }
  }
  :deep(.ant-table-column-sorter-inner) {
    color: #fff !important;
  }
  :deep(.ant-table-thead) > tr > th {
    color: #fff !important;
    background: #1677ff !important;
    border-radius: 0 !important;
    text-align: center !important;
  }
  :deep(.ant-table-tbody) > tr > td,
  .ant-table-wrapper .ant-table-summary > tr > td {
    text-align: center !important;
  }
  .ant-table-wrapper .ant-table-summary > tr > td {
    background-color: #e7f5ff;
    font-weight: bolder;
  }
}
</style>

相关文章:

  • Java 集合数据处理技巧:使用 Stream API 实现多种操作
  • 八大经典排序算法
  • LeetCode:2595.奇偶位数
  • 云原生DevOps:Zadig架构设计与企业实践分析
  • 七星棋牌源码高阶技术指南:6端互通、200+子游戏玩法深度剖析与企业级搭建实战(完全开源)
  • 适用于复杂背景的YOLOv8改进:基于DCN的特征提取能力提升研究
  • Windows网络安全基础
  • 向 OpenAI ChatGPT 提问如何学习黑客
  • 硬盘识别不出来了怎么办?硬盘读不出来的解决方法
  • 基于Flask的租房信息可视化系统的设计与实现
  • 【项目实践06】【Retrofit2 框架的使用】
  • Linux-C/C++《C++/1、C++基础》(C++语言特性、面向对象等)
  • 【人工智能】用Python迈向轻量化深度学习——模型压缩与量化实战指南
  • 植物大战僵尸杂交版v3.2.1最新版本(附下载链接)
  • java简单实现请求deepseek
  • MySQL多列索引查询优化
  • express+Vue2进行项目实战-景点后台管理系统(上篇)
  • SpringCloud-Eureka初步使用
  • uniapp实现app的pdf预览
  • 手机控制电脑远程关机
  • 浙江纪委监察部网站绍兴陈建设/百度seo网站
  • 如何做电视剧的短视频网站/太原seo排名公司
  • 企业应加强自身网站建设/网站seo设计
  • 画中画有哪些网站可以做/中国十大流量网站
  • 福州做网站哪家公司好/采集站seo赚钱辅导班
  • wordpress如何从网站登录后台/热狗网站排名优化外包