lrf402788946 4 年之前
父节点
当前提交
f48f6b4347
共有 2 个文件被更改,包括 87 次插入0 次删除
  1. 6 0
      src/router/index.js
  2. 81 0
      src/views/home/index.vue

+ 6 - 0
src/router/index.js

@@ -11,6 +11,12 @@ const routes = [
     name: 'frame',
     component: () => import('@/views/index.vue'),
     children: [
+      {
+        path: '/',
+        name: 'home',
+        meta: { title: '首页' },
+        component: () => import('@/views/home/index.vue'),
+      },
       {
         path: '/info',
         name: 'teacherInfo_index',

+ 81 - 0
src/views/home/index.vue

@@ -0,0 +1,81 @@
+<template>
+  <div id="index">
+    <el-card header="已安排的课程">
+      <el-table :data="list" border stripe height="700px">
+        <el-table-column align="center" label="日期" prop="day"></el-table-column>
+        <el-table-column align="center" label="期" prop="term"></el-table-column>
+        <el-table-column align="center" label="班级" prop="classname"></el-table-column>
+        <el-table-column align="center" label="课程" prop="subname"></el-table-column>
+      </el-table>
+    </el-card>
+  </div>
+</template>
+
+<script>
+const _ = require('lodash');
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('trainplan');
+const { mapActions: teaplan } = createNamespacedHelpers('teaplan');
+const { mapActions: teacher } = createNamespacedHelpers('teacher');
+const { mapActions: subject } = createNamespacedHelpers('subject');
+const { mapActions: classtype } = createNamespacedHelpers('classtype');
+export default {
+  name: 'index',
+  props: {},
+  components: {},
+  data: function() {
+    return {
+      list: [],
+    };
+  },
+  created() {
+    this.search();
+  },
+  methods: {
+    ...mapActions(['query', 'delete', 'fetch']),
+    async search() {
+      let { planid } = this.defaultOption;
+      let { userid } = this.user;
+      if (!planid) return;
+      let res = await this.fetch(planid);
+      if (!this.$checkRes(res)) return;
+      const { termnum } = res.data;
+      let arr = [];
+      termnum.map(t => {
+        let { term, _id: termid } = t;
+        let obj = { term: term * 1, termid };
+        t.batchnum.map(b => {
+          const { _id: batchid, batch, class: classes } = b;
+          classes.map(c => {
+            let { lessons, name: classname } = c;
+            let tealesson = lessons.filter(f => f.teaid === userid);
+            tealesson = tealesson.map(tl => {
+              if (parseInt(classname)) classname = parseInt(classname);
+              tl.classname = classname;
+              tl.termid = termid;
+              tl.batchid = batchid;
+              tl.term = term;
+              tl.batch = batch;
+              return tl;
+            });
+            arr = [...arr, ...tealesson];
+          });
+        });
+      });
+      arr = _.orderBy(arr, ['day', 'term', 'classname'], ['asc', 'asc', 'asc']);
+      this.$set(this, `list`, arr);
+    },
+  },
+  computed: {
+    ...mapState(['user', 'defaultOption']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>