lrf402788946 há 4 anos atrás
pai
commit
b386a5ce82
2 ficheiros alterados com 83 adições e 129 exclusões
  1. 26 2
      src/components/excel-term-lesson.vue
  2. 57 127
      src/views/new-plan/teacher-lesson.vue

+ 26 - 2
src/components/excel-term-lesson.vue

@@ -37,8 +37,10 @@
                   {{ c.name.includes('班') ? c.name : `${c.name}班` }}
                   <tr>
                     <template v-for="(d, dindex) in getBatchDayList(type.code, t._id, b)">
-                      <td :key="`date-${dindex}`" style="display: grid;width:65px">
-                        {{ getTeacher(d, c) }}
+                      <td :key="`date-${dindex}`" style="display: grid;width:65px;word-break:break-all;">
+                        <!-- <el-link :type="getMessage" :underline="false" style="font-size:16px">{{ getTeacher(d, c) }}</el-link> -->
+                        <span @click="tdClick(d, c, t._id, b._id)">{{ getTeacher(d, c) }}</span>
+                        <el-link v-if="checkMsg(d, c)" :type="getMessage()" :underline="false">未确认</el-link>
                       </td>
                     </template>
                   </tr>
@@ -61,6 +63,7 @@ export default {
   props: {
     classType: { type: Array, default: () => [] },
     termnum: { type: Array, default: () => [] },
+    subjectList: { type: Array, default: () => [] },
   },
   components: {},
   data: function() {
@@ -136,6 +139,26 @@ export default {
         return r.teaname || '-';
       } else return '-';
     },
+    // 检查信息
+    checkMsg(date, cla) {
+      if (this.getTeacher(date, cla) === '-') return false;
+      // TODO检查消息列表,是否有这个教师的消息,如果没有,也return false
+      return true;
+    },
+    //获取信息接收状态
+    getMessage() {
+      // 检查这个教师是否收到消息,确认返回 success 未确认 warning
+      return 'info';
+    },
+    //点击更换教师
+    tdClick(date, cla, termid, batchid) {
+      const {lessons} = cla;
+      let r = lessons.find(f=>f.date === date);
+      if(r) {
+        
+      }
+      console.log(date, cla, termid, batchid);
+    },
   },
   computed: {
     ...mapState(['user']),
@@ -154,6 +177,7 @@ tr,
 th,
 td {
   text-align: center;
+  min-height: 50px;
 }
 .row_header {
   .el-col {

+ 57 - 127
src/views/new-plan/teacher-lesson.vue

@@ -1,48 +1,12 @@
 <template>
   <div id="teacher-lesson">
     <list-frame :title="pageTitle" :needFilter="false" :needAdd="false" :needPag="false">
-      <!-- <el-radio-group v-model="view">
-        <el-radio-button label="table">表格</el-radio-button>
-        <el-radio-button label="new">新课表</el-radio-button>
-      </el-radio-group> -->
       <el-row style="padding:15px 0" :gutter="10">
-        <el-col :span="2">
+        <el-col :span="4">
           <el-select v-model="form.termid" placeholder="请选择期数" size="mini" clearable filterable>
-            <el-option v-for="(i, index) in termList" :key="index" :label="`第${i.term}期`" :value="i.id"></el-option>
+            <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">
-          <el-select v-model="form.classtype" placeholder="请选择班级类型" size="mini" clearable filterable>
-            <el-option v-for="(i, index) in ctList" :key="index" :label="i.name" :value="i.code"></el-option>
-          </el-select>
-        </el-col>
-        <el-col :span="3">
-          <el-select v-model="form.subject" placeholder="请选择您想申请授课的科目" size="mini" clearable filterable>
-            <el-option v-for="(i, index) in subjectList" :key="index" :label="i.name" :value="i._id"></el-option>
-          </el-select>
-        </el-col>
-        <el-col :span="5">
-          <el-date-picker
-            v-model="form.range"
-            type="daterange"
-            range-separator="至"
-            start-placeholder="开始日期"
-            end-placeholder="结束日期"
-            size="mini"
-            format="yyyy-MM-dd"
-            value-format="yyyy-MM-dd"
-            clearable
-          >
-          </el-date-picker>
-        </el-col>
-        <el-col :span="6" style="text-align:right">
-          安排教师情况:
-          <el-radio-group v-model="form.has_teacher">
-            <el-radio :label="undefined">全部</el-radio>
-            <el-radio label="true">已安排</el-radio>
-            <el-radio label="false">未安排</el-radio>
-          </el-radio-group>
-        </el-col>
         <el-col :span="2" style="text-align:right">
           <el-button type="primary" size="mini" @click="toArrrangeDialog">安排教师</el-button>
         </el-col>
@@ -53,26 +17,8 @@
           <el-button type="warning" size="mini" @click="toConDialog">确定安排</el-button>
         </el-col>
       </el-row>
-      <el-table :data="filterList()" border stripe @cell-click="cellClick" v-if="view === 'table'">
-        <el-table-column align="center" label="期" prop="term" sortable></el-table-column>
-        <el-table-column align="center" label="班级" prop="name" sortable></el-table-column>
-        <el-table-column align="center" label="科目" prop="subname" sortable></el-table-column>
-        <el-table-column align="center" label="日期" prop="day" sortable></el-table-column>
-        <el-table-column align="center" label="已安排授课教师(点击修改)" prop="teaname">
-          <template v-slot="{ row }">
-            <el-row>
-              <el-col :span="24">
-                {{ row.teaname }}
-                <el-link v-if="getNoticeStatus(row)" :type="getNoticeStatus(row) === '0' ? 'warning' : 'success'">
-                  {{ getNoticeStatus(row) === '0' ? '未确认' : '已确认' }}
-                </el-link>
-              </el-col>
-            </el-row>
-          </template>
-        </el-table-column>
-      </el-table>
-      <div v-else>
-        <excel-term-lesson v-if="lessonsList.length > 0" :data="lessonsList" :classType="ctList" :termnum="plan.termnum"></excel-term-lesson>
+      <div>
+        <excel-term-lesson :classType="ctList" :termnum="filterList()" :subject="subjectList"></excel-term-lesson>
       </div>
 
       <el-dialog title="选择教师" width="30%" :visible.sync="dialog" center :destroy-on-close="true" @close="toClose">
@@ -193,7 +139,7 @@ export default {
   },
   data: function() {
     return {
-      view: 'table',
+      view: 'new',
       dialog: false,
       msgDialog: false,
       conDialog: false,
@@ -330,90 +276,74 @@ export default {
         await this.getNotice();
       }
       await this.getTrain();
-      this.setData();
     },
     async getTrain() {
       const { planid } = this.options;
-      const res = await this.getPlan(planid);
-      if (this.$checkRes(res)) this.$set(this, `plan`, res.data);
+      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() {
-      let res = this.lessonsList.filter(f => {
-        let r = this.subjectList.find(sf => sf.id == f.subid);
-        if (r) {
-          const { need_teacher } = r;
-          return need_teacher == '0';
-        }
-        return false;
-      });
-      const { subject, range, classtype, termid, has_teacher } = this.form;
-      if (subject) {
-        res = res.filter(f => f.subid == subject);
-      }
-      if (_.isArray(range) && _.get(range, 'length', 0) == 2) {
-        const start = range[0];
-        const end = range[1];
-        res = res.filter(f => moment(f.day).isBetween(start, end, null, '[]'));
-      }
-      if (classtype) res = res.filter(f => f.type == classtype);
-      if (termid) res = res.filter(f => f.termid == termid);
-      if (has_teacher && has_teacher != undefined)
-        res = res.filter(f => {
-          if (has_teacher == 'true') return f.teaid;
-          else return !f.teaid;
-        });
-      res = _.orderBy(res, ['term', 'day'], ['asc', 'asc']);
-      return res;
+      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;
     },
-    setData() {
-      let ti = 1;
-      let { termnum } = this.plan;
-      if (!termnum) return;
-      termnum = termnum.map(i => {
-        i.term = i.term * 1;
-        return i;
-      });
-      // 期列表
-      let termList = termnum.map(i => ({ term: i.term, id: i._id }));
-      this.$set(this, `termList`, _.orderBy(termList, ['term'], ['asc']));
-      // 整理出课表
-      let arr = [];
-      for (const t of termnum) {
-        const { batchnum, term, _id: termid } = t;
-        // 班级和课程一一匹配显示在列表上
-        for (const b of batchnum) {
-          let { class: classes, lessons, startdate, enddate, _id: batchid } = b;
-          let claslesList = this.setList(term, termid, batchid, classes, lessons);
-          arr.push(...claslesList);
+    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;
+          }
         }
       }
-      this.$set(this, `lessonsList`, arr);
+      return termnum;
     },
-    setList(term, termid, batchid, classes, lessonTemplate) {
-      let arr = [];
-      // 班级和课程匹配
-      for (let cla of classes) {
-        cla.term = term;
-        cla.termid = termid;
-        cla.batchid = batchid;
-        let { lessons } = cla;
-        if (!lessons) cla.lessons = lessonTemplate;
-        cla.lessons.map(i => {
-          let obj = _.omit(cla, ['lessons']);
-          obj = { ...obj, ...i, classid: _.clone(cla._id) };
-          arr.push(obj);
-        });
-      }
 
-      return arr;
-    },
     async getCtList() {
       const res = await this.getCt();
-      if (this.$checkRes(res)) this.$set(this, `ctList`, res.data);
+      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();