<template>
  <div class="cooperate-list ele-body">
    <el-card shadow="never" element-loading-background="rgba(255, 255, 255, 1)">
      <search @search:task="updateParams($event)" />
      <el-table
        border
        highlight-current-row
        :data="dataList"
        :height="tableHeight"
        v-loading="loading"
        ref="table"
      >
        <el-table-column
          type="index"
          width="50"
          align="center"
          label="序号"
        ></el-table-column>
        <el-table-column
          label="申请部门"
          align="center"
          width="150"
          prop="applyDeptName"
        ></el-table-column>
        <el-table-column
          label="申请时间"
          align="center"
          width="160"
          prop="createTime"
        ></el-table-column
        ><el-table-column
          label="申请理由"
          align="center"
          width="150"
          prop="note"
        ></el-table-column>
        <el-table-column
          label="产业链名称"
          align="center"
          width="150"
          prop="categoryName"
        ></el-table-column>
        <el-table-column
          label="类型"
          align="center"
          width="100"
          prop="typeName"
        ></el-table-column>
        <el-table-column
          label="指标名称"
          align="center"
          min-width="200"
          prop="content"
        ></el-table-column>
        <el-table-column
          label="分值"
          align="center"
          width="80"
          prop="points"
        ></el-table-column>
        <el-table-column
          label="第一牵头部门"
          align="center"
          width="130"
          prop="leaderDeptName"
        >
          <template slot-scope="{ row }">
            <pre>{{ row.leaderDeptList | formatList }}</pre>
          </template>
        </el-table-column>
        <el-table-column
          label="其它牵头部门"
          align="center"
          width="130"
          prop="otherDeptName"
        >
          <template slot-scope="{ row }">
            <pre>{{ row.otherDeptList | formatList }}</pre>
          </template>
        </el-table-column>
        <el-table-column
          label="配合部门"
          align="center"
          width="130"
          prop="cooperateDeptName"
        >
          <template slot-scope="{ row }">
            <pre>{{ row.cooperateDeptList | formatList }}</pre>
          </template>
        </el-table-column>
        <el-table-column label="状态" align="center" width="80">
          <template slot-scope="{ row }">
            <el-link type="primary" v-if="row.status == 0">审核中</el-link>
            <el-link type="primary" v-if="row.status == 1">审核通过</el-link>
            <el-link type="primary" v-if="row.status == 2">已驳回</el-link>
          </template>
        </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 search from "../search";
import { mapGetters } from "vuex";
import api from "@/api/chain/coordinationManage/approvalCooperation";
export default {
  components: {
    search,
  },
  data() {
    return {
      searchParams: {},
      dataList: [],
      count: 0,
      page: {
        page: 1,
        limit: Math.floor(
          (document.documentElement.clientHeight - 220 - 45) / 45
        ),
      },
      tableHeight: document.documentElement.clientHeight - 220,
      loading: false,
      form: {},
      showEdit: false,
    };
  },
  computed: {
    ...mapGetters(["user"]),
  },
  created() {
    this.getDataList();
  },
  methods: {
    updateParams(data) {
      this.searchParams = data;
      this.resetCurrentPage();
      this.getDataList();
    },
    resetCurrentPage() {
      let page = this.page;
      page.page = 1;
      this.page = page;
    },
    getDataList() {
      try {
        this.$refs.table.bodyWrapper.scrollTop = 0;
      } catch (e) {}
      this.loading = true;
      api
        .getDataList(Object.assign({}, this.page, this.searchParams))
        .then((res) => {
          let data = res.data.data;
          this.count = data.total;
          this.dataList = data.records;
        })
        .catch((e) => {
          this.dataList = [];
          this.count = 0;
        })
        .finally(() => {
          this.loading = false;
        });
    },
  },
  filters: {
    formatList(val) {
      if (val) {
        return val.join("\n");
      }
    },
  },
};
</script>

<style>
</style>