Procházet zdrojové kódy

排课数据组合完毕

1
Xiao_Mo před 4 roky
rodič
revize
9d0b8a8f45

+ 14 - 0
src/api/buildTeam.js

@@ -1586,3 +1586,17 @@ export function musicGroupSchoolTermCourseDetail(data) {
     requestType:'form'
   })
 }
+
+// 会员乐团预排课
+export function preCourseSchedule(data) {
+  return request2({
+    url: api + `/classGroup/preCourseSchedule`,
+    method: 'post',
+    params:{},
+    data,
+    requestType:'json'
+  })
+}
+
+
+

+ 57 - 20
src/views/teamDetail/components/memberClassList.vue

@@ -111,7 +111,10 @@
         >
           <template slot-scope="scope" v-if="scope.row.lockFlag != 1">
             <div>
-              <el-button type="text" v-if="scope.row.preTotalClassTimes == 0" @click="planCourse(scope.row)"
+              <el-button
+                type="text"
+                v-if="scope.row.preTotalClassTimes == 0"
+                @click="planCourse(scope.row)"
                 >预排课</el-button
               >
               <el-button type="text" v-else>取消排课</el-button>
@@ -147,16 +150,32 @@
     <!--    /**
     :classType="classType" // 调整类型
         :teacherList="teacherList"
+        :cooperationList="cooperationList" // 助教列表
         :musicGroupId="teamid"
         :activeType="activeType" // 班级类型
-        :courseTypeList="courseTypeList" // 班级可排课类型
-        :cooperationList="cooperationList" // 助教列表
+        :courseTypeList="courseTypeList" // 班级可排课类型 
         :detail="infoDetail" // activeRow
         :studentSubmitedData="studentSubmitedData" 班级的学生信息
         @close="infoVisible = false" // 显示隐藏
         @submited="getList"  刷新列表 */ -->
-    <el-dialog title="班级排课"   width="1200px" :modal-append-to-body="false"  :visible.sync="courseVisible">
-        <memberClassSetting />
+    <el-dialog
+      title="班级排课"
+      width="1200px"
+      :modal-append-to-body="false"
+      :visible.sync="courseVisible"
+    >
+      <memberClassSetting
+      :musicGroupSchoolTermCourseDetailId="musicGroupSchoolTermCourseDetailId"
+        :teacherList="teacherList"
+        :cooperationList="cooperationList"
+         :courseTypeList="courseTypeList"
+        :musicGroupId="teamid"
+        :activeType="activeType"
+        :detail="classDteail"
+        :endSchoolTerm="form.endSchoolTerm"
+        @close="courseVisible = false"
+        @submited="getList"
+      />
     </el-dialog>
   </div>
 </template>
@@ -165,13 +184,14 @@ import {
   getAllSignClassandTeacher,
   getTeamBaseInfo,
   musicGroupSchoolTermCourseDetail,
+  getTeacher,
 } from "@/api/buildTeam";
 import { classTimeList, musicClassTypeList } from "@/utils/searchArray";
