Commit a637534e by wangyalan-git

评论管理模块/资讯管理模块

parent 72b977bd
...@@ -13,7 +13,8 @@ export default { ...@@ -13,7 +13,8 @@ export default {
return { return {
flag: true, flag: true,
tinymceId: tinymceId, tinymceId: tinymceId,
myEditor: null myEditor: null,
resourcesUrl: window.SITE_CONFIG.resourcesUrl,
} }
}, },
props: { props: {
...@@ -53,8 +54,10 @@ export default { ...@@ -53,8 +54,10 @@ export default {
} }
const formData = new FormData() const formData = new FormData()
formData.append('editorFile', blobInfo.blob()) formData.append('editorFile', blobInfo.blob())
formData.append('file', blobInfo.blob())
formData.append('fileType', 'tinymce')
this.$http({ this.$http({
url: this.$http.adornUrl(`/admin/file/upload/tinymceEditor`), url: this.$http.adornUrl(`/fileBapi/upload`),
headers: { headers: {
'Content-Type': 'multipart/form-data', 'Content-Type': 'multipart/form-data',
'token': this.$cookie.get('token') 'token': this.$cookie.get('token')
...@@ -62,7 +65,7 @@ export default { ...@@ -62,7 +65,7 @@ export default {
method: 'post', method: 'post',
data: formData data: formData
}).then(({ data }) => { }).then(({ data }) => {
success(data) success(this.resourcesUrl + data.result.filePath)
}).catch(() => { }).catch(() => {
failure('服务器出了点小差') failure('服务器出了点小差')
}) })
......
export const tableOption = {
border: true,
index: true,
indexLabel: '序号',
stripe: true,
menuAlign: 'center',
align: 'center',
addBtn: false,
editBtn: false,
delBtn: false,
column: [
{
label: '用户昵称',
prop: 'nickName'
},
{
label: '用户头像',
prop: 'pic',
slot: true
},
{
label: '资讯标题',
prop: 'consultTitle',
},
{
label: '评论内容',
prop: 'content'
},
{
label: '评论时间',
prop: 'createTime'
},
{
label: '状态',
prop: 'status',
search: true,
slot: true,
type: 'select',
dicData: [
{
label: '启用',
value: 0
}, {
label: '禁用',
value: 1
}
]
},
]
}
export const tableOption = {
border: true,
index: true,
indexLabel: '序号',
stripe: true,
menuAlign: 'center',
align: 'center',
addBtn: false,
editBtn: false,
delBtn: false,
column: [
{
label: '资讯标题',
prop: 'title',
search: true
},
{
label: '标题主图',
prop: 'pic',
slot: true
},
{
label: '点赞数',
prop: 'praiseNumber'
},
{
label: '评论数',
prop: 'commentNumber'
},
{
label: '状态',
prop: 'status',
search: true,
slot: true,
type: 'select',
dicData: [
{
label: '启用',
value: 0
}, {
label: '禁用',
value: 1
}
]
},
{
label: '资讯类型',
prop: 'type',
search: true,
slot: true,
type: 'select',
dicData: [
{
label: '全供头条',
value: 1
}, {
label: '热议专区',
value: 2
}
]
},
{
label: '评论状态',
prop: 'commentStatus',
search: true,
slot: true,
type: 'select',
dicData: [
{
label: '启用',
value: 0
}, {
label: '禁用',
value: 1
}
]
},
{
label: '时间',
prop: 'createTime'
},
]
}
<template>
<div class="mod-shop-notice">
<avue-crud ref="crud"
:page="page"
:data="dataList"
:table-loading="dataListLoading"
:option="tableOption"
@search-change="searchChange"
@on-load="getDataList"
@refresh-change="refreshChange">
<template slot-scope="scope"
slot="pic">
<img :src="scope.row.pic" style="width: 60px;" alt="">
</template>
<template slot-scope="scope"
slot="status">
<el-tag v-if="scope.row.status === 0"
size="small"
>启用</el-tag>
<el-tag v-else
size="small"
type="danger">禁用</el-tag>
</template>
<template slot-scope="scope"
slot="menu">
<el-button v-if="isAuth('shop:notice:update')"
type="primary"
size="small"
icon="el-icon-edit"
@click="addOrUpdateHandle(scope.row.id, scope.row.status)">{{scope.row.status == 1? '启用': '禁用'}}</el-button>
<el-button v-if="isAuth('shop:notice:delete')"
type="danger"
icon="el-icon-delete"
size="small"
@click.stop="deleteHandle(scope.row.id)">删除</el-button>
</template>
</avue-crud>
<!-- <add-or-update v-if="addOrUpdateVisible"-->
<!-- ref="addOrUpdate"-->
<!-- @refreshDataList="refreshChange"></add-or-update>-->
</div>
</template>
<script>
import { tableOption } from '@/crud/shop/comments'
// import AddOrUpdate from './comments-add-or-update'
export default {
data () {
return {
dataList: [],
page: {
total: 0, // 总页数
currentPage: 1, // 当前页数
pageSize: 10 // 每页显示多少条
},
dataListLoading: false,
tableOption: tableOption,
permission: {
delBtn: this.isAuth('shop:notice:delete')
},
addOrUpdateVisible: false
}
},
components: {
// AddOrUpdate
},
created () {
},
mounted () {
},
methods: {
getDataList (page, params) {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/consultComment/getListPage'),
method: 'get',
params: this.$http.adornParams(Object.assign({
current: page == null ? this.page.currentPage : page.currentPage,
size: page == null ? this.page.pageSize : page.pageSize
}, params))
}).then(({ data }) => {
this.dataList = data.records
this.page.total = data.total
this.dataListLoading = false
})
},
// 新增 / 修改
addOrUpdateHandle (id,status) {
let content = ''
if(status == 1){
content = '确定启用该条评论吗'
}else{
content = '确定禁用该条评论吗'
}
this.$confirm(content , '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http({
url: this.$http.adornUrl('/consultComment/updateComment'),
method: 'post',
data: this.$http.adornData({id: id,status: status ? 0: 1})
}).then(({ data }) => {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.getDataList()
}
})
})
}).catch(() => { })
// this.addOrUpdateVisible = true
// this.$nextTick(() => {
// this.$refs.addOrUpdate.init(id)
// })
},
deleteHandle (id) {
this.$confirm('确定进行删除操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http({
url: this.$http.adornUrl('/consultComment/deleteCommentById?id='+id),
method: 'post',
data: this.$http.adornData({id: id})
}).then(({ data }) => {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.getDataList()
}
})
})
}).catch(() => { })
},
/**
* 刷新回调
*/
refreshChange () {
this.getDataList(this.page)
},
searchChange (params) {
this.getDataList(this.page, params)
}
}
}
</script>
<style lang="scss" scoped>
</style>
<template>
<el-dialog :title="!dataForm.id ? '新增' : '修改'"
:close-on-click-modal="false"
:visible.sync="visible">
<el-form :model="dataForm"
:rules="dataRule"
ref="dataForm"
@keyup.enter.native="dataFormSubmit()"
label-width="100px">
<el-form-item label="资讯标题"
prop="title">
<el-input v-model="dataForm.title"></el-input>
</el-form-item>
<el-row type="flex">
<el-col :spsn="12">
<el-form-item label="标题图标">
<pic-upload v-model="dataForm.icon" fileType="news"></pic-upload>
</el-form-item>
</el-col>
<el-col :spsn="12">
<el-form-item label="标题主图">
<pic-upload v-model="dataForm.pic" fileType="news"></pic-upload>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="类型"
prop="type">
<el-radio-group v-model="dataForm.type">
<el-radio :label="1">全供头条</el-radio>
<el-radio :label="2">热议专区</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="评论"
prop="commentStatus">
<el-radio-group v-model="dataForm.commentStatus">
<el-radio :label="0">启用</el-radio>
<el-radio :label="1">禁用</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="顺序"
prop="sort">
<el-input v-model="dataForm.sort"></el-input>
</el-form-item>
<el-form-item label="虚拟点赞数"
prop="inventNum">
<el-input type="number" v-model="dataForm.inventNum"></el-input>
</el-form-item>
<el-form-item label="状态"
prop="status">
<el-radio-group v-model="dataForm.status">
<el-radio :label="0">启用</el-radio>
<el-radio :label="1">禁用</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="说明"
prop="remark">
<el-input v-model="dataForm.remark"></el-input>
</el-form-item>
<el-form-item label="公告内容"
prop="content">
<tiny-mce v-model="dataForm.content"></tiny-mce>
</el-form-item>
</el-form>
<span slot="footer"
class="dialog-footer">
<el-button size="small"
@click="visible = false">取消</el-button>
<el-button size="small"
type="primary"
@click="dataFormSubmit()">确定</el-button>
</span>
</el-dialog>
</template>
<script>
import TinyMce from '@/components/tiny-mce'
import PicUpload from '@/components/pic-upload'
export default {
data () {
return {
visible: false,
roleList: [],
dataForm: {
"id": '',
"commentStatus": 0,
"content": "",
"icon": "",
"inventNum": 0,
"pic": "",
"remark": "",
"sort": 1,
"status": 0,
"title": "",
"type": 1
},
dataRule: {
}
}
},
components: {
TinyMce,
PicUpload
},
methods: {
init (id) {
this.dataForm.id = id || 0
this.visible = true
this.$nextTick(() => {
if (this.dataForm.id) {
this.$http({
url: this.$http.adornUrl('/consult/getOneById'),
method: 'get',
params: this.$http.adornParams({id: this.dataForm.id})
}).then(({ data }) => {
this.dataForm = data.result
})
} else {
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
this.dataForm.pic = ''
this.dataForm.icon = ''
this.dataForm.content = ''
})
}
})
},
// 表单提交
dataFormSubmit () {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
if(this.dataForm.id){
this.$http({
url: this.$http.adornUrl('/consult/updateConsultById'),
method: 'post',
data: this.$http.adornData(this.dataForm)
}).then(({ data }) => {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
this.dataForm.content = ''
}
})
})
}else {
this.$http({
url: this.$http.adornUrl('/consult/insertConsult'),
method: 'post',
data: this.$http.adornData(this.dataForm)
}).then(({ data }) => {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
this.dataForm.content = ''
}
})
})
}
}
})
}
}
}
</script>
<template>
<div class="mod-shop-notice">
<avue-crud ref="crud"
:page="page"
:data="dataList"
:table-loading="dataListLoading"
:option="tableOption"
@search-change="searchChange"
@on-load="getDataList"
@refresh-change="refreshChange">
<template slot-scope="scope"
slot="pic">
<img :src="scope.row.pic" style="width: 60px;" alt="">
</template>
<template slot-scope="scope"
slot="status">
<el-tag v-if="scope.row.status === 0"
size="small"
>启用</el-tag>
<el-tag v-else
size="small"
type="danger">禁用</el-tag>
</template>
<template slot-scope="scope"
slot="type">
<el-tag v-if="scope.row.type === 1"
size="small">全供头条</el-tag>
<el-tag v-else
size="small"
type="success">热议专区</el-tag>
</template>
<template slot-scope="scope"
slot="commentStatus">
<el-tag v-if="scope.row.commentStatus === 0"
size="small">启用</el-tag>
<el-tag v-else
size="small"
type="success">禁用</el-tag>
</template>
<template slot="menuLeft">
<el-button v-if="isAuth('shop:notice:save')"
type="primary"
size="small"
icon="el-icon-plus"
@click="addOrUpdateHandle()">新增</el-button>
</template>
<template slot-scope="scope"
slot="menu">
<el-button v-if="isAuth('shop:notice:update')"
type="primary"
size="small"
icon="el-icon-edit"
@click="addOrUpdateHandle(scope.row.id)">修改</el-button>
<el-button v-if="isAuth('shop:notice:delete')"
type="danger"
icon="el-icon-delete"
size="small"
@click.stop="deleteHandle(scope.row.id)">删除</el-button>
</template>
</avue-crud>
<add-or-update v-if="addOrUpdateVisible"
ref="addOrUpdate"
@refreshDataList="refreshChange"></add-or-update>
</div>
</template>
<script>
import { tableOption } from '@/crud/shop/news'
import AddOrUpdate from './news-add-or-update'
export default {
data () {
return {
dataList: [],
page: {
total: 0, // 总页数
currentPage: 1, // 当前页数
pageSize: 10 // 每页显示多少条
},
dataListLoading: false,
tableOption: tableOption,
permission: {
delBtn: this.isAuth('shop:notice:delete')
},
addOrUpdateVisible: false
}
},
components: {
AddOrUpdate
},
created () {
},
mounted () {
},
methods: {
getDataList (page, params) {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/consult/getListPage'),
method: 'get',
params: this.$http.adornParams(Object.assign({
current: page == null ? this.page.currentPage : page.currentPage,
size: page == null ? this.page.pageSize : page.pageSize
}, params))
}).then(({ data }) => {
this.dataList = data.records
this.page.total = data.total
this.dataListLoading = false
})
},
// 新增 / 修改
addOrUpdateHandle (id) {
this.addOrUpdateVisible = true
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id)
})
},
deleteHandle (id) {
this.$confirm('确定进行删除操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http({
url: this.$http.adornUrl('/consult/deleteById?id='+id),
method: 'post',
data: this.$http.adornData({id: id})
}).then(({ data }) => {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.getDataList()
}
})
})
}).catch(() => { })
},
/**
* 刷新回调
*/
refreshChange () {
this.getDataList(this.page)
},
searchChange (params) {
this.getDataList(this.page, params)
}
}
}
</script>
<style lang="scss" scoped>
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment