浏览代码

fix:修改流量套餐的提示语判断问题

zeng.chen 2 月之前
父节点
当前提交
b67067e61f
共有 2 个文件被更改,包括 14 次插入11 次删除
  1. 3 3
      src/views/service/package/detail.vue
  2. 11 8
      src/views/service/vip/detail.vue

+ 3 - 3
src/views/service/package/detail.vue

@@ -246,10 +246,10 @@ export default {
           // 如果freeOptions为空,清空freeActivityId
           // 如果freeOptions为空,清空freeActivityId
           if (this.freeOptions.length === 0) {
           if (this.freeOptions.length === 0) {
             this.$message.warning('没有可用的会员套餐!');
             this.$message.warning('没有可用的会员套餐!');
-            this.form.freeActivityId = undefined;
+            this.form.freeActivityId = null;
           }
           }
           // 如果freeOptions有值且freeActivityId有值,检查是否存在对应的选项
           // 如果freeOptions有值且freeActivityId有值,检查是否存在对应的选项
-          else if (this.form.freeActivityId !== undefined) {
+          else if (this.form.freeActivityId !== null) {
             const exists = this.freeOptions.some(item => {
             const exists = this.freeOptions.some(item => {
               // console.log("item.id:", item.id, "freeActivityId:", this.form.freeActivityId);
               // console.log("item.id:", item.id, "freeActivityId:", this.form.freeActivityId);
               return String(item.id) === String(this.form.freeActivityId);
               return String(item.id) === String(this.form.freeActivityId);
@@ -257,7 +257,7 @@ export default {
             console.log("找匹配的会员套餐:", this.form.freeActivityId, exists);
             console.log("找匹配的会员套餐:", this.form.freeActivityId, exists);
             if (!exists) {
             if (!exists) {
               this.$message.warning('原关联的会员套餐已不可用,请重新选择!');
               this.$message.warning('原关联的会员套餐已不可用,请重新选择!');
-              this.form.freeActivityId = undefined;
+              this.form.freeActivityId = null;
             } else {
             } else {
             }
             }
           }
           }

+ 11 - 8
src/views/service/vip/detail.vue

@@ -225,7 +225,7 @@ export default {
           this.form = res.data
           this.form = res.data
           this.isFreeFlow = res.data.isFreeFlow === 1 ? true : false
           this.isFreeFlow = res.data.isFreeFlow === 1 ? true : false
           // 将 freeActivityId 转换为字符串
           // 将 freeActivityId 转换为字符串
-          this.form.freeActivityId = res.data.freeActivityId ? String(res.data.freeActivityId) : undefined
+          this.form.freeActivityId = res.data.freeActivityId ? String(res.data.freeActivityId) : null
           this.deviceIds = res.data.deviceIds.split(',')
           this.deviceIds = res.data.deviceIds.split(',')
           // console.log("获取到详情2:", JSON.stringify(res.data))
           // console.log("获取到详情2:", JSON.stringify(res.data))
           // console.log("设备id:", res.data.id, ":", res.data.name, ":", res.data.freeActivityId)
           // console.log("设备id:", res.data.id, ":", res.data.name, ":", res.data.freeActivityId)
@@ -264,18 +264,21 @@ export default {
           // 如果freeOptions为空,清空freeActivityId
           // 如果freeOptions为空,清空freeActivityId
           if (this.freeOptions.length === 0) {
           if (this.freeOptions.length === 0) {
             this.$message.warning('没有可用的流量套餐!');
             this.$message.warning('没有可用的流量套餐!');
-            this.form.freeActivityId = undefined;
+            this.form.freeActivityId = null;
           }
           }
           // 如果freeOptions有值且freeActivityId有值,检查是否存在对应的选项
           // 如果freeOptions有值且freeActivityId有值,检查是否存在对应的选项
-          else if (this.form.freeActivityId !== undefined) {
+
+          else if (this.form.freeActivityId != null) {
+            console.log("找匹配的流量套餐1:", this.form.freeActivityId);
+
             const exists = this.freeOptions.some(item => {
             const exists = this.freeOptions.some(item => {
               // console.log("item.id:", item.id, "freeActivityId:", this.form.freeActivityId);
               // console.log("item.id:", item.id, "freeActivityId:", this.form.freeActivityId);
               return String(item.id) === String(this.form.freeActivityId);
               return String(item.id) === String(this.form.freeActivityId);
             });
             });
-            console.log("找匹配的流量套餐:", this.form.freeActivityId, exists);
-            if (!exists) {
+            console.log("找匹配的流量套餐2:", this.form.freeActivityId, exists);
+            if (exists) {
               this.$message.warning('原关联的流量套餐已不可用,请重新选择!');
               this.$message.warning('原关联的流量套餐已不可用,请重新选择!');
-              this.form.freeActivityId = undefined;
+              this.form.freeActivityId = null;
             } else {
             } else {
             }
             }
           }
           }
@@ -291,11 +294,11 @@ export default {
           this.form.platformIds = JSON.stringify(this.platformIds)
           this.form.platformIds = JSON.stringify(this.platformIds)
           this.form.isFreeFlow = this.isFreeFlow ? 1 : 0
           this.form.isFreeFlow = this.isFreeFlow ? 1 : 0
           console.log('提交:', this.form)
           console.log('提交:', this.form)
-          if (this.form.isFreeFlow && this.form.freeActivityId === undefined) {
+          if (this.form.isFreeFlow && this.form.freeActivityId == null) {
             this.$message.warning('请选择赠送流量套餐!');
             this.$message.warning('请选择赠送流量套餐!');
             return;
             return;
           } else if (this.form.isFreeFlow != true) {
           } else if (this.form.isFreeFlow != true) {
-            this.form.freeActivityId = undefined;
+            this.form.freeActivityId = null;
           }
           }
           if (this.form.id) {
           if (this.form.id) {
             edit(this.form).then(res => {
             edit(this.form).then(res => {