<template>
  <div ref="UniversitiesColleges" class="app-container" v-loading="loading">
    <el-card :style="{'background-image':backimg}" style="padding:30px;margin:10px 0;background-color:white;background-repeat: no-repeat;background-position: bottom right;">
      <p style="color:#A6A6A6;font-size:24px;font-weight:bold;">UNIVERSITIES AND COLLECGES</p>
      <p style="color:#414141;font-size:24px;font-weight:bold;">院校库</p>
      <hr class="layui-bg-orange" style="width:40px;height:4px;margin-top:10px;" />
    </el-card>
    <el-card style="background-color: #ffffff;font-size: 14px;padding:5px;">
      <el-row class="radioInput">
        <div>
          <span class="radiaTitle">院校省份:</span>
        </div>
        <el-radio-group v-model="filter_form.location">
          <el-radio-button label="">所有</el-radio-button>
          <el-radio-button v-for="item in filter_list.locations" :key="item" :label="item" style="margin-bottom:10px"></el-radio-button>
        </el-radio-group>
      </el-row>
      <el-row class="radioInput" style="background-color: #ffffff;font-size: 14px;padding:5px;">
        <div>
          <span class="radiaTitle">院校类型:</span>
        </div>
        <el-radio-group v-model="filter_form.type">
          <el-radio-button label="">所有</el-radio-button>
          <el-radio-button v-for="item in filter_list.types" :key="item" :label="item" style="margin-bottom:10px"></el-radio-button>
        </el-radio-group>
      </el-row>
      <el-row class="radioInput" style="background-color: #ffffff;font-size: 14px;padding:5px;">
        <div>
          <span class="radiaTitle">院校层次:</span>
        </div>
        <el-radio-group v-model="filter_form.features">
          <el-radio-button label="">所有</el-radio-button>
          <el-radio-button v-for="item in filter_list.features" :key="item" :label="item" style="margin-bottom:10px"></el-radio-button>
        </el-radio-group>
      </el-row>
      <el-row class="radioInput" style="background-color: #ffffff;font-size: 14px;padding:5px;">
        <div>
          <span class="radiaTitle">学历层次:</span>
        </div>
        <el-radio-group v-model="filter_form.level">
          <el-radio-button label="">所有</el-radio-button>
          <el-radio-button v-for="item in filter_list.levels" :key="item" :label="item" style="margin-bottom:10px"></el-radio-button>
        </el-radio-group>
      </el-row>
      <el-row class="radioInput"  style="background-color: #ffffff;font-size: 14px;padding:5px;">
        <div>
          <span class="radiaTitle">办学类型:</span>
        </div>
        <el-radio-group v-model="filter_form.natureTypeCN">
          <el-radio-button label="">所有</el-radio-button>
          <el-radio-button v-for="item in filter_list.natureTypes" :key="item" :label="item" style="margin-bottom:10px"></el-radio-button>
        </el-radio-group>
      </el-row>
      <mx-search-group justify="end"  v-model="collegeName" @search="clickSuffix">
        <p>共 <span class="f-primary">{{pageForm.total}}</span> 条</p>
      </mx-search-group>
      <el-row class="mt10 ">
        <div v-if="pageForm.total > 0">
          <div class="list-wrap pl30">
            <div class="list-item fx-row mb30" v-for="item in collegeList">
              <div class="img" >
                <img style="width: 100%;height: 100%" :src="item.logo" alt="">
              </div>
              <div class="info ml20">
                <div class="college_name pointer f-333 f20 mb5" @click="toDetail(item)">{{item.name}}</div>
                <div class="tags" v-if="item.features">
                  <span class="mr5 el-tag el-tag--info el-tag--plain" v-for="feature in item.features.split(',')">{{ feature }}</span>
                </div>
                <div class="college-desc mt5 f14 f-666">
                  <p>{{`${item.location} ${item.cityName} ${item.type} / ${item.natureTypeCN} / ${item.managerType} `}}</p>
                </div>
              </div>
              <div class="heat f12 f-666">
                <p>排名</p>
                <p class="mt3">{{ `第${item.ranking}名 / 综合指数${item.comScore}` }}</p>
              </div>
              <div class="heat f12  f-666">
                <p>热度</p>
                <p class="mt3">{{ (item.hits/10000).toFixed(1) }}万</p>
              </div>
            </div>
          </div>
          <pagination class="mt10" :total="pageForm.total" :autoScroll="false" @pagination="onChangePage"
                      :page.sync="pageForm.pageNum"
                      :limit.sync="pageForm.pageSize"
          ></pagination>
        </div>

        <evaluation-empty v-else shadow title="暂无数据"></evaluation-empty>
      </el-row>
    </el-card>
  </div>
