Parcourir la source

Merge branch 'master' of http://git.cc-lotus.info/new_train/train-director

lrf402788946 il y a 4 ans
Parent
commit
9da6d9b0d8

+ 14 - 6
src/router/index.js

@@ -82,18 +82,26 @@ const routes = [
         component: () => import('@/views/classes/completion-detail.vue'),
       },
 
-      {
-        path: '/classes/lesson',
-        name: 'classes_lesson',
-        meta: { title: '班级', sub: '课程表' },
-        component: () => import('@/views/classes/lesson.vue'),
-      },
+      // {
+      //   path: '/classes/lesson',
+      //   name: 'classes_lesson',
+      //   meta: { title: '班级', sub: '课程表' },
+      //   component: () => import('@/views/classes/lesson.vue'),
+      // },
       {
         path: '/classes/bedroom',
         name: 'classes_bedroom',
         meta: { title: '班级', sub: '寝室' },
         component: () => import('@/views/classes/bedroom.vue'),
       },
+      // 新增课表查看
+      {
+        path: '/train/plan/term/lesson',
+        name: 'classes_bedroom',
+        meta: { title: '班级', sub: '课程表' },
+        component: () => import('@/views/classes/lesson.vue'),
+      },
+
       // 新增-打印名单
 
       // {

+ 2 - 0
src/store/index.js

@@ -26,6 +26,7 @@ import leave from '@frame/store/leave';
 import setting from '@frame/store/setting';
 import notice from '@frame/store/notice';
 import trainBatch from '@frame/store/train-plan-year';
+import group from '@frame/store/group';
 import * as ustate from '@frame/store/user/state';
 import * as umutations from '@frame/store/user/mutations';
 import * as dostate from '@frame/store/setting/state';
@@ -60,6 +61,7 @@ export default new Vuex.Store({
     trainBatch,
     questionanswer,
     notice,
+    group,
   },
   state: { ...ustate, ...dostate },
   mutations: { ...umutations, ...domutations },

+ 95 - 193
src/views/classes/lesson.vue

@@ -1,220 +1,126 @@
 <template>
-  <div id="lesson-table">
-    <detail-frame title="课程安排" :returns="toreturn">
-      <el-card>
-        <el-table :data="lessonList" border stripe>
-          <el-table-column align="center" label="时间" prop="time"></el-table-column>
-          <el-table-column align="center" v-for="(i, index) in dateList" :key="index" :label="i" :prop="`subname_day${index + 1}`">
-            <template v-slot="{ row, $index }">
-              <el-row>
-                <el-col :span="24">{{ getProp(row, `subname_day${index + 1}`) }}</el-col>
-                <el-col
-                  @click.native="searchTeacher(getProp(row, `teaid_day${index + 1}`))"
-                  class="teaname"
-                  :span="24"
-                  v-if="getProp(row, `teaname_day${index + 1}`)"
-                  >{{ getProp(row, `teaname_day${index + 1}`) }}</el-col
-                >
-              </el-row>
-            </template>
-          </el-table-column>
-        </el-table>
-        <el-dialog title="教师信息" :visible.sync="dialogVisible">
-          <teacherForm :teacherId="teacherId" style="height:1200px;"></teacherForm>
-        </el-dialog>
-      </el-card>
+  <div id="lesson">
+    <detail-frame title="班级课表">
+      <class-table ref="lesson" :classInfo="classInfo" @saveResult="getRes"></class-table>
+      <el-divider></el-divider>
+      <info-class
+        ref="classes"
+        :classInfo.sync="classInfo"
+        :locationList="locationList"
+        :lyTeacherList="lyTeacherList"
+        :headTeacherList="headTeacherList"
+        @saveResult="getRes"
+      ></info-class>
     </detail-frame>
   </div>
 </template>
 
 <script>
-var moment = require('moment');
 import _ from 'lodash';
 import detailFrame from '@frame/layout/admin/detail-frame';
-import teacherForm from '@frame/parts/teacher';
+import classTable from './parts/class-table';
+import infoClass from './parts/class-info';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: classes } = createNamespacedHelpers('classes');
 const { mapActions: lesson } = createNamespacedHelpers('lesson');
