elementUi 中table表尾插入行

<template>
  <div>
    <el-table stripe class="jx-table" :data="tableData" border ref="table" style="width: 100%">
      <el-table-column prop="firstColumn" :label="firstColLabel" :resizable="false">el-table-column>
      <el-table-column prop="date" label="时间" :resizable="false">el-table-column>
      <el-table-column prop="name" label="姓名" :resizable="false">el-table-column>
      <el-table-column prop="province" label="地点" :resizable="false">el-table-column>
    el-table>
  div>
template>
<script>
import { map } from "lodash";
export default {
  created() {
    this.init();
  },
  data() {
    return {
      fullTableData: [],
      firstColLabel: "",
      tableFoot: [],
      allDate: {
        TabData: {
          result: [
            {
              date: "2016-05-02",
              name: "王小虎",
              province: "上海",
              firstColumn: 1
            },
            {
              date: "2016-05-04",
              name: "王小虎",
              province: "上海",
             title: 12
            },
            {
              date: "2016-05-01",
              name: "王小虎",
              province: "上海",
              title: 123
            },
            {
              date: "2016-05-03",
              name: "王小虎",
              province: "上海",
              title: 124
            }
          ],
          avg: { date: "---", name: "--", province: "-" },
          count: { date: "_", name: "__", province: "___" }
        },
        csNick: "标题"
      }
    };
  },
  methods: {
    init() {
      const { result, avg, count } = this.allDate.TabData;
      this.fullTableData = map(result, (object, key) => {
        return {
          firstColumn: object.title,
          ...object
        };
      });
      count.firstColumn = "汇总";
      avg.firstColumn = "均值";
      this.tableFoot = [count, avg];
      this.firstColLabel = this.allDate.csNick;
    }
  },
  computed: {
    tableData() {
      const tbody = this.fullTableData;
      return tbody.length ? [...tbody, ...this.tableFoot] : [];
    }
  }
};
script>
<style lang="scss" scoped>
style>

效果图如下:
elementUi 中table表尾插入行_第1张图片

你可能感兴趣的:(elementUI)