<template>
  <div class="mainBase">
    <el-select class="mr-10px" v-model="props.normal_school" placeholder="请选择学校" size="large" @change="handelSchool">
      <el-option label="全部" value="0" />
      <el-option v-for="item in props.school_list" :key="item.value" :label="item.label" :value="item.value"  />
    </el-select>
  </div>
</template>

<script setup lang="ts">
import {normalSchool_list } from '@/pages/api';
import { useRouter } from "vue-router";
const router = useRouter();
import { defineProps,defineEmits } from 'vue';
const props = defineProps(['normal_school','school_list']);
// const emit = defineEmits(['parentClick'])


let normal_school = ref("");

let school_list = ref([{
  value: '1',
  label: '学校1'
}, {
  value: '2',
  label: '学校2'
}]);

onMounted(() => {
  // initSchool();
})

//初始化学校
const initSchool = () => {
  let transObj = {
    ze_id:1015//考试ID
  }
  normalSchool_list(transObj)
    .then(res => {
      if (res.code == "1") {
        // let allData = res.data.list;
        //接口模拟数据
        let allData = [
          {
            sm_id: "267",
            sm_name: "博智测试学校",
            classes: [
              {
                cm_id: "8683",
                cm_name: "高一(25)班"
              }
            ]
          }
        ]
        let tempArr = [];
        allData.forEach(item => {
          tempArr.push({
            value: item.sm_name,
            label: item.sm_id
          })
          school_list.value = tempArr;
        })

        console.log(res, "00");
      }
    })
    .catch(error => { console.log(error) });
}


const handelSchool = (item) => {
  let tempIn = allData.value.filter(item => item.sm_id == item);
  // classroom_list.value=
  console.log(item);
}

</script>

<style scoped>

</style>
