广告详情页修改

This commit is contained in:
yulixing 2019-07-17 19:39:57 +08:00
parent 2a3658f756
commit d7cdb1a889
5 changed files with 69 additions and 50 deletions

BIN
dist.zip Normal file

Binary file not shown.

View File

@ -1,6 +1,9 @@
<template>
<div class="app-container">
<h2>投放设置<span style="font-size: 12px;" v-if="this.adForm.companyid && !writeable">(公司ID {{this.adForm.companyid}})</span></h2>
<h2>投放设置<span
style="font-size: 12px;"
v-if="this.adForm.companyid && !writeable"
>(公司ID {{this.adForm.companyid}})</span></h2>
<el-form
ref="adForm"
@ -115,6 +118,8 @@
:on-success="uploadSuccess"
:on-error="uploadErr"
:disabled="!writeable"
:show-file-list="false"
:before-upload="beforeUpload"
>
<img
v-if="adForm.ad_image"
@ -126,6 +131,7 @@
class="el-icon-plus uploader-icon"
/>
</el-upload>
<span class="ipt-tip" style="margin-top: 6px;">只能上传小于 600k 的图片</span>
</el-form-item>
<el-form-item
label="跳转链接"
@ -225,33 +231,41 @@ export default {
companyid: 0
},
adFormRules: {
name: [{ required: true, message: '请输入公司名', trigger: 'blur' }],
name: [{ required: true, message: '请输入广告名称', trigger: 'blur' }],
gameid: [
{ required: true, message: '请输入联系人', trigger: 'blur' },
{ type: 'number', 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_title: [
{ required: true, message: '请输入联系人', trigger: 'blur' }
{ required: true, message: '请输入广告标题', trigger: 'blur' }
],
ad_body: [
{ required: true, message: '请输入广告正文', trigger: 'blur' }
],
ad_body: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
ad_image: [
{ required: true, message: '请输入联系人', trigger: 'blur' }
{ required: true, message: '请上传广告头像', trigger: 'blur' }
],
ad_url: [
{ required: true, message: '请输入跳转链接', trigger: 'blur' }
],
ad_url: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
ad_num: [
{ type: 'number', message: '状态必须是数值', trigger: 'blur' }
],
status: [{ type: 'number', message: '状态必须是数值', trigger: 'blur' }]
{ type: 'number', message: '计划书必须是数值', trigger: 'blur' }
]
}
}
},
async mounted() {
const gameList = await this.getGameList()
this.gameList = gameList
this.gameList = gameList.map(item => {
return {
game: `${item.game}(${item.platform_name})`,
game_id: `${item.game_id}:${item.platform_id}`
}
})
const pos = await this.getAdPos()
this.locationList = pos.message.map(item => {
@ -261,11 +275,15 @@ export default {
return item
})
const roles = this.$store.getters.roles
const isAdmin = roles.includes('admin')
const username = this.$store.getters.username
const companyResult = await this.getComList({ user: username })
const company = companyResult.message[0]
if (company && company.status === 1) {
this.companyid = parseInt(company.id)
} else if (isAdmin) {
this.companyid = 0
} else {
this.$message.error('公司未通过审核,请先认证!')
this.$router.push('/company')
@ -275,22 +293,17 @@ export default {
if (ad_id) {
const ad = await this.getAd({ id: ad_id })
const adData = JSON.parse(JSON.stringify(ad.message[0]))
console.log(adData)
adData.dateRange = [
this.formDate(adData.begin_time),
this.formDate(adData.end_time)
]
this.adForm = adData
console.log(this.adForm)
} else {
this.adForm.companyid = company ? parseInt(company.id) : 0
}
this.writeable = this.companyid === this.adForm.companyid ? true : false
},
methods: {
// common
@ -389,9 +402,21 @@ export default {
this.$router.go(-1)
},
formDate(date) {
return moment(date).utc().zone(+0).format('YYYY-MM-DD HH:mm:ss')
return moment(date)
.utc()
.zone(+0)
.format('YYYY-MM-DD HH:mm:ss')
},
// form
beforeUpload(file) {
const isLt600k = file.size / 1024 / 1024 < 0.6
if (!isLt600k) {
this.$message.error('广告头像不可超过 600k!')
}
return isLt600k
},
uploadSuccess(res, file) {
this.adForm.ad_image = res.message.url
this.$message.success('图片上传成功!')
@ -409,7 +434,6 @@ export default {
this.adForm.begin_time = this.adForm.dateRange[0]
this.adForm.end_time = this.adForm.dateRange[1]
// delete this.adForm.dateRange
console.log('submit', this.adForm)
if (this.adForm.id) {
this.adForm.status = 0
const result = await this.updateAd(this.adForm)

View File

@ -167,6 +167,11 @@
fixed="right"
>
<template slot-scope="scope">
<el-button
type="text"
size="small"
@click.stop="view(scope.row)"
>详情</el-button>
<el-button
type="text"
size="small"
@ -249,7 +254,8 @@ export default {
async mounted() {
const gameList = await this.getGameList()
gameList.map(item => {
this.gameList[item.game_id] = item.game
const key = `${item.game_id}:${item.platform_id}`
this.gameList[key] = `${item.game}(${item.platform_name})`
})
const pos = await this.getAdPos()
@ -397,7 +403,12 @@ export default {
}
},
formDate(row, column, cellValue, index) {
return cellValue ? moment(cellValue).utc().zone(+0).format('YYYY-MM-DD HH:mm:ss') : '-'
return cellValue
? moment(cellValue)
.utc()
.zone(+0)
.format('YYYY-MM-DD HH:mm:ss')
: '-'
},
formGame(row, column, cellValue, index) {
return `${this.gameList[cellValue]}`
@ -417,7 +428,6 @@ export default {
view(row) {
this.$router.push(`/ad/edit?ad_id=${row.id}`)
},
del(row) {
this.$confirm(`是否删除【${row.name}】的广告信息?`, '提示', {
confirmButtonText: '确定',

View File

@ -259,8 +259,10 @@ export default {
},
async mounted() {
const gameList = await this.getGameList()
gameList.map(item => {
this.gameList[item.game_id] = item.game
const key = `${item.game_id}:${item.platform_id}`
this.gameList[key] = `${item.game}(${item.platform_name})`
})
const pos = await this.getAdPos()
@ -474,7 +476,12 @@ export default {
}
},
formDate(row, column, cellValue, index) {
return cellValue ? moment(cellValue).utc().zone(+0).format('YYYY-MM-DD HH:mm:ss') : '-'
return cellValue
? moment(cellValue)
.utc()
.zone(+0)
.format('YYYY-MM-DD HH:mm:ss')
: '-'
},
formGame(row, column, cellValue, index) {
return `${this.gameList[cellValue]}`
@ -492,8 +499,7 @@ export default {
this.multipleSelection = val
},
view(row) {
this.modalForm = JSON.parse(JSON.stringify(row))
this.openModal()
this.$router.push(`/ad/edit?ad_id=${row.id}`)
},
approve(row) {
this.$confirm(`是否通过【${row.name}】的审核申请?`, '提示', {
@ -598,27 +604,6 @@ export default {
const start = this.pageSize * (this.currentPage - 1)
const end = this.pageSize * this.currentPage
this.showData = this.tableData.slice(start, end)
},
// modal
openModal() {
this.modalVisible = true
},
closeModal() {
this.modalVisible = false
this.clearValidate('modalForm')
},
async save() {
try {
const valid = await this.validate('modalForm')
if (valid) {
const result = await this.updateAd(this.modalForm)
this.closeModal()
this.refreshData()
this.$message.success('保存成功!')
}
} catch (err) {
console.log(err)
}
}
}
}

View File

@ -40,7 +40,7 @@ module.exports = {
// change xxx-api/login => mock/login
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: {
target: `http://ad.kingsome.cn/`,
target: `http://154.8.214.202:5015/interface`,
changeOrigin: true,
pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: '',