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

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'
# upload
VUE_APP_UPLOAD = '/upload/cos'
# VUE_APP_UPLOAD = '/upload/cos'
VUE_APP_UPLOAD = 'http://promotion.kingsome.cn/interface/cos_upload'
# area api
VUE_APP_MP = '/mp'

View File

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

View File

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

View File

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

View File

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

Binary file not shown.