el-table分组合并行

接到一个需求,把数据按照天 分组显示 时间单独一行,数据在一块

这里新知识点:span-method

const plist = ref([{
dateHeader:'2024-01-23',
list:[{dateHeader:'2024-01-23'},{name:'数据1',id:1},{name:'数据2',id:2}]
},
{
dateHeader:'2024-01-24',
list:[{dateHeader:'2024-01-24'},{name:'数据22',id:1},{name:'数据23',id:2}]
},
{
dateHeader:'2024-01-25',
list:[{dateHeader:'2024-01-25'},{name:'数据33',id:1},{name:'数据34',id:2}]
}])
const tableConfig = reactive([
  { prop: 'name', label: '计划名称', minWidth: '10' },
  { prop: 'id', label: 'ID', minWidth: '15' },
  { prop: 'operation', label: '操作', minWidth: '15' }
]);
     
const arraySpanMethod = (row, column, rowIndex, columnIndex) => {
  let hideColArr = [1, 2];//数组是根据要合并哪几个来定
  if (row.rowIndex == 0) {
    if (hideColArr.includes(row.columnIndex)) {
      return { display: 'none' };
    }
    return { rowspan: 1, colspan: 3 };
  }
};

 <template v-for="(item2, index2) in plist" :key="index2"> 
 <el-table
          :data="item2.list"
          :show-header="index2 === 0"
          :span-method="arraySpanMethod"
          :cell-style="{ padding: '3px' }"
        >
          <el-table-column
            v-for="(value, key) in tableConfig"
            :key="key"
            :prop="value.prop"
            :label="value.label"
            :min-width="value.minWidth"
          >
            <template #default="scope">
              <div v-if="scope.row.dateHeader">{{ scope.row.dateHeader }}</div>
            </template>
          </el-table-column>
        </el-table>
            </template>
相关推荐
勿语&25 分钟前
Element-UI Plus 暗黑主题切换及自定义主题色
开发语言·javascript·ui
黄尚圈圈26 分钟前
Vue 中引入 ECharts 的详细步骤与示例
前端·vue.js·echarts
一路向前的月光5 小时前
Vue2中的监听和计算属性的区别
前端·javascript·vue.js
长路 ㅤ   5 小时前
vue-live2d看板娘集成方案设计使用教程
前端·javascript·vue.js·live2d
Fan_web5 小时前
jQuery——事件委托
开发语言·前端·javascript·css·jquery
Jiaberrr6 小时前
Element UI教程:如何将Radio单选框的圆框改为方框
前端·javascript·vue.js·ui·elementui
安冬的码畜日常8 小时前
【D3.js in Action 3 精译_029】3.5 给 D3 条形图加注图表标签(上)
开发语言·前端·javascript·信息可视化·数据可视化·d3.js
太阳花ˉ8 小时前
html+css+js实现step进度条效果
javascript·css·html
程序员大金9 小时前
基于SpringBoot+Vue+MySQL的装修公司管理系统
vue.js·spring boot·mysql