评论管理

This commit is contained in:
2024-10-15 15:32:55 +08:00
parent cd13e8635a
commit be61850df2
4 changed files with 94 additions and 17 deletions

View File

@@ -24,13 +24,21 @@
>查询</el-button
>
</el-form-item>
<el-button type="text"
<el-button
v-if="tableData.length > 0"
style="position: absolute;right: 0;"
type="danger"
size="small"
@click="deleteHandle('all')"
>批量删除</el-button
>
<!-- <el-button type="text"
@click="changeDefalutExpand()"
style="position: absolute;right: 0;"
:style="`color:${defaultExpand?'#17B3A3':'#333'}`"
>{{ !defaultExpand ? "收起" : "展开" }}全部评论
<i class="el-icon-s-comment" ></i
></el-button>
></el-button> -->
</el-form>
<!-- -->
@@ -40,10 +48,18 @@
:default-expand-all="defaultExpand"
:data="tableData"
style="width: 100%"
height="calc(100% - 100px)"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
height="calc(100% - 40px)"
@selection-change="handleSelectionChange"
:default-sort="{ prop: 'date', order: 'descending' }"
>
<el-table-column fixed prop="createTime" label="日期" width="200">
<el-table-column type="selection" width="55"> </el-table-column>
<el-table-column
fixed
prop="createTime"
label="日期"
width="200"
sortable
>
</el-table-column>
<el-table-column prop="name" label="姓名" width="120">
<template slot-scope="scope">
@@ -51,9 +67,8 @@
<el-tooltip placement="top" v-if="scope.row.user">
<div slot="content">
<div>
<p v-if="scope.row.user.nickname ">
<p v-if="scope.row.user.nickname">
昵称{{ scope.row.user.nickname }}
</p>
<p v-if="scope.row.user.name">
姓名{{ scope.row.user.name }}
@@ -91,7 +106,7 @@
<template slot-scope="scope">
<span
style="color: red;cursor: pointer;"
@click="deleteHandle(scope.row.id)"
@click="deleteHandle('one', scope.row.id)"
>
删除
</span>
@@ -118,6 +133,7 @@ export default {
data() {
return {
tableData: [],
selectData: [],
query: {
content: ""
},
@@ -130,6 +146,10 @@ export default {
},
created() {},
methods: {
handleSelectionChange(data) {
console.log("data at line 141:", data);
this.selectData = data;
},
changeDefalutExpand() {
this.refreshTable = false;
this.$nextTick(() => {
@@ -161,7 +181,7 @@ export default {
limit: this.pageSize,
page: this.pageIndex,
type: 0, //类型0课程1章节
courseId: this.courseId,
courseId: this.courseId ? this.courseId : "",
chapterId: "",
content: this.query.content //内容
@@ -182,19 +202,27 @@ export default {
});
},
deleteHandle(id) {
this.$confirm("请确认是否删除?", "提示", {
deleteHandle(type, id) {
if (type == "all") {
if (this.selectData.length == 0) {
this.$message.error("请至少选择一条评论");
return false;
}
}
this.$confirm(`请确认是否${type == "all" ? "批量" : ""}删除?`, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
var ids = this.selectData.map(e => e.id).join(",");
console.log("ids at line 205:", ids);
this.$http({
url: this.$http.adornUrl(
`/master/courseGuestbook/delCourseGuestbook`
),
method: "post",
data: this.$http.adornData({
id: id
ids: type == "all" ? ids : id
})
}).then(({ data }) => {
if (data && data.code === 0) {