<script setup lang="ts">
import StaticConstant from "@/utils/StaticConstant";
import {reactive} from 'vue';
import axiosInstance from '@/utils/http';
import apiConstant from "@/utils/ApiConstant";
import {AxiosResponse} from "axios";
import {ScoreControlLineEntity} from "@/types";

document.title = '省控线|' + import.meta.env.VITE_PROGRAM_TYPE;
const state = reactive({
  scoreResult:{
    size:0,
    total:0,
    current:1,
    records:[] as Array<ScoreControlLineEntity>
  },
  loading:false,
  professionalCategory:'',
  category:'',
  year:'2024',
  pageNo:1,
  pageSize:10,
})

scoreControlLineList()


//获取省控线列表
function scoreControlLineList(){
  state.loading=true
  axiosInstance({
    url: apiConstant.Score.historyScoreControlLineList,
    method: 'get',
    params: {
      pageNo:state.pageNo,
      pageSize:state.pageSize,
      year:state.year,
      category:state.category,
      professionalCategory:state.professionalCategory
    },
    showLoading: false,//是否显示加载图标
  }).then((response: AxiosResponse) => {
    return response?.data
  }).then((data) => {
    if (data.success) {
      //有数据情况下
      state.scoreResult = data.result
    }
  }).catch((error: any) => {
    console.log(error);
  }).finally(() => {
    state.loading=false
  });
}

//点击分页跳转
const handlePage = (page: number) => {
  if (page) {
    state.pageNo = page
    scoreControlLineList()
  }
}
</script>

<template>
  <LeftNav/>
  <div class="main-container wrap main-fullScreen" style="min-height: 800px;">
    <el-row :gutter="20">
      <!--  左侧 院校列表-->
      <el-col :span="24">
        <el-card class="box-card">
          <div style="margin-bottom: 10px">
            <el-form :inline="true" :model="state" class="demo-form-inline">
              <el-row :gutter="20">
                <el-col :xs="24">
                  <el-form-item label="年份">
                    <el-radio-group v-model="state.year" @change="scoreControlLineList">
                      <el-radio v-for="item in StaticConstant.allYear" :label="item.label"  name="year">{{item.label}}</el-radio>
                    </el-radio-group>
                  </el-form-item>
                </el-col>

                <el-col :xs="24">
                  <el-form-item label="专业类别">
                    <el-radio-group v-model="state.professionalCategory" @change="scoreControlLineList">
                      <el-radio label=""  name="professionalCategory">全部</el-radio>
                      <el-radio v-for="item in StaticConstant.zyOptions" :label="item.label"  name="professionalCategory">{{item.value}}</el-radio>
                    </el-radio-group>
                  </el-form-item>
                </el-col>
                <el-col :xs="24">
                  <el-form-item label="文理分科">
                    <el-radio-group v-model="state.category" @change="scoreControlLineList">
                      <el-radio label="" name="state">全部</el-radio>
                      <el-radio label="文科" name="category">历史组</el-radio>
                      <el-radio label="理科" name="category">物理组</el-radio>
                    </el-radio-group>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
            <el-divider/>
            <el-table :data="state.scoreResult.records" border style="width: 100%" v-loading="state.loading">
              <el-table-column prop="year" label="年份" />
              <el-table-column prop="professionalCategory" label="专业类别" width="180" />
              <el-table-column prop="category" label="文理分科" width="180" />
              <el-table-column prop="culturalScore" label="文化成绩分数" />
              <el-table-column prop="specialScore" label="专业成绩分数" />
              <el-table-column prop="batch" label="批次" />
            </el-table>
          </div>
          <div class="page"><!--v-if="state.isShowPage"-->
            <el-pagination background @current-change="handlePage" :current-page="state.scoreResult.current"
                           :page-size="state.scoreResult.size" :total="state.scoreResult.total"
                           layout="total, prev, pager, next,jumper"/>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<style scoped lang="scss">
root {
  width: 100%;
}
</style>
