ingame annc
This commit is contained in:
parent
02c8bd5114
commit
04e7d2ddd1
@ -23,3 +23,27 @@ export function updateAnnc(data) {
|
|||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function addIngameAnnc(data) {
|
||||||
|
return request({
|
||||||
|
url: '/annc/addIngameAnnc',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getIngameAnncList(data) {
|
||||||
|
return request({
|
||||||
|
url: '/annc/anncIngameList',
|
||||||
|
method: 'get',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateIngameAnnc(data) {
|
||||||
|
return request({
|
||||||
|
url: '/annc/updateIngameAnnc/' + data.idx,
|
||||||
|
method: 'put',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -160,6 +160,8 @@ export const asyncRoutes = [
|
|||||||
component: Layout,
|
component: Layout,
|
||||||
redirect: '/index',
|
redirect: '/index',
|
||||||
meta: {
|
meta: {
|
||||||
|
icon: 'documentation',
|
||||||
|
title: '公告',
|
||||||
pername: 'announcement'
|
pername: 'announcement'
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
@ -167,7 +169,13 @@ export const asyncRoutes = [
|
|||||||
path: 'index',
|
path: 'index',
|
||||||
component: () => import('@/views/announcement/index'),
|
component: () => import('@/views/announcement/index'),
|
||||||
name: 'Announcement',
|
name: 'Announcement',
|
||||||
meta: { title: '公告', icon: 'documentation', pername: 'announcement' }
|
meta: { title: '登录公告', pername: 'announcement' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'ingame',
|
||||||
|
component: () => import('@/views/ingameannouncement/index'),
|
||||||
|
name: 'IngameAnnouncement',
|
||||||
|
meta: { title: '游戏内公告', pername: 'announcement' }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}, {
|
}, {
|
||||||
|
241
src/views/ingameannouncement/index.vue
Normal file
241
src/views/ingameannouncement/index.vue
Normal file
@ -0,0 +1,241 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<div class="filter-container">
|
||||||
|
<el-button v-show="visibleAddannouncement" class="filter-item" style="margin-left: 10px;" type="primary" @click="handleCreate">
|
||||||
|
新增公告
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
<el-table
|
||||||
|
:data="anncList"
|
||||||
|
border
|
||||||
|
fit
|
||||||
|
highlight-current-row
|
||||||
|
style="width: 100%;"
|
||||||
|
>
|
||||||
|
<el-table-column
|
||||||
|
prop="title"
|
||||||
|
label="标题"
|
||||||
|
width="180"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="begin_time"
|
||||||
|
label="发送时间"
|
||||||
|
width="160"
|
||||||
|
>
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>
|
||||||
|
{{ parseTime(scope.row.begin_time) }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="end_time"
|
||||||
|
label="停止时间"
|
||||||
|
width="160"
|
||||||
|
>
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>
|
||||||
|
{{ parseTime(scope.row.end_time) }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="是否生效"
|
||||||
|
width="80"
|
||||||
|
align="center"
|
||||||
|
>
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<svg-icon v-if="scope.row.is_open === 1" icon-class="ok" style="font-size: 20px;" />
|
||||||
|
<svg-icon v-else icon-class="no" style="font-size: 20px;" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="公告内容"
|
||||||
|
prop="content"
|
||||||
|
:show-overflow-tooltip="true"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
fixed="right"
|
||||||
|
label="操作"
|
||||||
|
width="100"
|
||||||
|
>
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button v-show="visibleEditannouncement" type="text" size="small" @click="handleUpdate(scope.row)">编辑</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible">
|
||||||
|
<el-form ref="form" :rules="rules" :model="form" label-position="left" label-width="80px" style="width: 400px; margin-left:50px;">
|
||||||
|
<el-form-item label="公告标题" prop="title">
|
||||||
|
<el-input v-model="form.title" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label-width="120px" label="发送时间>=:" prop="begin_time">
|
||||||
|
<el-date-picker v-model.number="form.begin_time" type="datetime" format="yyyy-MM-dd HH:mm:ss" value-format="timestamp" placeholder="Select date and time" required />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label-width="120px" label="发送时间<=:" class="postInfo-container-item" prop="end_time">
|
||||||
|
<el-date-picker v-model.number="form.end_time" type="datetime" format="yyyy-MM-dd HH:mm:ss" value-format="timestamp" placeholder="Select date and time" required />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="是否生效">
|
||||||
|
<el-switch
|
||||||
|
v-model="form.is_open"
|
||||||
|
:active-value="1"
|
||||||
|
:inactive-value="0"
|
||||||
|
active-color="#13ce66"
|
||||||
|
inactive-color="#ff4949"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="公告内容" prop="content">
|
||||||
|
<el-input v-model="form.content" type="textarea" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="dialogFormVisible = false">
|
||||||
|
Cancel
|
||||||
|
</el-button>
|
||||||
|
<el-button type="primary" @click="dialogStatus==='create'?createData():updateData()">
|
||||||
|
Confirm
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// import Pagination from '@/components/Pagination/index.vue'
|
||||||
|
import { addIngameAnnc, getIngameAnncList, updateIngameAnnc } from '@/api/announcement'
|
||||||
|
import { Message } from 'element-ui'
|
||||||
|
import { checkuipermission } from '@/store/modules/permission'
|
||||||
|
import { parseTime } from '@/utils'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {
|
||||||
|
title: '',
|
||||||
|
begin_time: '',
|
||||||
|
end_time: '',
|
||||||
|
content: '',
|
||||||
|
is_open: 1
|
||||||
|
},
|
||||||
|
dialogFormVisible: false,
|
||||||
|
dialogStatus: '',
|
||||||
|
dialogTitle: '发布公告',
|
||||||
|
listLoading: true,
|
||||||
|
anncList: [],
|
||||||
|
visibleAddannouncement: false,
|
||||||
|
visibleEditannouncement: false,
|
||||||
|
rules: {
|
||||||
|
title: [{ required: true, message: 'required', trigger: 'blur' }],
|
||||||
|
begin_time: [{ required: true, message: 'required', trigger: 'blur' }],
|
||||||
|
end_time: [{ required: true, message: 'required', trigger: 'blur' }],
|
||||||
|
content: [{ required: true, message: 'required', trigger: 'blur' }]
|
||||||
|
},
|
||||||
|
data: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList()
|
||||||
|
if (checkuipermission('addannouncement')) {
|
||||||
|
this.visibleAddannouncement = true
|
||||||
|
} else {
|
||||||
|
this.visibleAddannouncement = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkuipermission('editannouncement')) {
|
||||||
|
this.visibleEditannouncement = true
|
||||||
|
} else {
|
||||||
|
this.visibleEditannouncement = false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
parseTime,
|
||||||
|
handleUpdate(row) {
|
||||||
|
console.log(row)
|
||||||
|
this.form.title = row.title
|
||||||
|
this.form.begin_time = row.begin_time * 1000
|
||||||
|
this.form.end_time = row.end_time * 1000
|
||||||
|
this.form.content = row.content
|
||||||
|
this.form.is_open = row.is_open
|
||||||
|
this.form.idx = row.idx
|
||||||
|
|
||||||
|
this.dialogStatus = 'update'
|
||||||
|
this.dialogTitle = '修改公告'
|
||||||
|
this.dialogFormVisible = true
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs['form'].clearValidate()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getList() {
|
||||||
|
getIngameAnncList().then(response => {
|
||||||
|
if (response.code === 0) {
|
||||||
|
this.anncList = response.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleCreate() {
|
||||||
|
this.resetTemp()
|
||||||
|
this.dialogStatus = 'create'
|
||||||
|
this.dialogTitle = '发布公告'
|
||||||
|
this.dialogFormVisible = true
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs['form'].clearValidate()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
resetTemp() {
|
||||||
|
this.form = {
|
||||||
|
title: '',
|
||||||
|
begin_time: '',
|
||||||
|
end_time: '',
|
||||||
|
content: '',
|
||||||
|
is_open: 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
createData() {
|
||||||
|
this.$refs['form'].validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
this.data = JSON.parse(JSON.stringify(this.form))
|
||||||
|
this.data.begin_time /= 1000
|
||||||
|
this.data.end_time /= 1000
|
||||||
|
addIngameAnnc(this.data).then(response => {
|
||||||
|
if (response.code === 0) {
|
||||||
|
this.dialogFormVisible = false
|
||||||
|
this.getList()
|
||||||
|
Message({
|
||||||
|
message: 'Created Successfully',
|
||||||
|
type: 'success',
|
||||||
|
duration: 2 * 1000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
updateData() {
|
||||||
|
this.$refs['form'].validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
this.data = JSON.parse(JSON.stringify(this.form))
|
||||||
|
this.data.begin_time /= 1000
|
||||||
|
this.data.end_time /= 1000
|
||||||
|
updateIngameAnnc(this.data).then(response => {
|
||||||
|
if (response.code === 0) {
|
||||||
|
this.dialogFormVisible = false
|
||||||
|
this.getList()
|
||||||
|
this.$notify({
|
||||||
|
title: 'Success',
|
||||||
|
message: 'Updated Successfully',
|
||||||
|
type: 'success',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
Loading…
x
Reference in New Issue
Block a user