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

+ 2 - 2
src/views/categroyManager/specialSetup/modals/chargesForm.vue

@@ -81,7 +81,7 @@
                 <el-option  v-for="item in boolOptions"
                             :key="item.label"
                             :label="item.label"
-                            :value="item.value">
+                            :value="String(item.value)">
                 </el-option>
               </el-select>
             </el-form-item>
@@ -189,7 +189,7 @@ import numeral from 'numeral'
 
 const plusNum = (items = [], key) => {
   let money = 0
-  const _items = items.filter(item => !item.isStudentOptional)
+  const _items = items.filter(item => item.isStudentOptional === 'false')
   for (const item of _items) {
     money += parseFloat(parseFloat(item[key] || 0).toFixed(2) || 0)
   }

+ 9 - 5
src/views/teamDetail/components/modals/classroom-setting-item.vue

@@ -2,9 +2,9 @@
   <div>
     <el-form-item
       label="排课次数"
-      prop="courseNum"
+      prop="courseTimes"
     >
-      <el-input v-model="form.courseNum" placeholder="请输入排课次数"/>
+      <el-input v-model="form.courseTimes" placeholder="请输入排课次数"/>
     </el-form-item>
     <el-form-item
       label="排课起始时间"
@@ -20,10 +20,11 @@
     </el-form-item>
     <el-form-item
       label="跳过节假日"
+      prop="holiday"
     >
-      <el-radio-group v-model="form.checked">
-        <el-radio :label="3">是</el-radio>
-        <el-radio :label="6">否</el-radio>
+      <el-radio-group v-model="form.holiday">
+        <el-radio :label="true">是</el-radio>
+        <el-radio :label="false">否</el-radio>
       </el-radio-group>
     </el-form-item>
     <el-table
@@ -139,6 +140,9 @@ export default {
       ]
     }
   },
