lrf402788946 4 anni fa
parent
commit
d300e92a11

+ 5 - 7
src/components/excel-term-lesson.vue

@@ -1,8 +1,8 @@
 <template>
   <div id="excel-term-lesson">
     <div style="overflow-x:auto;" v-for="(t, tindex) in termnum" :key="`term-${tindex}`">
-      <el-card :header="`第${t.term}期课表`" :body-style="{ overflowX: 'auto' }">
-        <table v-for="(type, typeIndex) in classType" :key="`ct-${typeIndex}`" border="1" cellspacing="0">
+      <el-card :header="`第${t.term}期课表`" :body-style="{ overflowX: 'auto', padding: '0' }">
+        <table v-for="(type, typeIndex) in classType" :key="`ct-${typeIndex}`" border="1" cellspacing="0" cellpadding="0" style="border-collapse: collapse ">
           <tr>
             <template v-for="(b, bindex) in getBatchData(type.code, t._id)">
               <th :key="`dateHeader-${bindex}`" style="width:60px;">
@@ -37,7 +37,7 @@
                   {{ 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;word-break:break-all;" @click="tdClick(d, c, t._id, b._id)">
+                      <td :key="`date-${dindex}`" style="display: grid;width:65px;word-break:break-all;" @click="tdClick(d, c, t._id, b._id, t.term, b.batch)">
                         <!-- <el-link :type="getMessage" :underline="false" style="font-size:16px">{{ getTeacher(d, c) }}</el-link> -->
                         <span>{{ getTeacher(d, c) }}</span>
                         <el-link v-if="checkMsg(d, c)" :type="getMessage()" :underline="false">未确认</el-link>
@@ -151,11 +151,11 @@ export default {
       return 'info';
     },
     //点击更换教师
-    tdClick(date, cla, termid, batchid) {
+    tdClick(date, cla, termid, batchid, term, batch) {
       const { lessons } = cla;
       let r = lessons.find(f => f.day === date);
       if (r) {
-        r = { ...r, termid, batchid };
+        r = { ...r, termid, batchid, term, batch, classid: cla._id, name: cla.name };
         this.$emit('changeTeacher', r);
       }
     },
@@ -173,8 +173,6 @@ export default {
 </script>
 
 <style lang="less" scoped>
-tr,
-th,
 td {
   text-align: center;
   min-height: 50px;

+ 22 - 8
src/views/new-plan/teacher-lesson.vue

@@ -18,7 +18,7 @@
         </el-col>
       </el-row>
       <div>
-        <excel-term-lesson :classType="ctList" :termnum="filterList()" :subject="subjectList"></excel-term-lesson>
+        <excel-term-lesson :classType="ctList" :termnum="filterList()" :subject="subjectList" @changeTeacher="cellClick"></excel-term-lesson>
       </div>
 
       <el-dialog title="选择教师" width="30%" :visible.sync="dialog" center :destroy-on-close="true" @close="toClose">
@@ -172,15 +172,27 @@ export default {
     ...trainplan({ getPlan: 'fetch', updatePlan: 'update' }),
     ...teacher({ getTeacher: 'query' }),
     // 手动修改教师
-    async cellClick(row, column, cell) {
-      let status = _.get(row, 'status');
+    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;
       }
-      let prop = _.get(column, 'property');
-      if (prop != 'teaname') return;
-      const { termid, subid, day: date } = row;
+      const { termid, day: date } = ldata;
       const r = await this.getApplyTeacher({ termid, subid, date });
       if (this.$checkRes(r)) {
         let { data } = r;
@@ -195,7 +207,8 @@ export default {
         data = _.orderBy(data, ['score'], ['desc']);
         this.$set(this, `applyList`, data);
       }
-      this.$set(this, `info`, _.cloneDeep(row));
+      console.log(ldata);
+      this.$set(this, `info`, _.cloneDeep(ldata));
       this.dialog = true;
     },
 
@@ -348,7 +361,8 @@ export default {
     async getSubjectList() {
       const res = await this.getSubject();
       if (this.$checkRes(res)) {
-        let r = res.data.filter(f => f.need_teacher == '0');
+        // 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})`;