-import memberClassSetting  from "./modals/member-class-setting.vue"
+import memberClassSetting from "./modals/member-class-setting.vue";
 import { getCourseType } from "@/utils/utils";
 import dayjs from "dayjs";
 export default {
-  components:{memberClassSetting},
+  components: { memberClassSetting },
   data() {
     return {
       musicClassTypeList,
@@ -190,13 +210,13 @@ export default {
       },
       lastDate: "",
       musicGroupSchoolTermCourseDetailId: "",
-      courseVisible:false,
-      teacherList:[],
-      courseTypeList:[],
-      cooperationList:[],
-      activeType:'',
-      teamid:''
-
+      courseVisible: false,
+      teacherList: [],
+      courseTypeList: [],
+      cooperationList: [],
+      activeType: "",
+      teamid: "",
+      classDteail:null
     };
   },
   mounted() {
@@ -240,6 +260,14 @@ export default {
       } catch (e) {
         console.log(e);
       }
+
+      // 获取主教老师和助教老师
+      getTeacher({ organId: this.organId }).then((res) => {
+        if (res.code == 200) {
+          this.cooperationList = res.data;
+          this.teacherList = res.data;
+        }
+      });
       this.getList();
     },
     changeMixClass(val) {
@@ -252,7 +280,12 @@ export default {
       getAllSignClassandTeacher({ musicGroupId: this.teamid, type: val }).then(
         (res) => {
           if (res.code == 200) {
-            this.activeSingleList = res.data;
+             this.activeSingleList = []
+            res.data.map(item=>{
+              if(item.type != 'HIGH'&&item.type != 'DEMO'&&item.type != 'HIGH_ONLINE'&&item.type != 'MUSIC_NETWORK'){
+               this.activeSingleList.push(item)
+              }
+            });
             // this.topForm.count = this.activeSingleList.length
           }
         }
@@ -287,7 +320,7 @@ export default {
                       cleanPreCourseFlag: true,
                     });
                     if (res.data) {
-                      this.$$message.success("修改成功");
+                      this.$message.success("修改成功");
                       this.form.startCourseDate = dayjs(
                         res.data.startCourseDate
                       ).format("YYYY-MM-DD");
@@ -306,7 +339,9 @@ export default {
                   this.form.startCourseDate = this.lastDate;
                 });
             }
+             console.log(res)
             if (res.code == 200) {
+             
               if (res.data) {
                 this.form.startCourseDate = dayjs(
                   res.data.startCourseDate
@@ -315,7 +350,7 @@ export default {
                   "YYYY-MM-DD"
                 );
                 this.musicGroupSchoolTermCourseDetailId = res.data.id;
-                this.$$message.success("修改成功");
+                this.$message.success("修改成功");
                 this.startVisible = false;
                 this.getList();
               }
@@ -331,12 +366,14 @@ export default {
       this.lastDate = JSON.parse(JSON.stringify(this.form.startCourseDate));
       this.startVisible = true;
     },
-    planCourse(row){
-
+    planCourse(row) {
+      this.classDteail = row
+      this.activeType = row.type;
+      console.log(row)
       this.setType(row.type);
       this.courseVisible = true;
     },
-        setType(type) {
+    setType(type) {
       this.courseTypeList = getCourseType(type);
       // this.activeSoundList = this.soundList;
     },

+ 48 - 15
src/views/teamDetail/components/modals/classroom-setting-item.vue

@@ -237,7 +237,10 @@
             <el-form-item
               inline-message
               :prop="'classs.' + type + '.cycle.' + scope.$index + '.endDate'"
-              :rules="[{ required: true, message: '请选择排课结束时间' }]"
+              :rules="[
+                { required: true, message: '请选择排课结束时间' },
+                { required: true, trigger: 'change', validator: validatePass },
+              ]"
             >
               <el-date-picker
                 v-model.trim="scope.row.endDate"
@@ -295,22 +298,33 @@ export default {
     "cooperationList",
     "coreid",
     "assistant",
+    "endSchoolTerm",
   ],
   data() {
+    const validatePass = (rule, value, callback) => {
+      // console.log(this.endSchoolTerm, "结束", value);
+      let timer = dayjs(this.endSchoolTerm).valueOf() - dayjs(value).valueOf();
+      if (this.endSchoolTerm&&timer < 0) {
+        callback(new Error(`结束时间不能超过${this.endSchoolTerm}`));
+      } else {
+        callback();
+      }
+    };
     return {
       classTimeListByType,
       useTime: 0,
+      validatePass,
     };
   },
   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("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(this.form.cycle);
   },
   computed: {
@@ -347,10 +361,19 @@ export default {
       this.$emit("setUserTime", time, this.type);
     },
     create() {
-      if (this.surplustime <= this.useTime) {
-        this.$message.error("已排课时长使用完毕,请修改预计课时数");
-        return;
+      console.log(this.surplustime);
+      if (this.endSchoolTerm) {
+        if (this.surplustime <= 0) {
+          this.$message.error("已排课时长使用完毕,请修改预计课时数");
+          return;
+        }
+      } else {
+        if (this.surplustime <= this.useTime) {
+          this.$message.error("已排课时长使用完毕,请修改预计课时数");
+          return;
+        }
       }
+
       const initVal = { coreTeacher: this.coreid, assistant: this.assistant };
       if (this.selectPrice) {
         initVal.time = this.selectPrice;
@@ -377,11 +400,21 @@ export default {
       }
       if (val) {
         let activeTime = val * Math.max(item.row.expectCourseNum || 0, 0);
-        this.$set(
-          item.row,
-          "expectCourseNum",
-          parseInt((this.surplustime - this.useTime + activeTime) / val)
-        );
+        console.log("activeTime", activeTime);
+        if (this.endSchoolTerm) {
+           this.$set(
+            item.row,
+            "expectCourseNum",
+            parseInt((this.surplustime+ activeTime) / val)
+          );
+        } else {
+          this.$set(
+            item.row,
+            "expectCourseNum",
+            parseInt((this.surplustime - this.useTime + activeTime) / val)
+          );
+        }
+
         // this.surplusTime
       } else {
         this.$set(item.row, "expectCourseNum", 0);

+ 3 - 4
src/views/teamDetail/components/modals/classroom-setting.vue

@@ -12,7 +12,7 @@
           label="班级名称"
           prop="className"
           label-width="88px"
-          :rules="[{ required: true, message: '请填写班级名称' }]"
+          :rules="[{ required: true, message: '请填写班级名称' }]" 
         >
           <el-input
             v-model.trim="form.className"
@@ -227,7 +227,7 @@ export default {
         classs: {},
       },
       allClasss: {},
-      prices: {},
+      prices: {}, //分部每种课程类型的时长
       collapses: [0],
       courseTimes: {},
       courseTypeListByName: {},
@@ -252,7 +252,6 @@ export default {
   },
   computed: {
     surplustime() {
-      console.log('计算剩余课时',this.form.classs)
       const _ = {};
       for (const key in this.form.classs) {
         if (this.form.classs.hasOwnProperty(key)) {
@@ -342,6 +341,7 @@ export default {
       // console.log(res);
       if (Object.keys(res).length <= 0) return;
       this.musicCourseSettings = res.data;
+      console.log('musicCourseSettings', this.musicCourseSettings)
       for (let key in this.musicCourseSettings) {
         this.musicSurplus[key] = 0;
       }
@@ -511,7 +511,6 @@ export default {
       // })
     },
     formatTeacher(row) {
-      console.log(row);
       let arr = [];
       if (row.coreTeacher) {
         let obj = {};

+ 354 - 7
src/views/teamDetail/components/modals/member-class-setting.vue

@@ -1,17 +1,364 @@
 <template>
   <div>
-    会员排课弹窗
+    <el-form
+      :model="form"
+      inline
+      ref="form"
+      label-suffix=": "
+      label-width="130px"
+    >
+      <el-form-item
+        v-if="!!Object.keys(allClasss).length"
+        style="display: block"
+        label="排课类型"
+        label-width="88px"
+      >
+        <el-tag
+          class="tag"
+          :effect="form.classs[key] ? 'dark' : 'plain'"
+          v-for="(item, key) in allClasss"
+          :key="key"
+          @click="changeTag(key)"
+          >{{ courseTypeListByName[key] }}</el-tag
+        >
+      </el-form-item>
+      <empty v-if="isEmpty" desc="暂无可排课时长" />
+      <p class="title">
+        <span
+          >该班级截止到{{ endSchoolTerm }}可预排课时长:{{
+            activeCourseTime
+          }}分钟</span
+        >
+        <span
+          >已排课时长:{{
+            musicSurplus
+          }}分钟,请根据教学规划安排各类型课程的课时数
+          <el-tooltip placement="top" popper-class="mTooltip">
+            <div slot="content">开课日期至本学期截止日期周次*4*45</div>
+            <i
+              class="el-icon-question micon el-tooltip"
+              style="font-size: 18px; color: #f56c6c"
+              v-permission="'export/teacherSalary'"
+            ></i> </el-tooltip
+        ></span>
+      </p>
+      <el-collapse v-model="collapses" @change="collapseChange">
+        <el-collapse-item
+          v-for="(item, key, index) in form.classs"
+          :name="index"
+          :key="key"
+        >
+          <template #title>
+            <p class="coursetitle">
+              {{ courseTypeListByName[key] }}
+              <span>已排课时长:{{ courseTimeList[key] }}分钟</span>
+            </p>
+          </template>
+          <courseItem
+            :endSchoolTerm="endSchoolTerm"
+            :surplustime="activeCourseTime"
+            @setUserTime="setUserTime"
+            :teacherList="teacherList"
+            :activeType="activeType"
+            :cooperationList="cooperationList"
+            :coreid="coreid"
+            :assistant="assistant"
+            :type="key"
+            :form="item"
+            :prices="prices"
+            :holidays="holidays"
+            :selectPrice="selectPrices ? selectPrices[key] : ''"
+          />
+        </el-collapse-item>
+      </el-collapse>
+    </el-form>
+    <div slot="footer" class="dialog-footer" v-if="classType != 5">
+      <el-button @click="$listeners.close">取 消</el-button>
+      <el-button type="primary" :disabled="isEmpty" @click="submit"
+        >确定</el-button
+      >
+    </div>
   </div>
 </template>
 <script>
 import courseItem from "./classroom-setting-item";
-export default {
-  components:{courseItem},
-  data(){
-    return{}
+import MusicStore from "@/views/resetTeaming/store"; // 乐团的基本信息
+import { isEmpty } from "lodash";
+import {
+  getMusicCourseSettingsWithStudents,
+  classGroupUpdate,
+  revisionClassGroup,
+  revisionAddClassGroup,
+  findClassCourseMinute,
+  mergeClassSplitClassAffirm,
+  preCourseSchedule,
+} from "@/api/buildTeam";
+import { queryByOrganIdAndCourseType } from "@/views/resetTeaming/api";
+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 {
+  components: { courseItem },
+  props: [
+    "activeType",
+    "courseTypeList",
+    "musicGroupId",
+    "detail",
+    "studentSubmitedData",
+    "classType",
+    "musicGroupPaymentCalenderDtos",
+    "classIdList",
+    "classGroupStudents",
+    "selectPrices",
+    "classCouresTimeList",
+    "teacherList",
+    "cooperationList",
+    "endSchoolTerm",
+    "musicGroupSchoolTermCourseDetailId",
+  ],
+
+  data() {
+    return {
+      form: { coreTeacher: "", assistant: "", classs: {} },
+      allClasss: {},
+      prices: {},
+      collapses: [0],
+      courseTimes: {},
+      courseTypeListByName: {},
+      musicCourseSettings: 0, // 可排课时长
+      musicSurplus: 0, //已排课时长
+      courseTimeList: {}, // 每种课程类型已排课
+      previewVisible: false,
+      previewList: [],
+      holidays: [],
+    };
+  },
+  async mounted() {
+    try {
+      await MusicStore.dispatch("getBaseInfo", {
+        data: { musicGroupId: this.musicGroupId },
+      });
+
+      const res = await queryByOrganIdAndCourseType({
+        organId: this.musicGroup.organId,
+      });
+      this.prices = res.data;
+    } 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) {
+        courseTypeListByName[item.value] = item.label;
+      }
+      this.courseTypeListByName = courseTypeListByName;
+    },
+    async formatClasss() {
+      this.coreid = "";
+      this.assistant = [];
+      if (this.detail) {
+        const { classGroupTeacherMapperList } = this.detail;
+        for (const item of classGroupTeacherMapperList || []) {
+          if (item.teacherRole === "BISHOP") {
+            this.coreid = String(item.userId);
+          }
+          if (item.teacherRole === "TEACHING") {
+            this.assistant.push(item.userId);
+          }
+        }
+        this.$set(this.form, "coreTeacher", String(this.coreid));
+        this.$set(this.form, "assistant", this.assistant);
+      }
+      const classGroupId = this.detail?.id;
+      if (!classGroupId) {
+        this.$message.error("班级信息错误");
+        return;
+      }
+      this.musicCourseSettings = this.detail.preSubMinutes;
+
+      const classs = {};
+      for (const item of this.courseTypeList) {
+        const key = item.value;
+        this.courseTimeList[key] = 0;
+        classs[key] = {
+          courseTotalMinuties: this.musicCourseSettings,
+          cycle: [
+            {
+              time: 0,
+              coreTeacher: this.coreid,
+              assistant: this.assistant,
+            },
+          ],
+        };
+      }
+      // console.log(classs,this.courseTypeList[0].value)
+      let key = this.courseTypeList[0].value;
+      this.allClasss = { ...classs };
+      let onlyClass = { [key]: classs[this.courseTypeList[0].value] };
+      console.log(onlyClass);
+      this.$set(this.form, "classs", onlyClass);
+    },
+    collapseChange(val) {
+      this.collapses = val;
+    },
+    async submit() {
+      if (this.activeCourseTime < 0) {
+        this.$message.error("课程使用时长超过最大预排课数");
+        return;
+      }
+      this.$refs.form.validate(async (valid) => {
+        if (valid) {
+          const list = [];
+          for (const key in this.form.classs) {
+            if (this.form.classs.hasOwnProperty(key)) {
+              const item = this.form.classs[key];
+              const data = {
+                type: this.detail ? undefined : this.activeType,
+                courseType: key,
+                classGroupName:
+                  this.studentSubmitedData?.name ||
+                  this.detail?.name ||
+                  this.form.className,
+                classGroupId: this.detail?.id,
+                musicGroupId: this.musicGroupId,
+                startDate: item.courseTime,
+                classGroupTeacherMapperList: formatClassGroupTeacherMapperList(
+                  this.form.coreTeacher,
+                  this.form.assistant
+                ),
+                holiday: item.holiday,
+                students: this.studentSubmitedData?.seleched,
+                courseTimes: item.cycle.length,
+                courseTimeDtoList: item.cycle.map((_) => ({
+                  classGroupTeacherMapperList: this.formatTeacher(_),
+                  courseType: key,
+                  dayOfWeek: _.dayOfWeek,
+                  endClassTime: _.endClassTime,
+                  startClassTime: _.startClassTime,
+                  startDate: _.startDate,
+                  endDate: _.endDate,
+                  holiday: _.holiday,
+                  expectCourseNum: _.expectCourseNum,
+                })),
+                musicGroupSchoolTermCourseDetailId:
+                  this.musicGroupSchoolTermCourseDetailId,
+              };
+              list.push(data);
+            }
+            console.log(list);
+          }
+          try {
+            const res = await preCourseSchedule(list);
+            this.$message.success("排课成功");
+            this.$listeners.submited();
+            this.$listeners.close();
+          } catch (e) {
+            console.log(e);
+          }
+        }
+      });
+    },
+    setUserTime(time, type) {
+      this.$set(this.courseTimeList, type, time || 0);
+      this.musicSurplus = 0;
+      for (let key in this.courseTimeList) {
+        this.musicSurplus += this.courseTimeList[key];
+      }
+      this.$forceUpdate();
+    },
+    changeTag(key) {
+      const clas = { ...this.form.classs };
+      if (clas[key]) {
+        delete clas[key];
+      } else {
+        clas[key] = this.allClasss[key];
+      }
+      console.log(clas);
+      this.$set(this.form, "classs", clas);
+    },
+    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;
+    },
+  },
+  watch: {
+    watch: {
+      courseTypeList() {
+        this.setCourseTypeListByName();
+      },
+      detail() {
+        this.formatClasss();
+      },
+    },
+  },
+  computed: {
+    musicGroup() {
+      return MusicStore.state.musicGroup;
+    },
+    isEmpty() {
+      return isEmpty(this.form.classs);
+    },
+    surplustime() {
+      return this.detail.preSubMinutes;
+    },
+    activeCourseTime() {
+      let time = this.detail.preSubMinutes - this.musicSurplus;
+      return time;
+    },
+  },
+};
 </script>
 <style lang="scss" scoped>
-
+.coursetitle {
+  padding: 0 20px;
+  font-size: 14px;
+  color: #606266;
+  line-height: 40px;
+}
+.title {
+  color: red;
+  margin-bottom: 30px;
+  font-size: 16px;
+  font-weight: bold;
+}
+.tag {
+  margin-right: 5px;
+  cursor: pointer;
+}
+.dialog-footer {
+  margin-top: 20px;
+  display: block;
+  text-align: right;
+}
 </style>