<template>
  <div class="constraint" v-loading="loading">
    <search :type="3" />
    <el-table
      :data="dataList"
      border
      highlight-current-row
      :height="tableHeight"
      ref="table"
    >
      <el-table-column type="index" label="序号" align="center" width="50">
      </el-table-column>
      <el-table-column
        label="申请部门"
        align="center"
        min-width="150"
      ></el-table-column
      ><el-table-column
        label="申请时间"
        align="center"
        min-width="150"
      ></el-table-column
      ><el-table-column
        label="申请理由"
        align="center"
        min-width="150"
      ></el-table-column>
      <el-table-column
        label="考核指标"
        min-width="80"
        align="center"
        prop="quota"
      ></el-table-column>

      <el-table-column
        label="考核内容和计分细则"
        align="center"
        min-width="400"
        prop="content"
      ></el-table-column>
      <el-table-column
        label="小条内容"
        align="center"
        min-width="150"
        prop="content"
      ></el-table-column>
      <el-table-column
        label="分值"
        min-width="60"
        align="center"
        prop="points"
      ></el-table-column>

      <el-table-column
        label="区牵头单位"
        min-width="95 "
        align="center"
        prop="leaderUnit"
      ></el-table-column>

      <el-table-column label="牵头部门" min-width="80" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.leaderDeptList | formatList }}</span>
        </template>
      </el-table-column>

      <el-table-column label="责任领导" min-width="80" align="center">
        <template slot-scope="{ row }">
          {{ row.leaderPrincipalList | formatList }}
        </template>
      </el-table-column>
      <el-table-column label="配合部门" min-width="80" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.leaderDeptList | formatList }}</span>
        </template>
      </el-table-column>

      <el-table-column label="责任领导" min-width="80" align="center">
        <template slot-scope="{ row }">
          {{ row.leaderPrincipalList | formatList }}
        </template>
      </el-table-column>
      <el-table-column label="操作" width="125" align="center">
        <el-link @click="edit(true)" type="primary" :underline="false"
          >同意</el-link
        >
        <el-link @click="edit(false)" type="primary" :underline="false"
          >不同意</el-link
        >
      </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"
      :flat="true"
      @current-change="getDataList()"
    />
    <el-dialog
      title="审核配合申请"
      :visible.sync="showEdit"
      width="400px"
      custom-class="ele-dialog-form"
      :lock-scroll="false"
      :destroy-on-close="true"
      @closed="form = {}"
    >
      <div class="warning">
        <span
          class="el-icon-warning-outline"
          style="color: #f7ac2c; font-size: 25px; margin-right: 20px"
        ></span>
        <div class="right">
          <h5>{{ warning.title }}</h5>
          <p>{{ warning.info }}</p>
        </div>
      </div>
      <div slot="footer">
        <el-button @click="showEdit = false">取消</el-button>&nbsp;
        <el-button type="primary" @click="save">保存</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import search from "../../search";
export default {
  components: {
    search,
  },
  data() {
    return {
      dataList: [[]],
      tableHeight: document.documentElement.clientHeight - 310,
      page: {
        page: 1,
        limit: Math.floor(
          (document.documentElement.clientHeight - 310 - 45) / 45
        ),
      },
      count: 0,
      showEdit: false,
      loading: false,
      form: {},
      warning: {
        title: "确定同意此申请？",
        info: "点击确定后，该部门将添加至考核任务配合部门中",
      },
    };
  },
  methods: {
    getDataList() {},
    edit(flag) {
      this.showEdit = true;
      if (flag) {
        this.warning = {
          title: "确定同意此申请？",
          info: "点击确定后，该部门将添加至考核任务配合部门中",
        };
      } else {
        this.warning = {
          title: "确定不同意此申请？",
          info:
            "点击确定后，该部门申请将驳回，如需再次添加，则有管理员确认后增加",
        };
      }
    },
    save() {},
  },
  filters: {
    formatList(val) {
      if (val) {
        return val.join(",");
      }
    },
  },
};
</script>

<style scoped>
.warning {
  display: flex;
  margin-bottom: 20px;
}
</style>