lrf402788946 5 jaren geleden
bovenliggende
commit
9c5e372e5a
2 gewijzigde bestanden met toevoegingen van 68 en 41 verwijderingen
  1. 3 19
      src/views/train-plan/parts/term-lesson-table.vue
  2. 65 22
      src/views/train-plan/term-lesson.vue

+ 3 - 19
src/views/train-plan/parts/term-lesson-table.vue

@@ -1,15 +1,6 @@
 <template>
   <div id="term-lesson-table">
-    <el-table
-      :data="list"
-      size="mini"
-      @cell-click="cellClick"
-      tooltip-effect="dark"
-      border
-      stripe
-      :cell-style="{ height: '50px' }"
-      :span-method="data => spanTable(data, 't1')"
-    >
+    <el-table :data="list" size="mini" @cell-click="cellClick" tooltip-effect="dark" border stripe :cell-style="{ height: '50px' }" :span-method="spanTable">
       <el-table-column align="center" label="日期" prop="date" :show-overflow-tooltip="true"></el-table-column>
       <el-table-column align="center" label="星期" :show-overflow-tooltip="true">
         <template v-slot="{ row, $index }">
@@ -49,19 +40,11 @@ export default {
   },
   created() {},
   methods: {
-    spanTable({ row, column, rowIndex, columnIndex }, arrayName) {
+    spanTable({ row, column, rowIndex, columnIndex }) {
       let { type } = row;
       let res = { rowspan: 1, colspan: 1 };
       let l = _.get(this.list, 'length');
       let b = this.batch * 1;
-      //区别在于改变的行数不一致,错位的
-      //b: 1-3
-      //t1 是要改变 0+6 至 l-1-2 行的内容 => 6 - 8
-      //t2 1+6 至 l-1-1 => 7-9
-      //t3 2+6 至 l-1-0 => 8-10
-      // b为该期的批次 batch
-      // 左侧是:0+6;1+6;2+6 => b-1+6
-      // 右侧是: l-1 -2; l-1  -1; l-1 -0 => l-1 -(3-b)
       //用row的type字段搞定了,上面的是以前思路,现在判断type就行,lesson和undefined不管;allday是全合并;headteacher/lyteacher/jslocation 是合并3个
       if (type == 'allday') res.colspan = 3 + this.classList.length; //TODO此处需要计算正常的3列(日期,星期,课程内容)后有几个班 x = 3+c(班级数量)
       if (type == 'headteacher' || type == 'lyteacher' || type == 'jslocation') {
@@ -80,6 +63,7 @@ export default {
       let index = this.list.findIndex(f => _.isEqual(f, row));
       let prop = _.get(column, 'property');
       let type = _.get(row, `type`);
+      console.log(type, prop);
       if (prop && prop.includes('name')) {
         let obj = { ...row, batch: this.batch, index };
         if (type == 'lesson') {

+ 65 - 22
src/views/train-plan/term-lesson.vue

@@ -77,6 +77,24 @@ export default {
   },
   async created() {
     await this.getSettingLists();
+    await this.search();
+    this.$watch(
+      'defaultOption',
+      val => {
+        if (!_.get(this, 'options')) {
+          this.$set(this, `options`, _.cloneDeep(val));
+          this.search();
+        } else {
+          let ntermid = _.get(val, 'termid');
+          let otermid = _.get(this.options, 'termid');
+          if (ntermid && !_.isEqual(ntermid, otermid)) {
+            this.$set(this, `options`, _.cloneDeep(val));
+            this.search();
+          }
+        }
+      },
+      { deep: true }
+    );
   },
   methods: {
     ...lesson({ getLesson: 'query', plupdate: 'pluralUpdate' }),
@@ -336,6 +354,7 @@ export default {
       this.$set(this, `form`, data);
       this.dloading = false;
     },
+    toDeleteDate() {},
     lessonSave(data) {
       let { index, batch, is_last, allday, ...info } = data;
       if (is_last) {
@@ -387,7 +406,6 @@ export default {
       let duplicate = _.cloneDeep(this.list);
       let dClass = _.cloneDeep(this.classList);
       let dLesson = _.cloneDeep(this.lessonList);
-      let data = duplicate[0];
       duplicate.map(data => {
         // console.log(data);
         let day = _.get(_.last(data), 'date', '全天');
@@ -507,9 +525,39 @@ export default {
           dLesson[lesi].lessons = dres;
         });
       });
-      dClass = dClass.map(i => _.omit(i, ['lessons']));
-      dLesson = dLesson.map(i => _.omit(i, ['meta']));
-      //最后数据 dClass,班级列表; dLesson 课程列表
+      let ndClass = dClass.map(i => _.omit(i, ['lessons']));
+      let ndLesson = dLesson.map(i => _.omit(i, ['meta']));
+      let res = this.checkClassConfig(dClass);
+      if (!res.length > 0) {
+        this.toSubmit(ndLesson, ndClass);
+        return;
+      }
+      const h = this.$createElement;
+      //[h('p', null, '您没有选择1班的礼仪课教师'), h('p', null, '您没有选择2班的礼仪课教师')]
+      let arrs = [];
+      for (const item of res) {
+        let r;
+        r = h(
+          'p',
+          null,
+          `${item.name}班:${item.headteacher ? '未选择班主任' : ''} ${item.lyteacher ? '未选择礼仪教师' : ''} ${item.jslocation ? '未选择教室' : ''}`
+        );
+        arrs.push(r);
+      }
+      this.$confirm(h('div', null, arrs), '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning',
+      })
+        .then(() => {
+          this.toSubmit(ndLesson, ndClass);
+        })
+        .catch(() => {});
+      // console.log(dLesson);
+    },
+    //提交接口请求
+    async toSubmit(dLesson, dClass) {
+      // 最后数据 dClass,班级列表; dLesson 课程列表
       let axiosArr = [];
       axiosArr.push(this.plupdate(dLesson));
       axiosArr.push(this.pcupdate(dClass));
@@ -545,24 +593,19 @@ export default {
       classes = classes.map(i => _.omit(i, ['meta']));
       return classes;
     },
-  },
-  watch: {
-    defaultOption: {
-      immediate: true,
-      deep: true,
-      handler(val) {
-        if (!_.get(this, 'options')) {
-          this.$set(this, `options`, _.cloneDeep(val));
-          this.search();
-        } else {
-          let ntermid = _.get(val, 'termid');
-          let otermid = _.get(this.options, 'termid');
-          if (ntermid && !_.isEqual(ntermid, otermid)) {
-            this.$set(this, `options`, _.cloneDeep(val));
-            this.search();
-          }
-        }
-      },
+    //检查班主任/教室/礼仪课教师
+    checkClassConfig(dClass) {
+      let res = [];
+      for (const cla of dClass) {
+        let { headteacherid, jslocationid, lyteacherid, name } = cla;
+        let obj = { name };
+        // true:表示这个位置没有id
+        if (!headteacherid) obj.headteacher = true;
+        if (!jslocationid) obj.jslocation = true;
+        if (!lyteacherid) obj.lyteacher = true;
+        if (Object.keys(obj).length > 1) res.push(obj);
+      }
+      return res;
     },
   },
   computed: {