Browse Source

到排课

1
mo 2 years ago
parent
commit
4c7834700e

+ 250 - 0
src/views/teamDetail/components/courseTransModals/startPlanCourse.vue

@@ -0,0 +1,250 @@
+<template>
+  <div>
+    <el-dialog
+      title="排课"
+      append-to-body
+      width="1050px"
+      :visible.sync="transPlanVisible"
+    >
+    <el-form :model="activeRow" :inline="true" ref="form">
+        <div v-if="activeRow.classs['HIGH_ONLINE']">
+          <p class="title">
+            <span style="font-weight: 600">线上基础技能课</span>
+            可排课时长:<span style="color: red">{{
+              form.courseConvertSum.courseMinute
+            }}</span
+            >分钟
+            <span style="color: #333"
+              >已排课时长:
+              <span style="color: red"> {{ this.alltime }}分钟</span></span
+            >
+          </p>
+
+          <courseItem
+            :form="activeRow.classs['HIGH_ONLINE']"
+            :teacherList="teacherList"
+            :surplustime="form.courseConvertSum.courseMinute"
+            :activeType="'HIGH_ONLINE'"
+            :coreid="activeRow.coreTeacher"
+            :type="'HIGH_ONLINE'"
+            :prices="prices"
+            :holidays="holidays"
+            @setUserTime="setUserTime"
+          />
+
+          <!--
+          :cooperationList="teacherList" -->
+        </div>
+      </el-form>
+
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="transClassVisible = false">取 消</el-button>
+        <el-button type="primary" @click="submit">确 定</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+<script>
+import { getSysTenantConfig } from "@/views/courseRulersManager/api";
+import { queryByOrganIdAndCourseType } from "@/views/resetTeaming/api";
+import courseItem from "../modals/classroom-setting-item.vue";
+import { isEmpty } from "lodash";
+const formatClassGroupTeacherMapperList = (core, ass) => {
+  const list = [];
+  if (core) {
+    list.push({ userId: core, teacherRole: "BISHOP" });
+  }
+  if (ass) {
+    for (const item of ass) {
+      list.push({ userId: item, teacherRole: "TEACHING" });
+    }
+  }
+  return list;
+};
+export default {
+  props: ["form", "teacherList", "activeRow"],
+  data() {
+    return {
+      prices: [],
+      holidays: [],
+      transPlanVisible: false,
+      allClasss: {},
+      courseTypeListByName: {},
+      courseTypeList: [{ value: "HIGH_ONLINE", label: "线上基础技能课" }],
+      alltime: 0,
+    };
+  },
+  components: {
+    courseItem,
+  },
+  methods: {
+    async init() {
+      try {
+        const res = await queryByOrganIdAndCourseType({
+          organId: this.$route.query.organId,
+        });
+        const res1 = await getSysTenantConfig({
+          group: "holiday",
+        });
+
+        this.holidays = JSON.parse(
+          res1.data[0].paranValue ? res1.data[0].paranValue : "[]"
+        );
+        this.prices = res.data;
+        let arr = [];
+        if (JSON.stringify(this.prices) == "{}") {
+          // 课程时长
+          arr.push("teamCourseTimer");
+        }
+        if (this.holidays.length <= 0) {
+          arr.push("holiday");
+        }
+        //
+        if (arr.length > 0) {
+          this.$bus.$emit("showguide", arr);
+          return;
+        }
+      } catch (error) {
+        console.log(error);
+      }
+    },
+    async openDialog() {
+      // 获取列表
+      this.init();
+      console.log(
+        this.activeRow,
+        this.form,
+        "初始化",
+        this.activeRow.classs["HIGH_ONLINE"]
+      );
+      this.transPlanVisible = true;
+    },
+    setCourseTypeListByName() {
+      const courseTypeListByName = {};
+      for (const item of this.courseTypeList) {
+        courseTypeListByName[item.value] = item.label;
+      }
+      this.courseTypeListByName = courseTypeListByName;
+    },
+    setUserTime(time, type) {
+      this.alltime = time;
+    },
+    formatTeacher(row) {
+      let arr = [];
+      if (row.coreTeacher) {
+        let obj = {};
+        obj.teacherRole = "BISHOP";
+        obj.userId = row.coreTeacher;
+        arr.push(obj);
+      }
+      if (row.assistant?.length > 0) {
+        row.assistant.forEach((ass) => {
+          arr.push({ teacherRole: "TEACHING", userId: ass });
+        });
+      }
+      return arr;
+    },
+    submit() {
+
+      if (this.alltime > this.form.courseConvertSum.courseMinute) {
+        this.$message.error("课程时长不足");
+        return;
+      }
+      console.log(this.form)
+      this.$refs.form.validate(async (valid) => {
+        let key = 'HIGH_ONLINE'
+        if (valid) {
+          const item = this.activeRow.classs[key];
+          const data = {
+            courseTimeDtoList: item.cycle.map((_) => ({
+              classGroupTeacherMapperList: this.formatTeacher(_),
+              courseType: key,
+              dayOfWeek: _.dayOfWeek,
+              endClassTime: _.endClassTime,
+              startClassTime: _.startClassTime,
+              startDate: _.startDate,
+              endDate: _.endDate,
+              holiday: _.holiday,
+              expectCourseNum: _.expectCourseNum,
+            })),
+          };
+          console.log(data)
+        } else {
+          this.$message.error("请先填写所有表单");
+        }
+      });
+    },
+    workOut (date, classCount, weekArr, id, startTime = '', endTime = '') {
+      // 这里是一天排一节课  现在要改成一天排多节
+      while (classCount && classCount > 0) {
+        for (let i in weekArr) {
+          let date1 = new Date(date.getTime());
+          let num; // 下次上课上几天后
+          // 星期4 - 当前是星期几 =>
+          weekArr[i].weekNum - date.getDay() >= 0 ? num = weekArr[i].weekNum - date.getDay() : num = weekArr[i].weekNum - date.getDay() + 7
+
+          let dataStr = this.getThinkDate(date, num);
+          let monthDay = this.getThinkDate(date1, num, 2)
+
+
+          if (this.isholiday) {
+            if (this.holidayList.indexOf(monthDay) != -1) {
+              // 这里说明有节假日
+              continue
+            }
+          }
+
+          // 排的是合奏班
+
+          let nowStartTime = this.week[i].startTime || startTime;
+          let nowEndTime = this.week[i].endTime || endTime;
+          //       date: this.getNowFormatDate(date),
+          this.tableList.push({
+            'classDate': dataStr,
+            'week': this.weekDay[weekArr[i].weekNum],
+            'type': courseType,
+            'id': id,
+            'name': className,
+            'classTime': nowStartTime + '-' + nowEndTime,
+            'startClassTimeStr': nowStartTime,
+            'endClassTimeStr': nowEndTime,
+            'weekNum': weekArr[i].weekNum,
+          })
+          // 这里我排声部课
+          //               date: this.getNowFormatDate(date),
+
+          for (let j in this.activeSingleList) {
+            this.classCardList.push({
+              'classDate': dataStr,
+              'classGroupId': this.activeSingleList[j].id,
+              'startClassTimeStr': nowStartTime,
+              'endClassTimeStr': nowEndTime,
+              'type': courseType,
+              'mixid': this.activeSingleList[j].mixid,
+              'weekNum': weekArr[i].weekNum,
+              'name': this.activeSingleList[j].name,
+              'option': 1
+            })
+          }
+          classCount--
+          if (classCount == 0) break
+        }
+        date.setDate(date.getDate() + 7);
+      }
+      // 请求排课
+    },
+  },
+  watch: {
+    courseTypeList() {
+      this.setCourseTypeListByName();
+    },
+  },
+  computed: {
+    isEmpty() {
+      return isEmpty(this.form.classs);
+    },
+  },
+};
+</script>
+<style lang="scss" scoped>
+</style>

