|
@@ -0,0 +1,105 @@
|
|
|
+<template>
|
|
|
+ <div id="lesson">
|
|
|
+ <detail-frame title="课程表" returns="/classes/index">
|
|
|
+ <el-card v-loading="loading">
|
|
|
+ <time-table v-if="!loading" :data="previews"></time-table>
|
|
|
+ </el-card>
|
|
|
+ </detail-frame>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+import detailFrame from '@frame/layout/admin/detail-frame';
|
|
|
+import axios from 'axios';
|
|
|
+import timeTable from '@frame/parts/time-table';
|
|
|
+import _ from 'lodash';
|
|
|
+const { mapActions: classes } = createNamespacedHelpers('classes'); //班级
|
|
|
+const { mapActions: lesson } = createNamespacedHelpers('lesson'); //课程
|
|
|
+const { mapActions: location } = createNamespacedHelpers('location'); //地点
|
|
|
+const { mapActions: subject } = createNamespacedHelpers('subject'); //科目
|
|
|
+const { mapActions: teacher } = createNamespacedHelpers('teacher'); //教师
|
|
|
+const { mapActions: director } = createNamespacedHelpers('director'); //班主任
|
|
|
+export default {
|
|
|
+ metaInfo: { title: '课程表' },
|
|
|
+ name: 'lesson',
|
|
|
+ props: {},
|
|
|
+ components: { timeTable, detailFrame },
|
|
|
+ data: () => ({
|
|
|
+ classInfo: {},
|
|
|
+ locationList: [],
|
|
|
+ subjectList: [],
|
|
|
+ previews: {},
|
|
|
+ loading: true,
|
|
|
+ }),
|
|
|
+ async created() {
|
|
|
+ await this.getOtherList();
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ id() {
|
|
|
+ return this.$route.query.id; //班级id
|
|
|
+ },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...classes(['fetch']),
|
|
|
+ ...director({ getDirector: 'fetch' }),
|
|
|
+ ...location({ getLocationList: 'query' }),
|
|
|
+ ...subject({ getSubjectList: 'query' }),
|
|
|
+ ...teacher({ getTeacher: 'fetch' }),
|
|
|
+ ...lesson({ getLessonList: 'query' }),
|
|
|
+ async search() {
|
|
|
+ let res = {};
|
|
|
+ let lesson = [];
|
|
|
+ let start = '';
|
|
|
+ let end = '';
|
|
|
+ //班级信息,课程合并请求
|
|
|
+ await axios.all([this.fetch(this.id), this.getLessonList({ class: this.id })]).then(
|
|
|
+ axios.spread((r1, r2) => {
|
|
|
+ if (this.$checkRes(r1)) res = r1;
|
|
|
+ if (this.$checkRes(r2)) {
|
|
|
+ if (r2.data.length > 0) {
|
|
|
+ lesson = r2.data[0];
|
|
|
+ start = _.get(_.head(lesson.lessons), 'date');
|
|
|
+ end = _.get(_.last(lesson.lessons), 'date');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ );
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ let tcc = res.data;
|
|
|
+ let numArr = tcc.name.match(/\d+/g);
|
|
|
+ let term = numArr[0];
|
|
|
+ let classes = numArr[2];
|
|
|
+ let js = this.locationList.find(f => f.id === tcc.jslocationid);
|
|
|
+ let kbys = this.locationList.find(f => f.id === tcc.kbyslocationid);
|
|
|
+ let tzxl = this.locationList.find(f => f.id === tcc.kzjhlocationid);
|
|
|
+ let yc = this.locationList.find(f => f.id === tcc.yclocationid);
|
|
|
+ let lyTeacher = {};
|
|
|
+ let headteacher = {};
|
|
|
+ //礼仪老师,班主任合并请求
|
|
|
+ await axios.all([this.getTeacher(tcc.lyteacherid), this.getDirector(tcc.headteacherid)]).then(
|
|
|
+ axios.spread((r1, r2) => {
|
|
|
+ if (this.$checkRes(r1)) lyTeacher = r1.data;
|
|
|
+ if (this.$checkRes(r2)) headteacher = r2.data;
|
|
|
+ })
|
|
|
+ );
|
|
|
+ let object = { term, class: classes, lessons: lesson.lessons, start, end, headteacher, lyTeacher, js, kbys, tzxl, yc };
|
|
|
+ this.$set(this, `previews`, object);
|
|
|
+ this.$set(this, `loading`, false);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async getOtherList() {
|
|
|
+ //地点,科目合并请求
|
|
|
+ let res = await axios.all([this.getLocationList(), this.getSubjectList()]).then(
|
|
|
+ axios.spread((r1, r2, r3) => {
|
|
|
+ if (this.$checkRes(r1)) this.$set(this, `locationList`, r1.data);
|
|
|
+ if (this.$checkRes(r2)) this.$set(this, `subjectList`, r2.data);
|
|
|
+ })
|
|
|
+ );
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped></style>
|