<template>
  <div class="basic-target ele-body">
    <el-card shadow="never">
      <el-table
        :data="dataList"
        border
        highlight-current-row
        :height="tableHeight"
        v-loading="loading"
        :span-method="arraySpanMethod"
      >
        <el-table-column type="index" label="序号" width="50" align="center">
        </el-table-column>
        <el-table-column
          label="类别"
          width="80"
          align="center"
          prop="categoryName"
        ></el-table-column>
        <el-table-column
          label="指标名称"
          min-width="100"
          align="center"
          prop="quotaName"
        ></el-table-column>
        <el-table-column
          label="单位"
          min-width="50"
          align="center"
          prop="quotaUnit"
        ></el-table-column>
        <el-table-column
          label="江宁开发区"
          min-width="80"
          align="center"
          prop="jiangningDevzone"
        ></el-table-column>
        <el-table-column
          label="江宁高新区"
          min-width="80"
          align="center"
          prop="jiangningHighzone"
        ></el-table-column>
        <el-table-column
          label="滨江开发区"
          min-width="80"
          align="center"
          prop="binjiangDevzone"
        ></el-table-column>
      </el-table>
      <el-pagination
        :current-page.sync="page.page"
        :page-size="page.limit"
        :total="count"
        :background="true"
        layout="total, prev, pager, next, jumper"
        :pager-count="5"
        class="ele-pagination-circle"
        @current-change="getDataList()"
      />
    </el-card>
  </div>
</template>

<script>
import api from "@/api/assessingTarget/commonquotatask";
import { mergeSpan } from "@/utils/mixin";
export default {
  components: {},
  data() {
    return {
      dataList: [],
      loading: false,
      count: 0,
      tableHeight: document.documentElement.clientHeight - 210,
      page: {
        page: 1,
        limit: Math.floor(
          (document.documentElement.clientHeight - 210 - 45) / 45
        ),
      },
    };
  },
  created() {
    this.getDataList();
  },
  mixins: [mergeSpan([
    {name: 'categoryName', col: [1]}
  ])],
  methods: {
    getDataList() {
      this.loading = true;
      api
        .getList(this.page)
        .then((res) => {
          this.loading = false;
          let data = res.data.data;
          this.dataList = this.reduceData(data.records);
          this.count = res.data.data.total;
        })
        .catch(() => {
          this.loading = false;
          this.dataList = [];
          this.count = 0;
        });
    },
  },
};
</script>

<style>
</style>