ソースを参照

添加班级课表

lrf402788946 5 年 前
コミット
fb762f4183
4 ファイル変更135 行追加2 行削除
  1. 6 0
      src/router/index.js
  2. 15 1
      src/store/index.js
  3. 9 1
      src/views/classes/index.vue
  4. 105 0
      src/views/classes/lesson.vue

+ 6 - 0
src/router/index.js

@@ -35,6 +35,12 @@ const routes = [
         meta: { title: '班级', sub: '名单' },
         component: () => import('@/views/classes/name-list.vue'),
       },
+      {
+        path: '/classes/lesson',
+        name: 'classes_lesson',
+        meta: { title: '班级', sub: '课程表' },
+        component: () => import('@/views/classes/lesson.vue'),
+      },
       {
         path: '/student/detail',
         name: 'student_detail',

+ 15 - 1
src/store/index.js

@@ -3,10 +3,17 @@ import Vuex from 'vuex';
 import trainplan from '@frame/store/trainplan';
 import dirPlan from '@frame/store/dir-plan';
 import classes from '@frame/store/classes';
+import location from '@frame/store/location';
+import teacher from '@frame/store/teacher';
+import dept from '@frame/store/dept';
+import subject from '@frame/store/subject';
+import teaPlan from '@frame/store/tea-plan';
 import student from '@frame/store/student';
 import completion from '@frame/store/question-completion';
 import nation from '@frame/store/nation';
 import school from '@frame/store/school';
+import lesson from '@frame/store/lesson';
+import director from '@frame/store/director';
 import termquest from '@frame/store/termquest';
 import questionnaire from '@frame/store/questionnaire';
 import login from '@frame/store/login';
@@ -26,8 +33,15 @@ export default new Vuex.Store({
     termquest,
     questionnaire,
     login,
+    location,
+    teacher,
+    dept,
+    teaPlan,
+    subject,
+    director,
+    lesson,
   },
   state: { ...ustate },
   mutations: { ...umutations },
-  actions: {},
+  actions: {}
 });

+ 9 - 1
src/views/classes/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div id="index">
     <list-frame title="班级管理" @query="search" :total="total" :filter="filFields" :needFilter="false" :needAdd="false">
-      <data-table :fields="fields" :data="list" :opera="opera" @edit="toEdit" @completion="toCompletion"></data-table>
+      <data-table :fields="fields" :data="list" :opera="opera" @edit="toEdit" @completion="toCompletion" @lesson="toLesson"></data-table>
     </list-frame>
   </div>
 </template>
@@ -31,6 +31,11 @@ export default {
         icon: 'el-icon-s-order',
         method: 'completion',
       },
+      {
+        label: '查看课程表',
+        icon: 'el-icon-date',
+        method: 'lesson',
+      },
     ],
     fields: [
       { label: '班级名称', prop: 'name' },
@@ -62,6 +67,9 @@ export default {
     toCompletion({ data }) {
       this.$router.push({ path: '/question/completion', query: { id: data.id } });
     },
+    toLesson({ data }) {
+      this.$router.push({ path: '/classes/lesson', query: { id: data.id } });
+    },
   },
 };
 </script>

+ 105 - 0
src/views/classes/lesson.vue

@@ -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>