+ 38 - 48
src/views/teamDetail/components/courseTransModals/tranPlanCourse.vue

@@ -25,18 +25,28 @@
                   </p>
                   </p>
                 </div>
                 </div>
 
 
-                 <el-button class="gotoPlan" type="text" @click.stop="gotoPlan(item)">排课</el-button>
+                <el-button
+                  class="gotoPlan"
+                  type="text"
+                  @click.stop="gotoPlan(item)"
+                  >排课</el-button
+                >
               </div>
               </div>
             </template>
             </template>
             <tranCourseItem
             <tranCourseItem
               :details="item.courseScheduleList"
               :details="item.courseScheduleList"
               class="tranCourseItem"
               class="tranCourseItem"
             />
             />
-
           </el-collapse-item>
           </el-collapse-item>
         </el-collapse>
         </el-collapse>
-        <courseItem v-if="activeRow"  :surplustime="form.courseConvertSum.courseMinute" :activeType="'HIGH_ONLINE'"   :teacherList="teacherList"  :cooperationList="teacherList" :coreid="activeRow.coreTeacher" :type='"HIGH_ONLINE"'  :prices="prices"
-            :holidays="holidays"/>
+        <div v-if="activeRow">
+          <startPlanCourse
+            ref="startPlanCourse"
+            :form="form"
+            :teacherList="teacherList"
+            :activeRow="activeRow"
+          />
+        </div>
       </div>
       </div>
       <div slot="footer" class="dialog-footer">
       <div slot="footer" class="dialog-footer">
         <el-button @click="transClassVisible = false">取 消</el-button>
         <el-button @click="transClassVisible = false">取 消</el-button>
