<script setup lang="ts">
import type { CourseType } from '../types'
import { getCourseList } from '../api'

const router = useRouter()
let list = $ref<CourseType[]>([])
function fetchList() {
  getCourseList().then(res => {
    list = res.data.list
  })
}
onMounted(() => {
  fetchList()
})
function handleChange(id: string, type: number) {
  if (type === 1) {
    router.push({ path: '/student/lab', query: { course_id: id } })
  }
}
</script>

<template>
  <div class="bg">
    <router-link to="/student/lab" class="link1"></router-link>
    <router-link to="/student/lab" class="link2"></router-link>
    <router-link to="/student/lab" class="link3"></router-link>
  </div>
  <div class="select-group">
    <el-select size="large" placeholder="我的实验课程" @change="handleChange($event, 1)">
      <el-option v-for="item in list" :key="item.id" :label="item.name" :value="item.id"></el-option>
    </el-select>
    <!-- <el-select size="large" placeholder="我的陪练项目" @change="handleChange($event, 2)">
      <el-option v-for="item in list" :key="item.id" :label="item.name" :value="item.id"></el-option>
    </el-select>
    <el-select size="large" placeholder="我的大赛项目" @change="handleChange($event, 3)">
      <el-option v-for="item in list" :key="item.id" :label="item.name" :value="item.id"></el-option>
    </el-select>
    <el-select size="large" placeholder="我的大赛成绩" @change="handleChange($event, 4)">
      <el-option v-for="item in list" :key="item.id" :label="item.name" :value="item.id"></el-option>
    </el-select> -->
  </div>
</template>

<style lang="scss" scoped>
.bg {
  position: relative;
  margin: 20px auto;
  background: url(@/assets/images/home_student_bg.png) no-repeat center center;
  background-size: contain;
  width: 1215px;
  height: 577px;
  .link1 {
    position: absolute;
    top: 160px;
    width: 250px;
    height: 250px;
  }
  .link2 {
    position: absolute;
    left: 400px;
    bottom: 0;
    width: 300px;
    height: 250px;
  }
  .link3 {
    position: absolute;
    top: 200px;
    right: 0;
    width: 300px;
    height: 300px;
  }
}
.select-group {
  position: fixed;
  bottom: 40px;
  .el-select {
    width: 144px;
    :deep(.el-input__wrapper) {
      box-shadow: none;
    }
  }
  .el-select + .el-select {
    margin-left: 20px;
  }
}
</style>
