<template>
  <div>
    <div class="d-flex flex-between">
      <div>
        <p><span class="blank">{{jkbb_bbmc}}</span></p>
      </div>
      <el-form label-width="100px" :inline="true">

        <el-button type="primary" class="mr15" @click="exportAll">导出</el-button>
      </el-form>
    </div>
    <el-table :data="tableData" tooltip-effect="dark" @selection-change="handleSelectionChange" v-loading="loading" ref="multipleTable" style="width: 100%">
      <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="年级编号" width="auto" prop="jkda_njbh">
        <template>

        </template>
      </el-table-column>
      <el-table-column label="班级编号" prop="jkda_bjbh" width="auto">
      </el-table-column>
      <el-table-column label="班级名称" prop="jkda_bjmc" width="auto">
      </el-table-column>
      <el-table-column label="学籍号" prop="jkda_xjh" width="auto">
      </el-table-column>
      <el-table-column label="民族" prop="jkda_mz" width="auto">
      </el-table-column>
      <el-table-column label="姓名" prop="jkda_xm" width="auto">
      </el-table-column>
      <el-table-column label="性别" prop="jkda_xb" width="auto">
      </el-table-column>
      <el-table-column label="出生日期" prop="jkda_csrq" width="auto">
      </el-table-column>
      <el-table-column label="操作" width="100">
        <template slot-scope="scope">
          <el-button type="text" @click="toDetail(scope.row.jkda_id)">详情 </el-button>
        </template>
      </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 { real_name, token } = useUserStore();
import { jkda_list, } from "./api";
export default {
  name: "index",
  data() {
    return {
      time: "",
      keyword: "",
      tableData: [],
      limit: 10,
      total: 12,
      cur_page: 1,
      multipleSelection: [],
      id: "",
      loading: false,
      isEdit: false,
      jkbb_bbmc: ""
    };
  },

  methods: {
    getListData() {
      this.loading = true;
      let data = {
        page: this.cur_page,
        limit: this.limit,
        keyword: this.keyword,
      };

      jkda_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);
      });
    },
    handleCurrentChange(val) {
      this.cur_page = val;
      this.getListData();
    },
    handleSelectionChange(val) {
      this.multipleSelection = [];
      for (let i in val) {
        this.multipleSelection.push(val[i].jkda_id);
      }

    },
    exportAll() {
      let ids = this.multipleSelection.join(",");
      let link =
        window.globalVariables.api +
        "/jdbg/jkda/index?api=xls&page=1&limit=10000&token=" +
        token +
        "&jkda_id=" + ids +
        "&jkbb_xq=" +
        this.$route.params.jkbb_xq +
        "&jkbb_bbmc=" +
        this.$route.params.jkbb_bbmc;
      window.open(link, "_blank");
    },
    // exportAll() {
    //   let ids = this.multipleSelection.join(",");
    //   let link =
    //     window.globalVariables.api +
    //     "/jdbg/jkda/index?api=xls&page=1&limit=10000&token=" +
    //     token +
    //     "&jkda_id=" + ids
    //   window.open(link, "_blank");
    // },
    toDetail(id) {
      this.$router.push({
        name: "bbtj_bbxq",
        params: {
          id: id,
        },
      });
    }
  },
  mounted() {
    if (this.$route.params.jkbb_xq != "" & this.$route.params.jkbb_bbmc != "") {
      this.jkbb_xq = this.$route.params.jkbb_xq;
      this.jkbb_bbmc = this.$route.params.jkbb_bbmc;
      this.getListData();
    }

  }
};
</script>

<style scoped>
</style>