Merge remote-tracking branch 'origin/master'

master
dsl 6 months ago
commit ac742bea17

@ -1,53 +1,81 @@
<template>
<!-- 主卡片容器用于包裹整个评论管理页面内容 -->
<el-card class="main-card">
<!-- 页面标题取自当前路由的名称 -->
<div class="title">{{ this.$route.name }}</div>
<!-- 评论状态筛选菜单 -->
<div class="review-menu">
<span>状态</span>
<!-- 全部评论筛选点击时重置审核状态为null添加激活样式 -->
<span @click="changeReview(null)" :class="isReview == null ? 'active-review' : 'review'"> 全部 </span>
<!-- 正常状态评论筛选点击时设置审核状态为1添加激活样式 -->
<span @click="changeReview(1)" :class="isReview == 1 ? 'active-review' : 'review'"> 正常 </span>
<!-- 审核中状态评论筛选点击时设置审核状态为0添加激活样式 -->
<span @click="changeReview(0)" :class="isReview == 0 ? 'active-review' : 'review'"> 审核中 </span>
</div>
<!-- 操作按钮区域 -->
<div class="operation-container">
<!-- 批量删除按钮当没有选中评论时禁用 -->
<el-button
type="danger"
size="small"
icon="el-icon-delete"
:disabled="commentIds.length == 0"
@click="remove = true">
type="danger"
size="small"
icon="el-icon-delete"
:disabled="commentIds.length == 0"
@click="remove = true">
批量删除
</el-button>
<!-- 批量通过按钮当没有选中评论时禁用 -->
<el-button
type="success"
size="small"
icon="el-icon-success"
:disabled="commentIds.length == 0"
@click="updateCommentReview(null)">
type="success"
size="small"
icon="el-icon-success"
:disabled="commentIds.length == 0"
@click="updateCommentReview(null)">
批量通过
</el-button>
<!-- 右侧搜索区域 -->
<div style="margin-left: auto">
<!-- 评论来源筛选下拉框 -->
<el-select clearable v-model="type" placeholder="请选择来源" size="small" style="margin-right: 1rem">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
<!-- 评论搜索输入框支持回车搜索 -->
<el-input
v-model="keywords"
prefix-icon="el-icon-search"
size="small"
placeholder="请输入用户昵称"
style="width: 200px"
@keyup.enter.native="searchComments" />
v-model="keywords"
prefix-icon="el-icon-search"
size="small"
placeholder="请输入用户昵称"
style="width: 200px"
@keyup.enter.native="searchComments" />
<!-- 搜索按钮 -->
<el-button type="primary" size="small" icon="el-icon-search" style="margin-left: 1rem" @click="searchComments">
搜索
</el-button>
</div>
</div>
<!-- 评论列表表格加载时显示loading状态支持选择功能 -->
<el-table border :data="comments" @selection-change="selectionChange" v-loading="loading">
<!-- 选择列 -->
<el-table-column type="selection" width="55" />
<!-- 头像列 -->
<el-table-column prop="avatar" label="头像" align="center" width="120">
<template slot-scope="scope">
<img :src="scope.row.avatar" width="40" height="40" />
</template>
</el-table-column>
<!-- 评论人列 -->
<el-table-column prop="nickname" label="评论人" align="center" width="120" />
<!-- 回复人列若无回复人显示"无" -->
<el-table-column prop="replyNickname" label="回复人" align="center" width="120">
<template slot-scope="scope">
<span v-if="scope.row.replyNickname">
@ -56,6 +84,8 @@
<span v-else></span>
</template>
</el-table-column>
<!-- 文章标题列若无关联文章显示"无" -->
<el-table-column prop="articleTitle" label="文章标题" align="center">
<template slot-scope="scope">
<span v-if="scope.row.articleTitle">
@ -64,23 +94,31 @@
<span v-else></span>
</template>
</el-table-column>
<!-- 评论内容列使用v-html渲染富文本内容 -->
<el-table-column prop="commentContent" label="评论内容" align="center">
<template slot-scope="scope">
<span v-html="scope.row.commentContent" class="comment-content" />
</template>
</el-table-column>
<!-- 评论时间列使用date过滤器格式化时间 -->
<el-table-column prop="createTime" label="评论时间" width="150" align="center">
<template slot-scope="scope">
<i class="el-icon-time" style="margin-right: 5px" />
{{ scope.row.createTime | date }}
</template>
</el-table-column>
<!-- 状态列使用标签显示审核状态 -->
<el-table-column prop="isReview" label="状态" width="80" align="center">
<template slot-scope="scope">
<el-tag v-if="scope.row.isReview == 0" type="warning"></el-tag>
<el-tag v-if="scope.row.isReview == 1" type="success"></el-tag>
</template>
</el-table-column>
<!-- 来源列使用标签显示评论来源类型 -->
<el-table-column label="来源" align="center" width="100">
<template slot-scope="scope">
<el-tag v-if="scope.row.type == 1"></el-tag>
@ -90,32 +128,41 @@
<el-tag v-if="scope.row.type == 5" type="warning"></el-tag>
</template>
</el-table-column>
<!-- 操作列 -->
<el-table-column label="操作" width="160" align="center">
<template slot-scope="scope">
<!-- 通过按钮仅对审核中状态的评论显示 -->
<el-button
v-if="scope.row.isReview == 0"
size="mini"
type="success"
slot="reference"
@click="updateCommentReview(scope.row.id)">
v-if="scope.row.isReview == 0"
size="mini"
type="success"
slot="reference"
@click="updateCommentReview(scope.row.id)">
通过
</el-button>
<!-- 删除确认弹窗触发器 -->
<el-popconfirm style="margin-left: 10px" title="确定删除吗?" @confirm="deleteComments(scope.row.id)">
<el-button size="mini" type="danger" slot="reference"> 删除 </el-button>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
<!-- 分页组件 -->
<el-pagination
class="pagination-container"
background
@size-change="sizeChange"
@current-change="currentChange"
:current-page="current"
:page-size="size"
:total="count"
:page-sizes="[10, 20]"
layout="total, sizes, prev, pager, next, jumper" />
class="pagination-container"
background
@size-change="sizeChange" <!-- 每页条数改变事件 -->
@current-change="currentChange" <!-- 当前页码改变事件 -->
:current-page="current" <!-- 当前页码 -->
:page-size="size" <!-- 每页条数 -->
:total="count" <!-- 总条数 -->
:page-sizes="[10, 20]" <!-- 可选每页条数 -->
layout="total, sizes, prev, pager, next, jumper" /> <!-- 分页布局 -->
<!-- 批量删除确认弹窗 -->
<el-dialog :visible.sync="remove" width="30%">
<div class="dialog-title-container" slot="title"><i class="el-icon-warning" style="color: #ff9900" />提示</div>
<div style="font-size: 1rem">是否彻底删除选中项</div>
@ -129,15 +176,19 @@
<script>
export default {
//
created() {
//
this.current = this.$store.state.pageState.comment
//
this.listComments()
},
//
data: function () {
return {
loading: true,
remove: false,
options: [
loading: true, //
remove: false, //
options: [ //
{
value: 1,
label: '文章'
@ -155,56 +206,68 @@ export default {
label: '友链'
}
],
comments: [],
commentIds: [],
type: null,
keywords: null,
isReview: null,
current: 1,
size: 10,
count: 0
comments: [], //
commentIds: [], // ID
type: null, //
keywords: null, //
isReview: null, // null:, 0:, 1:
current: 1, //
size: 10, //
count: 0 //
}
},
methods: {
// ID
selectionChange(comments) {
this.commentIds = []
comments.forEach((item) => {
this.commentIds.push(item.id)
})
},
// 1
searchComments() {
this.current = 1
this.listComments()
},
//
sizeChange(size) {
this.size = size
this.listComments()
},
//
currentChange(current) {
this.current = current
//
this.$store.commit('updateCommentPageState', current)
this.listComments()
},
//
changeReview(review) {
this.current = 1
this.isReview = review
this.current = 1 // 1
this.isReview = review //
},
//
updateCommentReview(id) {
let param = {}
// IDID
if (id != null) {
param.ids = [id]
} else {
param.ids = this.commentIds
}
param.isReview = 1
param.isReview = 1 // 1
//
this.axios.put('/api/admin/comments/review', param).then(({ data }) => {
if (data.flag) {
//
this.$notify.success({
title: '成功',
message: data.message
})
//
this.listComments()
} else {
//
this.$notify.error({
title: '失败',
message: data.message
@ -212,67 +275,84 @@ export default {
}
})
},
//
deleteComments(id) {
var param = {}
// IDID
if (id == null) {
param = { data: this.commentIds }
} else {
param = { data: [id] }
}
//
this.axios.delete('/api/admin/comments', param).then(({ data }) => {
if (data.flag) {
//
this.$notify.success({
title: '成功',
message: data.message
})
//
this.listComments()
} else {
//
this.$notify.error({
title: '失败',
message: data.message
})
}
//
this.remove = false
})
},
//
listComments() {
this.axios
.get('/api/admin/comments', {
params: {
current: this.current,
size: this.size,
keywords: this.keywords,
type: this.type,
isReview: this.isReview
}
})
.then(({ data }) => {
this.comments = data.data.records
this.count = data.data.count
this.loading = false
})
.get('/api/admin/comments', {
params: {
current: this.current, //
size: this.size, //
keywords: this.keywords, //
type: this.type, //
isReview: this.isReview //
}
})
.then(({ data }) => {
//
this.comments = data.data.records
//
this.count = data.data.count
//
this.loading = false
})
}
},
//
watch: {
//
isReview() {
this.current = 1
this.listComments()
this.current = 1 // 1
this.listComments() //
},
//
type() {
this.current = 1
this.listComments()
this.current = 1 // 1
this.listComments() //
}
}
}
</script>
<style scoped>
/* 评论内容样式 */
.comment-content {
display: inline-block;
}
/* 操作按钮区域样式 */
.operation-container {
margin-top: 1.5rem;
}
/* 评论状态筛选菜单样式 */
.review-menu {
font-size: 14px;
margin-top: 40px;
@ -281,12 +361,14 @@ export default {
.review-menu span {
margin-right: 24px;
}
/* 未选中的筛选选项样式 */
.review {
cursor: pointer;
}
/* 选中的筛选选项样式 */
.active-review {
cursor: pointer;
color: #333;
font-weight: bold;
}
</style>
</style>
Loading…
Cancel
Save