|
@@ -6,7 +6,7 @@
|
|
<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" />
|
|
</el-select>
|
|
</el-select>
|
|
</el-form-item> -->
|
|
</el-form-item> -->
|
|
- <el-form-item label="套餐名称:">
|
|
|
|
|
|
+ <el-form-item label="套餐名称:" prop="name">
|
|
<el-input v-model="form.name" placeholder="请输入套餐名称" />
|
|
<el-input v-model="form.name" placeholder="请输入套餐名称" />
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="关联设备:">
|
|
<el-form-item label="关联设备:">
|
|
@@ -15,7 +15,7 @@
|
|
</el-select>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="资源平台:">
|
|
<el-form-item label="资源平台:">
|
|
- <el-select v-model="form.platformId" filterable multiple placeholder="请选择资源平台" :disabled="disabled()">
|
|
|
|
|
|
+ <el-select v-model="platformIds" filterable multiple placeholder="请选择资源平台" :disabled="disabled()">
|
|
<el-option v-for="item in platformOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
<el-option v-for="item in platformOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
</el-select>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
@@ -57,11 +57,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.isFreeContentVip" />
|
|
|
|
|
|
+ <el-switch v-model="form.isFreeFlow" />
|
|
</el-form-item>
|
|
</el-form-item>
|
|
- <el-form-item v-if="form.isFreeContentVip" 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="form.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>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-form-item>
|
|
@@ -96,11 +96,27 @@ export default {
|
|
callback()
|
|
callback()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ let checkFreeVip = (rule, value, callback) => {
|
|
|
|
+ if (this.form.isFreeFlow && !value) {
|
|
|
|
+ callback(new Error('请选择赠送流量套餐!'))
|
|
|
|
+ } else {
|
|
|
|
+ callback()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ let checkName = (rule, value, callback) => {
|
|
|
|
+ if ((value ?? "").length == 0) {
|
|
|
|
+ callback(new Error('请输入套餐名称!'))
|
|
|
|
+ } else {
|
|
|
|
+ callback()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return {
|
|
return {
|
|
// 表单
|
|
// 表单
|
|
form: {},
|
|
form: {},
|
|
// 关联设备
|
|
// 关联设备
|
|
deviceIds: [],
|
|
deviceIds: [],
|
|
|
|
+ // 资源平台
|
|
|
|
+ platformIds: [],
|
|
// 区分
|
|
// 区分
|
|
typeList: [],
|
|
typeList: [],
|
|
// 流量套餐
|
|
// 流量套餐
|
|
@@ -155,6 +171,14 @@ export default {
|
|
discount: [{
|
|
discount: [{
|
|
validator: checkedDiscount,
|
|
validator: checkedDiscount,
|
|
trigger: 'blur'
|
|
trigger: 'blur'
|
|
|
|
+ }],
|
|
|
|
+ freeActivityId: [{
|
|
|
|
+ validator: checkFreeVip,
|
|
|
|
+ trigger: 'blur'
|
|
|
|
+ }],
|
|
|
|
+ name: [{
|
|
|
|
+ validator: checkName,
|
|
|
|
+ trigger: 'blur'
|
|
}]
|
|
}]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -165,21 +189,23 @@ export default {
|
|
if (val !== 5) {
|
|
if (val !== 5) {
|
|
delete this.form.sort
|
|
delete this.form.sort
|
|
}
|
|
}
|
|
- this.getDeviceGoodsList(this.deviceIds ?? [], val, this.form.isFreeContentVip ?? false)
|
|
|
|
|
|
+ this.getDeviceGoodsList(this.deviceIds ?? [], val, this.form.isFreeFlow ?? false)
|
|
},
|
|
},
|
|
'form.platform'(val) {
|
|
'form.platform'(val) {
|
|
this.getDevList({ type: val })
|
|
this.getDevList({ type: val })
|
|
},
|
|
},
|
|
- 'form.isFreeContentVip'(val) {
|
|
|
|
|
|
+ 'form.isFreeFlow'(val) {
|
|
if (val === true) {
|
|
if (val === true) {
|
|
this.getDeviceGoodsList(this.deviceIds ?? [], this.form.businessType ?? -1, val)
|
|
this.getDeviceGoodsList(this.deviceIds ?? [], this.form.businessType ?? -1, val)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
- this.typeList = this.$route.query.typeList
|
|
|
|
- console.log(this.typeList)
|
|
|
|
- console.log(this.$route.query)
|
|
|
|
|
|
+ // this.typeList = this.$route.query.typeList
|
|
|
|
+ this.typeList = this.$route.query.typeList.split(',')
|
|
|
|
+ console.log("typeList:", this.typeList, this.$route.query.typeList)
|
|
|
|
+ this.form.type = this.typeList[0]
|
|
|
|
+ this.form.freeOptions = []
|
|
if (this.$route.query.id) {
|
|
if (this.$route.query.id) {
|
|
this.form.id = this.$route.query.id
|
|
this.form.id = this.$route.query.id
|
|
this.getList()
|
|
this.getList()
|
|
@@ -192,24 +218,61 @@ 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.form.isFreeFlow = res.data.isFreeFlow ? true : false
|
|
|
|
+ this.form.freeActivityId = res.data.freeActivityId
|
|
this.deviceIds = res.data.deviceIds.split(',')
|
|
this.deviceIds = res.data.deviceIds.split(',')
|
|
|
|
+ console.log("设备id:", JSON.stringify(res.data))
|
|
|
|
+ // 如果有platformIds,转换为数组
|
|
|
|
+ if (res.data.platformIds) {
|
|
|
|
+ try {
|
|
|
|
+ this.platformIds = JSON.parse(res.data.platformIds)
|
|
|
|
+ } catch (e) {
|
|
|
|
+ this.platformIds = [res.data.platformIds]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 如果有freeActivityId,获取对应的流量套餐选项
|
|
|
|
+ if (res.data.isFreeFlow && res.data.freeActivityId) {
|
|
|
|
+ this.getDeviceGoodsList(this.deviceIds, res.data.businessType, true)
|
|
|
|
+ }
|
|
|
|
+
|
|
console.log("请求到设备:", this.deviceIds.length)
|
|
console.log("请求到设备:", this.deviceIds.length)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
// 流量套餐
|
|
// 流量套餐
|
|
- getDeviceGoodsList(deviceIds, businessType, isFreeContentVip) {
|
|
|
|
- if ((deviceIds ?? []).length === 0 || (businessType ?? -1) < 0 || (isFreeContentVip ?? false) != true) {
|
|
|
|
- console.log('设备id或业务类型为空', deviceIds, businessType, isFreeContentVip)
|
|
|
|
|
|
+ getDeviceGoodsList(deviceIds, businessType, isFreeFlow) {
|
|
|
|
+ if ((deviceIds ?? []).length === 0 || (businessType ?? -1) < 0 || (isFreeFlow ?? false) != true) {
|
|
|
|
+ console.log('设备id或业务类型为空', deviceIds, businessType, isFreeFlow)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- console.log('开始请求', this.typeList[0], deviceIds.join(","), businessType, isFreeContentVip)
|
|
|
|
|
|
+ console.log('开始请求', this.typeList[0], deviceIds.join(","), businessType, isFreeFlow)
|
|
|
|
|
|
- deviceGoodsList(this.typeList[0], businessType, deviceIds.join(",")).then((res) => {
|
|
|
|
- console.log("流量套餐", JSON.stringify(res.data));
|
|
|
|
|
|
+ deviceGoodsList(0, 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);
|
|
|
|
+
|
|
|
|
+ // 如果freeOptions为空,清空freeActivityId
|
|
|
|
+ if (this.freeOptions.length === 0) {
|
|
|
|
+ if (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);
|
|
|
|
+ if (!exists) {
|
|
|
|
+ this.$message.warning('原关联的流量套餐已不可用,请重新选择!');
|
|
|
|
+ this.form.freeActivityId = undefined;
|
|
|
|
+ } else {
|
|
|
|
+ console.log("已找到匹配的流量套餐:", this.form.freeActivityId);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
@@ -217,8 +280,18 @@ export default {
|
|
// 提交
|
|
// 提交
|
|
getSubmit() {
|
|
getSubmit() {
|
|
this.$refs.form.validate((valid) => {
|
|
this.$refs.form.validate((valid) => {
|
|
|
|
+ console.log('提交:', this.form)
|
|
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.isFreeFlow = this.form.isFreeFlow ? 1 : 0
|
|
|
|
+ console.log('提交:', this.form)
|
|
|
|
+ if (this.form.isFreeFlow && this.form.freeActivityId === undefined) {
|
|
|
|
+ this.$message.warning('请选择赠送流量套餐!');
|
|
|
|
+ return;
|
|
|
|
+ } else if (this.form.isFreeFlow != true) {
|
|
|
|
+ this.form.freeActivityId = undefined;
|
|
|
|
+ }
|
|
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) {
|