@@ -47,69 +57,49 @@
 </template>
 </template>
 <script>
 <script>
 import tranCourseItem from "./tranCourseItem";
 import tranCourseItem from "./tranCourseItem";
-import courseItem from '../modals/classroom-setting-item.vue'
-import { getSysTenantConfig } from "@/views/courseRulersManager/api";
-import { queryByOrganIdAndCourseType } from "@/views/resetTeaming/api";
+import startPlanCourse from "./startPlanCourse";
+
 export default {
 export default {
-  props: ["form",'teacherList'],
+  props: ["form", "teacherList"],
   components: {
   components: {
     tranCourseItem,
     tranCourseItem,
-    courseItem
+    startPlanCourse,
   },
   },
   data() {
   data() {
     return {
     return {
       transPlanVisible: false,
       transPlanVisible: false,
       activeNames: [],
       activeNames: [],
-      activeRow:null,
-      prices:[],
-      holidays:[]
+      activeRow: null,
     };
     };
   },
   },
   mounted() {},
   mounted() {},
   methods: {
   methods: {
     async openDialog() {
     async openDialog() {
       // 获取列表
       // 获取列表
-      this.init()
       this.transPlanVisible = true;
       this.transPlanVisible = true;
-
     },
     },
-    async init() {
-      try {
-        await MusicStore.dispatch("getBaseInfo", {
-          data: { musicGroupId: this.musicGroupId },
-        });
-        const res = await queryByOrganIdAndCourseType({
-          organId: this.musicGroup.organId,
-        });
-        const res1 = await getSysTenantConfig({
-          group: "holiday",
-        });
 
 
-        this.holidays = JSON.parse(
-          res1.data[0].paranValue ? res1.data[0].paranValue : "[]"
-        );
-        this.prices = res.data;
-        let arr = [];
-        if (JSON.stringify(this.prices) == "{}") {
-          // 课程时长
-          arr.push("teamCourseTimer");
-        }
-        if (this.holidays.length <= 0) {
-          arr.push("holiday");
-        }
-        //
-        if (arr.length > 0) {
-          this.$bus.$emit("showguide", arr);
-          return;
-        }
-      } catch (error) {
-        console.log(error);
-      }
-    },
     gotoNext() {},
     gotoNext() {},
-    gotoPlan(item){
+    gotoPlan(item) {
       // 判断一下 如果班级数大于1 就进入次数排课
       // 判断一下 如果班级数大于1 就进入次数排课
       this.activeRow = item;
       this.activeRow = item;
+      console.log(item, "item");
+      this.$nextTick(() => {
+        if (!item.classs) {
+          item.classs = {
+            HIGH_ONLINE: {
+              courseTotalMinuties: this.form.courseConvertSum.courseMinute,
+              cycle: [
+                {
+                  assistant: [],
+                  coreTeacher: item.coreTeacher,
+                },
+              ],
+            },
+          };
+        }
+        this.$refs.startPlanCourse.openDialog();
+      });
     },
     },
   },
   },
 };
 };
