<template>
  <div>
    <div class="d-flex flex-between">
      <div>
        <el-button type="primary" size="medium" @click="exportAll">
          <span class="d-in-block v-mid font-size-16">导出</span>
        </el-button>
      </div>
      <el-form label-width="100px" :inline="true">
        <el-form-item prop="jsxw_uo_name">
          <el-select class="mr10" v-model="jjnh_uo_name" placeholder="全部学校" @change="getListData">
            <el-option value="" label="选择学校">全部学校</el-option>
            <el-option
                v-for="bm in orgList"
                :label="bm.uo_name"
                :key="bm.uo_id"
                :value="bm.uo_name">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item prop="keyword">
          <el-input placeholder="请输入搜索关键字" v-model="keyword" clearable @clear="getListData">
          </el-input>
        </el-form-item>
        <el-button type="primary" class="ml5" @click="getListData">搜索</el-button>
      </el-form>
    </div>
    <el-table :data="tableData" tooltip-effect="dark" v-loading="loading" style="width: 100%" @selection-change="handleSelectionChange">
      <el-table-column type="selection" align="center" width="55">
      </el-table-column>
      <el-table-column label="序号" align="center" type="index" width="50">
      </el-table-column>
      <el-table-column label="年度" prop="jjnh_year">
      </el-table-column>
      <el-table-column label="学校（单位）" prop="jjnh_uo_name"></el-table-column>
      <el-table-column label="姓名" prop="jjnh_xm"></el-table-column>
      <el-table-column label="考核情况" prop="jjnh_khqk"></el-table-column>
      <el-table-column label="上传时间" prop="jjnh_scsj"></el-table-column>
    </el-table>
    <footer class="flex-item-none" style="display: flex; justify-content: flex-end; margin-top: 30px">
      <el-pagination background layout="total,prev, pager, next" :page-size="limit" :total="total" :current-page.sync="cur_page" @current-change="handleCurrentChange"></el-pagination>
    </footer>
  </div>
</template>

<script>
import {useUserStore} from "@/stores/user";

const {token} = useUserStore();
import {org_list,ndkh_list} from "./api";

export default {
  name: "index",
  data() {
    return {
      time: "",
      keyword: "",
      tableData: [],
      limit: 10,
      total: 0,
      cur_page: 1,
      dialogFormVisible: false,
      state_value: "",
      state_list: [
        {
          label: "全部",
          value: "0",
        },
        {
          label: "通过",
          value: "1",
        },
        {
          label: "未通过",
          value: "2",
        },
      ],
      dialogForm: {
        wlc_id: "",
        wlc_lzry: "",
        wlc_ssbm: "",
        wlc_rzrq: "",
        wlc_sqlzrq: "",
        wlc_lzyy: "",
      },
      id: "",
      title: "",
      loading: false,
      jjnh_uo_name:'',
      orgList:[],
      multipleSelection: []
    };
  },
  methods: {
    handleSelectionChange(val) {
      this.multipleSelection = [];
      val.forEach(item=>{
        this.multipleSelection.push(item.jjnh_id)
      })
    },
    getListData() {
      this.loading = true;
      let data = {
        page: this.cur_page,
        limit: this.limit,
        keyword: this.keyword,
        jjnh_uo_name:this.jjnh_uo_name
      };
      ndkh_list(data).then((res) => {
        this.loading = false;
        this.tableData = res.data.page_data;
        this.cur_page = Number(res.data.page_now);
        this.total = Number(res.data.total_rows);
      });
    },
    getOrgList() {
      let data = {};
      org_list(data).then((res) => {
        if (res.code == 1) {
          this.orgList = res.data.page_data;
        }
      })
    },
    handleCurrentChange(val) {
      this.cur_page = val;
      this.getListData();
    },
    exportAll() {
      let link =
        window.globalVariables.api +
        "/jdbg/jsldgl_ndkhhz/index?api=xls&page=1&limit=10000&token=" +
        token + '&jjnh_id='+ this.multipleSelection.join(',');
      window.open(link, "_blank");
    },
  },

  mounted() {
    this.getOrgList();
    this.getListData();
  },
};
</script>

<style lang="scss" scoped>
</style>