Pārlūkot izejas kodu

Merge branch '03/23resetCourse'

lex-xin 4 gadi atpakaļ
vecāks
revīzija
4563800843

+ 59 - 8
src/views/teamDetail/components/modals/classroom-setting-item.vue

@@ -365,19 +365,38 @@ export default {
       return num
     },
     updateEndTime(row) {
-      if (row.dayOfWeek && row.startDate && typeof row.holiday === 'boolean') {
-          const num = this.addData(row.startDate, row.dayOfWeek)
-          const exp = Math.max(row.expectCourseNum - 1, 0)
-          let end = dayjs(row.startDate).add(num + (exp*7), 'day')
+      console.log(row)
+        if (row.dayOfWeek && row.startDate && typeof row.holiday === 'boolean') {
+          // const num = this.addData(row.startDate, row.dayOfWeek)
+          // const week = dayjs(row.startDate).get('day') == 0 ? 7 : dayjs(row.startDate).get('day')
+          const selectWeek = row.dayOfWeek == 7 ? 0 : row.dayOfWeek
+          let exp = Math.max(row.expectCourseNum, 0)
+          let end = dayjs(row.startDate)
+          // console.log(selectWeek, end.get('day'))
           if (row.holiday) {
-            for (const d of this.holidays) {
-              if (dayjs(d).isBetween(row.startDate, end.format('YYYY-MM-DD'), null, '[]')) {
-                end = end.add(1, 'day')
+            while (exp > 0) {
+              if (selectWeek == end.get('day') && !this.holidays.includes(end.format('YYYY-MM-DD'))) {
+                exp--
+              }
+              end = end.add(1, 'day')
+              if (exp === 0) {
+                end = end.subtract(1, 'day')
+              }
+            }
+          } else {
+            while (exp > 0) {
+              if (selectWeek == end.get('day')) {
+                exp--
+              }
+              end = end.add(1, 'day')
+              if (exp === 0) {
+                end = end.subtract(1, 'day')
               }
             }
           }
           const enumd = this.addData(end.format('YYYY-MM-DD'), row.dayOfWeek)
-          end = end.add(enumd, 'day')
+          console.log(enumd)
+          // end = end.add(enumd, 'day')
           this.$set(
           row,
           "endDate",
@@ -390,6 +409,38 @@ export default {
           ''
         );
       }
+
+
+
+
+
+      // if (row.dayOfWeek && row.startDate && typeof row.holiday === 'boolean') {
+      //     // const num = this.addData(row.startDate, row.dayOfWeek)
+      //     const week = dayjs(row.startDate).get('day') == 0 ? 7 : dayjs(row.startDate).get('day')
+      //     const selectWeek = row.dayOfWeek
+      //     const exp = Math.max(row.expectCourseNum - (selectWeek >= week ? 1 : 0), 0)
+      //     let end = dayjs(row.startDate).add((exp*7), 'day')
+      //     if (row.holiday) {
+      //       for (const d of this.holidays) {
+      //         if (dayjs(d).isBetween(row.startDate, end.format('YYYY-MM-DD'), null, '[]') && row.dayOfWeek - 1 == dayjs(d).get('day')) {
+      //           end = end.add(7, 'day')
+      //         }
+      //       }
+      //     }
+      //     const enumd = this.addData(end.format('YYYY-MM-DD'), row.dayOfWeek)
+      //     end = end.add(enumd, 'day')
+      //     this.$set(
+      //     row,
+      //     "endDate",
+      //     end.format('YYYY-MM-DD')
+      //   );
+      // } else {
+      //   this.$set(
+      //     row,
+      //     "endDate",
+      //     ''
+      //   );
+      // }
     },
     changeStartDate(val, row) {
       this.updateEndTime(row)