+  mounted() {
+    console.log(this.form)
+  },
   methods: {
     create() {
       this.form.cycle.push({})

+ 80 - 40
src/views/teamDetail/components/modals/classroom-setting.vue

@@ -46,14 +46,15 @@
       </el-form-item>
       <el-collapse v-model="collapses" @change="collapseChange">
         <el-collapse-item
-          v-for="(item, index) in courseTypeList"
-          :title="item.label"
+          v-for="(item, key, index) in form.classs"
           :name="index"
-          :key="index"
+          :key="key"
         >
+          <template #title>
+            <p>{{courseTypeListByName[key]}}, 剩余可排课时长{{item.courseTotalMinuties}}分钟</p>
+          </template>
           <courseItem
-            :key="index"
-            :form="form.classs[item.value]"
+            :form="item"
           />
         </el-collapse-item>
       </el-collapse>
@@ -65,8 +66,22 @@
   </div>
 </template>
 <script>
-import { getMusicCourseSettingsWithStudents, classGroupUpdate } from '@/api/buildTeam'
+import { getMusicCourseSettingsWithStudents, classGroupUpdate, revisionClassGroup, revisionAddClassGroup } from '@/api/buildTeam'
 import courseItem from "./classroom-setting-item";
+
+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: ["teacherList", "activeType", "courseTypeList", 'cooperationList', 'musicGroupId', 'detail', 'studentSubmitedData'],
   components: {
@@ -80,58 +95,77 @@ export default {
         classs: {}
       },
       collapses: [0],
-      courseTimes: {}
+      courseTimes: {},
+      courseTypeListByName: {}
     };
   },
-  created() {
-    const classs = {}
-    for (const item of this.courseTypeList) {
-      classs[item.value] = {
-        cycle: [{}]
+  watch: {
+    courseTypeList() {
+      const courseTypeListByName = {}
+      for (const item of this.courseTypeList) {
+        courseTypeListByName[item.value] = item.label
       }
+      this.courseTypeListByName = courseTypeListByName
+    },
+    studentSubmitedData() {
+      this.formatClasss()
+    },
+    detail() {
+      this.formatClasss()
     }
-    this.form.classs = classs
   },
   async mounted() {
-    try {
-      const studentIds = this.detail ? this.detail.subjectIdList : this.studentSubmitedData.seleched.join(',')
-      const res = await getMusicCourseSettingsWithStudents({
-        musicGroupId: this.musicGroupId,
-        studentIds: studentIds
-      })
-      const classs = {}
-      const courseTimes = {}
-      for (const item of res.data) {
-        courseTimes[item.courseType] = item
-      }
-      for (const key in this.form.classs) {
-        if (this.form.classs.hasOwnProperty(key)) {
-          const item = this.form.classs[key]
+    this.formatClasss()
+  },
+  methods: {
+    async formatClasss() {
+      try {
+        console.log(this.detail)
+        const res = await getMusicCourseSettingsWithStudents({
+          musicGroupId: this.musicGroupId,
+          studentIds: (this.detail ? undefined : this.studentSubmitedData?.seleched.join(',')),
+          classGroupId: this.detail?.id
+        })
+        const classs = {}
+        const courseTimes = {}
+        for (const item of res.data) {
+          courseTimes[item.courseType] = item
+        }
+        for (const item of this.courseTypeList) {
+          const key = item.value
           if (courseTimes[key]) {
-            classs[key] = item
+            classs[key] = {
+              courseTotalMinuties: courseTimes[key].courseTotalMinuties,
+              cycle: [{}]
+            }
           }
         }
+        this.$set(this.form, 'classs', classs)
+        // this.courseTimes = courseTimes
+      } catch (error) {
+        console.log(error)
       }
-      console.log(classs)
-      this.$set(this.form, 'classs', classs)
-      this.courseTimes = courseTimes
-    } catch (error) {}
-  },
-  methods: {
+    },
     submit() {
       this.$refs.form.validate(async valid => {
         if (valid) {
-          console.log({...this.form})
           const list = []
           for (const key in this.form.classs) {
             if (this.form.classs.hasOwnProperty(key)) {
               const item = this.form.classs[key];
               list.push({
                 type: key,
+                courseType: key,
                 classGroupId: this.detail?.id,
+                musicGroupId: this.musicGroupId,
                 startDate: item.courseTime,
-                coreTeacher: this.form.coreTeacher,
-                assistant: this.form.assistant,
+                classGroupTeacherMapperList: formatClassGroupTeacherMapperList(
+                  this.form.coreTeacher,
+                  this.form.assistant
+                ),
+                holiday: item.holiday,
+                students: this.studentSubmitedData.seleched,
+                courseTimes: item.courseTimes,
                 courseTimeDtoList: item.cycle.map(_ => ({
                   courseType: key,
                   dayOfWeek: _.dayOfWeek,
@@ -142,9 +176,15 @@ export default {
             }
           }
           try {
-            await classGroupUpdate(list)
-            tthis.$message.success('排课成功')
-          } catch (error) {}
+            if (this.detail) {
+              await classGroupUpdate(list)
+              tthis.$message.success('排课成功')
+            } else {
+              await revisionClassGroup(list)
+            }
+          } catch (error) {
+            console.log(error)
+          }
         }
       })
     },

+ 5 - 1
src/views/teamDetail/components/resetClass.vue

@@ -301,6 +301,7 @@
       :modal-append-to-body="false"
     >
       <classroomSetting
+        :classType="classType"
         :teacherList="teacherList"
         :musicGroupId="teamid"
         :activeType="activeType"
@@ -764,6 +765,7 @@ export default {
   },
   data () {
     return {
+      classType: 0,
       pickerOptions: {
         firstDayOfWeek: 1,
         disabledDate (time) {
@@ -998,6 +1000,7 @@ export default {
     },
     // 临时调整
     temporary () {
+      this.classType = 1;
       this.activeClass = "";
       this.activeListStudent = [];
       this.studentList = [];
@@ -1756,7 +1759,8 @@ export default {
           sound: "",
           expectStudentNum: ""
         };
-        this.$refs["teacherForm"].resetFields();
+        this.infoDetail = null
+        // this.$refs["teacherForm"].resetFields();
         this.weekList = [];
       }
     },