-const { mapActions: mapUtil } = createNamespacedHelpers('util');
-const { mapActions: subject } = createNamespacedHelpers('subject');
-const { mapActions: teacher } = createNamespacedHelpers('teacher');
-const { mapActions: school } = createNamespacedHelpers('school'); //给选老师组件使用.这个页面请求完就不销毁了
-
-// 本页的组合数据,变量用x表示: _id_day[x];subname_day[x];subid_day[x];teaid_day[x];teaname_day:[x]
+//info-class
+const { mapActions: location } = createNamespacedHelpers('location'); //地点
+const { mapActions: teacher } = createNamespacedHelpers('teacher'); //教师
+const { mapActions: dirPlan } = createNamespacedHelpers('dirPlan'); //班主任不能上课的列表
+const { mapActions: teaplan } = createNamespacedHelpers('teaPlan');
+const { mapActions: mapDept } = createNamespacedHelpers('dept'); //配合教师表使用的部门表
 export default {
-  name: 'lesson-table',
-  props: {
-    classInfo: { type: Object, default: () => {} },
-  },
-  components: { teacherForm, detailFrame },
+  name: 'lesson',
+  props: {},
+  components: { detailFrame, classTable, infoClass },
   data: function() {
-    var that = this;
     return {
-      lessonInfo: {},
-      lessonList: [],
-      dateList: [],
-      timeList: [],
-      subjectList: [],
-      teacherList: [],
-      schoolList: [], //给选老师组件用
-      form: {},
-      dialogVisible: false,
-      teacherId: {},
-      dayType: [{ label: '活动' }, { label: '课程' }],
-      actList: [
-        { label: '--' },
-        { label: '报道+开班仪式' },
-        { label: '午餐+休息' },
-        { label: '晚餐' },
-        { label: '团队组建' },
-        { label: '拓展交流' },
-        { label: '课程作业小组展示' },
-        { label: '课程作业' },
-        { label: '礼仪课小组面试' },
-        { label: '结业仪式' },
-      ],
+      classInfo: {},
+      locationList: [],
+      lyTeacherList: [],
+      headTeacherList: [],
+      deptList: [],
+      result: [],
     };
   },
   created() {
-    this.getOtherList();
-    this.search();
+    this.getClassInfo();
   },
   methods: {
-    ...mapUtil(['fetch']),
-    ...lesson(['query', 'create', 'update']),
-    ...subject({ getSubject: 'query' }),
-    ...teacher({ getTeacher: 'query' }),
-    ...school({ getSchool: 'query' }),
-    async search() {
-      let res = await this.fetch({ model: 'lesson', classid: this.id });
+    ...classes(['fetch']),
+    ...location({ getLocationList: 'query' }),
+    ...teacher({ getTeacherList: 'query' }),
+    ...dirPlan({ dirQuery: 'getDirTeacher' }),
+    ...mapDept({ getDept: 'query' }),
+    ...teaplan(['findTeacher']),
+    ...lesson(['confirmLesson']),
+    async getClassInfo() {
+      let classid = _.get(this.defaultOption, 'classid');
+      console.log(classid);
+      let res = await this.fetch(classid);
       if (this.$checkRes(res)) {
-        if (res.data.lessons.length <= 0) this.$message.warning('请先将本期的课程按模板进行初始化');
-        this.$set(this, `lessonInfo`, _.omit(res.data, ['lessons']));
-        let arr = _.get(res.data, `lessons`, []);
-        let x = this.getX(JSON.parse(JSON.stringify(arr)));
-        this.getY(JSON.parse(JSON.stringify(arr)));
-        this.$set(this, `dateList`, x);
-        arr = this.aData(arr);
-        this.$set(this, `lessonList`, arr);
+        this.$set(this, `classInfo`, res.data);
+        this.getSettingLists(this.classInfo);
       }
     },
-    //请求后整理数据方法
-    aData(data) {
-      let duplicate = JSON.parse(JSON.stringify(data));
-      //按时间分组
-      duplicate = _.flatten(_.toPairs(_.groupBy(data, 'time'))).filter(f => _.isArray(f));
-      let r = duplicate.map(i => {
-        //按日期排序
-        let aa = i.sort((a, b) => moment(a.date).format('X') - moment(b.date).format('X'));
-        //组合数据:{time,day1,id_day1,subid_day1}
-        let object = { time: _.get(i[0], 'time') };
-        aa.map(a => {
-          let index = this.dateList.findIndex(f => f == a.date);
-          if (index >= 0) {
-            index = index + 1;
-          }
-          let obj = this.resetData(a, index);
-          object = { ...object, ...obj };
-        });
-        return object;
-      });
-      r = this.getOrderForTime(r);
-      return r;
-    },
-    //获取指定数据
-    getOrderDate(data, index, needDate = false) {
-      let obj = { index: index };
-      if (_.get(data, `_id_day${index}`)) obj[`_id`] = _.get(data, `_id_day${index}`);
-      obj[`subname`] = _.get(data, `subname_day${index}`, `--`);
-      if (_.get(data, `subid_day${index}`)) obj[`subid`] = _.get(data, `subid_day${index}`);
-      if (_.get(data, `teaid_day${index}`)) obj[`teaid`] = _.get(data, `teaid_day${index}`);
-      if (_.get(data, `teaname_day${index}`)) obj[`teaname`] = _.get(data, `teaname_day${index}`);
-      if (needDate) {
-        //所有的数据都还原了,没必要遥index了
-        delete obj.index;
-        obj.date = this.dateList[index - 1];
+    getRes({ from, result }) {
+      let r = this.result.find(f => f.from == from);
+      if (r) {
+        console.log(`已有${from}的保存结果,未清除`);
+        return;
+      } else {
+        this.result.push({ from, result });
+      }
+      console.log(this.result);
+      if (this.result.length == 2) {
+        let resR = this.result.every(e => e.result == true);
+        if (resR) this.$message.success('保存成功');
+        this.$set(this, `result`, []);
       }
-      return obj;
-    },
-    //整理,匹配数据是哪天,该显示在哪
-    resetData(data, index) {
-      let obj = {};
-      if (_.get(data, '_id')) obj[`_id_day${index}`] = _.get(data, '_id');
-      obj[`subname_day${index}`] = _.get(data, 'subname', '--');
-      if (_.get(data, 'subid')) obj[`subid_day${index}`] = _.get(data, 'subid');
-      if (_.get(data, 'teaid')) obj[`teaid_day${index}`] = _.get(data, 'teaid');
-      if (_.get(data, 'teaname')) obj[`teaname_day${index}`] = _.get(data, 'teaname');
-      return obj;
-    },
-    //根据时间排序
-    getOrderForTime(data) {
-      let duplicate = JSON.parse(JSON.stringify(data));
-      duplicate = duplicate.sort((a, b) => {
-        let a_arr = a.time.split('-');
-        let b_arr = b.time.split('-');
-        let at = moment(`${moment().format('YYYY-MM-DD')} ${a_arr[0]}`).format('X');
-        let bt = moment(`${moment().format('YYYY-MM-DD')} ${b_arr[0]}`).format('X');
-        return at - bt;
-      });
-      return duplicate;
-    },
-    //整理出标头,根据日期排序
-    getX(data) {
-      let r = _.uniqBy(data, 'date').map(i => i.date);
-      r = r.sort((a, b) => moment(a).format('X') - moment(b).format('X'));
-      return r;
-    },
-    //获得时间列表
-    getY(data) {
-      let duplicate = JSON.parse(JSON.stringify(data));
-      let arr = _.uniqBy(
-        duplicate.map(i => _.pick(i, ['time'])),
-        'time'
-      );
-      arr = this.getOrderForTime(arr);
-      this.$set(
-        this,
-        `timeList`,
-        arr.map(i => i.time)
-      );
-    },
-    //教师列表,课程列表
-    async getOtherList() {
-      let res = await this.getSubject();
-      if (this.$checkRes(res)) this.$set(this, `subjectList`, res.data);
-      res = await this.getTeacher({ status: '4' });
-      if (this.$checkRes(res)) this.$set(this, `teacherList`, res.data);
-    },
-    //显示
-    getProp(data, prop) {
-      return _.get(data, prop);
-    },
-    async searchTeacher(id) {
-      this.dialogVisible = true;
-      this.teacherId = id;
-      console.log(id);
     },
-    toreturn() {
-      window.history.go(-1);
+    async getSettingLists(data) {
+      let res;
+      if (this.locationList.length <= 0) {
+        res = await this.getLocationList();
+        if (this.$checkRes(res)) this.$set(this, `locationList`, res.data);
+      }
+      if (this.lyTeacherList.length <= 0) {
+        res = await this.getTeacherList({ islyteacher: '1', status: '4' });
+        if (this.$checkRes(res)) this.$set(this, `lyTeacherList`, res.data);
+      }
+      if (this.headTeacherList.length <= 0) {
+        res = await this.findTeacher({ planid: data.planid, termid: data.termid, batchid: data.batchid });
+        let duplicate = _.cloneDeep(res.data);
+        if (this.$checkRes(res)) {
+          if (this.deptList.length <= 0) {
+            let dept = await this.getDept();
+            if (this.$checkRes(res)) this.$set(this, `deptList`, dept.data);
+          }
+          //班主任按部门分组
+          let group = _.groupBy(res.data, 'department');
+          let keys = Object.keys(group);
+          let arr = keys.map(key => {
+            let r = this.deptList.find(f => f.id == key);
+            let obj = {};
+            if (r) {
+              obj.name = r.name;
+              obj.list = group[key];
+            }
+            return obj;
+          });
+          this.$set(this, `headTeacherList`, arr);
+          //班主任筛选可以当礼仪老师列表,和 礼仪教师列表合并
+          duplicate = duplicate.filter(f => f.islyteacher == '1');
+          this.$set(this, `lyTeacherList`, [...this.lyTeacherList, ...duplicate]);
+        }
+      }
     },
   },
   computed: {
-    ...mapState(['user']),
+    ...mapState(['user', 'defaultOption']),
     pageTitle() {
       return `${this.$route.meta.title}`;
     },
-    id() {
-      return this.$route.query.id;
-    },
-  },
-  watch: {
-    classInfo: {
-      handler(val) {
-        let id = _.get(val, '_id');
-        if (id) this.search();
-      },
-      immediate: true,
-      deep: true,
-    },
   },
   metaInfo() {
     return { title: this.$route.meta.title };
@@ -222,8 +128,4 @@ export default {
 };
 </script>
 
-<style lang="less" scoped>
-.teaname {
-  border-top: 1px dashed #cccccc;
-}
-</style>
+<style lang="less" scoped></style>

+ 68 - 42
src/views/classes/name-list.vue

@@ -25,11 +25,13 @@
 </template>
 
 <script>
+import _ from 'lodash';
 import listFrame from '@frame/layout/admin/list-frame';
 import dataTable from '@frame/components/data-table';
 import dataForm from '@frame/components/form';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions } = createNamespacedHelpers('student');
+const { mapActions: group } = createNamespacedHelpers('group');
 export default {
   metaInfo: { title: '班级名单' },
   name: 'name-list',
@@ -39,50 +41,74 @@ export default {
     dataTable,
     dataForm,
   },
-  data: () => ({
-    opera: [
-      {
-        label: '编辑',
-        icon: 'el-icon-edit',
-        method: 'edit',
-      },
-      {
-        label: '删除',
-        icon: 'el-icon-delete',
-        method: 'delete',
-        confirm: true,
-      },
-      // {
-      //   label: '管理任职',
-      //   icon: 'el-icon-check',
-      //   method: 'post',
-      // },
-    ],
-    fields: [
-      { label: '姓名', prop: 'name' },
-      { label: '性别', prop: 'gender' },
-      { label: '民族', prop: 'nation' },
-      { label: '学校', prop: 'school_name' },
-      { label: '院系', prop: 'yard' },
-      { label: '专业', prop: 'major' },
-      { label: '职务', prop: 'job' },
-      { label: '手机号', prop: 'phone' },
-    ],
-    list: [],
-    total: 0,
-    form: {},
-    drawer: false,
-    formFields: [
-      { label: '姓名', model: 'name', type: 'text' },
-      { label: '性别', model: 'gender', custom: true },
-      { label: '手机号', model: 'phone', type: 'text' },
-      { label: '职务', required: true, model: 'job', type: 'radio' },
-    ],
-    rules: {},
-  }),
-  created() {},
+  data: function() {
+    var _this = this;
+    return {
+      opera: [
+        {
+          label: '编辑',
+          icon: 'el-icon-edit',
+          method: 'edit',
+        },
+        {
+          label: '删除',
+          icon: 'el-icon-delete',
+          method: 'delete',
+          confirm: true,
+          display: i => {
+            // return !_this.groupList.find(stu => {
+            //   return stu.stuid == i.id;
+            // });
+            return !_this.groupList.find(stu => stu.stuid == i.id);
+          },
+        },
+        // {
+        //   label: '管理任职',
+        //   icon: 'el-icon-check',
+        //   method: 'post',
+        // },
+      ],
+      fields: [
+        { label: '姓名', prop: 'name' },
+        { label: '性别', prop: 'gender' },
+        { label: '民族', prop: 'nation' },
+        { label: '学校', prop: 'school_name' },
+        { label: '院系', prop: 'yard' },
+        { label: '专业', prop: 'major' },
+        { label: '职务', prop: 'job' },
+        { label: '手机号', prop: 'phone' },
+      ],
+      list: [],
+      total: 0,
+      form: {},
+      drawer: false,
+      formFields: [
+        { label: '姓名', model: 'name', type: 'text' },
+        { label: '性别', model: 'gender', custom: true },
+        { label: '手机号', model: 'phone', type: 'text' },
+        { label: '职务', required: true, model: 'job', type: 'radio' },
+      ],
+      rules: {},
+      // 组
+      groupList: [],
+    };
+  },
+  created() {
+    this.seachGroup();
+  },
   methods: {
     ...mapActions(['query', 'delete']),
+    ...group({ groupQuery: 'query' }),
+    async seachGroup() {
+      let classid = this.id;
+      let res = await this.groupQuery({ classid });
+      if (this.$checkRes(res)) {
+        let arr = res.data.map(item => item.students);
+        arr = _.flattenDeep(arr);
+        console.log(arr);
+        this.$set(this, `groupList`, arr);
+      }
+    },
     async search({ skip = 0, limit = 10, ...info } = {}) {
       const res = await this.query({ skip, limit, ...info, classid: this.id });
       if (this.$checkRes(res)) {

+ 88 - 0
src/views/classes/parts/class-info.vue

@@ -0,0 +1,88 @@
+<template>
+  <div id="class-info">
+    <data-form ref="form" :inline="true" :needSave="false" :data="form" :fields="fields" :rules="{}" @save="handleSave" :reset="false">
+      <template #options="{item, form}">
+        <template v-if="item.model == 'headteacherid'">
+          <el-option-group v-for="(dept, index) in headTeacherList" :label="dept.name" :key="index">
+            <el-option v-for="(i, tIndex) in dept.list" :key="`${index}-${tIndex}`" :label="i.name" :value="i._id"></el-option>
+          </el-option-group>
+        </template>
+        <template v-if="item.model == 'lyteacherid'">
+          <el-option v-for="(tea, index) in lyTeacherList" :key="`${item.model}${index}`" :label="tea.name" :value="tea.id"></el-option>
+        </template>
+        <template v-if="item.model == 'jslocationid'">
+          <el-option v-for="(place, index) in locationList" :key="`${item.model}${index}`" :label="place.name" :value="place.id"></el-option>
+        </template>
+        <template v-if="item.model == 'kbyslocationid'">
+          <el-option v-for="(place, index) in locationList" :key="`${item.model}${index}`" :label="place.name" :value="place.id"></el-option>
+        </template>
+        <template v-if="item.model == 'kzjhlocationid'">
+          <el-option v-for="(place, index) in locationList" :key="`${item.model}${index}`" :label="place.name" :value="place.id"></el-option>
+        </template>
+        <template v-if="item.model == 'yclocationid'">
+          <el-option v-for="(place, index) in locationList" :key="`${item.model}${index}`" :label="place.name" :value="place.id"></el-option>
+        </template>
+      </template>
+    </data-form>
+  </div>
+</template>
+
+<script>
+import _ from 'lodash';
+import dataForm from '@frame/components/form';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: classes } = createNamespacedHelpers('classes');
+export default {
+  name: 'class-info',
+  props: {
+    classInfo: { type: Object, default: () => {} },
+    locationList: { type: Array, default: () => [] },
+    lyTeacherList: { type: Array, default: () => [] },
+    headTeacherList: { type: Array, default: () => [] },
+  },
+  components: { dataForm },
+  data: function() {
+    var that = this;
+    return {
+      // form: {},
+      fields: [
+        // { label: '', model: 'name', type: 'text' },
+        // { label: '人数', model: 'number', type: 'text' },
+        { label: '班主任', model: 'headteacherid', type: 'select', options: { disabled: true } },
+        { label: '礼仪课教师', model: 'lyteacherid', type: 'select', options: { disabled: true } },
+        { label: '教室地点', model: 'jslocationid', type: 'select', options: { disabled: true } },
+        { label: '开班地点', model: 'kbyslocationid', type: 'select', options: { disabled: true } },
+        { label: '拓展训练地点', model: 'kzjhlocationid', type: 'select', options: { disabled: true } },
+        { label: '用餐地点', model: 'yclocationid', type: 'select', options: { disabled: true } },
+      ],
+    };
+  },
+  created() {},
+  methods: {
+    ...classes(['update']),
+    toSave() {
+      this.$refs.form.save();
+    },
+    async handleSave({ data }) {
+      let res = await this.update(data);
+      if (this.$checkRes(res, null, res.errmsg || '保存失败')) {
+        this.$emit('saveResult', { from: 'info', result: true });
+      }
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+    form() {
+      return _.cloneDeep(this.classInfo);
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 440 - 0
src/views/classes/parts/class-table.vue

@@ -0,0 +1,440 @@
+<template>
+  <div id="class-table">
+    <el-card>
+      <template #header>
+        <el-row type="flex" align="middle" justify="space-between">
+          <el-col :span="4">课程安排</el-col>
+        </el-row>
+      </template>
+      <el-table :data="lessonList" border stripe @cell-click="cellClick">
+        <el-table-column align="center" label="时间" prop="time"></el-table-column>
+        <el-table-column align="center" v-for="(i, index) in dateList" :key="index" :label="i" :prop="`subname_day${index + 1}`">
+          <template v-slot="{ row, $index }">
+            <el-row>
+              <el-col :span="24">{{ getProp(row, `subname_day${index + 1}`) }}</el-col>
+              <el-col :span="24" v-if="getProp(row, `teaname_day${index + 1}`)">{{ getProp(row, `teaname_day${index + 1}`) }}</el-col>
+            </el-row>
+          </template>
+        </el-table-column>
+      </el-table>
+    </el-card>
+
+    <el-drawer :visible.sync="drawer" direction="rtl" title="课程安排" @close="toClose">
+      <data-form :data="form" :fields="resetForm()" :rules="{}" @save="handleSave" :reset="false">
+        <template #radios="{item, form}">
+          <template v-if="item.model == 'type'">
+            <el-radio @change="radioClearForm" v-for="(i, index) in dayType" :key="index" :label="i.label">{{ i.label }}</el-radio>
+          </template>
+        </template>
+        <template #options="{item, form}">
+          <template v-if="item.model == 'subname'">
+            <el-option v-for="(i, index) in actList" :key="index" :label="i.label" :value="i.label"></el-option>
+          </template>
+          <template v-if="item.model == 'subid'">
+            <el-option v-for="(i, index) in subjectList" :key="index" :label="i.name" :value="i.id"></el-option>
+          </template>
+        </template>
+
+        <template #custom="{item, form}">
+          <template v-if="item.model == 'teaname'">
+            <el-input v-model="form.teaname" :readonly="true" placeholder="点击选择教师" @click.native="toChooseTeacher"></el-input>
+            <!-- <el-input v-model="form.reason" v-if="needReason()" placeholder="请填写修改教师原因"></el-input> -->
+          </template>
+        </template>
+      </data-form>
+    </el-drawer>
+    <el-drawer :visible.sync="drawerTime" direction="rtl" title="课程时间安排" @close="toClose">
+      <el-form :model="form" size="mini" style="padding:20px">
+        <el-form-item label="时间">
+          <el-time-picker
+            v-model="form.time"
+            placeholder="请选择时间"
+            :is-range="true"
+            value-format="HH:mm"
+            :picker-options="{ format: 'HH:mm' }"
+          ></el-time-picker>
+        </el-form-item>
+        <el-form-item>
+          <el-row type="flex" align="middle" justify="center">
+            <el-col :span="4">
+              <el-button type="primary" plain @click="hsavetime('save')">保存</el-button>
+            </el-col>
+            <el-col :span="4">
+              <el-button type="danger" plain v-if="form && form.index >= 0" @click="hsavetime('delete')">删除</el-button>
+            </el-col>
+          </el-row>
+        </el-form-item>
+      </el-form>
+    </el-drawer>
+  </div>
+</template>
+
+<script>
+var moment = require('moment');
+import _ from 'lodash';
+import dataForm from '@frame/components/form';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: lesson } = createNamespacedHelpers('lesson');
+const { mapActions: mapUtil } = createNamespacedHelpers('util');
+const { mapActions: subject } = createNamespacedHelpers('subject');
+const { mapActions: teacher } = createNamespacedHelpers('teacher');
+const { mapActions: school } = createNamespacedHelpers('school'); //给选老师组件使用.这个页面请求完就不销毁了
+
+// 本页的组合数据,变量用x表示: _id_day[x];subname_day[x];subid_day[x];teaid_day[x];teaname_day:[x]
+export default {
+  name: 'class-table',
+  props: {
+    classInfo: { type: Object, default: () => {} },
+  },
+  components: { dataForm },
+  data: function() {
+    var that = this;
+    return {
+      oLessonList: [],
+      lessonInfo: {},
+      lessonList: [],
+      dateList: [],
+      timeList: [],
+      subjectList: [],
+      teacherList: [],
+      schoolList: [], //给选老师组件用
+      drawer: false,
+      drawerTime: false,
+      dialog: false,
+      form: {},
+      fields: [
+        { label: '日期', model: 'date', type: 'text' },
+        { label: '时间', model: 'time', type: 'text' },
+        { label: '类型', model: 'type', type: 'radio' },
+        { label: '课程安排', model: 'subid', type: 'select', display: (fields, form) => that.fieldDisplay(fields, form) },
+        { label: '活动安排', model: 'subname', type: 'select', display: (fields, form) => that.fieldDisplay(fields, form) },
+        { label: '教师', model: 'teaname', custom: true, display: (fields, form) => that.fieldDisplay(fields, form) },
+      ],
+      dayType: [{ label: '活动' }, { label: '课程' }],
+      actList: [
+        { label: '--' },
+        { label: '报道+开班仪式' },
+        { label: '午餐+休息' },
+        { label: '晚餐' },
+        { label: '团队组建' },
+        { label: '拓展交流' },
+        { label: '课程作业小组展示' },
+        { label: '课程作业' },
+        { label: '礼仪课小组面试' },
+        { label: '结业仪式' },
+      ],
+    };
+  },
+  created() {
+    this.getOtherList();
+  },
+  methods: {
+    ...mapUtil(['fetch']),
+    ...lesson(['query', 'create', 'update']),
+    ...subject({ getSubject: 'query' }),
+    ...teacher({ getTeacher: 'query' }),
+    ...school({ getSchool: 'query' }),
+    async search() {
+      let res = await this.fetch({ model: 'lesson', classid: _.get(this.classInfo, '_id') });
+      if (this.$checkRes(res)) {
+        if (!_.get(res.data, 'lessons') || res.data.lessons.length <= 0) {
+          this.$message.warning('请先将本期的课程按模板进行初始化');
+          return;
+        }
+        this.$set(this, `lessonInfo`, _.omit(res.data, ['lessons']));
+        let arr = _.get(res.data, `lessons`, []);
+        this.$set(this, `oLessonList`, _.cloneDeep(arr));
+        let x = this.getX(JSON.parse(JSON.stringify(arr)));
+        this.getY(JSON.parse(JSON.stringify(arr)));
+        this.$set(this, `dateList`, x);
+        arr = this.aData(arr);
+        this.$set(this, `lessonList`, arr);
+      }
+    },
+    async toSave() {
+      //整理成原数据形式,提交
+      let data = JSON.parse(JSON.stringify(this.lessonList));
+      data = this.returnData(data);
+      let lesson = JSON.parse(JSON.stringify(this.lessonInfo));
+      lesson.lessons = data;
+      let res = await this.update(lesson);
+      if (this.$checkRes(res, null, res.errmsg || '课程表保存失败')) {
+        this.$emit('saveResult', { from: 'lesson', result: true });
+      }
+    },
+    //点击单元格事件
+    cellClick(row, column) {
+      return false;
+      // let prop = _.get(column, 'property');
+      // if (prop != 'time') {
+      //   let date = _.get(column, 'label');
+      //   let time = _.get(row, 'time');
+      //   let num = _.get(column, 'property').match(/\d+(.\d+)?/g)[0];
+      //   let obj = this.getOrderDate(row, num);
+      //   obj.type = obj.subid ? '课程' : '活动';
+      //   this.$set(this, `form`, { date, time, ...obj });
+      //   this.drawer = true;
+      // } else {
+      //   let obj = _.cloneDeep(row);
+      //   let index = this.lessonList.findIndex(f => f.time == obj.time);
+      //   obj.time = obj.time.split('-');
+      //   obj.index = index;
+      //   this.$set(this, `form`, obj);
+      //   this.drawerTime = true;
+      // }
+    },
+    //抽屉保存
+    handleSave({ data }) {
+      let num = _.get(data, 'index');
+      let type = _.get(data, `type`);
+      let time = _.get(data, `time`);
+      let yIndex = this.lessonList.findIndex(f => f.time == time);
+      let obj = {};
+      if (type == '课程') {
+        obj = _.pick(data, ['subid', 'teaid', 'teaname', '_id', 'reason']);
+        let r = this.subjectList.find(f => f.id == obj.subid);
+        if (r) obj.subname = r.name;
+      } else {
+        obj = _.pick(data, ['subname', '_id']);
+      }
+      obj = this.resetData(obj, num);
+      this.$set(this.lessonList, yIndex, { ...this.lessonList[yIndex], ...obj });
+      this.setSubTea();
+      this.drawer = false;
+    },
+    //提交整理数据
+    returnData(data) {
+      let returnArr = [];
+      data.map(i => {
+        let keys = Object.keys(i);
+        let time = _.get(i, `time`);
+        let arr = _.compact(_.uniq(_.flatten(keys.map(i => i.match(/\d+(.\d+)?/g)))));
+        arr.map(index => {
+          let obj = this.getOrderDate(i, index, true);
+          obj.time = time;
+          obj.day = '0';
+          returnArr.push(obj);
+        });
+      });
+      let r = returnArr.filter(f => f.date == _.last(this.dateList));
+      let allday = '0';
+      let res = r.find(f => {
+        //TODO 根据开始时间不超过12点判断是 整天还是半天
+        if (f.subname != '--') {
+          let ts = f.time.split('-');
+          let time = moment(`${f.date} ${ts[0]}`).format('X');
+          let twl = moment(`${f.date} 12:00`).format('X');
+          return twl <= time;
+        }
+      });
+      if (res) allday = '1';
+      returnArr = returnArr.map(i => {
+        if (i.date == _.last(this.dateList)) i.allday = allday;
+        else i.allday = '0';
+        return i;
+      });
+      return returnArr;
+    },
+    //field的显示
+    fieldDisplay(f, form) {
+      if (f.model == 'teaname' || f.model == 'subid') {
+        return form.type == '课程';
+      } else return form.type == '活动';
+    },
+    //请求后整理数据方法
+    aData(data) {
+      let duplicate = JSON.parse(JSON.stringify(data));
+      //按时间分组
+      duplicate = _.flatten(_.toPairs(_.groupBy(data, 'time'))).filter(f => _.isArray(f));
+      let r = duplicate.map(i => {
+        //按日期排序
+        let aa = i.sort((a, b) => moment(a.date).format('X') - moment(b.date).format('X'));
+        //组合数据:{time,day1,id_day1,subid_day1}
+        let object = { time: _.get(i[0], 'time') };
+        aa.map(a => {
+          let index = this.dateList.findIndex(f => f == a.date);
+          if (index >= 0) {
+            index = index + 1;
+          }
+          let obj = this.resetData(a, index);
+          object = { ...object, ...obj };
+        });
+        return object;
+      });
+      r = this.getOrderForTime(r);
+      return r;
+    },
+    //获取指定数据
+    getOrderDate(data, index, needDate = false) {
+      let obj = { index: index };
+      if (_.get(data, `_id_day${index}`)) obj[`_id`] = _.get(data, `_id_day${index}`);
+      obj[`subname`] = _.get(data, `subname_day${index}`, `--`);
+      if (_.get(data, `subid_day${index}`)) obj[`subid`] = _.get(data, `subid_day${index}`);
+      if (_.get(data, `teaid_day${index}`)) obj[`teaid`] = _.get(data, `teaid_day${index}`);
+      if (_.get(data, `teaname_day${index}`)) obj[`teaname`] = _.get(data, `teaname_day${index}`);
+      if (_.get(data, `reason${index}`)) obj[`reason`] = _.get(data, `reason${index}`);
+      if (needDate) {
+        //所有的数据都还原了,没必要要index了
+        delete obj.index;
+        obj.date = this.dateList[index - 1];
+      }
+      return obj;
+    },
+    //整理,匹配数据是哪天,该显示在哪
+    resetData(data, index) {
+      let obj = {};
+      if (_.get(data, '_id')) obj[`_id_day${index}`] = _.get(data, '_id');
+      obj[`subname_day${index}`] = _.get(data, 'subname', '--');
+      if (_.get(data, 'subid')) obj[`subid_day${index}`] = _.get(data, 'subid');
+      if (_.get(data, 'teaid')) obj[`teaid_day${index}`] = _.get(data, 'teaid');
+      if (_.get(data, 'teaname')) obj[`teaname_day${index}`] = _.get(data, 'teaname');
+      if (_.get(data, 'reason')) obj[`reason${index}`] = _.get(data, 'reason');
+      return obj;
+    },
+    //修改:选择科目/教师后,将次科目的所有数据统一
+    setSubTea() {
+      let duplicate = _.cloneDeep(this.lessonList);
+      let arr = this.returnData(duplicate);
+      let teaList = arr.filter(f => f.teaid);
+      let res = arr.map(i => {
+        let r = teaList.find(f => f.subid == i.subid);
+        if (r) {
+          i.teaid = r.teaid;
+          i.teaname = r.teaname;
+        }
+        return i;
+      });
+      res = this.aData(res);
+      this.$set(this, 'lessonList', res);
+    },
+    //根据时间排序
+    getOrderForTime(data) {
+      let duplicate = JSON.parse(JSON.stringify(data));
+      duplicate = duplicate.sort((a, b) => {
+        let a_arr = a.time.split('-');
+        let b_arr = b.time.split('-');
+        let at = moment(`${moment().format('YYYY-MM-DD')} ${a_arr[0]}`).format('X');
+        let bt = moment(`${moment().format('YYYY-MM-DD')} ${b_arr[0]}`).format('X');
+        return at - bt;
+      });
+      return duplicate;
+    },
+    //整理出标头,根据日期排序
+    getX(data) {
+      let r = _.uniqBy(data, 'date').map(i => i.date);
+      r = r.sort((a, b) => moment(a).format('X') - moment(b).format('X'));
+      return r;
+    },
+    //获得时间列表
+    getY(data) {
+      let duplicate = JSON.parse(JSON.stringify(data));
+      let arr = _.uniqBy(
+        duplicate.map(i => _.pick(i, ['time'])),
+        'time'
+      );
+      arr = this.getOrderForTime(arr);
+      this.$set(
+        this,
+        `timeList`,
+        arr.map(i => i.time)
+      );
+    },
+    //教师列表,课程列表
+    async getOtherList() {
+      let res = await this.getSubject();
+      if (this.$checkRes(res)) this.$set(this, `subjectList`, res.data);
+      res = await this.getTeacher({ status: '4' });
+      if (this.$checkRes(res)) this.$set(this, `teacherList`, res.data);
+    },
+    //关闭抽屉
+    toClose() {
+      this.drawer = false;
+      this.drawerTime = false;
+      this.form = {};
+    },
+    //修改类型清除数据
+    radioClearForm(data) {
+      if (data == '活动') {
+        delete this.form.subid;
+        this.form.subname = '--';
+      }
+    },
+    //打开选择教师的dialog
+    async toChooseTeacher() {
+      this.dialog = true;
+      if (this.schoolList.length <= 0) {
+        let res = await this.getSchool();
+        if (this.$checkRes(res)) this.$set(this, `schoolList`, res.data);
+      }
+    },
+    //选择教师
+    selTea(data) {
+      this.dialog = false;
+      this.$set(this, `form`, { ...this.form, ...data });
+    },
+    //显示
+    getProp(data, prop) {
+      return _.get(data, prop);
+    },
+    //时间处理
+    hsavetime(type) {
+      let { index } = this.form;
+      if (type == 'delete') this.lessonList.splice(index, 1);
+      else {
+        let data = _.cloneDeep(this.form);
+        data.time = data.time.join('-');
+        if (index != undefined && index >= 0) this.$set(this.lessonList, index, data);
+        else this.lessonList.push(data);
+      }
+      this.toClose();
+      //重新排序
+      this.$set(this, `lessonList`, this.getOrderForTime(this.lessonList));
+    },
+    //判断是否修改教师,需要填写修改教师的原因
+    needReason() {
+      if (this.form.reason) return true;
+      else {
+        let { _id, teaid } = this.form;
+        let r = this.oLessonList.find(f => f._id == _id);
+        if (r) {
+          if (_.get(r, 'teaid')) return _.isEqual(teaid, r.teaid);
+          else return false;
+        } else return false;
+        // teaid
+      }
+    },
+    resetForm() {
+      let res = this.needReason();
+      let fields = _.cloneDeep(this.fields);
+      if (res) {
+        fields.push({ label: '修改教师原因', model: 'reason', required: true });
+      }
+      return fields;
+    },
+    toConfirm() {
+      this.$emit('toConfirm', _.get(this.lessonInfo, `_id`));
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  watch: {
+    classInfo: {
+      handler(val) {
+        let id = _.get(val, '_id');
+        if (id) this.search();
+      },
+      immediate: true,
+      deep: true,
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 1 - 1
src/views/new-plan/classInfo.vue

@@ -60,7 +60,7 @@ export default {
     async search({ skip = 0, limit = 10, ...info } = {}) {
       let termid = _.get(this.defaultOption, 'termid');
       let classid = _.get(this.defaultOption, 'classid');
-      const res = await this.query({ termid: termid, classid: classid, ...info, skip, limit });
+      const res = await this.query({ termid: termid, classid: classid, status: '0', ...info, skip, limit });
       if (this.$checkRes(res)) {
         var arr = res.data;
         //.filter(item => item.status == '0');

+ 1 - 1
src/views/new-plan/studentCheck.vue

@@ -6,7 +6,7 @@
           <template v-if="item.model === 'status'">
             <el-radio label="0">待确定</el-radio>
             <el-radio label="1">确定</el-radio>
-            <el-radio label="2">失败</el-radio>
+            <!-- <el-radio label="2">失败</el-radio> -->
           </template>
           <template v-else-if="item.model === 'gender'">
             <el-radio label="男">男</el-radio>