Browse Source

vip优化完毕

1
mo 3 years ago
parent
commit
888270450d
1 changed files with 85 additions and 33 deletions
  1. 85 33
      src/views/buildVip/index.vue

+ 85 - 33
src/views/buildVip/index.vue

@@ -155,7 +155,12 @@
               v-model.trim="leftForm.activeType"
               filterable
               clearable
-              :disabled="!leftForm.courseType || (!leftForm.students || leftForm.students && leftForm.students.length <= 0) || isMusicTheory"
+              :disabled="
+                !leftForm.courseType ||
+                !leftForm.students ||
+                (leftForm.students && leftForm.students.length <= 0) ||
+                isMusicTheory
+              "
               @change="chioseActive"
             >
               <el-option
@@ -182,7 +187,11 @@
               v-model.trim="leftForm.activeType"
               filterable
               clearable
-              :disabled="!leftForm.courseType || (!leftForm.students || leftForm.students && leftForm.students.length <= 0) "
+              :disabled="
+                !leftForm.courseType ||
+                !leftForm.students ||
+                (leftForm.students && leftForm.students.length <= 0)
+              "
               @change="chioseActive"
             >
               <el-option
@@ -512,7 +521,6 @@
           <el-date-picker
             v-model.trim="maskForm.courseStartOnline"
             type="date"
-
             :picker-options="courseOption"
             placeholder="请选择开课时间"
           />