</template>

<script>
import { mapState } from 'vuex';
import UniversitiesTable from '@/views/career/components/UniversitiesTable';
import { selectUniversityList, universityFilters } from '@/api/webApi/career-course'
import MxSearchGroup from '@/components/MxSearch/mx-search-group'
export default {
  name: "UniversitiesColleges",
  components: { MxSearchGroup, UniversitiesTable },
  data() {
    return {
      backimg: 'url(' + require('@/assets/images/career/icon_colleges.png') + ')',
      filter_form:{
        location:'',
        natureTypeCN:'',
        type:'',
        level:'',
        features:'',
        name:''
      },
      loading:false,
      collegeName:'',
      pageForm:{
        pageSize:10,
        pageNum:1,
        total:0
      },
      filter_list:{},
      collegeList:[],
      headerFixed: true
    }
  },
  computed: {
    ...mapState({ theme: state => state.settings.theme }),
  },
  watch: {
    theme: {
      immediate: true,
      handler(val) {
        this.$nextTick(() => {
          this.$refs.UniversitiesColleges.style.setProperty('--themeColor', val)
        })
      }
    },
    filter_form:{
      immediate: true,
      deep:true,
      handler(val) {
          this.getUniversityList()
      }
    },
    'universityParams.locationsRes': {
      handler(val) {
        this.universityParams.name = ''
        this.univerName = ''
      }
    }
  },
  created() {
    this.getFilter()
  },
  methods: {
    toDetail(item) {
      console.log(item)
      this.$router.push({path:'/career/plan/UniversityDetail',query: {code:item.code}})
    },
    onChangePage(page) {
      this.pageForm.pageSize = page.limit
      this.pageForm.pageNum = page.page
      this.getUniversityList()
    },
    clickSuffix() {
      this.filter_form.name = this.univerName
    },
    getFilter() {
      universityFilters().then(res => {
        this.filter_list = res.data
      })
    },
    getUniversityList(){
      this.loading = true
      // console.log(params)
      selectUniversityList({ ...this.filter_form,
        pageNum:this.pageForm.pageNum,
        pageSize:this.pageForm.pageSize,
      }).then(res=>{
        this.pageForm.total =res.total
        this.collegeList =res.rows
      }).finally(() => {
        this.loading = false
      })
    },
  }
}
</script>

<style lang="scss" scoped>
.layui-bg-orange {
  background-color: var(--themeColor);
  margin-left: 0;
}
.heat{
  width: 200px;
  height: 72px;
  padding-top: 22px;
  color: #666;
}
.info{
  width: 400px;
}
.img{
  width: 72px;
  height: 72px;
}
.tags {
  .el-tag{
    height: 16px;
    line-height: 16px;
    font-size: 12px;
    color: #909399;
  }
}
.radioInput ::v-deep {
  .el-radio {
    .el-radio__input {
      display: none;
    }
  }
}
.radioInput ::v-deep {
  display: flex;
  .el-radio-button .el-radio-button__inner {
    border-radius: 4px !important;
    border: none;
    padding: 5px 10px !important;
    font-weight: 400;
    font-family: PingFangSC-Regular, PingFang SC;
  }
  .el-radio-button__orig-radio:checked + .el-radio-button__inner {
    box-shadow: none;
  }
  .radiaTitle {
    display: inline-block;
    width: 80px;
    font-size: 14px;
    text-align: right;
    margin-top: 2px;
    margin-right:10px;
  }
}
// 吸顶
.issFixed{
  position: absolute;
  top: 0px;
  background: #fff;
  left: 0px;
  right: 0px;
  z-index: 4;

}
</style>
