|
@@ -0,0 +1,317 @@
|
|
|
|
+<template>
|
|
|
|
+ <div class="app-container">
|
|
|
|
+ <el-form :model="form" :rules="rules" ref="form" label-width="110px">
|
|
|
|
+ <el-form-item label="流量平台:">
|
|
|
|
+ <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-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="关联设备:">
|
|
|
|
+ <el-select v-model="deviceIds" filterable multiple placeholder="请选择关联设备">
|
|
|
|
+ <el-option v-for="(item, index) in devOptions" :key="`${item.value}-${index}`" :value="item.value"
|
|
|
|
+ :label="item.label" /> </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="套餐名称:">
|
|
|
|
+ <el-input v-model="form.name" placeholder="请输入套餐名称" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="服务类型:">
|
|
|
|
+ <el-select v-model="form.businessType" placeholder="请选择服务类型" :disabled="disabled()">
|
|
|
|
+ <el-option v-for="item in serviceTypeOptions" :key="item.value" :value="item.value" :label="item.label" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item v-if="typeList[0] === '13'" label="资源平台:">
|
|
|
|
+ <el-select v-model="form.platformId" placeholder="请选择资源平台" :disabled="disabled()">
|
|
|
|
+ <el-option v-for="item in platformOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item v-else label="流量套餐:">
|
|
|
|
+ <el-select v-model="form.goodsId" placeholder="请选择流量套餐" :disabled="disabled()">
|
|
|
|
+ <el-option v-for="(item, index) in goodsOptions" :key="index" :label="item" :value="index" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item v-if="form.platformId === 10" label="栏目:">
|
|
|
|
+ <el-select v-model="form.groupId" placeholder="请选择爱听栏目">
|
|
|
|
+ <el-option v-for="item in sceneOptions" :key="item.value" :value="item.value" :label="item.label" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="原价:" prop="price">
|
|
|
|
+ <el-input-number v-model="form.price" :min="0" :max="500" :controls="false" :precision="2"
|
|
|
|
+ placeholder="请输入原价" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="活动价:" prop="discount">
|
|
|
|
+ <el-input-number v-model="form.discount" :min="0" :max="500" :controls="false" :precision="2"
|
|
|
|
+ placeholder="请输入活动价" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="服务时长:">
|
|
|
|
+ <el-select v-model="form.indate" placeholder="请选择服务时长">
|
|
|
|
+ <el-option v-for="item in serviceTimeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="是否推荐:">
|
|
|
|
+ <el-select v-model="form.isRecommend" placeholder="请选择是否推荐">
|
|
|
|
+ <el-option v-for="item in recommendOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="排序:" v-if="form.businessType === 5">
|
|
|
|
+ <el-input-number v-model="form.sort" :min="1" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label='赠送会员:'>
|
|
|
|
+ <el-switch v-model="isFreeContentVip" :disabled="disableVip" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item v-if="isFreeContentVip" label="关联会员套餐:" prop="freeActivityId">
|
|
|
|
+ <el-select v-model="form.freeActivityId" placeholder="请选择会员套餐:" :disabled="disableVip">
|
|
|
|
+ <el-option v-for="(item, index) in freeOptions" :key="`free-option-${item.id}-${index}`" :label="item.name"
|
|
|
|
+ :value="item.id" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <el-button @click="cancel">取消</el-button>
|
|
|
|
+ <el-button type="primary" @click="getSubmit">提交</el-button>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+import { devMixin, serviceTimeMixin, serviceTypeMixin } from '@/mixin/index'
|
|
|
|
+import { list } from '@/api/operation/scene'
|
|
|
|
+import { detail, edit, create, goodsList, deviceGoodsList } from '@/api/service/package'
|
|
|
|
+export default {
|
|
|
|
+ name:"serviceMusicDetail",
|
|
|
|
+ mixins: [devMixin, serviceTimeMixin, serviceTypeMixin],
|
|
|
|
+ data() {
|
|
|
|
+ let checkedPrice = (rule, value, callback) => {
|
|
|
|
+ if (Number(value) > 500) {
|
|
|
|
+ callback(new Error('原价不得超过500'))
|
|
|
|
+ } else {
|
|
|
|
+ if (this.form.discount !== undefined) {
|
|
|
|
+ this.$refs.form.validateField('discount')
|
|
|
|
+ }
|
|
|
|
+ callback()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ let checkedDiscount = (rule, value, callback) => {
|
|
|
|
+ if (Number(value) > Number(this.form.price)) {
|
|
|
|
+ callback(new Error('活动价不得大于原价!'))
|
|
|
|
+ } else {
|
|
|
|
+ callback()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ let checkFreeFlow = (rule, value, callback) => {
|
|
|
|
+ if (this.isFreeContentVip && !value) {
|
|
|
|
+ callback(new Error('请选择赠送会员套餐!'))
|
|
|
|
+ } else {
|
|
|
|
+ callback()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return {
|
|
|
|
+ // 表单
|
|
|
|
+ form: {},
|
|
|
|
+ // 关联设备
|
|
|
|
+ deviceIds: [],
|
|
|
|
+ // 区分
|
|
|
|
+ typeList: [],
|
|
|
|
+ // 流量套餐
|
|
|
|
+ goodsOptions: [],
|
|
|
|
+ // 爱听专区
|
|
|
|
+ sceneOptions: [],
|
|
|
|
+ // 赠送会员套餐
|
|
|
|
+ freeOptions: [],
|
|
|
|
+ isFreeContentVip: false,
|
|
|
|
+ disableVip: false,
|
|
|
|
+ // 资源平台
|
|
|
|
+ platformOptions: [{
|
|
|
|
+ value: 6,
|
|
|
|
+ label: 'QQ音乐'
|
|
|
|
+ }, {
|
|
|
|
+ value: 9,
|
|
|
|
+ label: '酷狗音乐'
|
|
|
|
+ }, {
|
|
|
|
+ value: 10,
|
|
|
|
+ label: '爱听音乐'
|
|
|
|
+ }],
|
|
|
|
+ // 是否推荐
|
|
|
|
+ recommendOptions: [{
|
|
|
|
+ value: 0,
|
|
|
|
+ label: '是'
|
|
|
|
+ }, {
|
|
|
|
+ value: 1,
|
|
|
|
+ label: '否'
|
|
|
|
+ }],
|
|
|
|
+ // 流量平台
|
|
|
|
+ typeOptions: [{
|
|
|
|
+ value: 0,
|
|
|
|
+ label: '树米'
|
|
|
|
+ }, {
|
|
|
|
+ value: 1,
|
|
|
|
+ label: '联通'
|
|
|
|
+ }],
|
|
|
|
+ // 校验
|
|
|
|
+ rules: {
|
|
|
|
+ price: [{
|
|
|
|
+ validator: checkedPrice,
|
|
|
|
+ trigger: 'blur'
|
|
|
|
+ }],
|
|
|
|
+ discount: [{
|
|
|
|
+ validator: checkedDiscount,
|
|
|
|
+ trigger: 'blur'
|
|
|
|
+ }],
|
|
|
|
+ freeActivityId: [{
|
|
|
|
+ validator: checkFreeFlow,
|
|
|
|
+ trigger: 'blur'
|
|
|
|
+ }],
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ watch: {
|
|
|
|
+ typeList(val) {
|
|
|
|
+ if (val[0] !== '12') {
|
|
|
|
+ this.getSceneList()
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ 'form.businessType'(val) {
|
|
|
|
+ if (val !== 5) {
|
|
|
|
+ delete this.form.sort
|
|
|
|
+ }
|
|
|
|
+ this.getDeviceGoodsList(this.deviceIds ?? [], val, this.isFreeContentVip ?? false)
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ 'form.platform'(val) {
|
|
|
|
+ this.getDevList({ type: val })
|
|
|
|
+ this.getGoodSList(val)
|
|
|
|
+ },
|
|
|
|
+ 'isFreeContentVip'(val) {
|
|
|
|
+ this.getDeviceGoodsList(this.deviceIds ?? [], this.form.businessType ?? -1, val)
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ mounted() {
|
|
|
|
+ this.typeList = this.$route.query.typeList.split(',')
|
|
|
|
+ console.log("typeList:", this.typeList, this.$route.query.typeList)
|
|
|
|
+
|
|
|
|
+ if (this.$route.query.id) {
|
|
|
|
+ this.form.id = this.$route.query.id
|
|
|
|
+ this.getList()
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ // 详情
|
|
|
|
+ getList() {
|
|
|
|
+ detail(this.form.id).then(res => {
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
+ this.form = res.data
|
|
|
|
+ this.isFreeContentVip = res.data.isFreeContentVip === 1 ? true : false
|
|
|
|
+ this.disableVip = this.isFreeContentVip
|
|
|
|
+
|
|
|
|
+ this.deviceIds = res.data.deviceIds.split(',')
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 流量套餐
|
|
|
|
+ getGoodSList(e) {
|
|
|
|
+ goodsList(e).then(res => {
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
+ this.goodsOptions = res.data
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 爱听专区
|
|
|
|
+ getSceneList() {
|
|
|
|
+ list().then(res => {
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
+ res.data.map(i => {
|
|
|
|
+ this.sceneOptions.push({
|
|
|
|
+ value: i.id,
|
|
|
|
+ label: i.name
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ // 会员套餐
|
|
|
|
+ getDeviceGoodsList(deviceIds, businessType, isFreeContentVip) {
|
|
|
|
+ if ((deviceIds ?? []).length === 0 || (businessType ?? -1) < 0 || (isFreeContentVip ?? false) != true) {
|
|
|
|
+ console.log('设备id或业务类型为空', deviceIds, businessType, isFreeContentVip)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ console.log('开始请求', this.typeList[0], deviceIds.join(","), businessType, isFreeContentVip)
|
|
|
|
+
|
|
|
|
+ deviceGoodsList(1, businessType, deviceIds.join(",")).then((res) => {
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
+ console.log("获取到流量套餐:", this.form.freeActivityId);
|
|
|
|
+ // 如果返回的数据为空数组,确保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 = null;
|
|
|
|
+ }
|
|
|
|
+ // 如果freeOptions有值且freeActivityId有值,检查是否存在对应的选项
|
|
|
|
+ else if (!(this.form.freeActivityId === null || 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 = null;
|
|
|
|
+ } else {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 提交
|
|
|
|
+ getSubmit() {
|
|
|
|
+ this.$refs.form.validate((valid) => {
|
|
|
|
+ if (valid) {
|
|
|
|
+ this.form.deviceIds = this.deviceIds.join(',')
|
|
|
|
+ this.form.platformIds = JSON.stringify(this.platformIds)
|
|
|
|
+ this.form.isFreeContentVip = this.isFreeContentVip ? 1 : 0
|
|
|
|
+ if (this.form.id) {
|
|
|
|
+ edit(this.form).then(res => {
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
+ this.$message.success('修改成功!')
|
|
|
|
+ this.cancel()
|
|
|
|
+ } else {
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ create(this.form).then(res => {
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
+ this.$message.success('新增成功!')
|
|
|
|
+ this.cancel()
|
|
|
|
+ } else {
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 取消
|
|
|
|
+ cancel() {
|
|
|
|
+ let url = this.typeList[0] === '13' ? 'musicPackage' : 'flowPackage'
|
|
|
|
+ this.$tab.closeOpenPage(`/service/${url}?typeList=${this.typeList}`);
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 禁止修改
|
|
|
|
+ disabled() {
|
|
|
|
+ return this.form.id ? true : false
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style lang="scss" scoped>
|
|
|
|
+.el-form {
|
|
|
|
+ width: 500px;
|
|
|
|
+}
|
|
|
|
+</style>
|