ElementUI-Table(复杂版)

ElementUI表格列相同值自动合并单元格( 多列 )

by Tomatoro

HTML

<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/element-ui@2.3.7/lib/index.js"></script>
<div id="app">
<template>
  <div>
    <el-table :data="tableData6" :span-method="objectSpanMethod" border style="width: 100%; margin-top: 20px">
      <el-table-column prop="name" label="姓名">
      </el-table-column>
      <el-table-column prop="amount1" label="数值 1(元)">
      </el-table-column>
      <el-table-column prop="amount2" label="数值 2(元)">
      </el-table-column>
      <el-table-column prop="amount3" label="数值 3(元)">
      </el-table-column>
    </el-table>
  </div>
</template>
</div>

SCSS

@import url("//unpkg.com/element-ui@2.3.7/lib/theme-chalk/index.css");

Babel + JSX

var Main = {
    data() {
      return {
        tableData6: [{
          name: '部门1',
          type: 0,
          amount1: '跟单员1',
          amount2: '成衣工厂1',
          amount3: 10
        }, {
          name: '部门1',
          type: 0,
          amount1: '跟单员1',
          amount2: '成衣工厂2',
          amount3: 12
        }, {
          name: '部门1',
          type: 0,
          amount1: '跟单员1',
          amount2: '成衣工厂3',
          amount3: 9
        }, {
          name: '部门1',
          type: 0,
          amount1: '跟单员2',
          amount2: '成衣工厂1',
          amount3: 17
        }, {
          name: '部门1',
          type: 0,
          amount1: '跟单员2',
          amount2: '成衣工厂2',
          amount3: 15
        },{
          name: '部门1',
          type: 0,
          amount1: '跟单员2',
          amount2: '成衣工厂3',
          amount3: 10
        }, {
          name: '部门1总计',
          type: 1,
          amount1: '部门1跟单员',
          amount2: '',
          amount3: 12
        },{
          name: '部门2',
          type: 0,
          amount1: '跟单员3',
          amount2: '成衣工厂1',
          amount3: 10
        }, {
          name: '部门2',
          type: 0,
          amount1: '跟单员3',
          amount2: '成衣工厂2',
          amount3: 12
        }, {
          name: '部门2',
          type: 0,
          amount1: '跟单员3',
          amount2: '成衣工厂3',
          amount3: 9
        }, {
          name: '部门2',
          type: 0,
          amount1: '跟单员3',
          amount2: '成衣工厂1',
          amount3: 17
        }, {
          name: '部门2',
          type: 0,
          amount1: '跟单员4',
          amount2: '成衣工厂2',
          amount3: 15
        },{
          name: '部门2',
          type: 0,
          amount1: '跟单员4',
          amount2: '成衣工厂3',
          amount3: 10
        }, {
          name: '部门2总计',
          type: 1,
          amount1: '部门2跟单员',
          amount2: '',
          amount3: 12
        }],
        arr1:[],
        arr2:[]
      };
    },
    created() {
   ...