<template>
  <div id="teaLeave">
    <el-row>
      <el-col :span="24" class="style">
        <el-col :span="24" class="top">
          <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
        </el-col>
        <el-col :span="24" class="main">
          <teaLeaveList :classList="classList"></teaLeaveList>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import NavBar from '@/layout/common/topInfo.vue';
import teaLeaveList from '@/layout/user/teaLeaveList.vue';
import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
const { mapActions: mapClass } = createNamespacedHelpers('classes');
const { mapActions: mapStudent } = createNamespacedHelpers('student');
export default {
  name: 'leave',
  props: {},
  components: {
    NavBar, //头部导航
    teaLeaveList, //班主任学生请假列表
  },
  data: () => ({
    classList: [],
    title: '',
    isleftarrow: '',
    navShow: true,
  }),
  created() {
    this.searchInfo();
  },
  computed: {
    ...mapState(['user']),
  },
  mounted() {
    this.title = this.$route.meta.title;
    this.isleftarrow = this.$route.meta.isleftarrow;
  },
  watch: {
    $route(to, from) {
      this.title = to.meta.title;
      this.isleftarrow = to.meta.isleftarrow;
    },
  },
  methods: {
    ...mapClass({ classinfo: 'query' }),
    ...mapStudent({ stuQuery: 'query', stuFetch: 'fetch' }),
    async searchInfo({ ...info } = {}) {
      const res = await this.classinfo({ ...info });
      var result = res.data.filter(item => item.headteacherid === this.user.userid);
      this.$set(this, `classList`, result);
    },
  },
};
</script>

<style lang="less" scoped>
.style {
  width: 100%;
  min-height: 667px;
  position: relative;
  background-color: #f9fafc;
}
.top {
  height: 46px;
  overflow: hidden;
}
.main {
  min-height: 570px;
}
</style>
