|
@@ -1,6 +1,6 @@
|
|
<template>
|
|
<template>
|
|
<div class="app-container">
|
|
<div class="app-container">
|
|
- <el-form :model="form" :rules="rules" ref="form" label-width="100px">
|
|
|
|
|
|
+ <el-form :model="form" :rules="rules" ref="form" label-width="110px">
|
|
<el-form-item label="流量平台:">
|
|
<el-form-item label="流量平台:">
|
|
<el-select v-model="form.platform" placeholder="请选择流量平台" :disabled="disabled()">
|
|
<el-select v-model="form.platform" placeholder="请选择流量平台" :disabled="disabled()">
|
|
<el-option v-for="item in typeOptions" :key="item.value" :value="item.value" :label="item.label" />
|
|
<el-option v-for="item in typeOptions" :key="item.value" :value="item.value" :label="item.label" />
|
|
@@ -56,11 +56,11 @@
|
|
<el-input-number v-model="form.sort" :min="1" />
|
|
<el-input-number v-model="form.sort" :min="1" />
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label='赠送会员:'>
|
|
<el-form-item label='赠送会员:'>
|
|
- <el-switch v-model="form.isFreeFlow" />
|
|
|
|
|
|
+ <el-switch v-model="isFreeContentVip" />
|
|
</el-form-item>
|
|
</el-form-item>
|
|
- <el-form-item v-if="form.isFreeFlow" label="关联会员套餐:">
|
|
|
|
- <el-select v-model="form.freeOptions" placeholder="请选择会员套餐:">
|
|
|
|
- <el-option v-for="item in form.freeOptions" :key="item.id" :label="item.name" :value="item.id" />
|
|
|
|
|
|
+ <el-form-item v-if="isFreeContentVip" label="关联会员套餐:" prop="freeActivityId">
|
|
|
|
+ <el-select v-model="form.freeActivityId" placeholder="请选择会员套餐:">
|
|
|
|
+ <el-option v-for="item in freeOptions" :key="item.id" :label="item.name" :value="item.id" />
|
|
</el-select>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-form-item>
|
|
@@ -74,7 +74,7 @@
|
|
<script>
|
|
<script>
|
|
import { devMixin, serviceTimeMixin, serviceTypeMixin } from '@/mixin/index'
|
|
import { devMixin, serviceTimeMixin, serviceTypeMixin } from '@/mixin/index'
|
|
import { list } from '@/api/operation/scene'
|
|
import { list } from '@/api/operation/scene'
|
|
-import { detail, edit, create, goodsList } from '@/api/service/package'
|
|
|
|
|
|
+import { detail, edit, create, goodsList, deviceGoodsList } from '@/api/service/package'
|
|
export default {
|
|
export default {
|
|
mixins: [devMixin, serviceTimeMixin, serviceTypeMixin],
|
|
mixins: [devMixin, serviceTimeMixin, serviceTypeMixin],
|
|
data() {
|
|
data() {
|
|
@@ -95,6 +95,13 @@ export default {
|
|
callback()
|
|
callback()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ let checkFreeFlow = (rule, value, callback) => {
|
|
|
|
+ if (this.isFreeContentVip && !value) {
|
|
|
|
+ callback(new Error('请选择赠送会员套餐!'))
|
|
|
|
+ } else {
|
|
|
|
+ callback()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return {
|
|
return {
|
|
// 表单
|
|
// 表单
|
|
form: {},
|
|
form: {},
|
|
@@ -106,6 +113,9 @@ export default {
|
|
goodsOptions: [],
|
|
goodsOptions: [],
|
|
// 爱听专区
|
|
// 爱听专区
|
|
sceneOptions: [],
|
|
sceneOptions: [],
|
|
|
|
+ // 赠送会员套餐
|
|
|
|
+ freeOptions: [],
|
|
|
|
+ isFreeContentVip: false,
|
|
// 资源平台
|
|
// 资源平台
|
|
platformOptions: [{
|
|
platformOptions: [{
|
|
value: 6,
|
|
value: 6,
|
|
@@ -142,7 +152,11 @@ export default {
|
|
discount: [{
|
|
discount: [{
|
|
validator: checkedDiscount,
|
|
validator: checkedDiscount,
|
|
trigger: 'blur'
|
|
trigger: 'blur'
|
|
- }]
|
|
|
|
|
|
+ }],
|
|
|
|
+ freeActivityId: [{
|
|
|
|
+ validator: checkFreeFlow,
|
|
|
|
+ trigger: 'blur'
|
|
|
|
+ }],
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -156,14 +170,14 @@ export default {
|
|
if (val !== 5) {
|
|
if (val !== 5) {
|
|
delete this.form.sort
|
|
delete this.form.sort
|
|
}
|
|
}
|
|
- this.getDeviceGoodsList(this.deviceIds ?? [], val, this.form.isFreeFlow ?? false)
|
|
|
|
|
|
+ this.getDeviceGoodsList(this.deviceIds ?? [], val, this.isFreeContentVip ?? false)
|
|
|
|
|
|
},
|
|
},
|
|
'form.platform'(val) {
|
|
'form.platform'(val) {
|
|
this.getDevList({ type: val })
|
|
this.getDevList({ type: val })
|
|
this.getGoodSList(val)
|
|
this.getGoodSList(val)
|
|
},
|
|
},
|
|
- 'form.isFreeFlow'(val) {
|
|
|
|
|
|
+ 'isFreeContentVip'(val) {
|
|
this.getDeviceGoodsList(this.deviceIds ?? [], this.form.businessType ?? -1, val)
|
|
this.getDeviceGoodsList(this.deviceIds ?? [], this.form.businessType ?? -1, val)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -182,6 +196,7 @@ export default {
|
|
detail(this.form.id).then(res => {
|
|
detail(this.form.id).then(res => {
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
this.form = res.data
|
|
this.form = res.data
|
|
|
|
+ this.isFreeContentVip = res.data.isFreeContentVip === 1 ? true : false
|
|
this.deviceIds = res.data.deviceIds.split(',')
|
|
this.deviceIds = res.data.deviceIds.split(',')
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -209,18 +224,39 @@ export default {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
- // 流量套餐
|
|
|
|
- getDeviceGoodsList(deviceIds, businessType, isFreeFlow) {
|
|
|
|
- if (this.typeList[0] != "18" || (deviceIds ?? []).length === 0 || (businessType ?? -1) < 0 || (isFreeFlow ?? false) != true) {
|
|
|
|
- console.log('设备id或业务类型为空', this.typeList[0], deviceIds, businessType, isFreeFlow)
|
|
|
|
|
|
+ // 会员套餐
|
|
|
|
+ getDeviceGoodsList(deviceIds, businessType, isFreeContentVip) {
|
|
|
|
+ if ((deviceIds ?? []).length === 0 || (businessType ?? -1) < 0 || (isFreeContentVip ?? false) != true) {
|
|
|
|
+ console.log('设备id或业务类型为空', deviceIds, businessType, isFreeContentVip)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- console.log('开始请求', this.typeList[0], deviceIds.join(","), businessType, isFreeFlow)
|
|
|
|
|
|
+ console.log('开始请求', this.typeList[0], deviceIds.join(","), businessType, isFreeContentVip)
|
|
|
|
|
|
- deviceGoodsList(this.typeList[0], businessType, deviceIds.join(",")).then((res) => {
|
|
|
|
- console.log("流量套餐", JSON.stringify(res.data));
|
|
|
|
|
|
+ deviceGoodsList(1, businessType, deviceIds.join(",")).then((res) => {
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
- this.form.freeOptions = res.data;
|
|
|
|
|
|
+
|
|
|
|
+ // 如果返回的数据为空数组,确保freeOptions也为空数组而不是null或undefined
|
|
|
|
+ this.freeOptions = res.data || [];
|
|
|
|
+ // console.log("获取到流量套餐:", this.freeOptions.length, this.form.freeActivityId);
|
|
|
|
+
|
|
|
|
+ // 如果freeOptions为空,清空freeActivityId
|
|
|
|
+ if (this.freeOptions.length === 0) {
|
|
|
|
+ this.$message.warning('没有可用的会员套餐!');
|
|
|
|
+ this.form.freeActivityId = undefined;
|
|
|
|
+ }
|
|
|
|
+ // 如果freeOptions有值且freeActivityId有值,检查是否存在对应的选项
|
|
|
|
+ else if (this.form.freeActivityId !== undefined) {
|
|
|
|
+ const exists = this.freeOptions.some(item => {
|
|
|
|
+ // console.log("item.id:", item.id, "freeActivityId:", this.form.freeActivityId);
|
|
|
|
+ return String(item.id) === String(this.form.freeActivityId);
|
|
|
|
+ });
|
|
|
|
+ console.log("找匹配的会员套餐:", this.form.freeActivityId, exists);
|
|
|
|
+ if (!exists) {
|
|
|
|
+ this.$message.warning('原关联的会员套餐已不可用,请重新选择!');
|
|
|
|
+ this.form.freeActivityId = undefined;
|
|
|
|
+ } else {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
@@ -230,11 +266,14 @@ export default {
|
|
this.$refs.form.validate((valid) => {
|
|
this.$refs.form.validate((valid) => {
|
|
if (valid) {
|
|
if (valid) {
|
|
this.form.deviceIds = this.deviceIds.join(',')
|
|
this.form.deviceIds = this.deviceIds.join(',')
|
|
|
|
+ this.form.platformIds = JSON.stringify(this.platformIds)
|
|
|
|
+ this.form.isFreeContentVip = this.isFreeContentVip ? 1 : 0
|
|
if (this.form.id) {
|
|
if (this.form.id) {
|
|
edit(this.form).then(res => {
|
|
edit(this.form).then(res => {
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
this.$message.success('修改成功!')
|
|
this.$message.success('修改成功!')
|
|
this.cancel()
|
|
this.cancel()
|
|
|
|
+ } else {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
} else {
|
|
} else {
|
|
@@ -242,6 +281,7 @@ export default {
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
this.$message.success('新增成功!')
|
|
this.$message.success('新增成功!')
|
|
this.cancel()
|
|
this.cancel()
|
|
|
|
+ } else {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|