@@ -846,11 +854,32 @@ export default {
     // 获取所有老师的接口  根据声部id获取老师
     // 获取课程类型的接口
     // 获取学生列表
-    Object.assign(this.$data, this.$options.data());
+    // Object.assign(this.$data, this.$options.data());
 
-    setTimeout(() => {
-      this.$refs["leftForm"].resetFields();
-    }, 100);
+    // setTimeout(() => {
+    //   this.$refs["leftForm"].resetFields();
+    // }, 100);
+    // 判断一下有没有缓存
+    let sotrage = JSON.parse(localStorage.getItem(`newVip`));
+    if (sotrage.leftForm?.classOrganId) {
+      this.$confirm("检测到您有未提交的数据, 是否恢复?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      }).then(() => {
+        this.activeStudentList = sotrage.activeStudentList;
+        this.centerForm = sotrage.centerForm;
+        this.leftForm = sotrage.leftForm;
+        this.rightForm = sotrage.rightForm;
+        this.timeTable = sotrage.timeTable;
+        this.educationList = sotrage.educationList;
+        this.courseTypeList = sotrage.courseTypeList;
+        this.scetionList = sotrage.scetionList;
+        this.studentList = sotrage.studentList;
+        this.activeList = sotrage.activeList;
+        this.studentLimit = sotrage.studentLimit;
+      });
+    }
     this.init();
   },
   activated() {
@@ -860,6 +889,26 @@ export default {
     // }, 100);
     // this.init();
   },
+  beforeDestroy() {
+    let obj = {
+      leftForm: this.leftForm,
+      centerForm: this.centerForm,
+      rightForm: this.rightForm,
+      timeTable: this.timeTable,
+      activeStudentList: this.activeStudentList,
+      teacherList: this.teacherList,
+      educationList: this.educationList,
+      courseTypeList: this.courseTypeList,
+      scetionList: this.scetionList,
+      studentList: this.studentList,
+      activeList: this.activeList,
+      studentLimit: this.studentLimit,
+      // computationalBtn:this.computationalBtn,
+    };
+    localStorage.setItem(`newVip`, JSON.stringify(obj));
+
+    console.log("页面即将销毁");
+  },
   methods: {
     async init() {
       if (this.$route.query.rules) {
@@ -909,8 +958,9 @@ export default {
         disabledDate: (time) => {
           if (self.leftForm.courseStart) {
             let date = new Date(self.leftForm.courseStart.replace(/-/, "/"));
-            let nowDate = new Date()
-            let changeDate = date.getTime()-nowDate.getTime() >0?date:nowDate
+            let nowDate = new Date();
+            let changeDate =
+              date.getTime() - nowDate.getTime() > 0 ? date : nowDate;
             return time.getTime() < changeDate.getTime();
           }
           return;
@@ -975,19 +1025,16 @@ export default {
           this.leftForm.classNum = this.courseTypeList[i].studentNum;
           this.studentLimit = this.courseTypeList[i].studentNum;
           // 每课时长
-          this.classTimeList = this.courseTypeList[i].singleClassMinutes.split(
-            ","
-          );
+          this.classTimeList =
+            this.courseTypeList[i].singleClassMinutes.split(",");
           // this.leftForm.classTime = this.courseTypeList[i].singleClassMinutes;
           this.leftForm.classTime = this.classTimeList[0];
           // 线上课单节价格
-          this.rightForm.onlinePrice = this.courseTypeList[
-            i
-          ].onlineClassesUnitPrice;
+          this.rightForm.onlinePrice =
+            this.courseTypeList[i].onlineClassesUnitPrice;
           // 线下课单节价格
-          this.rightForm.offlinePrice = this.courseTypeList[
-            i
-          ].offlineClassesUnitPrice;
+          this.rightForm.offlinePrice =
+            this.courseTypeList[i].offlineClassesUnitPrice;
           this.isMusicTheory = this.courseTypeList[i].musicTheory;
         }
       }
@@ -1016,19 +1063,16 @@ export default {
             // 学生人数
             this.leftForm.classNum = this.courseTypeList[i].studentNum;
             // 每课时长
-            this.classTimeList = this.courseTypeList[
-              i
-            ].singleClassMinutes.split(",");
+            this.classTimeList =
+              this.courseTypeList[i].singleClassMinutes.split(",");
             // this.leftForm.classTime = this.courseTypeList[i].singleClassMinutes;
             this.leftForm.classTime = this.classTimeList[0];
             // 线上课单节价格
-            this.rightForm.onlinePrice = this.courseTypeList[
-              i
-            ].onlineClassesUnitPrice;
+            this.rightForm.onlinePrice =
+              this.courseTypeList[i].onlineClassesUnitPrice;
             // 线下课单节价格
-            this.rightForm.offlinePrice = this.courseTypeList[
-              i
-            ].offlineClassesUnitPrice;
+            this.rightForm.offlinePrice =
+              this.courseTypeList[i].offlineClassesUnitPrice;
           }
         }
         // 根须活动id获取 相应的值
@@ -1524,11 +1568,12 @@ export default {
         subjectIdList: this.leftForm.subject,
         educationalTeacherId: this.leftForm.educationalTeacherId,
         organId: this.leftForm.classOrganId,
-        firstStudentId: this.leftForm.students[0] || null
+        firstStudentId: this.leftForm.students[0] || null,
       };
       // 新增
       createVip(obj).then((res) => {
         if (res.code == 200) {
+          localStorage.removeItem('newVip')
           if (res.data == "ING") {
             this.$confirm(
               "课程提交成功,已提交运营主管审批,审批通过后,课程创建成功!",
@@ -1560,9 +1605,8 @@ export default {
             });
           }
         }
-            console.log(res)
+        console.log(res);
         if (res.code == 206) {
-
           this.$confirm(res.msg, "提示", {
             confirmButtonText: "确定",
             type: "warning",
@@ -1570,6 +1614,7 @@ export default {
             obj.allowOverstepActivityStudentNum = 1;
             createVip(obj).then((res) => {
               if (res.code == 200) {
+                  localStorage.removeItem('newVip')
                 this.$message.success("提交成功");
                 this.$store.dispatch("delVisitedViews", this.$route);
                 this.$router.push({
@@ -1643,6 +1688,7 @@ export default {
       // 课程分部改变时
       // 老师 乐团主管 都要重置
       this.studentList = [];
+      this.activeStudentList = [];
       this.$set(this.leftForm, "students", []);
       this.$set(this.leftForm, "teacher", "");
       this.$set(this.leftForm, "educationalTeacherId", "");
@@ -1820,6 +1866,7 @@ export default {
     changeStudent(val) {
       this.leftForm.activeType = "";
       this.activeStudentList = [];
+
       this.studentList.forEach((stu) => {
         if (val.indexOf(stu.userId) != -1) {
           this.activeStudentList.push({
@@ -1831,13 +1878,18 @@ export default {
           });
         }
       });
-      if (this.leftForm.courseType && this.leftForm.teacher && this.leftForm.students && this.leftForm.students.length >= 1) {
-        let studentIds = this.leftForm.students.join(',')
+      if (
+        this.leftForm.courseType &&
+        this.leftForm.teacher &&
+        this.leftForm.students &&
+        this.leftForm.students.length >= 1
+      ) {
+        let studentIds = this.leftForm.students.join(",");
         // 根据课程类型获取活动方案
         vipGroupActivityFind({
           categoryId: this.leftForm.courseType,
           teacherId: this.leftForm.teacher,
-          studentIds
+          studentIds,
         }).then((res) => {
           if (res.code == 200) {
             this.activeList = res.data;