<template>
  <div>
    <div class="d-flex flex-right">
      <el-form label-width="100px" :inline="true">
        <el-form-item prop="jsxw_uo_name">
          <el-select class="mr10" v-model="jjmk_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" style="width: 100%">
      <el-table-column label="序号" align="center" type="index" width="50">
      </el-table-column>
      <el-table-column label="学校（单位）" prop="jjmk_uo_name">
      </el-table-column>
      <el-table-column label="姓名" prop="jjmk_xm"></el-table-column>
      <el-table-column label="考核类别" prop="jjmkl_jjmkl_name_1"></el-table-column>
      <el-table-column label="名师类别" prop="jjmkl_jjmkl_name_2"></el-table-column>
      <el-table-column label="教学类别" prop="jjmkl_jjmkl_name_3"></el-table-column>
      <el-table-column label="校端审核情况" prop="jjmkl_xdshqk"></el-table-column>
      <el-table-column label="局端审核情况" prop="jjmkl_jdshqk"></el-table-column>

      <el-table-column label="操作" align="center">
        <template slot-scope="scope">

          <el-button type="text" @click="toDetail(scope.row.jjmk_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 {token} = useUserStore();
import {org_list,khhz_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,
      jjmk_uo_name:'',
      orgList:[]
    };
  },
  methods: {
    getListData() {
      this.loading = true;
      let data = {
        page: this.cur_page,
        limit: this.limit,
        keyword: this.keyword,
        jjmk_uo_name:this.jjmk_uo_name
      };
      khhz_list(data).then((res) => {
        this.loading = false;
        this.tableData = res.data.page_data;
        res.data.page_data.forEach(item => {
            if(item.jjmkl_jjmkl_id_1=='10'){
              item.jjmkl_zbdffj_json = JSON.parse(item.jjmkl_zbdffj_json)
              item.jjmkl_jjmkl_name_3 = item.jjmkl_zbdffj_json[0].cate1
            }
          })
        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();
    },
    toDetail(id) {
      this.$router.push({name: "jsld_myjsjxkh_khhz_detail", params: {id: id}});
    },
  },

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

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