table循环实现表格相同列合并

先上效果图:

实现效果图

实现代码:利用lb-element-table实现。

template中:

<el-card v-for="(table,index) in listData" :key="index" style="margin-bottom: 10px;">
    <div slot="header">
       <span>{{table.indicatorType}}</span>
    </div>
    <div>
       <lb-table :column="column" :data="table.tableData" :merge="['project']" border></lb-table>
    </div>
</el-card>

注:其中merge中的数组是你需要合并的列的属性名。

data中定义column:

column = [
        {
          prop: "project",
          label: "项目"
        },
        {
          prop: "indicatorName",
          label: "指标"
        }
      ];

data中定义tableData的值:

listData: [
        {
          indicatorType: "指标分类1",
          tableData: [
            {
              project: "工艺流程名称2",
              indicatorName: "指标名称2",
              name: "2019-01-01",
              value1: "8",
              value2: "90",
              value3: "14",
              value4: "14",
              value5: "10",
              value6: "17",
              value7: "1",
              unit: "kg"
            },
            {
              project: "工艺流程名称2",
              indicatorName: "指标名称2",
              name: "2019-01-02",
              value1: "10",
              value2: "1",
              value3: "140",
              value4: "100",
              value5: "10",
              value6: "14",
              value7: "10"
            },
            {
              project: "工艺流程名称3",
              indicatorName: "指标名称2",
              name: "2019-01-02",
              value1: "10",
              value2: "10",
              value3: "10",
              value4: "10",
              value5: "10",
              value6: "10",
              value7: "10"
            },
            {
              project: "工艺流程名称3",
              indicatorName: "指标名称2",
              name: "2019-01-03",
              value1: "10",
              value2: "10",
              value3: "10",
              value4: "10",
              value5: "10",
              value6: "10",
              value7: "10"
            },
            {
              project: "工艺流程名称4",
              indicatorName: "指标名称2",
              value1: "10",
              value2: "10",
              value3: "10",
              value4: "10",
              value5: "10",
              value6: "10",
              value7: "10"
            }
          ]
        },
        {
          indicatorType: "指标分类2",
          tableData: [
            {
              project: "工艺流程名称6",
              indicatorName: "指标名称2",
              name: "2019-01-01",
              value1: "10",
              value2: "1",
              value3: "10",
              value4: "10",
              value5: "102",
              value6: "107",
              value7: "1",
              unit: "kg"
            },
            {
              project: "工艺流程名称6",
              indicatorName: "指标名称2",
              name: "2019-01-02",
              value1: "10",
              value2: "106",
              value3: "10",
              value4: "10",
              value5: "106",
              value6: "10",
              value7: "10"
            },
            {
              project: "工艺流程名称6",
              indicatorName: "指标名称2",
              name: "2019-01-02",
              value1: "106",
              value2: "10",
              value3: "10",
              value4: "10",
              value5: "10",
              value6: "10",
              value7: "106"
            },
            {
              project: "工艺流程名称7",
              indicatorName: "指标名称2",
              name: "2019-01-03",
              value1: "10",
              value2: "10",
              value3: "10",
              value4: "106",
              value5: "10",
              value6: "10",
              value7: "10"
            },
            {
              project: "工艺流程名称7",
              indicatorName: "指标名称2",
              value1: "10",
              value2: "10",
              value3: "1",
              value4: "10",
              value5: "10",
              value6: "10",
              value7: "10"
            }
          ]
        }
      ],

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值