lrf402788946 пре 4 година
родитељ
комит
ac3bed4cf4
1 измењених фајлова са 477 додато и 477 уклоњено
  1. 477 477
      src/views/new-plan/teacher-lesson.vue

+ 477 - 477
src/views/new-plan/teacher-lesson.vue

@@ -1,477 +1,477 @@
-<template>
-  <div id="teacher-lesson">
-    <list-frame :title="pageTitle" :needFilter="false" :needAdd="false" :needPag="false">
-      <el-row style="padding:15px 0" :gutter="10">
-        <el-col :span="4">
-          <el-select v-model="form.termid" placeholder="请选择期数" size="mini" clearable filterable>
-            <el-option v-for="(i, index) in plan.termnum" :key="index" :label="`第${i.term}期`" :value="i._id"></el-option>
-          </el-select>
-        </el-col>
-        <el-col :span="2" style="text-align:right">
-          <el-button type="primary" size="mini" @click="toArrrangeDialog">安排教师</el-button>
-        </el-col>
-        <el-col :span="2" style="text-align:right">
-          <el-button type="primary" size="mini" @click="toSendDialog">发送通知</el-button>
-        </el-col>
-        <el-col :span="2" style="text-align:right">
-          <el-button type="warning" size="mini" @click="toConDialog">确定安排</el-button>
-        </el-col>
-      </el-row>
-      <div>
-        <excel-term-lesson
-          :classType="ctList"
-          :termnum="filterList()"
-          :subjectList="subjectList"
-          :noticeList="noticeList"
-          @changeTeacher="cellClick"
-        ></excel-term-lesson>
-      </div>
-
-      <el-dialog title="选择教师" width="30%" :visible.sync="dialog" center :destroy-on-close="true" @close="toClose">
-        <el-row class="row">
-          <el-col :span="24">期:{{ info.term }}</el-col>
-          <el-col :span="24">班级:{{ info.name }}</el-col>
-          <el-col :span="24">科目:{{ info.subname }}</el-col>
-          <el-col :span="24">日期:{{ info.day }}</el-col>
-          <el-col :span="24">
-            教师:
-            <el-select v-model="info.teaid" placeholder="请选择教师" size="mini" filterable clearable @change="selectTeacher">
-              <el-option v-for="(i, index) in applyList" :key="index" :label="`${i.teaname}(${i.score})`" :value="i.teacherid"></el-option>
-            </el-select>
-          </el-col>
-        </el-row>
-        <span slot="footer" class="dialog-footer">
-          <el-button @click="dialog = false">取 消</el-button>
-          <el-button type="primary" @click="toUpdate">确 定</el-button>
-        </span>
-      </el-dialog>
-      <el-dialog title="安排教师" width="40%" :visible.sync="arrDialog" center :destroy-on-close="true" @close="toClose">
-        <el-row style="text-align:center" class="msgrow">
-          <el-col :span="24">请选择需要安排教师期数</el-col>
-          <el-checkbox-group v-model="termForm">
-            <el-col :span="6" v-for="(i, index) in plan.termnum" :key="index">
-              <el-checkbox :label="i._id">第{{ i.term }}期</el-checkbox>
-            </el-col>
-          </el-checkbox-group>
-        </el-row>
-        <el-row style="text-align:center" class="msgrow">
-          <el-col :span="24">请选择班级类型</el-col>
-          <el-radio-group v-model="ctselect">
-            <el-col :span="8">
-              <el-radio border size="small" :label="undefined">全部</el-radio>
-            </el-col>
-            <el-col :span="8" v-for="(i, index) in ctList" :key="index">
-              <el-radio :label="i.code" border size="small">{{ i.name }}</el-radio>
-            </el-col>
-          </el-radio-group>
-        </el-row>
-        <span slot="footer" class="dialog-footer">
-          <el-button @click="arrDialog = false">取 消</el-button>
-          <el-button type="primary" @click="toArrrange">确 定</el-button>
-        </span>
-      </el-dialog>
-      <el-dialog title="发送通知" width="40%" :visible.sync="msgDialog" center :destroy-on-close="true" @close="toClose">
-        <el-row style="text-align:center" class="msgrow">
-          <el-col :span="24">请选择期数,系统将会对教师发送通知(发送通知并不代表确定安排)</el-col>
-          <el-checkbox-group v-model="msgForm">
-            <el-col :span="6" v-for="(i, index) in plan.termnum" :key="index">
-              <el-checkbox :label="i._id">第{{ i.term }}期</el-checkbox>
-            </el-col>
-          </el-checkbox-group>
-        </el-row>
-        <el-row style="text-align:center" class="msgrow">
-          <el-col :span="24">请选择班级类型</el-col>
-          <el-radio-group v-model="ctselect">
-            <el-col :span="8">
-              <el-radio border size="small" :label="undefined">全部</el-radio>
-            </el-col>
-            <el-col :span="8" v-for="(i, index) in ctList" :key="index">
-              <el-radio :label="i.code" border size="small">{{ i.name }}</el-radio>
-            </el-col>
-          </el-radio-group>
-        </el-row>
-        <span slot="footer" class="dialog-footer">
-          <el-button @click="msgDialog = false">取 消</el-button>
-          <el-button type="primary" @click="toSendMsg">确 定</el-button>
-        </span>
-      </el-dialog>
-      <el-dialog title="确认安排" width="40%" :visible.sync="conDialog" center :destroy-on-close="true" @close="toClose">
-        <el-row style="text-align:center" class="msgrow">
-          <el-col :span="24">请选择期数确定安排</el-col>
-          <el-checkbox-group v-model="conForm">
-            <el-col :span="6" v-for="(i, index) in plan.termnum" :key="index">
-              <el-checkbox :label="i._id">第{{ i.term }}期</el-checkbox>
-            </el-col>
-          </el-checkbox-group>
-        </el-row>
-        <el-row style="text-align:center" class="msgrow">
-          <el-col :span="24">请选择班级类型</el-col>
-          <el-radio-group v-model="ctselect">
-            <el-col :span="8">
-              <el-radio border size="small" :label="undefined">全部</el-radio>
-            </el-col>
-            <el-col :span="8" v-for="(i, index) in ctList" :key="index">
-              <el-radio :label="i.code" border size="small">{{ i.name }}</el-radio>
-            </el-col>
-          </el-radio-group>
-        </el-row>
-        <span slot="footer" class="dialog-footer">
-          <el-button @click="conDialog = false">取 消</el-button>
-          <el-button type="primary" @click="toConfirm">确 定</el-button>
-        </span>
-      </el-dialog>
-    </list-frame>
-  </div>
-</template>
-
-<script>
-import excelTermLesson from '@/components/excel-term-lesson.vue';
-import listFrame from '@frame/layout/admin/list-frame';
-const _ = require('lodash');
-const moment = require('moment');
-import { mapState, createNamespacedHelpers } from 'vuex';
-const { mapActions: trainplan } = createNamespacedHelpers('trainplan');
-const { mapActions: subject } = createNamespacedHelpers('subject');
-const { mapActions: ct } = createNamespacedHelpers('classtype');
-const { mapActions: teacher } = createNamespacedHelpers('teacher');
-const { mapActions: teaplan } = createNamespacedHelpers('teaPlan');
-const { mapActions: notice } = createNamespacedHelpers('notice');
-export default {
-  name: 'teacher-lesson',
-  props: {},
-  components: {
-    listFrame,
-    excelTermLesson,
-  },
-  data: function() {
-    return {
-      view: 'new',
-      dialog: false,
-      msgDialog: false,
-      conDialog: false,
-      arrDialog: false,
-      form: {
-        range: [],
-      },
-      termForm: [],
-      msgForm: [],
-      conForm: [],
-      ctselect: undefined,
-      teacherList: [],
-      plan: {},
-      options: null,
-      lessonsList: [],
-      subjectList: [],
-      ctList: [],
-      termList: [],
-      applyList: [],
-      info: {},
-      noticeList: [],
-    };
-  },
-  created() {},
-  methods: {
-    ...notice({ getNoticeList: 'query' }),
-    ...teaplan({ getApplyTeacher: 'query', toArrrangeTeacher: 'arrangeTeacher', sendMsg: 'sendMsg', confirmPlan: 'confirmPlan' }),
-    ...ct({ getCt: 'query' }),
-    ...subject({ getSubject: 'query' }),
-    ...trainplan({ getPlan: 'fetch', updatePlan: 'update' }),
-    ...teacher({ getTeacher: 'query' }),
-    // 手动修改教师
-    async cellClick(ldata) {
-      // 查看是否需要安排教师
-      let subid = _.get(ldata, 'subid');
-      if (!subid) return;
-      let subject = this.subjectList.find(f => f._id === subid);
-      if (!subject) {
-        console.warn('未找到该科目,可能是活动');
-        return false;
-      }
-      const { need_teacher } = subject;
-      if (need_teacher === '1') {
-        this.$message.warning('该科目不需要教师');
-        return;
-      }
-      // 查看是否已经确定教师
-      let status = _.get(ldata, 'status');
-      if (status === '1') {
-        this.$message.warning('此天教师已确定,不能更改!');
-        return false;
-      }
-      const { termid, day: date } = ldata;
-      const r = await this.getApplyTeacher({ termid, subid, date });
-      if (this.$checkRes(r)) {
-        let { data } = r;
-        data = data.map(i => {
-          let r = this.teacherList.find(f => f.id == i.teacherid);
-          if (r) {
-            i.teaname = r.name;
-            i.score = _.get(r, 'xsscore', '');
-          }
-          return i;
-        });
-        data = _.orderBy(data, ['score'], ['desc']);
-        this.$set(this, `applyList`, data);
-      }
-      console.log(ldata);
-      this.$set(this, `info`, _.cloneDeep(ldata));
-      this.dialog = true;
-    },
-
-    // 保存
-    async toUpdate() {
-      const msg = this.$message({ duration: 0, message: '正在处理,请稍后...' });
-      let dup = _.cloneDeep(this.info);
-      const { termid, batchid, classid, ...info } = dup;
-      let updata = _.pick(info, ['day', 'subid', 'subname', 'teaid', 'teaname', 'time']);
-      const data = this.plan.termnum.map(t => {
-        // 找到期
-        if (t._id == termid) {
-          t.batchnum = t.batchnum.map(b => {
-            if (b._id == batchid) {
-              // 找到批次
-              b.class = b.class.map(c => {
-                if (c._id == classid) {
-                  if (c.lessons) {
-                    // 说明有课程安排,找有没有重复的,没有就推进去,有就更改,subid查
-                    let r = c.lessons.find(f => f.subid == updata.subid);
-                    if (r) {
-                      let rindex = c.lessons.findIndex(f => f.subid == updata.subid);
-                      c.lessons[rindex] = updata;
-                    } else {
-                      c.lessons.push(updata);
-                    }
-                  } else {
-                    // 说明没有课程安排,放进去一条保存
-                    c.lessons = [updata];
-                  }
-                }
-                return c;
-              });
-            }
-            return b;
-          });
-        }
-
-        return t;
-      });
-      let planDup = _.cloneDeep(this.plan);
-      planDup.termnum = data;
-      const res = await this.updatePlan(planDup);
-      msg.close();
-      if (this.$checkRes(res, '修改成功', res.errmsg || '修改失败')) {
-        this.getInfo('reload');
-        this.toClose();
-      }
-    },
-    // 发送通知
-    async toSendMsg() {
-      const msg = this.$message({ duration: 0, message: '正在发送通知...' });
-      const { planid } = this.options;
-      const dup = _.cloneDeep(this.msgForm);
-      const res = await this.sendMsg({ planid, ids: dup, classtype: this.ctselect });
-      this.toClose();
-      msg.close();
-      this.$message.success('发送完成');
-    },
-    // 确认指定期安排
-    async toConfirm() {
-      let msg = this.$message({ message: '正在处理,请稍后...', duration: 0 });
-      const { planid } = this.defaultOption;
-      const dup = _.cloneDeep(this.conForm);
-      console.log(this.ctselect);
-      const res = await this.confirmPlan({ planid, ids: dup, classtype: this.ctselect });
-      msg.close();
-      if (this.$checkRes(res, '教师安排确认成功', '教师安排确认失败')) {
-        this.getInfo('reload');
-      }
-      this.toClose();
-    },
-    async getInfo(type) {
-      if (type != 'reload') {
-        await this.getCtList();
-        await this.getSubjectList();
-        await this.getTeacherList();
-        await this.getNotice();
-      }
-      await this.getTrain();
-    },
-    async getTrain() {
-      const { planid } = this.options;
-      let res = await this.getPlan(planid);
-      let { termnum } = res.data;
-      if (!termnum) {
-        this.$message.error(`没有找到期信息,无法进行排课`);
-        return;
-      }
-      const plan = res.data;
-      plan.termnum = termnum.map(i => {
-        i.order = parseInt(i.term);
-        return i;
-      });
-      plan.termnum = _.orderBy(plan.termnum, ['order'], ['asc']);
-      plan.termnum = this.setClassLesson(plan.termnum);
-      if (this.$checkRes(res)) this.$set(this, `plan`, plan);
-    },
-    async getTeacherList() {
-      const res = await this.getTeacher();
-      if (this.$checkRes(res)) this.$set(this, `teacherList`, res.data);
-    },
-    filterList() {
-      const d = _.cloneDeep(_.get(this.plan, 'termnum'));
-      const { termid } = this.form;
-      if (termid) {
-        const r = d.filter(f => f._id === termid);
-        return r;
-      } else return d;
-    },
-    setClassLesson(termnum) {
-      // 为班级设置lessons,有的就不设置了
-      for (let t of termnum) {
-        const { batchnum } = t;
-        if (!batchnum || !_.isArray(batchnum)) {
-          this.$message.error(`第${t.term}期的批次数据错误!`);
-          continue;
-        }
-        for (const b of t.batchnum) {
-          const { class: cla, lessons } = b;
-          if (!cla) {
-            console.warn(`${t.term}期${b.batch}批次没有班级列表`);
-            continue;
-          }
-          if (!lessons) {
-            console.warn(`${t.term}期${b.batch}批次没有课表`);
-            continue;
-          }
-          for (const c of b.class) {
-            const { lessons } = c;
-            if (!lessons) c.lessons = lessons;
-          }
-        }
-      }
-      return termnum;
-    },
-
-    async getCtList() {
-      const res = await this.getCt();
-      if (this.$checkRes(res)) {
-        let d = _.cloneDeep(res.data);
-        d = d.map(i => {
-          i.order = parseInt(i.code);
-          return i;
-        });
-        d = _.orderBy(d, ['order'], ['asc']);
-        this.$set(this, `ctList`, d);
-      }
-    },
-    async getSubjectList() {
-      const res = await this.getSubject();
-      if (this.$checkRes(res)) {
-        // let r = res.data.filter(f => f.need_teacher == '0');
-        let r = _.cloneDeep(res.data);
-        r = r.map(i => {
-          let ctr = this.ctList.find(f => f.code == i.type);
-          if (ctr) i.name = `${i.name}(${ctr.name})`;
-          return i;
-        });
-        this.$set(this, `subjectList`, r);
-      }
-    },
-    toClose() {
-      this.dialog = false;
-      this.msgDialog = false;
-      this.conDialog = false;
-      this.info = {};
-      this.msgForm = [];
-      this.conForm = [];
-      this.ctselect = undefined;
-    },
-    selectTeacher(teaid) {
-      let r = this.applyList.find(f => f.teacherid == teaid);
-      if (r) this.info.teaname = r.teaname;
-      else this.$set(this, `info`, _.omit(this.info, ['teaid', 'teaname']));
-    },
-    toArrrangeDialog() {
-      this.arrDialog = true;
-    },
-    async toArrrange() {
-      let msg = this.$message({ message: '正在处理,请稍后...', duration: 0 });
-      const { planid } = this.defaultOption;
-      const dup = _.cloneDeep(this.termForm);
-      const res = await this.toArrrangeTeacher({ planid, ids: dup, classtype: this.ctselect });
-      msg.close();
-      if (this.$checkRes(res, '教师安排成功', '教师安排失败')) {
-        this.getInfo('reload');
-      }
-    },
-    async getNotice() {
-      const { planid } = this.defaultOption;
-      const res = await this.getNoticeList({ planid, type: '6' });
-      if (this.$checkRes(res)) this.$set(this, `noticeList`, res.data);
-    },
-    toSendDialog() {
-      this.msgDialog = true;
-    },
-    toConDialog() {
-      this.conDialog = true;
-    },
-    getNoticeStatus(row) {
-      const { teaid } = row;
-      if (!teaid) return;
-      const res = this.noticeList.find(f => f.termid == row.termid && f.classid == row.classid);
-      if (res) {
-        const { notified } = res;
-        if (_.isArray(notified)) {
-          const r = notified.find(f => f.notifiedid === teaid);
-          if (r) {
-            return r.status;
-          }
-        }
-      }
-    },
-  },
-  watch: {
-    defaultOption: {
-      immediate: true,
-      deep: true,
-      handler(val) {
-        if (!_.get(this, 'options')) {
-          this.$set(this, `options`, _.cloneDeep(val));
-          this.getInfo();
-        } else {
-          let nplanid = _.get(val, 'planid');
-          let oplanid = _.get(this.options, 'planid');
-          if (nplanid && !_.isEqual(nplanid, oplanid)) {
-            this.getInfo();
-          }
-          // let ntermid = _.get(val, 'termid');
-          // let otermid = _.get(this.options, 'termid');
-          // if (ntermid && !_.isEqual(ntermid, otermid)) {
-          //   this.$set(this, `options`, _.cloneDeep(val));
-          //   this.getInfo();
-          // }
-        }
-      },
-    },
-  },
-  computed: {
-    ...mapState(['user', 'defaultOption']),
-    pageTitle() {
-      return `${this.$route.meta.title}`;
-    },
-  },
-  metaInfo() {
-    return { title: this.$route.meta.title };
-  },
-};
-</script>
-
-<style lang="less" scoped>
-.row,
-.msgrow {
-  .el-col {
-    font-size: 18px;
-    padding: 10px 5px;
-  }
-}
-</style>
+<template>
+  <div id="teacher-lesson">
+    <list-frame :title="pageTitle" :needFilter="false" :needAdd="false" :needPag="false">
+      <el-row style="padding:15px 0" :gutter="10">
+        <el-col :span="4">
+          <el-select v-model="form.termid" placeholder="请选择期数" size="mini" clearable filterable>
+            <el-option v-for="(i, index) in plan.termnum" :key="index" :label="`第${i.term}期`" :value="i._id"></el-option>
+          </el-select>
+        </el-col>
+        <el-col :span="2" style="text-align:right">
+          <el-button type="primary" size="mini" @click="toArrrangeDialog">安排教师</el-button>
+        </el-col>
+        <!-- <el-col :span="2" style="text-align:right">
+          <el-button type="primary" size="mini" @click="toSendDialog">发送通知</el-button>
+        </el-col> -->
+        <el-col :span="2" style="text-align:right">
+          <el-button type="warning" size="mini" @click="toConDialog">确定安排</el-button>
+        </el-col>
+      </el-row>
+      <div>
+        <excel-term-lesson
+          :classType="ctList"
+          :termnum="filterList()"
+          :subjectList="subjectList"
+          :noticeList="noticeList"
+          @changeTeacher="cellClick"
+        ></excel-term-lesson>
+      </div>
+
+      <el-dialog title="选择教师" width="30%" :visible.sync="dialog" center :destroy-on-close="true" @close="toClose">
+        <el-row class="row">
+          <el-col :span="24">期:{{ info.term }}</el-col>
+          <el-col :span="24">班级:{{ info.name }}</el-col>
+          <el-col :span="24">科目:{{ info.subname }}</el-col>
+          <el-col :span="24">日期:{{ info.day }}</el-col>
+          <el-col :span="24">
+            教师:
+            <el-select v-model="info.teaid" placeholder="请选择教师" size="mini" filterable clearable @change="selectTeacher">
+              <el-option v-for="(i, index) in applyList" :key="index" :label="`${i.teaname}(${i.score})`" :value="i.teacherid"></el-option>
+            </el-select>
+          </el-col>
+        </el-row>
+        <span slot="footer" class="dialog-footer">
+          <el-button @click="dialog = false">取 消</el-button>
+          <el-button type="primary" @click="toUpdate">确 定</el-button>
+        </span>
+      </el-dialog>
+      <el-dialog title="安排教师" width="40%" :visible.sync="arrDialog" center :destroy-on-close="true" @close="toClose">
+        <el-row style="text-align:center" class="msgrow">
+          <el-col :span="24">请选择需要安排教师期数</el-col>
+          <el-checkbox-group v-model="termForm">
+            <el-col :span="6" v-for="(i, index) in plan.termnum" :key="index">
+              <el-checkbox :label="i._id">第{{ i.term }}期</el-checkbox>
+            </el-col>
+          </el-checkbox-group>
+        </el-row>
+        <el-row style="text-align:center" class="msgrow">
+          <el-col :span="24">请选择班级类型</el-col>
+          <el-radio-group v-model="ctselect">
+            <el-col :span="8">
+              <el-radio border size="small" :label="undefined">全部</el-radio>
+            </el-col>
+            <el-col :span="8" v-for="(i, index) in ctList" :key="index">
+              <el-radio :label="i.code" border size="small">{{ i.name }}</el-radio>
+            </el-col>
+          </el-radio-group>
+        </el-row>
+        <span slot="footer" class="dialog-footer">
+          <el-button @click="arrDialog = false">取 消</el-button>
+          <el-button type="primary" @click="toArrrange">确 定</el-button>
+        </span>
+      </el-dialog>
+      <el-dialog title="发送通知" width="40%" :visible.sync="msgDialog" center :destroy-on-close="true" @close="toClose">
+        <el-row style="text-align:center" class="msgrow">
+          <el-col :span="24">请选择期数,系统将会对教师发送通知(发送通知并不代表确定安排)</el-col>
+          <el-checkbox-group v-model="msgForm">
+            <el-col :span="6" v-for="(i, index) in plan.termnum" :key="index">
+              <el-checkbox :label="i._id">第{{ i.term }}期</el-checkbox>
+            </el-col>
+          </el-checkbox-group>
+        </el-row>
+        <el-row style="text-align:center" class="msgrow">
+          <el-col :span="24">请选择班级类型</el-col>
+          <el-radio-group v-model="ctselect">
+            <el-col :span="8">
+              <el-radio border size="small" :label="undefined">全部</el-radio>
+            </el-col>
+            <el-col :span="8" v-for="(i, index) in ctList" :key="index">
+              <el-radio :label="i.code" border size="small">{{ i.name }}</el-radio>
+            </el-col>
+          </el-radio-group>
+        </el-row>
+        <span slot="footer" class="dialog-footer">
+          <el-button @click="msgDialog = false">取 消</el-button>
+          <el-button type="primary" @click="toSendMsg">确 定</el-button>
+        </span>
+      </el-dialog>
+      <el-dialog title="确认安排" width="40%" :visible.sync="conDialog" center :destroy-on-close="true" @close="toClose">
+        <el-row style="text-align:center" class="msgrow">
+          <el-col :span="24">请选择期数确定安排</el-col>
+          <el-checkbox-group v-model="conForm">
+            <el-col :span="6" v-for="(i, index) in plan.termnum" :key="index">
+              <el-checkbox :label="i._id">第{{ i.term }}期</el-checkbox>
+            </el-col>
+          </el-checkbox-group>
+        </el-row>
+        <el-row style="text-align:center" class="msgrow">
+          <el-col :span="24">请选择班级类型</el-col>
+          <el-radio-group v-model="ctselect">
+            <el-col :span="8">
+              <el-radio border size="small" :label="undefined">全部</el-radio>
+            </el-col>
+            <el-col :span="8" v-for="(i, index) in ctList" :key="index">
+              <el-radio :label="i.code" border size="small">{{ i.name }}</el-radio>
+            </el-col>
+          </el-radio-group>
+        </el-row>
+        <span slot="footer" class="dialog-footer">
+          <el-button @click="conDialog = false">取 消</el-button>
+          <el-button type="primary" @click="toConfirm">确 定</el-button>
+        </span>
+      </el-dialog>
+    </list-frame>
+  </div>
+</template>
+
+<script>
+import excelTermLesson from '@/components/excel-term-lesson.vue';
+import listFrame from '@frame/layout/admin/list-frame';
+const _ = require('lodash');
+const moment = require('moment');
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: trainplan } = createNamespacedHelpers('trainplan');
+const { mapActions: subject } = createNamespacedHelpers('subject');
+const { mapActions: ct } = createNamespacedHelpers('classtype');
+const { mapActions: teacher } = createNamespacedHelpers('teacher');
+const { mapActions: teaplan } = createNamespacedHelpers('teaPlan');
+const { mapActions: notice } = createNamespacedHelpers('notice');
+export default {
+  name: 'teacher-lesson',
+  props: {},
+  components: {
+    listFrame,
+    excelTermLesson,
+  },
+  data: function() {
+    return {
+      view: 'new',
+      dialog: false,
+      msgDialog: false,
+      conDialog: false,
+      arrDialog: false,
+      form: {
+        range: [],
+      },
+      termForm: [],
+      msgForm: [],
+      conForm: [],
+      ctselect: undefined,
+      teacherList: [],
+      plan: {},
+      options: null,
+      lessonsList: [],
+      subjectList: [],
+      ctList: [],
+      termList: [],
+      applyList: [],
+      info: {},
+      noticeList: [],
+    };
+  },
+  created() {},
+  methods: {
+    ...notice({ getNoticeList: 'query' }),
+    ...teaplan({ getApplyTeacher: 'query', toArrrangeTeacher: 'arrangeTeacher', sendMsg: 'sendMsg', confirmPlan: 'confirmPlan' }),
+    ...ct({ getCt: 'query' }),
+    ...subject({ getSubject: 'query' }),
+    ...trainplan({ getPlan: 'fetch', updatePlan: 'update' }),
+    ...teacher({ getTeacher: 'query' }),
+    // 手动修改教师
+    async cellClick(ldata) {
+      // 查看是否需要安排教师
+      let subid = _.get(ldata, 'subid');
+      if (!subid) return;
+      let subject = this.subjectList.find(f => f._id === subid);
+      if (!subject) {
+        console.warn('未找到该科目,可能是活动');
+        return false;
+      }
+      const { need_teacher } = subject;
+      if (need_teacher === '1') {
+        this.$message.warning('该科目不需要教师');
+        return;
+      }
+      // 查看是否已经确定教师
+      let status = _.get(ldata, 'status');
+      if (status === '1') {
+        this.$message.warning('此天教师已确定,不能更改!');
+        return false;
+      }
+      const { termid, day: date } = ldata;
+      const r = await this.getApplyTeacher({ termid, subid, date });
+      if (this.$checkRes(r)) {
+        let { data } = r;
+        data = data.map(i => {
+          let r = this.teacherList.find(f => f.id == i.teacherid);
+          if (r) {
+            i.teaname = r.name;
+            i.score = _.get(r, 'xsscore', '');
+          }
+          return i;
+        });
+        data = _.orderBy(data, ['score'], ['desc']);
+        this.$set(this, `applyList`, data);
+      }
+      console.log(ldata);
+      this.$set(this, `info`, _.cloneDeep(ldata));
+      this.dialog = true;
+    },
+
+    // 保存
+    async toUpdate() {
+      const msg = this.$message({ duration: 0, message: '正在处理,请稍后...' });
+      let dup = _.cloneDeep(this.info);
+      const { termid, batchid, classid, ...info } = dup;
+      let updata = _.pick(info, ['day', 'subid', 'subname', 'teaid', 'teaname', 'time']);
+      const data = this.plan.termnum.map(t => {
+        // 找到期
+        if (t._id == termid) {
+          t.batchnum = t.batchnum.map(b => {
+            if (b._id == batchid) {
+              // 找到批次
+              b.class = b.class.map(c => {
+                if (c._id == classid) {
+                  if (c.lessons) {
+                    // 说明有课程安排,找有没有重复的,没有就推进去,有就更改,subid查
+                    let r = c.lessons.find(f => f.subid == updata.subid);
+                    if (r) {
+                      let rindex = c.lessons.findIndex(f => f.subid == updata.subid);
+                      c.lessons[rindex] = updata;
+                    } else {
+                      c.lessons.push(updata);
+                    }
+                  } else {
+                    // 说明没有课程安排,放进去一条保存
+                    c.lessons = [updata];
+                  }
+                }
+                return c;
+              });
+            }
+            return b;
+          });
+        }
+
+        return t;
+      });
+      let planDup = _.cloneDeep(this.plan);
+      planDup.termnum = data;
+      const res = await this.updatePlan(planDup);
+      msg.close();
+      if (this.$checkRes(res, '修改成功', res.errmsg || '修改失败')) {
+        this.getInfo('reload');
+        this.toClose();
+      }
+    },
+    // 发送通知
+    async toSendMsg() {
+      const msg = this.$message({ duration: 0, message: '正在发送通知...' });
+      const { planid } = this.options;
+      const dup = _.cloneDeep(this.msgForm);
+      const res = await this.sendMsg({ planid, ids: dup, classtype: this.ctselect });
+      this.toClose();
+      msg.close();
+      this.$message.success('发送完成');
+    },
+    // 确认指定期安排
+    async toConfirm() {
+      let msg = this.$message({ message: '正在处理,请稍后...', duration: 0 });
+      const { planid } = this.defaultOption;
+      const dup = _.cloneDeep(this.conForm);
+      console.log(this.ctselect);
+      const res = await this.confirmPlan({ planid, ids: dup, classtype: this.ctselect });
+      msg.close();
+      if (this.$checkRes(res, '教师安排确认成功', '教师安排确认失败')) {
+        this.getInfo('reload');
+      }
+      this.toClose();
+    },
+    async getInfo(type) {
+      if (type != 'reload') {
+        await this.getCtList();
+        await this.getSubjectList();
+        await this.getTeacherList();
+        await this.getNotice();
+      }
+      await this.getTrain();
+    },
+    async getTrain() {
+      const { planid } = this.options;
+      let res = await this.getPlan(planid);
+      let { termnum } = res.data;
+      if (!termnum) {
+        this.$message.error(`没有找到期信息,无法进行排课`);
+        return;
+      }
+      const plan = res.data;
+      plan.termnum = termnum.map(i => {
+        i.order = parseInt(i.term);
+        return i;
+      });
+      plan.termnum = _.orderBy(plan.termnum, ['order'], ['asc']);
+      plan.termnum = this.setClassLesson(plan.termnum);
+      if (this.$checkRes(res)) this.$set(this, `plan`, plan);
+    },
+    async getTeacherList() {
+      const res = await this.getTeacher();
+      if (this.$checkRes(res)) this.$set(this, `teacherList`, res.data);
+    },
+    filterList() {
+      const d = _.cloneDeep(_.get(this.plan, 'termnum'));
+      const { termid } = this.form;
+      if (termid) {
+        const r = d.filter(f => f._id === termid);
+        return r;
+      } else return d;
+    },
+    setClassLesson(termnum) {
+      // 为班级设置lessons,有的就不设置了
+      for (let t of termnum) {
+        const { batchnum } = t;
+        if (!batchnum || !_.isArray(batchnum)) {
+          this.$message.error(`第${t.term}期的批次数据错误!`);
+          continue;
+        }
+        for (const b of t.batchnum) {
+          const { class: cla, lessons } = b;
+          if (!cla) {
+            console.warn(`${t.term}期${b.batch}批次没有班级列表`);
+            continue;
+          }
+          if (!lessons) {
+            console.warn(`${t.term}期${b.batch}批次没有课表`);
+            continue;
+          }
+          for (const c of b.class) {
+            const { lessons } = c;
+            if (!lessons) c.lessons = lessons;
+          }
+        }
+      }
+      return termnum;
+    },
+
+    async getCtList() {
+      const res = await this.getCt();
+      if (this.$checkRes(res)) {
+        let d = _.cloneDeep(res.data);
+        d = d.map(i => {
+          i.order = parseInt(i.code);
+          return i;
+        });
+        d = _.orderBy(d, ['order'], ['asc']);
+        this.$set(this, `ctList`, d);
+      }
+    },
+    async getSubjectList() {
+      const res = await this.getSubject();
+      if (this.$checkRes(res)) {
+        // let r = res.data.filter(f => f.need_teacher == '0');
+        let r = _.cloneDeep(res.data);
+        r = r.map(i => {
+          let ctr = this.ctList.find(f => f.code == i.type);
+          if (ctr) i.name = `${i.name}(${ctr.name})`;
+          return i;
+        });
+        this.$set(this, `subjectList`, r);
+      }
+    },
+    toClose() {
+      this.dialog = false;
+      this.msgDialog = false;
+      this.conDialog = false;
+      this.info = {};
+      this.msgForm = [];
+      this.conForm = [];
+      this.ctselect = undefined;
+    },
+    selectTeacher(teaid) {
+      let r = this.applyList.find(f => f.teacherid == teaid);
+      if (r) this.info.teaname = r.teaname;
+      else this.$set(this, `info`, _.omit(this.info, ['teaid', 'teaname']));
+    },
+    toArrrangeDialog() {
+      this.arrDialog = true;
+    },
+    async toArrrange() {
+      let msg = this.$message({ message: '正在处理,请稍后...', duration: 0 });
+      const { planid } = this.defaultOption;
+      const dup = _.cloneDeep(this.termForm);
+      const res = await this.toArrrangeTeacher({ planid, ids: dup, classtype: this.ctselect });
+      msg.close();
+      if (this.$checkRes(res, '教师安排成功', '教师安排失败')) {
+        this.getInfo('reload');
+      }
+    },
+    async getNotice() {
+      const { planid } = this.defaultOption;
+      const res = await this.getNoticeList({ planid, type: '6' });
+      if (this.$checkRes(res)) this.$set(this, `noticeList`, res.data);
+    },
+    toSendDialog() {
+      this.msgDialog = true;
+    },
+    toConDialog() {
+      this.conDialog = true;
+    },
+    getNoticeStatus(row) {
+      const { teaid } = row;
+      if (!teaid) return;
+      const res = this.noticeList.find(f => f.termid == row.termid && f.classid == row.classid);
+      if (res) {
+        const { notified } = res;
+        if (_.isArray(notified)) {
+          const r = notified.find(f => f.notifiedid === teaid);
+          if (r) {
+            return r.status;
+          }
+        }
+      }
+    },
+  },
+  watch: {
+    defaultOption: {
+      immediate: true,
+      deep: true,
+      handler(val) {
+        if (!_.get(this, 'options')) {
+          this.$set(this, `options`, _.cloneDeep(val));
+          this.getInfo();
+        } else {
+          let nplanid = _.get(val, 'planid');
+          let oplanid = _.get(this.options, 'planid');
+          if (nplanid && !_.isEqual(nplanid, oplanid)) {
+            this.getInfo();
+          }
+          // let ntermid = _.get(val, 'termid');
+          // let otermid = _.get(this.options, 'termid');
+          // if (ntermid && !_.isEqual(ntermid, otermid)) {
+          //   this.$set(this, `options`, _.cloneDeep(val));
+          //   this.getInfo();
+          // }
+        }
+      },
+    },
+  },
+  computed: {
+    ...mapState(['user', 'defaultOption']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.row,
+.msgrow {
+  .el-col {
+    font-size: 18px;
+    padding: 10px 5px;
+  }
+}
+</style>