lrf402788946 4 gadi atpakaļ
vecāks
revīzija
9ca99c3066
1 mainītis faili ar 53 papildinājumiem un 10 dzēšanām
  1. 53 10
      src/views/new-plan/arrange/arrange/table.vue

+ 53 - 10
src/views/new-plan/arrange/arrange/table.vue

@@ -4,7 +4,7 @@
       <table border="1" class="table" style="zoom:0.8" v-for="month in 12" :key="month">
         <template v-if="toDisplay(month)">
           <tr>
-            <th :rowspan="getRowNumber(month)" class="mouthTitle" style="width:58px;">{{ month | getWord }}月</th>
+            <th :rowspan="getRowNumber(month)" class="mouthTitle" style="width:55px;">{{ month | getWord }}月</th>
             <th class="th" v-for="(item, index) in makeCalendar(month)" :key="index">
               <p>{{ item }}</p>
               <p>{{ item | getWeekDay }}</p>
@@ -64,9 +64,7 @@ export default {
       already: false,
     };
   },
-  created() {
-    // this.init();
-  },
+  created() {},
   methods: {
     makeCalendar(month = 1) {
       if (month * 1 < 10) month = `0${month}`;
@@ -110,7 +108,8 @@ export default {
               for (const cla of classList) {
                 //拼成每个班的数据
                 let ncla = { term: tn, batch: bn, start, end, ...cla, color };
-                let ind = list[month].findIndex(f => f.every(e => e.batch == bn && e.name == ncla.name));
+                let ind = list[month].findIndex(f => f.every(e => e.batch == ncla.batch && (e.class == ncla.class || !e.class)));
+                // console.log(ncla);
                 //根据batch,name确定是否有行,如果有行
                 if (ind < 0) {
                   //此时是没找到的情况,就说明没有该批次,班级,需要放进去
@@ -121,10 +120,48 @@ export default {
               }
             }
           }
-          list[month].push([]);
-        } else list[month] = [{}];
+        }
+      }
+      let arr = Object.keys(list);
+      let obj = {};
+      arr.map(i => {
+        let nl = list[i];
+        let rl = [];
+        if (nl.length > 1) {
+          let rl = [];
+          let array = _.orderBy(nl.flat(), ['batch', 'class'], ['asc', 'asc']);
+          let bl = _.uniq(array.map(i => i.batch));
+          let al = _.toPairs(_.groupBy(array, 'class'))
+            .flat()
+            .filter(_.isArray);
+          al = al.map(ai => _.groupBy(ai, 'batch'));
+          for (const bn of bl) {
+            for (const a of al) {
+              let mid = _.get(a, bn);
+              if (mid) rl.push(mid);
+            }
+          }
+          obj[i] = rl;
+        }
+      });
+      //整理列数最大值
+      let lenl = [];
+      for (const o of arr) {
+        if (obj[o]) lenl.push(obj[o].length);
       }
-      this.$set(this, `list`, list);
+      let maxlen = _.max(lenl);
+      //每个月都加到最大值
+      for (let i = 1; i <= 12; i++) {
+        if (!obj[i]) {
+          obj[i] = [];
+          for (let ind = 0; ind < maxlen + 1; ind++) {
+            obj[i].push([]);
+          }
+        } else {
+          obj[i].push([]);
+        }
+      }
+      this.$set(this, `list`, obj);
     },
     setVS(date, month, bi, ci) {
       let style = { cursor: 'default' };
@@ -172,7 +209,7 @@ export default {
       //不在假期中的 查看是否在事件中
       if (!ir) {
         let res = this.checkEvents(date, month, bi, true);
-        console.log(res);
+        // console.log(res);
         if (res) {
           let { col } = this.getEventsRowCol(date, month, res, bi);
           result = col;
@@ -400,6 +437,7 @@ export default {
       date = this.pointToCross(date);
       let dml = _.get(this.list, month, []);
       let bInfo = dml[bi]; //在不同期,同批次的数据 中 取出指定批次
+      if (Object.keys(bInfo).length <= 0) return;
       let r = bInfo.find(ff => moment(date).isBetween(ff.start, ff.end, null, '[]')); //找到改时间点属于哪个期的数据
       if (r) {
         res = r;
@@ -464,7 +502,7 @@ export default {
     },
 
     toDisplay(month) {
-      return _.inRange(month, 6, 9);
+      return _.inRange(month, 1, 13);
     },
   },
   filters: {
@@ -519,9 +557,14 @@ export default {
 .th p {
   width: 55px;
   font-size: 14px;
+  word-break: break-all;
+}
+tr {
+  height: 18.75px;
 }
 td {
   text-align: center;
+  width: 55px;
   height: 15px;
 }
 </style>