lex-xin 4 лет назад
Родитель
Сommit
a6f977ae7b
1 измененных файлов с 49 добавлено и 46 удалено
  1. 49 46
      src/views/buildVip/index.vue

+ 49 - 46
src/views/buildVip/index.vue

@@ -122,12 +122,41 @@
               />
             </el-select>
           </el-form-item>
-          <el-form-item label="活动方案" prop="activeType" v-if="isMusicTheory">
+          <el-form-item label="上课学员" prop="students">
+            <el-select
+              v-model.trim="leftForm.students"
+              collapse-tags
+              multiple
+              clearable
+              placeholder="请输入上课学员"
+              remote
+              reserve-keyword
+              @change="changeStudent"
+              filterable
+              :multiple-limit="studentLimit"
+              :disabled="!leftForm.classOrganId || !leftForm.courseType"
+              :remote-method="remoteMethod"
+              :loading="remoteLoading"
+            >
+              <el-option
+                v-for="item in studentList"
+                :key="item.userId"
+                :label="item.username"
+                :value="item.userId"
+              >
+                <span style="float: left">{{ item.username }}</span>
+                <span style="float: right; color: #8492a6; font-size: 13px">{{
+                  item.parentsPhone
+                }}</span>
+              </el-option>
+            </el-select>
+          </el-form-item>
+          <el-form-item label="活动方案1" prop="activeType" v-if="isMusicTheory">
             <el-select
               v-model.trim="leftForm.activeType"
               filterable
               clearable
-              :disabled="!leftForm.courseType || isMusicTheory"
+              :disabled="!leftForm.courseType || (!leftForm.students || leftForm.students && leftForm.students.length <= 0) || isMusicTheory"
               @change="chioseActive"
             >
               <el-option
@@ -139,7 +168,7 @@
             </el-select>
           </el-form-item>
           <el-form-item
-            label="活动方案"
+            label="活动方案2"
             prop="activeType"
             v-else
             :rules="[
@@ -154,7 +183,7 @@
               v-model.trim="leftForm.activeType"
               filterable
               clearable
-              :disabled="!leftForm.courseType"
+              :disabled="!leftForm.courseType || (!leftForm.students || leftForm.students && leftForm.students.length <= 0) "
               @change="chioseActive"
             >
               <el-option
@@ -206,35 +235,6 @@
               placeholder="请选择时间"
             />
           </el-form-item>
-          <el-form-item label="上课学员" prop="students">
-            <el-select
-              v-model.trim="leftForm.students"
-              collapse-tags
-              multiple
-              clearable
-              placeholder="请输入上课学员"
-              remote
-              reserve-keyword
-              @change="changeStudent"
-              filterable
-              :multiple-limit="studentLimit"
-              :disabled="!leftForm.classOrganId || !leftForm.courseType"
-              :remote-method="remoteMethod"
-              :loading="remoteLoading"
-            >
-              <el-option
-                v-for="item in studentList"
-                :key="item.userId"
-                :label="item.username"
-                :value="item.userId"
-              >
-                <span style="float: left">{{ item.username }}</span>
-                <span style="float: right; color: #8492a6; font-size: 13px">{{
-                  item.parentsPhone
-                }}</span>
-              </el-option>
-            </el-select>
-          </el-form-item>
         </el-form>
       </div>
       <div class="center">
@@ -992,19 +992,6 @@ export default {
           this.isMusicTheory = this.courseTypeList[i].musicTheory;
         }
       }
-      // teacherId
-
-      if (this.leftForm.courseType && this.leftForm.teacher) {
-        // 根据课程类型获取活动方案
-        vipGroupActivityFind({
-          categoryId: this.leftForm.courseType,
-          teacherId: this.leftForm.teacher,
-        }).then((res) => {
-          if (res.code == 200) {
-            this.activeList = res.data;
-          }
-        });
-      }
     },
     // 选择活动方案
     chioseActive(val) {
@@ -1538,6 +1525,7 @@ export default {
         subjectIdList: this.leftForm.subject,
         educationalTeacherId: this.leftForm.educationalTeacherId,
         organId: this.leftForm.classOrganId,
+        firstStudentId: this.leftForm.students[0] || null
       };
       // 新增
       createVip(obj).then((res) => {
@@ -1831,6 +1819,7 @@ export default {
       }
     },
     changeStudent(val) {
+      this.leftForm.activeType = "";
       this.activeStudentList = [];
       this.studentList.forEach((stu) => {
         if (val.indexOf(stu.userId) != -1) {
@@ -1843,6 +1832,20 @@ export default {
           });
         }
       });
+
+      if (this.leftForm.courseType && this.leftForm.teacher && this.activeStudentList.length == 1) {
+        let firstStudentId = this.activeStudentList[0].studentId
+        // 根据课程类型获取活动方案
+        vipGroupActivityFind({
+          categoryId: this.leftForm.courseType,
+          teacherId: this.leftForm.teacher,
+          firstStudentId
+        }).then((res) => {
+          if (res.code == 200) {
+            this.activeList = res.data;
+          }
+        });
+      }
     },
     // 制定属性去重
     deweight(arr, key) {