瀏覽代碼

Merge branch '04/16vipactiveRange' of http://git.dayaedu.com/molingzhide/dy-admin-manager into 04/16vipactiveRange

lex-xin 4 年之前
父節點
當前提交
1761d0c8cb
共有 1 個文件被更改,包括 59 次插入32 次删除
  1. 59 32
      src/views/buildVip/index.vue

+ 59 - 32
src/views/buildVip/index.vue

@@ -138,13 +138,18 @@
               />
             </el-select>
           </el-form-item>
-          <el-form-item label="活动方案" prop="activeType" v-else :rules=' [
-          {
-            required: true,
-            message: "请选择活动方案",
-            trigger: "change",
-          },
-        ]'>
+          <el-form-item
+            label="活动方案"
+            prop="activeType"
+            v-else
+            :rules="[
+              {
+                required: true,
+                message: '请选择活动方案',
+                trigger: 'change',
+              },
+            ]"
+          >
             <el-select
               v-model.trim="leftForm.activeType"
               filterable
@@ -239,6 +244,13 @@
           :closable="false"
           class="vipMsg"
         ></el-alert>
+
+        <p class="submitP" v-if="minCourseNum&&maxCourseNum&&this.hotType == 'DISCOUNT'">
+          该活动最小课时数:<span style="color: red">{{ minCourseNum }}</span
+          >节 最大课时数:<span style="color: red">{{ maxCourseNum }}</span
+          >节
+        </p>
+
         <el-form
           :inline="true"
           :model="centerForm"
@@ -684,6 +696,8 @@ export default {
       attribute1: "",
       attribute2: "",
       attribute3: "",
+      maxCourseNum: 0,
+      minCourseNum: 0,
       salaryReadonlyFlag: "", // 老师课酬是否可配
       paymentReadonlyFlag: "", // 课程单价是否可配
       lookList: [],
@@ -865,19 +879,20 @@ export default {
       this.courseOption = this.coursesDate();
     },
     onCourseNumChange(type) {
-      let centerForm = this.centerForm
       // 折扣类型,并且设置的排课数有值
-      if(this.hotType == 'DISCOUNT' && this.attribute3 && this.attribute3 > 0) {
-        // 判断线上或线下总和等于排课次数
-        // console.log((parseInt(centerForm.onlineCourseNum) + parseInt(centerForm.offlineCourseNum)), this.attribute3)
-        let onlineNum = centerForm.onlineCourseNum || 0
-        let offlineNum = centerForm.offlineCourseNum || 0
-        if((parseInt(onlineNum) + parseInt(offlineNum)) > this.attribute3) {
-          if(type == 'online') {
-            this.$message.error('线上课数加线下课数必须等于待排课数')
-          } else if(type == 'offline') {
-            this.$message.error('线上课数加线下课数必须等于待排课数')
-          }
+      let centerForm = this.centerForm;
+      if (
+        this.hotType == "DISCOUNT" &&
+        this.maxCourseNum &&
+        this.minCourseNum
+      ) {
+        // 判断线上或线下总和大于排课次数
+        let onlineNum = centerForm.onlineCourseNum || 0;
+        let offlineNum = centerForm.offlineCourseNum || 0;
+        let allNUm = parseInt(onlineNum) + parseInt(offlineNum);
+        if (allNUm > this.maxCourseNum || allNUm < this.minCourseNum) {
+          this.$message.error("待排课数不可超过该活动限制");
+          return;
         }
       }
     },
@@ -992,7 +1007,8 @@ export default {
       this.timeTable = [];
       this.attribute1 = "";
       this.attribute2 = "";
-      this.attribute3 = ""
+      this.attribute3 = "";
+
       this.giveNum = 0;
       this.isGiveClass = false;
       this.leftForm.courseStart = "";
@@ -1023,11 +1039,12 @@ export default {
         // 根须活动id获取 相应的值
         for (let i in this.activeList) {
           if (this.activeList[i].id == val) {
-            console.log(this.activeList[i])
             // 如果是买赠就必须选择赠课类型
             // 报名开始 报名结束 课程开始 课程结束 // 判断是否有线上,线下课 并同步状态
             // this.leftForm.signUpStart = this.activeList[i].startTime;
             // this.leftForm.signUpEnd = this.activeList[i].endTime;
+            this.maxCourseNum = this.activeList[i].maxCourseNum || 0;
+            this.minCourseNum = this.activeList[i].minCourseNum || 0;
             this.leftForm.courseStart = this.activeList[i].coursesStartTime;
             this.leftForm.courseEnd = this.activeList[i].coursesEndTime;
             // 获取活动种类并保存
@@ -1513,7 +1530,7 @@ export default {
                 //   message: '提交成功!'
                 // });
                 this.$message.success("提交成功");
-                this.$store.dispatch('delVisitedViews', this.$route)
+                this.$store.dispatch("delVisitedViews", this.$route);
                 this.$router.push({
                   path: "/vipManager/vipList",
                   query: {
@@ -1524,7 +1541,7 @@ export default {
               });
             } else {
               this.$message.success("恭喜您创建成功");
-              this.$store.dispatch('delVisitedViews', this.$route)
+              this.$store.dispatch("delVisitedViews", this.$route);
               this.$router.push({
                 path: "/vipManager/vipList",
                 query: {
@@ -1634,7 +1651,7 @@ export default {
       }
     },
     onCancel() {
-      this.$store.dispatch('delVisitedViews', this.$route)
+      this.$store.dispatch("delVisitedViews", this.$route);
       this.$router.push({
         path: "/vipManager/vipList",
         query: {
@@ -1655,15 +1672,20 @@ export default {
 
       this.$refs["leftForm"].validate((vali) => {
         if (vali) {
-
-          let centerForm = this.centerForm
-          if(this.hotType == 'DISCOUNT' && this.attribute3 && this.attribute3 > 0) {
+          let centerForm = this.centerForm;
+          if (
+            this.hotType == "DISCOUNT" &&
+            this.maxCourseNum &&
+            this.minCourseNum
+          ) {
             // 判断线上或线下总和大于排课次数
-            let onlineNum = centerForm.onlineCourseNum || 0
-            let offlineNum = centerForm.offlineCourseNum || 0
-            if((parseInt(onlineNum) + parseInt(offlineNum)) != this.attribute3) {
-              this.$message.error('线上课数加线下课数必须等于待排课数')
-              return
+            let onlineNum = centerForm.onlineCourseNum || 0;
+            let offlineNum = centerForm.offlineCourseNum || 0;
+            let allNUm = parseInt(onlineNum) + parseInt(offlineNum);
+            if (allNUm > this.maxCourseNum || allNUm < this.minCourseNum) {
+              this.$message.error("待排课数不可超过该活动限制");
+
+              return;
             }
           }
           this.dialogFormVisible = true;
@@ -1920,4 +1942,9 @@ export default {
   background-color: #f97215;
   float: right;
 }
+.submitP {
+  margin-bottom: 20px;
+  font-size: 14px;
+  padding-left: 24px;
+}
 </style>