<template>
  <div id="lineTable">
    <div style="text-align: right;margin-bottom: 10px;" class="search">
      <el-input style="width:40%;" suffix-icon=" " placeholder="搜索" v-model="tableParams.univerName" @keyup.enter.native="clickSuffix">
           <span slot="suffix" @click="clickSuffix" style="cursor: pointer">
            <i class="el-icon-search" style="margin-right: 10px;"></i>
          </span>
      </el-input>
    </div>
    <el-table :data="tableData" border>
      <el-table-column prop="code" label="院校" align="center">
        <template slot-scope="scope">
          <el-link :underline="false" @click="goDetails(scope.row.universityId)">【{{scope.row.universityName}}】</el-link>
        </template>
      </el-table-column>
      <el-table-column prop="location" label="所在地" align="center"></el-table-column>
      <el-table-column prop="year" label="年份" align="center"></el-table-column>
      <el-table-column prop="type" label="科类" align="center"></el-table-column>
      <el-table-column prop="level" label="层次" align="center"></el-table-column>
      <el-table-column prop="score" label="投档线" align="center"></el-table-column>
    </el-table>
    <el-pagination
      style="margin-top:10px;"
      :page-sizes="[10,20,30,40,50,60,70,80,90,100]"
      :page-size=tableParams.pageSize
      layout="prev,pager,next,jumper,total,sizes"
      :total="examRecordTotal"
      @current-change="currentChange"
      @size-change="sizeChange"
    >
    </el-pagination>
  </div>
</template>

<script>
  import {selectUniversityList} from '@/api/webApi/shiftLine'
    export default {
        name: "UniversitiesLineTable",
      props:{
        universityParams:{type:Object,default(){return {}}}
      },
      data(){
        return{
          examRecordTotal:0,
          tableParams:{
            pageSize:20,
            pageNum:1,
            level:'',
            location:'',
            type:'',
            univerName:'',
            year:''
          },
          tableData:[]
        }
      },
      watch:{
        universityParams:{
          immediate:true,
          deep:true,
          handler(val){
            this.tableParams.level=val.levelsRes
            this.tableParams.location=val.locationsRes
            this.tableParams.type=val.typeRes
            this.tableParams.year=val.yearRes
            this.getUniversityList()
          }
        }
      },
      methods:{
        clickSuffix(){
          this.getUniversityList()
        },
        getUniversityList(){
          console.log(this.tableParams)
          selectUniversityList(this.tableParams).then(res=>{
            console.log(res)
            this.tableData=res.rows
            this.examRecordTotal=res.total
          })
        },
        sizeChange(e){
          this.tableParams.pageSize=e
          this.getUniversityList()
        },
        currentChange(e){
          //页数
          this.tableParams.pageNum=e
          this.getUniversityList()
        },
        goDetails(id){
          this.$router.push({ name: 'UniversityDetail', params: { id: id } })
        }
      }
    }
</script>

<style lang="scss">
  #lineTable{
    .search{
      .el-input {
        .el-input__inner {
          border-radius: 50px;
        }
      }
    }
  }

</style>
