فهرست منبع

Merge branch '03/23resetCourse' into test

wolyshaw 4 سال پیش
والد
کامیت
dd5372bec5

+ 7 - 0
src/main.js

@@ -2,11 +2,18 @@ import Vue from 'vue'
 import ElementUI from 'element-ui'
 
 import dayjs from 'dayjs'
+import isSameOrBefore from 'dayjs/plugin/isSameOrBefore'
+import isSameOrAfter from 'dayjs/plugin/isSameOrAfter'
+import isBetween from 'dayjs/plugin/isBetween'
 import numeral from 'numeral'
 import lodash from 'lodash'
 import qs from 'qs'
 import { permission,getFullPermission } from "@/utils/directivePage";
 
+dayjs.extend(isSameOrBefore)
+dayjs.extend(isSameOrAfter)
+dayjs.extend(isBetween)
+
 import * as constant from '@/constant'
 
 import 'normalize.css/normalize.css' // A modern alternative to CSS resets

+ 43 - 22
src/views/teamDetail/components/modals/classroom-setting-item.vue

@@ -145,6 +145,26 @@
           </el-form-item>
         </template>
       </el-table-column>
+      <el-table-column label="是否跳过节假日" width="160">
+        <template slot-scope="scope">
+          <el-form-item
+            :prop="'classs.' + type + '.cycle.' + scope.$index + '.holiday'"
+            :rules="[{ required: true, message: '请选择是否跳过节假日' }]"
+            inline-message
+          >
+            <el-select
+              v-model.trim="scope.row.holiday"
+              style="width: 100% !important"
+              placeholder="是否跳过节假日"
+              filterable
+              @change="holidayChange(scope.row)"
+            >
+              <el-option label="是" :value="true"></el-option>
+              <el-option label="否" :value="false"> </el-option>
+            </el-select>
+          </el-form-item>
+        </template>
+      </el-table-column>
       <el-table-column label="排课起始时间" width="170">
         <template slot-scope="scope">
           <el-form-item
@@ -189,25 +209,6 @@
           </el-form-item>
         </template>
       </el-table-column>
-      <el-table-column label="是否跳过节假日" width="160">
-        <template slot-scope="scope">
-          <el-form-item
-            :prop="'classs.' + type + '.cycle.' + scope.$index + '.holiday'"
-            :rules="[{ required: true, message: '请选择是否跳过节假日' }]"
-            inline-message
-          >
-            <el-select
-              v-model.trim="scope.row.holiday"
-              style="width: 100% !important"
-              placeholder="是否跳过节假日"
-              filterable
-            >
-              <el-option label="是" :value="true"></el-option>
-              <el-option label="否" :value="false"> </el-option>
-            </el-select>
-          </el-form-item>
-        </template>
-      </el-table-column>
       <el-table-column prop="date" width="50px">
         <template slot-scope="scope">
           <i
@@ -241,7 +242,7 @@ for (const item of classTimeList) {
 }
 
 export default {
-  props: ["form", "type", "surplustime", "prices", "selectPrice"],
+  props: ["form", "type", "surplustime", "prices", "selectPrice", "holidays"],
   data() {
     return {
       classTimeListByType,
@@ -250,7 +251,7 @@ export default {
   },
   mounted() {
     // console.log("surplustime", this.surplustime);
-    console.log(this.form.cycle);
+    // console.log(this.form.cycle);
   },
   computed: {
     pickerOptions() {
@@ -338,6 +339,20 @@ export default {
       }
       this.updateUseTime()
     },
+    holidayChange(row) {
+      if(row){
+          this.$set(
+          row,
+          "startDate",
+          ''
+        );
+             this.$set(
+          row,
+          "endDate",
+          ''
+        );
+      }
+    },
     getUseTime(row) {
       if(row){
           this.$set(
@@ -368,10 +383,16 @@ export default {
         row.dayOfWeek - date.getDay() >= 0
           ? (num = row.dayOfWeek - date.getDay())
           : (num = row.dayOfWeek - date.getDay() + 7);
+          let end = dayjs(val).add(num+(row.expectCourseNum*7), 'day')
+          for (const d of this.holidays) {
+            if (dayjs(d).isBetween(row.startDate, end.format('YYYY-MM-DD'), null, '[]')) {
+              end = end.add(7, 'day')
+            }
+          }
           this.$set(
           row,
           "endDate",
-         dayjs(val).add(num+(row.expectCourseNum*7), 'day').format('YYYY-MM-DD')
+          end.format('YYYY-MM-DD')
         );
       }else{
 this.$set(

+ 14 - 2
src/views/teamDetail/components/modals/classroom-setting.vue

@@ -105,6 +105,7 @@
             :type="key"
             :form="item"
             :prices="prices"
+            :holidays="holidays"
             :selectPrice="selectPrices ? selectPrices[key] : ''"
           />
         </el-collapse-item>
@@ -152,6 +153,7 @@ import {
 import courseItem from "./classroom-setting-item";
 import { classTimeList } from "@/utils/searchArray";
 import MusicStore from "@/views/resetTeaming/store";
+import { sysConfigList } from '@/api/generalSettings'
 import { queryByOrganIdAndCourseType } from "@/views/resetTeaming/api";
 import { isEmpty } from "lodash";
 import classromePreview from './classroom-preview'
@@ -219,6 +221,7 @@ export default {
       musicSurplus: {},
       previewVisible: false,
       previewList: [],
+      holidays: []
     };
   },
   watch: {
@@ -263,8 +266,17 @@ export default {
     } catch (error) {}
     this.setCourseTypeListByName();
     this.formatClasss();
+    this.FetchHoliday()
   },
   methods: {
+    async FetchHoliday() {
+      try {
+        const res = await sysConfigList({
+          group: 'holiday'
+        })
+        this.holidays = JSON.parse(res.data[0].paranValue)
+      } catch (error) {}
+    },
     setCourseTypeListByName() {
       const courseTypeListByName = {};
       for (const item of this.courseTypeList) {
@@ -467,9 +479,9 @@ export default {
 
     },
     setUserTime(time, type) {
-      console.log(time, type)
+      // console.log(time, type)
       this.$set(this.musicSurplus, type, (time || 0))
-      console.log(this.musicSurplus)
+      // console.log(this.musicSurplus)
        this.$forceUpdate()
       // this.$nextTick(res=>{
       //   this.musicSurplus[type] = time;