限制分享类型选择

This commit is contained in:
yulixing 2019-06-06 19:31:25 +08:00
parent 669519c38a
commit 20c8b4d5d8
2 changed files with 41 additions and 8 deletions

View File

@ -11,7 +11,12 @@
<el-input v-model="gameInfo.game_name" disabled/> <el-input v-model="gameInfo.game_name" disabled/>
</el-form-item> </el-form-item>
<el-form-item label="分享类型" prop="share_type"> <el-form-item label="分享类型" prop="share_type">
<el-select v-model="shareForm.share_type" placeholder="请选择分享类型" style="width: 100%"> <el-select
v-model="shareForm.share_type"
placeholder="请选择分享类型"
style="width: 100%"
@change="changeShareType"
>
<el-option <el-option
v-for="(item,index) in shareTypes" v-for="(item,index) in shareTypes"
:key="index" :key="index"
@ -88,7 +93,6 @@
</el-row> </el-row>
<el-button v-if="permEdit" size="mini" @click="addShareGroup">添加分享语</el-button> <el-button v-if="permEdit" size="mini" @click="addShareGroup">添加分享语</el-button>
</el-form-item> </el-form-item>
<div v-if="!onlyShare"> <div v-if="!onlyShare">
<el-form-item label="广告 ID" prop="ad_id"> <el-form-item label="广告 ID" prop="ad_id">
<el-input v-model="shareForm.ad_id"/> <el-input v-model="shareForm.ad_id"/>
@ -112,7 +116,6 @@
<el-button @click="goBack">返回</el-button> <el-button @click="goBack">返回</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- Modal - 编辑分享类型 --> <!-- Modal - 编辑分享类型 -->
<el-dialog title="分享类型列表" :visible.sync="modalShareTypeVisible" width="35%"> <el-dialog title="分享类型列表" :visible.sync="modalShareTypeVisible" width="35%">
<el-button v-if="permEdit" type="primary" @click="addShareType">新增</el-button> <el-button v-if="permEdit" type="primary" @click="addShareType">新增</el-button>
@ -142,7 +145,7 @@
:visible.sync="modalShareTypeEditVisible" :visible.sync="modalShareTypeEditVisible"
append-to-body append-to-body
:before-close="closeShareTypeEditModal" :before-close="closeShareTypeEditModal"
width="35%" width="35%"
> >
<el-form <el-form
ref="shareTypeForm" ref="shareTypeForm"
@ -163,7 +166,7 @@
</span> </span>
</el-dialog> </el-dialog>
<!-- Modal - 编辑地域 --> <!-- Modal - 编辑地域 -->
<el-dialog title="地域列表" :visible.sync="modalAreaVisible" width="35%"> <el-dialog title="地域列表" :visible.sync="modalAreaVisible" width="35%">
<el-button v-if="permEdit" type="primary" @click="addArea">新增</el-button> <el-button v-if="permEdit" type="primary" @click="addArea">新增</el-button>
<el-table <el-table
:data="areas" :data="areas"
@ -190,7 +193,7 @@
:visible.sync="modalAreaEditVisible" :visible.sync="modalAreaEditVisible"
append-to-body append-to-body
:before-close="closeModalAreaEdit" :before-close="closeModalAreaEdit"
width="35%" width="35%"
> >
<el-form ref="areaForm" :model="areaForm" :rules="areaFormRules" label-width="50px"> <el-form ref="areaForm" :model="areaForm" :rules="areaFormRules" label-width="50px">
<el-form-item label="说明" prop="name"> <el-form-item label="说明" prop="name">
@ -269,7 +272,8 @@ import {
delShareType, delShareType,
getShare, getShare,
saveShare, saveShare,
updateShare updateShare,
getShareList
} from '@/api/share' } from '@/api/share'
import { getGame } from '@/api/games' import { getGame } from '@/api/games'
import { getRegions, saveArea, getAreas, delArea } from '@/api/common' import { getRegions, saveArea, getAreas, delArea } from '@/api/common'
@ -289,6 +293,8 @@ export default {
areas: [], areas: [],
token: '', token: '',
onlyShare: false, onlyShare: false,
curShareType: '',
selectedShareType: [],
// main // main
shareForm: { shareForm: {
default_share: false, default_share: false,
@ -417,6 +423,7 @@ export default {
this.$route.meta.title = this.gameInfo.game_name this.$route.meta.title = this.gameInfo.game_name
if (this.$route.query.id && this.$route.query.id !== 'new') { if (this.$route.query.id && this.$route.query.id !== 'new') {
this.getShare() this.getShare()
this.getShareList()
} }
} }
}) })
@ -476,6 +483,7 @@ export default {
share_image: this.shareForm.share_images[i] share_image: this.shareForm.share_images[i]
}) })
} }
this.curShareType = this.shareForm.share_type
if (this.shareForm.type === 2) this.onlyShare = true if (this.shareForm.type === 2) this.onlyShare = true
} }
}) })
@ -483,9 +491,32 @@ export default {
console.log(err) console.log(err)
}) })
}, },
getShareList() {
getShareList({
uid: this.uid,
gameId: this.gameInfo.game_id
})
.then(res => {
const data = res.data
if (data.errcode === 0) {
this.selectedShareType = data.records.map(item => {
return item.share_type
})
}
})
.catch(err => {
console.log(err)
})
},
changeType(val) { changeType(val) {
val === 2 ? (this.onlyShare = true) : (this.onlyShare = false) val === 2 ? (this.onlyShare = true) : (this.onlyShare = false)
}, },
changeShareType(val) {
if (this.selectedShareType.includes(val) && this.curShareType !== val) {
this.shareForm.share_type = ''
this.$message.error('已有此分享类型,请选择其他分享类型!')
}
},
submitForm(formName) { submitForm(formName) {
if (this.shareGroups.length > 0) { if (this.shareGroups.length > 0) {
this.shareForm.share_word = this.shareGroups[0].share_word this.shareForm.share_word = this.shareGroups[0].share_word
@ -524,6 +555,8 @@ export default {
if (data.errcode === 0) { if (data.errcode === 0) {
this.$message.success('分享图更新成功!') this.$message.success('分享图更新成功!')
this.$refs['shareForm'].clearValidate() this.$refs['shareForm'].clearValidate()
this.curShareType = this.shareForm.share_type
this.getShareList()
} }
}) })
.catch(err => { .catch(err => {

View File

@ -62,7 +62,7 @@
</el-table-column> </el-table-column>
<el-table-column prop="ad_id" label="广告ID" show-overflow-tooltip sortable/> <el-table-column prop="ad_id" label="广告ID" show-overflow-tooltip sortable/>
<el-table-column <el-table-column
prop="name" prop="default_share"
label="默认分享" label="默认分享"
show-overflow-tooltip show-overflow-tooltip
sortable sortable