|
@@ -57,9 +57,9 @@
|
|
|
<el-input-number v-model="form.sort" :min="1" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label='赠送流量:'>
|
|
|
- <el-switch v-model="form.isFreeFlow" />
|
|
|
+ <el-switch v-model="isFreeFlow" />
|
|
|
</el-form-item>
|
|
|
- <el-form-item v-if="form.isFreeFlow" label="关联流量套餐:" prop="freeActivityId">
|
|
|
+ <el-form-item v-if="isFreeFlow" 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>
|
|
@@ -75,7 +75,7 @@
|
|
|
<script>
|
|
|
import { devMixin, serviceTimeMixin, serviceTypeMixin } from '@/mixin/index'
|
|
|
// import { list } from '@/api/operation/scene'
|
|
|
-import { detail, edit, create, goodsList, newGoodsList, deviceGoodsList } from '@/api/service/package'
|
|
|
+import { detail, edit, create, goodsList, deviceGoodsList } from '@/api/service/package'
|
|
|
export default {
|
|
|
mixins: [devMixin, serviceTimeMixin, serviceTypeMixin],
|
|
|
data() {
|
|
@@ -97,7 +97,7 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
let checkFreeVip = (rule, value, callback) => {
|
|
|
- if (this.form.isFreeFlow && !value) {
|
|
|
+ if (this.isFreeFlow && !value) {
|
|
|
callback(new Error('请选择赠送流量套餐!'))
|
|
|
} else {
|
|
|
callback()
|
|
@@ -123,12 +123,13 @@ export default {
|
|
|
goodsOptions: [],
|
|
|
// 赠送套餐
|
|
|
freeOptions: [],
|
|
|
+ isFreeFlow: false,
|
|
|
// 资源平台
|
|
|
platformOptions: [{
|
|
|
value: 6,
|
|
|
label: 'QQ音乐'
|
|
|
}, {
|
|
|
- value: 11,
|
|
|
+ value: 12,
|
|
|
label: '喜马拉雅'
|
|
|
}],
|
|
|
// 设备会员收费时间
|
|
@@ -189,12 +190,12 @@ export default {
|
|
|
if (val !== 5) {
|
|
|
delete this.form.sort
|
|
|
}
|
|
|
- this.getDeviceGoodsList(this.deviceIds ?? [], val, this.form.isFreeFlow ?? false)
|
|
|
+ this.getDeviceGoodsList(this.deviceIds ?? [], val, this.isFreeFlow ?? false)
|
|
|
},
|
|
|
'form.platform'(val) {
|
|
|
this.getDevList({ type: val })
|
|
|
},
|
|
|
- 'form.isFreeFlow'(val) {
|
|
|
+ 'isFreeFlow'(val) {
|
|
|
if (val === true) {
|
|
|
this.getDeviceGoodsList(this.deviceIds ?? [], this.form.businessType ?? -1, val)
|
|
|
}
|
|
@@ -215,13 +216,17 @@ export default {
|
|
|
methods: {
|
|
|
// 详情
|
|
|
getList() {
|
|
|
- detail(this.form.id).then(res => {
|
|
|
+ detail(String(this.form.id)).then(res => {
|
|
|
if (res.code === 0) {
|
|
|
+ console.log("获取到详情:", JSON.stringify(res.data))
|
|
|
this.form = res.data
|
|
|
- this.form.isFreeFlow = res.data.isFreeFlow ? true : false
|
|
|
- this.form.freeActivityId = res.data.freeActivityId
|
|
|
+ this.isFreeFlow = res.data.isFreeFlow === 1 ? true : false
|
|
|
+ // 将 freeActivityId 转换为字符串
|
|
|
+ this.form.freeActivityId = res.data.freeActivityId ? String(res.data.freeActivityId) : undefined
|
|
|
this.deviceIds = res.data.deviceIds.split(',')
|
|
|
- console.log("设备id:", JSON.stringify(res.data))
|
|
|
+ // console.log("获取到详情2:", JSON.stringify(res.data))
|
|
|
+ // console.log("设备id:", res.data.id, ":", res.data.name, ":", res.data.freeActivityId)
|
|
|
+
|
|
|
// 如果有platformIds,转换为数组
|
|
|
if (res.data.platformIds) {
|
|
|
try {
|
|
@@ -231,11 +236,6 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 如果有freeActivityId,获取对应的流量套餐选项
|
|
|
- if (res.data.isFreeFlow && res.data.freeActivityId) {
|
|
|
- this.getDeviceGoodsList(this.deviceIds, res.data.businessType, true)
|
|
|
- }
|
|
|
-
|
|
|
console.log("请求到设备:", this.deviceIds.length)
|
|
|
}
|
|
|
})
|
|
@@ -254,23 +254,24 @@ export default {
|
|
|
|
|
|
// 如果返回的数据为空数组,确保freeOptions也为空数组而不是null或undefined
|
|
|
this.freeOptions = res.data || [];
|
|
|
- console.log("获取到流量套餐:", this.freeOptions.length);
|
|
|
+ // console.log("获取到流量套餐:", this.freeOptions.length, this.form.freeActivityId);
|
|
|
|
|
|
// 如果freeOptions为空,清空freeActivityId
|
|
|
if (this.freeOptions.length === 0) {
|
|
|
- if (this.form.freeActivityId !== undefined) {
|
|
|
- this.$message.warning('没有可用的流量套餐!');
|
|
|
- this.form.freeActivityId = undefined;
|
|
|
- }
|
|
|
+ this.$message.warning('没有可用的流量套餐!');
|
|
|
+ this.form.freeActivityId = undefined;
|
|
|
}
|
|
|
// 如果freeOptions有值且freeActivityId有值,检查是否存在对应的选项
|
|
|
else if (this.form.freeActivityId !== undefined) {
|
|
|
- const exists = this.freeOptions.some(item => item.id == this.form.freeActivityId);
|
|
|
+ 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 {
|
|
|
- console.log("已找到匹配的流量套餐:", this.form.freeActivityId);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -284,7 +285,7 @@ export default {
|
|
|
if (valid) {
|
|
|
this.form.deviceIds = this.deviceIds.join(',')
|
|
|
this.form.platformIds = JSON.stringify(this.platformIds)
|
|
|
- this.form.isFreeFlow = this.form.isFreeFlow ? 1 : 0
|
|
|
+ this.form.isFreeFlow = this.isFreeFlow ? 1 : 0
|
|
|
console.log('提交:', this.form)
|
|
|
if (this.form.isFreeFlow && this.form.freeActivityId === undefined) {
|
|
|
this.$message.warning('请选择赠送流量套餐!');
|