guhongwei 4 years ago
parent
commit
65c2a3da0b
2 changed files with 78 additions and 12 deletions
  1. 1 2
      src/views/train-plan/lesson.vue
  2. 77 10
      src/views/train-plan/print.vue

+ 1 - 2
src/views/train-plan/lesson.vue

@@ -43,10 +43,9 @@ const { mapActions: lesson } = createNamespacedHelpers('lesson');
 //info-class
 const { mapActions: location } = createNamespacedHelpers('location'); //地点
 const { mapActions: teacher } = createNamespacedHelpers('teacher'); //教师
-const { mapActions: dept } = createNamespacedHelpers('dept'); //配合教师表使用的部门表
 const { mapActions: dirPlan } = createNamespacedHelpers('dirPlan'); //班主任不能上课的列表
 const { mapActions: teaplan } = createNamespacedHelpers('teaPlan');
-const { mapActions: mapDept } = createNamespacedHelpers('dept');
+const { mapActions: mapDept } = createNamespacedHelpers('dept'); //配合教师表使用的部门表
 export default {
   name: 'lesson',
   props: {},

+ 77 - 10
src/views/train-plan/print.vue

@@ -34,36 +34,47 @@
       </template>
     </list-frame>
     <detail-frame title="学生名签" v-if="view == 'nameList'" :returns="toReturns">
-      <name-card :list="studList"></name-card>
+      <name-card v-loading="loading" :list="studList"></name-card>
     </detail-frame>
     <detail-frame title="打印证书" v-if="view == 'certList'" :returns="toReturns">
       <cert-card :list="studList"></cert-card>
     </detail-frame>
     <detail-frame title="学生报道表" v-if="view == 'signList'" :returns="toReturns">
-      <sign-list :list="studList"></sign-list>
+      <sign-list v-loading="loading" :list="studList"></sign-list>
+    </detail-frame>
+    <detail-frame title="学生报道表" v-if="view == 'lesson'" :returns="toReturns">
+      <lesson-table v-loading="loading" :data="classInfo" :th="lth" :tr="ltr" :lessons="lessons"></lesson-table>
     </detail-frame>
   </div>
 </template>
 
 <script>
 import _ from 'lodash';
+import axios from 'axios';
 import signList from './parts/print-sign';
 import dataTable from '@frame/components/filter-page-table';
 import nameCard from '@/views/student/namCard.vue';
 import certCard from '@/views/student/certCard.vue';
+import lessonTable from '@frame/parts/time-table.vue';
 import listFrame from '@frame/layout/admin/list-frame';
 import detailFrame from '@frame/layout/admin/detail-frame';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: classes } = createNamespacedHelpers('classes');
 const { mapActions: trainplan } = createNamespacedHelpers('trainplan');
 const { mapActions: student } = createNamespacedHelpers('student');
+const { mapActions: util } = createNamespacedHelpers('util');
+const { mapActions: location } = createNamespacedHelpers('location'); //地点
+const { mapActions: teacher } = createNamespacedHelpers('teacher'); //教师
+const { mapActions: director } = createNamespacedHelpers('director'); //教师
+
 export default {
   name: 'print',
   props: {},
-  components: { listFrame, nameCard, certCard, detailFrame, dataTable, signList },
+  components: { listFrame, nameCard, certCard, detailFrame, dataTable, signList, lessonTable },
   data: function() {
     return {
       view: 'list',
+      loading: false,
       form: {},
       termList: [],
       batchList: [],
@@ -92,9 +103,12 @@ export default {
       ],
       total: 0,
       classList: [],
-
       //打印数据
       studList: [],
+      classInfo: {},
+      lth: [], //table表头
+      ltr: [], //table y轴
+      lessons: [], //原始课表,取出来什么样就什么样
     };
   },
   created() {
@@ -104,6 +118,10 @@ export default {
     ...trainplan({ planfetch: 'fetch' }),
     ...classes({ classesquery: 'query' }),
     ...student({ getStudentList: 'query' }),
+    ...util({ modelFetch: 'fetch' }),
+    ...location({ getLocation: 'fetch' }),
+    ...teacher({ getTeacher: 'fetch' }),
+    ...director({ getDirector: 'fetch' }),
     async searchinfo() {
       const res = await this.planfetch(this.defaultOption.planid);
       let terms = res.data.termnum;
@@ -120,8 +138,8 @@ export default {
         this.$set(this, `batchList`, batchnum);
       }
     },
-    async search() {
-      const res = await this.classesquery({ batchid: this.form.batchid, termid: this.form.termid });
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.classesquery({ skip, limit, batchid: this.form.batchid, termid: this.form.termid });
       this.$set(this, `tableData`, res.data);
       this.$set(this, `total`, res.total);
     },
@@ -129,16 +147,36 @@ export default {
       this.classList = val;
     },
     async nameList({ data }) {
+      this.loading = true;
+      this.view = 'nameList';
       let { _id: classid } = data;
       let res = await this.getStudentList({ classid });
       if (this.$checkRes(res)) this.$set(this, `studList`, res.data);
-      this.view = 'nameList';
+      this.loading = false;
     },
     async signList({ data }) {
+      this.loading = true;
+      this.view = 'signList';
       let { _id: classid } = data;
       let res = await this.getStudentList({ classid });
       if (this.$checkRes(res)) this.$set(this, `studList`, res.data);
-      this.view = 'signList';
+      this.loading = false;
+    },
+    async classLesson({ data }) {
+      this.loading = true;
+      this.view = 'lesson';
+      let { _id: classid } = data;
+      let res = await this.modelFetch({ model: 'lesson', classid });
+      if (this.$checkRes(res)) {
+        let { lessons } = res.data;
+        let { x, y } = this.proLesson(lessons);
+        this.$set(this, `lth`, x);
+        this.$set(this, `ltr`, y);
+        this.$set(this, `lessons`, lessons);
+        data = await this.getRemarkParts(data);
+        this.$set(this, `classInfo`, data);
+      }
+      this.loading = false;
     },
     async certList({ data }) {
       let { _id: classid } = data;
@@ -146,8 +184,37 @@ export default {
       if (this.$checkRes(res)) this.$set(this, `studList`, res.data);
       this.view = 'certList';
     },
-    classLesson({ data }) {
-      console.log(this.classList);
+    async getRemarkParts(data) {
+      let { headteacherid, jslocationid, lyteacherid } = data;
+      let aArr = [];
+      aArr.push(this.getDirector(headteacherid));
+      aArr.push(this.getLocation(jslocationid));
+      axios.all(aArr).then(
+        axios.spread((r1, r2) => {
+          if (r1 && r1.errcode == 0) data.headteacher = r1.data.name;
+          if (r2 && r2.errcode == 0) data.jslocation = r2.data.name;
+        })
+      );
+      let check = data => {
+        if (!data || data.errcode != 0) return false;
+        let obj = _.get(data, `data`);
+        if (!obj) return false;
+        return obj.name;
+      };
+      //单独处理礼仪教师,因为数据可能从2个表来
+      let res = await this.getDirector(lyteacherid);
+      let name = check(res);
+      if (name) data.lyteacher = name;
+      else res = await this.getTeacher(lyteacherid);
+      name = check(res);
+      if (name) data.lyteacher = name;
+      return data;
+    },
+    proLesson(data) {
+      let duplicate = _.cloneDeep(data);
+      let x = _.uniq(_.orderBy(duplicate, 'date', 'asc').map(i => i.date));
+      let y = _.uniq(_.orderBy(duplicate, 'time', 'asc').map(i => i.time));
+      return { x, y };
     },
     toReturns() {
       this.view = 'list';