修复暂停/启用显示 表单提交验证

This commit is contained in:
yulixing 2019-09-05 16:57:44 +08:00
parent f95aef88ae
commit c9f34d573c
6 changed files with 88 additions and 49 deletions

View File

@ -11,7 +11,8 @@ VUE_APP_LDAP_USER = 'ops-apiuser'
VUE_APP_LDAP_PWD = 'hhsxafTuUtVV' VUE_APP_LDAP_PWD = 'hhsxafTuUtVV'
# upload # upload
VUE_APP_UPLOAD = '/upload/cos' # VUE_APP_UPLOAD = '/upload/cos'
VUE_APP_UPLOAD = 'http://promotion.kingsome.cn/interface/cos_upload'
# area api # area api
VUE_APP_MP = '/mp' VUE_APP_MP = '/mp'

View File

@ -195,7 +195,7 @@
</el-form-item> </el-form-item>
<el-form-item <el-form-item
label="跳转参数" label="跳转参数"
prop="jump_param" prop="ad_property.jump_param"
v-if="adForm.jump_status === 1" v-if="adForm.jump_status === 1"
> >
<el-input <el-input
@ -282,9 +282,9 @@
</template> </template>
<script> <script>
import { getAdPos, getAd, addAd, updateAd, getAdAreaList } from '@/api/ad' import {getAdPos, getAd, addAd, updateAd, getAdAreaList} from '@/api/ad'
import { getGameList } from '@/api/game' import {getGameList} from '@/api/game'
import { typeList, modeList } from '@/utils/ad-data' import {typeList, modeList} from '@/utils/ad-data'
import moment from 'moment' import moment from 'moment'
export default { export default {
@ -293,13 +293,23 @@ export default {
const validateJumpParams = (rule, value, callback) => { const validateJumpParams = (rule, value, callback) => {
if ( if (
this.adForm.jump_status === 1 && this.adForm.jump_status === 1 &&
(this.adForm.jump_param === '' || this.adForm.ad_property.appid === '') this.adForm.ad_property.jump_param === ''
) { ) {
callback(new Error('请填写跳转参数')) callback(new Error('请填写跳转参数'))
} else { } else {
callback() callback()
} }
} }
const validateAppId = (rule, value, callback) => {
if (
this.adForm.jump_status === 1 &&
this.adForm.ad_property.appid === ''
) {
callback(new Error('请填写APPID'))
} else {
callback()
}
}
return { return {
//common //common
@ -337,49 +347,47 @@ export default {
is_new: 0, is_new: 0,
is_recommend: 0, is_recommend: 0,
appid: '', appid: '',
jump_param: '' jump_param: '',
} // }, //
}, },
adFormRules: { adFormRules: {
name: [{ required: true, message: '请输入广告名称', trigger: 'blur' }], name: [{required: true, message: '请输入广告名称', trigger: 'blur'}],
gameid: [ gameid: [{required: true, message: '请选择投放游戏', trigger: 'blur'}],
{ required: true, message: '请选择投放游戏', trigger: 'blur' }
],
channelid: [ channelid: [
{ required: true, message: '请选择投放平台', trigger: 'blur' } {required: true, message: '请选择投放平台', trigger: 'blur'},
], ],
locationid: [ locationid: [
{ required: true, message: '请选择投放位置', trigger: 'blur' }, {required: true, message: '请选择投放位置', trigger: 'blur'},
{ type: 'number', message: '投放位置必须是数值', trigger: 'blur' } {type: 'number', message: '投放位置必须是数值', trigger: 'blur'},
], ],
ad_image: [ ad_image: [
{ required: true, message: '请上传广告头像', trigger: 'blur' } {required: true, message: '请上传广告头像', trigger: 'blur'},
], ],
jump_param: [ jump_param: [
{ required: true, validator: validateJumpParams, trigger: 'blur' } {required: true, validator: validateJumpParams, trigger: 'blur'},
], ],
ad_num: [ ad_num: [
{ type: 'number', message: '计划数必须是数值', trigger: 'blur' } {type: 'number', message: '计划数必须是数值', trigger: 'blur'},
], ],
'ad_property.jump_param': [ 'ad_property.jump_param': [
{ required: true, validator: validateJumpParams, trigger: 'blur' } {required: true, validator: validateJumpParams, trigger: 'blur'},
], ],
'ad_property.appid': [ 'ad_property.appid': [
{ required: true, validator: validateJumpParams, trigger: 'blur' } {required: true, validator: validateAppId, trigger: 'blur'},
], ],
'ad_property.is_shake': [ 'ad_property.is_shake': [
{ type: 'number', message: '是否抖动必须是数值', trigger: 'blur' } {type: 'number', message: '是否抖动必须是数值', trigger: 'blur'},
], ],
'ad_property.is_hot': [ 'ad_property.is_hot': [
{ type: 'number', message: '是否热门必须是数值', trigger: 'blur' } {type: 'number', message: '是否热门必须是数值', trigger: 'blur'},
], ],
'ad_property.is_new': [ 'ad_property.is_new': [
{ type: 'number', message: '是否新游必须是数值', trigger: 'blur' } {type: 'number', message: '是否新游必须是数值', trigger: 'blur'},
], ],
'ad_property.is_recommend': [ 'ad_property.is_recommend': [
{ type: 'number', message: '是否推荐必须是数值', trigger: 'blur' } {type: 'number', message: '是否推荐必须是数值', trigger: 'blur'},
] ],
} },
} }
}, },
async mounted() { async mounted() {
@ -405,14 +413,14 @@ export default {
const platform = item.split('-') const platform = item.split('-')
return { return {
platform_id: parseInt(platform[0]), platform_id: parseInt(platform[0]),
platform_name: platform[1] platform_name: platform[1],
} }
}) })
let hasAd = true let hasAd = true
const ad_id = this.$route.query.ad_id const ad_id = this.$route.query.ad_id
if (ad_id) { if (ad_id) {
const ad = await this.getAd({ id: ad_id }) const ad = await this.getAd({id: ad_id})
if (ad.message.length === 0) { if (ad.message.length === 0) {
hasAd = false hasAd = false
return return
@ -420,7 +428,7 @@ export default {
const adData = JSON.parse(JSON.stringify(ad.message[0])) const adData = JSON.parse(JSON.stringify(ad.message[0]))
adData.dateRange = [ adData.dateRange = [
this.formDate(adData.begin_time), this.formDate(adData.begin_time),
this.formDate(adData.end_time) this.formDate(adData.end_time),
] ]
this.adForm = adData this.adForm = adData
this.adForm.ad_property = this.adForm.ad_property this.adForm.ad_property = this.adForm.ad_property
@ -434,7 +442,7 @@ export default {
is_new: 0, is_new: 0,
is_recommend: 0, is_recommend: 0,
appid: '', appid: '',
jump_param: '' jump_param: '',
} }
} }
@ -582,7 +590,7 @@ export default {
this.adForm.locationid = '' this.adForm.locationid = ''
const location = await this.getAdPos({ const location = await this.getAdPos({
channelid: this.adForm.channelid, channelid: this.adForm.channelid,
gameid: this.adForm.gameid gameid: this.adForm.gameid,
}) })
if (!location.message || location.message.length === 0) { if (!location.message || location.message.length === 0) {
this.locationList = [] this.locationList = []
@ -595,7 +603,7 @@ export default {
id: item.id, id: item.id,
label: `${this.areaList[area[0]]}-(${area[1]},${area[2]})-${ label: `${this.areaList[area[0]]}-(${area[1]},${area[2]})-${
this.modeList[item.mode] this.modeList[item.mode]
}` }`,
} }
}) })
}, },
@ -638,8 +646,8 @@ export default {
} catch (err) { } catch (err) {
console.log(err) console.log(err)
} }
} },
} },
} }
</script> </script>