@@ -131,7 +121,7 @@ export default {
 // ::v-deep .el-collapse-item__arrow {
 // ::v-deep .el-collapse-item__arrow {
 //   display: none!important;
 //   display: none!important;
 // }
 // }
-.titleWrap{
+.titleWrap {
   padding-left: 20px;
   padding-left: 20px;
   font-weight: bold;
   font-weight: bold;
   display: flex;
   display: flex;

+ 10 - 17
src/views/teamDetail/components/modals/classroom-setting-item.vue

@@ -10,7 +10,8 @@
         <el-radio :label="false">否</el-radio>
         <el-radio :label="false">否</el-radio>
       </el-radio-group>
       </el-radio-group>
     </el-form-item> -->
     </el-form-item> -->
-    <el-table v-if="form && form.cycle" :data="form.cycle" :show-header="false">
+
+    <el-table v-if="form && form.cycle&&form.cycle.length>0" :data="form.cycle" :show-header="false">
       <el-table-column>
       <el-table-column>
         <template slot-scope="scope">
         <template slot-scope="scope">
           <div>
           <div>
@@ -27,7 +28,7 @@
                 clearable
                 clearable
                 filterable
                 filterable
               >
               >
-                <!--     @change="changecoreTeacher" -->
+
                 <el-option
                 <el-option
                   v-for="(item, index) in teacherList"
                   v-for="(item, index) in teacherList"
                   :key="index"
                   :key="index"
@@ -40,7 +41,7 @@
                   }}</span>
                   }}</span>
                 </el-option>
                 </el-option>
               </el-select>
               </el-select>
-              <!-- <remote-search :commit="'setTeachers'" v-model="form.coreTeacher"  /> -->
+
             </el-form-item>
             </el-form-item>
             <el-form-item
             <el-form-item
               prop="assistant"
               prop="assistant"
@@ -53,7 +54,7 @@
                 type != 'MUSIC_NETWORK'
                 type != 'MUSIC_NETWORK'
               "
               "
             >
             >
-              <!-- <remote-search :commit="'setTeachers'" v-model="form.assistant"  :multiple='true'/> -->
+
               <el-select
               <el-select
                 v-model.trim="scope.row.assistant"
                 v-model.trim="scope.row.assistant"
                 placeholder="请选择助教老师"
                 placeholder="请选择助教老师"
@@ -104,7 +105,7 @@
                 >
                 >
                 </el-option>
                 </el-option>
               </el-select>
               </el-select>
-              <!-- <el-input disabled v-model="scope.row.time" placeholder="请输入课程时长"/> -->
+
             </el-form-item>
             </el-form-item>
             <el-form-item
             <el-form-item
               :prop="
               :prop="
@@ -117,7 +118,7 @@
               ]"
               ]"
               inline-message
               inline-message
             >
             >
-              <!--  style="width: 130px !important" -->
+
               <el-input
               <el-input
                 style="width: 180px !important"
                 style="width: 180px !important"
                 type="number"
                 type="number"
@@ -175,7 +176,7 @@
                   selectableRange: ['04:30:00 - 23:59:59'],
                   selectableRange: ['04:30:00 - 23:59:59'],
                 }"
                 }"
               >
               >
-                <!--   @change="startTimeChange(scope.row)" -->
+
               </el-time-picker>
               </el-time-picker>
             </el-form-item>
             </el-form-item>
             <el-form-item
             <el-form-item
@@ -331,16 +332,8 @@ export default {
     };
     };
   },
   },
   mounted() {
   mounted() {
-    console.log("surplustime", this.surplustime);
-    "form", "type", "surplustime", "prices", "selectPrice", "holidays","teacherList","activeType",'cooperationList','coreid','assistant'
-    console.log("form", this.form);
-    console.log("surplustime", this.surplustime);
-    console.log("prices", this.prices);
-    console.log("selectPrice", this.selectPrice);
-    console.log("holidays", this.holidays);
-    console.log("activeType", this.activeType);
-    console.log("type", this.type);
-    console.log(this.form.cycle);
+
+    this.updateUseTime()
   },
   },
   computed: {
   computed: {
     weekDateList() {
     weekDateList() {

+ 1 - 0
src/views/teamDetail/components/modals/classroom-setting.vue

@@ -253,6 +253,7 @@ export default {
   },
   },
   computed: {
   computed: {
     surplustime() {
     surplustime() {
+      console.log(this.form,'classssurplustime')
       const _ = {};
       const _ = {};
       for (const key in this.form.classs) {
       for (const key in this.form.classs) {
         if (this.form.classs.hasOwnProperty(key)) {
         if (this.form.classs.hasOwnProperty(key)) {