wolyshaw 4 年之前
父節點
當前提交
757256784c

+ 7 - 0
src/views/teamDetail/api.js

@@ -6,3 +6,10 @@ export const queryRemainCourseTypeDuration = data => request2({
   params: data,
   params: data,
   requestType: 'form'
   requestType: 'form'
 })
 })
+
+// 调整学员
+export const updateClassGroupStudents = data => request2({
+  url: '/api-web/classGroupStudent/updateClassGroupStudents',
+  data,
+  method: 'post'
+})

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

@@ -45,6 +45,13 @@
           ></el-option>
           ></el-option>
         </el-select>
         </el-select>
       </el-form-item>
       </el-form-item>
+      <el-alert
+        v-if="isEmpty"
+        :closable="false"
+        style="margin-bottom: 20px"
+        title="暂无可排课时长"
+        type="warning">
+      </el-alert>
       <el-collapse v-model="collapses" @change="collapseChange">
       <el-collapse v-model="collapses" @change="collapseChange">
         <el-collapse-item
         <el-collapse-item
           v-for="(item, key, index) in form.classs"
           v-for="(item, key, index) in form.classs"
@@ -64,7 +71,7 @@
     </el-form>
     </el-form>
     <div slot="footer" class="dialog-footer">
     <div slot="footer" class="dialog-footer">
       <el-button @click="$listeners.close">取 消</el-button>
       <el-button @click="$listeners.close">取 消</el-button>
-      <el-button type="primary" @click="submit">确 定</el-button>
+      <el-button type="primary" v-if="!isEmpty" @click="submit">确 定</el-button>
     </div>
     </div>
   </div>
   </div>
 </template>
 </template>
@@ -72,6 +79,7 @@
 import { getMusicCourseSettingsWithStudents, classGroupUpdate, revisionClassGroup, revisionAddClassGroup } from '@/api/buildTeam'
 import { getMusicCourseSettingsWithStudents, classGroupUpdate, revisionClassGroup, revisionAddClassGroup } from '@/api/buildTeam'
 import courseItem from "./classroom-setting-item";
 import courseItem from "./classroom-setting-item";
 import { classTimeList } from '@/utils/searchArray'
 import { classTimeList } from '@/utils/searchArray'
+import { isEmpty } from 'lodash'
 
 
 const classTimeListByType = {}
 const classTimeListByType = {}
 for (const item of classTimeList) {
 for (const item of classTimeList) {
@@ -138,6 +146,9 @@ export default {
         }
         }
       }
       }
       return _
       return _
