<template>
  <div id="personalDetail">
    <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">
          <studentteainfo :messInfo="messInfo" :teainfo="teainfo"></studentteainfo>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import NavBar from '@/layout/common/topInfo.vue';
import studentteainfo from '@/layout/class/studentteainfo.vue';

import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
const { mapActions: mapDirectors } = createNamespacedHelpers('director');
const { mapActions: mapStudent } = createNamespacedHelpers('student');
const { mapActions: mapteacher } = createNamespacedHelpers('teacher');
const { mapActions: mapDept } = createNamespacedHelpers('dept');
export default {
  name: 'personalDetail',
  props: {},
  components: {
    NavBar, //头部导航
    studentteainfo, //学生详细信息
  },
  data: () => ({
    messInfo: {},
    teainfo: {},
    stulist: {},
    title: '',
    isleftarrow: '',
    navShow: true,
    jianshiinfo: {},
  }),
  created() {
    this.searchInfo();
  },
  computed: {
    id() {
      return this.$route.query.id;
    },
    ...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: {
    ...mapDirectors({ directorQuery: 'query', directorFetch: 'fetch' }),
    ...mapStudent({ studentQuery: 'query', studentFetch: 'fetch' }),
    ...mapDept({ deptFetch: 'fetch' }),
    ...mapteacher({ teacherFether: 'fetch' }),

    async searchInfo() {
      const res = await this.studentFetch(this.id);
      this.$set(this, `messInfo`, res.data);
      const val = await this.directorFetch(this.id);
      if (val.data != null) {
        const arr = await this.deptFetch(val.data.department);
        val.data.department = arr.data.name;
        this.$set(this, `teainfo`, val.data);
      }
    },
  },
};
</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>