View File

@ -166,6 +166,7 @@
prop="name" prop="name"
label="操作" label="操作"
fixed="right" fixed="right"
width="130"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -179,6 +180,12 @@
@click.stop="stop(scope.row)" @click.stop="stop(scope.row)"
v-if="scope.row.status === 1" v-if="scope.row.status === 1"
>暂停</el-button> >暂停</el-button>
<el-button
type="text"
size="small"
@click.stop="approve(scope.row)"
v-if="scope.row.status === 3"
>启用</el-button>
<el-button <el-button
type="text" type="text"
size="small" size="small"
@ -206,10 +213,10 @@
</template> </template>
<script> <script>
import { getAd, updateAd, delAd, getAdPos, getAdAreaList } from '@/api/ad' import {getAd, updateAd, delAd, getAdPos, getAdAreaList} from '@/api/ad'
import { getGameList } from '@/api/game' import {getGameList} from '@/api/game'
import { typeList, modeList } from '@/utils/ad-data' import {typeList, modeList} from '@/utils/ad-data'
import { Promise, reject } from 'q' import {Promise, reject} from 'q'
import moment from 'moment' import moment from 'moment'
export default { export default {
@ -227,16 +234,16 @@ export default {
'0': '按固定次数推广', '0': '按固定次数推广',
'1': '个性化推荐', '1': '个性化推荐',
'2': '长期推广', '2': '长期推广',
'3': '系统默认推广' '3': '系统默认推广',
}, },
// filter // filter
filterForm: { filterForm: {
status: '' status: '',
}, },
// toolbar // toolbar
batch: { batch: {
show: false, show: false,
txt: '批量操作' txt: '批量操作',
}, },
// table // table
tableData: [], tableData: [],
@ -246,7 +253,7 @@ export default {
// pagination // pagination
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: 10,
total: 0 total: 0,
} }
}, },
async mounted() { async mounted() {
@ -436,10 +443,10 @@ export default {
this.$confirm(`是否删除【${row.name}】的广告信息?`, '提示', { this.$confirm(`是否删除【${row.name}】的广告信息?`, '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning',
}) })
.then(async () => { .then(async () => {
const data = { id: row.id } const data = {id: row.id}
try { try {
const result = await this.delAd(data) const result = await this.delAd(data)
@ -457,7 +464,7 @@ export default {
this.$confirm(`是否暂停广告:【${row.name}】?`, '提示', { this.$confirm(`是否暂停广告:【${row.name}】?`, '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning',
}) })
.then(async () => { .then(async () => {
const data = JSON.parse(JSON.stringify(row)) const data = JSON.parse(JSON.stringify(row))
@ -476,6 +483,29 @@ export default {
this.$message.info('操作已取消!') this.$message.info('操作已取消!')
}) })
}, },
approve(row) {
this.$confirm(`是否启用【${row.name}】?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(async () => {
const data = JSON.parse(JSON.stringify(row))
data.status = 1
data.begin_time = this.formDate(null, null, data.begin_time)
data.end_time = this.formDate(null, null, data.end_time)
try {
const result = await this.updateAd(data)
this.$message.success('状态修改成功!')
this.refreshData()
} catch (err) {
console.log(err)
}
})
.catch(() => {
this.$message.info('操作已取消!')
})
},
// pagination // pagination
sizeChange(val) { sizeChange(val) {
this.pageSize = val this.pageSize = val
@ -489,8 +519,8 @@ export default {
const start = this.pageSize * (this.currentPage - 1) const start = this.pageSize * (this.currentPage - 1)
const end = this.pageSize * this.currentPage const end = this.pageSize * this.currentPage
this.showData = this.tableData.slice(start, end) this.showData = this.tableData.slice(start, end)
} },
} },
} }
</script> </script>

View File

@ -177,7 +177,7 @@
prop="name" prop="name"
label="操作" label="操作"
fixed="right" fixed="right"
width="220" width="180"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button

View File

@ -54,7 +54,7 @@ module.exports = {
}, },
}, },
[process.env.VUE_APP_UPLOAD]: { [process.env.VUE_APP_UPLOAD]: {
target: `http://192.168.100.20:9999`, target: `http://promotion.kingsome.cn/interface/cos_upload`,
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
'/upload': '', '/upload': '',

Binary file not shown.