+    },
+    isEmpty() {
+      return isEmpty(this.form.classs)
     }
     }
   },
   },
   async mounted() {
   async mounted() {
@@ -153,11 +164,17 @@ export default {
       this.courseTypeListByName = courseTypeListByName
       this.courseTypeListByName = courseTypeListByName
     },
     },
     async formatClasss() {
     async formatClasss() {
+      const studentIds = (this.detail ? undefined : this.studentSubmitedData?.seleched.join(','))
+      const classGroupId = this.detail?.id
+      if (!studentIds && !classGroupId) {
+        return
+      }
+
       try {
       try {
         const res = await getMusicCourseSettingsWithStudents({
         const res = await getMusicCourseSettingsWithStudents({
           musicGroupId: this.musicGroupId,
           musicGroupId: this.musicGroupId,
-          studentIds: (this.detail ? undefined : this.studentSubmitedData?.seleched.join(',')),
-          classGroupId: this.detail?.id
+          studentIds,
+          classGroupId
         })
         })
         const classs = {}
         const classs = {}
         for (const item of this.courseTypeList) {
         for (const item of this.courseTypeList) {

+ 41 - 10
src/views/teamDetail/components/modals/select-student.vue

@@ -2,7 +2,7 @@
   <div>
   <div>
     <el-form :model="form" ref="form" label-suffix=": " inline>
     <el-form :model="form" ref="form" label-suffix=": " inline>
       <el-row>
       <el-row>
-        <el-col :span="10">
+        <el-col :span="10" v-if="!isOnlyChangeUser">
           <el-form-item
           <el-form-item
             label="班级名称"
             label="班级名称"
             prop="name"
             prop="name"
@@ -17,13 +17,14 @@
             />
             />
           </el-form-item>
           </el-form-item>
         </el-col>
         </el-col>
-        <el-col :span="10" :offset="4">
+        <el-col :span="10" :offset="!isOnlyChangeUser ? 4 : 0">
           <el-form-item label="声部">
           <el-form-item label="声部">
             <el-select
             <el-select
               v-model="sound"
               v-model="sound"
               style="width: 100%"
               style="width: 100%"
               clearable
               clearable
               filterable
               filterable
+              @change="change"
               placeholder="请选择声部"
               placeholder="请选择声部"
             >
             >
               <el-option
               <el-option
@@ -69,13 +70,14 @@
 </template>
 </template>
 <script>
 <script>
 import { genderType } from "@/constant";
 import { genderType } from "@/constant";
+import { updateClassGroupStudents } from '../../api'
 export default {
 export default {
-  props: ["studentList", "soundList", "activeType"],
+  props: ["studentList", "soundList", "activeType", 'activeListStudent', 'isOnlyChangeUser', 'classGroupId'],
   computed: {
   computed: {
     data() {
     data() {
       return this.studentList.map((item) => ({
       return this.studentList.map((item) => ({
-        value: item.id,
-        key: item.id,
+        value: item.userId,
+        key: item.userId,
         name: item.name,
         name: item.name,
         subjectName: item.subjectName,
         subjectName: item.subjectName,
         gender: genderType[item.gender],
         gender: genderType[item.gender],
@@ -91,7 +93,21 @@ export default {
       seleched: [],
       seleched: [],
     };
     };
   },
   },
+  watch: {
+    activeListStudent() {
+      this.setSelectedUser()
+    }
+  },
+  mounted() {
+    console.log(this.isOnlyChangeUser)
+    this.setSelectedUser()
+  },
   methods: {
   methods: {
+    setSelectedUser() {
+      const ids = this.activeListStudent.map(item => item.userId)
+      console.log(ids, this.data)
+      this.seleched = [...ids]
+    },
     filterStudent(query, item) {
     filterStudent(query, item) {
       return (
       return (
         item.name.indexOf(query) > -1 ||
         item.name.indexOf(query) > -1 ||
@@ -108,6 +124,10 @@ export default {
         </div>
         </div>
       );
       );
     },
     },
+    change(val) {
+      this.$listeners.changeActiveChioseSound(val)
+      this.$listeners.searchStudent()
+    },
     submit() {
     submit() {
       if (this.activeType == 'HIGH_ONLINE' && (this.seleched.length < 3 || this.seleched.length > 5)) {
       if (this.activeType == 'HIGH_ONLINE' && (this.seleched.length < 3 || this.seleched.length > 5)) {
         return this.$message.error('线上技能班必须为3-5人')
         return this.$message.error('线上技能班必须为3-5人')
@@ -115,12 +135,23 @@ export default {
       if (this.seleched.length < 1) {
       if (this.seleched.length < 1) {
         return this.$message.error('请至少选择一名学生')
         return this.$message.error('请至少选择一名学生')
       }
       }
-      this.$refs.form.validate(valid => {
+      this.$refs.form.validate(async valid => {
         if (valid) {
         if (valid) {
-          this.$listeners.submited({
-            seleched: this.seleched,
-            name: this.form.name
-          })
+          if (this.isOnlyChangeUser) {
+            try {
+              await updateClassGroupStudents({
+                classGroupId: this.classGroupId,
+                studentIds: this.seleched.join(',')
+              })
+              this.$message.success('提交成功')
+            } catch (error) {}
+            this.$listeners.submited()
+          } else {
+            this.$listeners.submited({
+              seleched: this.seleched,
+              name: this.form.name
+            })
+          }
           this.$listeners.close()
           this.$listeners.close()
         }
         }
       })
       })

+ 48 - 30
src/views/teamDetail/components/resetClass.vue

@@ -158,9 +158,14 @@
       destroy-on-close
       destroy-on-close
     >
     >
       <selectStudent
       <selectStudent
+        :activeListStudent="activeListStudent"
         :studentList="studentList"
         :studentList="studentList"
         :soundList="soundList"
         :soundList="soundList"
+        :classGroupId="activeClass"
+        :isOnlyChangeUser="isOnlyChangeUser"
         :activeType="activeType"
         :activeType="activeType"
+        @changeActiveChioseSound="changeActiveChioseSound"
+        @searchStudent="searchStudent"
         @submited="studentSubmited"
         @submited="studentSubmited"
         @close="studentVisible = false"
         @close="studentVisible = false"
       />
       />
@@ -800,6 +805,7 @@ export default {
       activeMixClass: "", // 选中的合奏班
       activeMixClass: "", // 选中的合奏班
       chioseStudent: [], // 勾选的学生信息
       chioseStudent: [], // 勾选的学生信息
       isNewClass: false, // 是否为新建班级
       isNewClass: false, // 是否为新建班级
+      isOnlyChangeUser: false,
       isSearch: false, // 是否需要搜索
       isSearch: false, // 是否需要搜索
       isTemporary: false, // 是否为临时班级
       isTemporary: false, // 是否为临时班级
       className: "", // 班级名称
       className: "", // 班级名称
@@ -963,8 +969,12 @@ export default {
       // 助教是从员工表里选
       // 助教是从员工表里选
     },
     },
     studentSubmited(data) {
     studentSubmited(data) {
-      this.studentSubmitedData = data
-      this.infoVisible = true
+      if (!this.isOnlyChangeUser) {
+        this.studentSubmitedData = data
+        this.infoVisible = true
+      } else {
+        this.getList()
+      }
     },
     },
     recourse (row) {
     recourse (row) {
       (this.weekList = [
       (this.weekList = [
@@ -980,6 +990,9 @@ export default {
     addMix () {
     addMix () {
       this.MixVisible = true;
       this.MixVisible = true;
     },
     },
+    changeActiveChioseSound(val) {
+      this.activeChioseSound = val
+    },
     setAssistant (val) {
     setAssistant (val) {
       for (let i in val) {
       for (let i in val) {
         if (val[i] == this.teacherForm.coreTeacher) {
         if (val[i] == this.teacherForm.coreTeacher) {
@@ -1010,6 +1023,7 @@ export default {
       this.studentList = [];
       this.studentList = [];
       this.isNewClass = true;
       this.isNewClass = true;
       this.studentVisible = true;
       this.studentVisible = true;
+      this.isOnlyChangeUser = false
       this.isSearch = true;
       this.isSearch = true;
       this.className = "";
       this.className = "";
       this.isTemporary = true;
       this.isTemporary = true;
@@ -1069,6 +1083,7 @@ export default {
     },
     },
     // 新增班级
     // 新增班级
     addNewClass (type) {
     addNewClass (type) {
+      this.isOnlyChangeUser = false
       this.classType = (type === 'NORMAL' ? 2 : 3)
       this.classType = (type === 'NORMAL' ? 2 : 3)
       /**
       /**
        *      { value: 'NORMAL', label: '单技班' },
        *      { value: 'NORMAL', label: '单技班' },
@@ -1090,6 +1105,7 @@ export default {
       this.getNoClassStudent(type);
       this.getNoClassStudent(type);
     },
     },
     searchStudent () {
     searchStudent () {
+      console.log(this.activeChioseSound)
       // 搜索学生
       // 搜索学生
       // 根据声部id  乐团id搜索学生
       // 根据声部id  乐团id搜索学生
       if (this.activeType == 'SPAN') {
       if (this.activeType == 'SPAN') {
@@ -1170,6 +1186,7 @@ export default {
     },
     },
     // 修改班级
     // 修改班级
     resetClass (row) {
     resetClass (row) {
+      this.isOnlyChangeUser = true
       this.isNewClass = false;
       this.isNewClass = false;
       this.className = row.name;
       this.className = row.name;
       this.studentVisible = true;
       this.studentVisible = true;
@@ -1238,35 +1255,36 @@ export default {
             // this.studentList = res.data.concat(this.activeListStudent).filter(item=>{
             // this.studentList = res.data.concat(this.activeListStudent).filter(item=>{
             //   return res.data
             //   return res.data
             // });
             // });
-            if (this.activeType == "SNAP") {
-              let idarr2 = [];
-              let arr3 = res.data
-              for (let j in this.activeListStudent) {
-                idarr2.push(this.activeListStudent[j].userId);
-              }
-              this.studentList = arr3.filter(item => {
-                return (
-                  idarr2.indexOf(item.userId) === -1
-                );
-              });
-              // let idarr1 = [];
-              // let idarr2 = [];
-              // let arr3 = res.data.concat(this.activeListStudent);
-              // for (let i in res.data) {
-              //   idarr1.push(res.data[i].userId);
-              // }
-              // for (let j in this.activeListStudent) {
-              //   idarr2.push(this.activeListStudent[j].userId);
-              // }
-              // this.studentList = arr3.filter(item => {
-              //   return (
-              //     idarr1.indexOf(item.userId) === -1 ||
-              //     idarr2.indexOf(item.userId) === -1
-              //   );
-              // });
-            } else {
+            // if (this.activeType == "SNAP") {
+            //   let idarr2 = [];
+            //   let arr3 = res.data
+            //   for (let j in this.activeListStudent) {
+            //     idarr2.push(this.activeListStudent[j].userId);
+            //   }
+            //   this.studentList = arr3.filter(item => {
+            //     return (
+            //       idarr2.indexOf(item.userId) === -1
+            //     );
+            //   });
+            //   console.log(params, [...this.studentList])
+            //   // let idarr1 = [];
+            //   // let idarr2 = [];
+            //   // let arr3 = res.data.concat(this.activeListStudent);
+            //   // for (let i in res.data) {
+            //   //   idarr1.push(res.data[i].userId);
+            //   // }
+            //   // for (let j in this.activeListStudent) {
+            //   //   idarr2.push(this.activeListStudent[j].userId);
+            //   // }
+            //   // this.studentList = arr3.filter(item => {
+            //   //   return (
+            //   //     idarr1.indexOf(item.userId) === -1 ||
+            //   //     idarr2.indexOf(item.userId) === -1
+            //   //   );
+            //   // });
+            // } else {
               this.studentList = res.data;
               this.studentList = res.data;
-            }
+            // }
           }
           }
         }
         }
       );
       );