Skip to content

Commit 097a668

Browse files
committed
新增评论管理功能,但是只有删除,没有修改
1 parent 81cdfd6 commit 097a668

File tree

4 files changed

+163
-20
lines changed

4 files changed

+163
-20
lines changed

config/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ const path = require('path')
66

77
module.exports = {
88
dev: {
9-
109
// Paths
1110
assetsSubDirectory: 'static',
1211
assetsPublicPath: '/',
1312
proxyTable: {
1413
'/api': {
15-
target: 'http://localhost:8888', //源地址 服务器地址
14+
target: 'http://39.104.22.73:8888', //代理地址,这里是真正访问的地址。使用本地接口服务时请用localhost,使用服务器数据库时请使用对应的ip
1615
changeOrigin: true, //改变源
1716
pathRewrite: {
1817
'^/api': '' //路径重写

src/components/Comment.vue

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/**
2+
* 此文件实现 评论管理 功能
3+
*/
4+
<template>
5+
<div>
6+
<div class="RightContent">
7+
<el-button type="primary" @click="">批量删除</el-button>
8+
9+
<el-dialog title="管理友链" :visible.sync="dialogFormVisible">
10+
<el-form :model="form">
11+
<el-form-item label="评论时间" :label-width="formLabelWidth">
12+
<el-input v-model="form.ArticleCommentDate"></el-input>
13+
</el-form-item>
14+
<el-form-item label="评论人" :label-width="formLabelWidth">
15+
<el-input v-model="form.ArticleCommentNickName"></el-input>
16+
</el-form-item>
17+
<el-form-item label="评论内容" :label-width="formLabelWidth">
18+
<el-input v-model="form.ArticleCommentText"></el-input>
19+
</el-form-item>
20+
</el-form>
21+
</el-dialog>
22+
23+
<!--表格操作栏-->
24+
<el-table :data="CommentList" style="width: 100%">
25+
<el-table-column prop="ArticleCommentDate" label="评论时间"></el-table-column>
26+
<el-table-column prop="ArticleCommentNickName" label="评论人"></el-table-column>
27+
<el-table-column prop="ArticleCommentText" label="评论内容"></el-table-column>
28+
<el-table-column fixed="right" label="操作" width="130">
29+
<template slot-scope="scope">
30+
<el-button @click="DeleteComment(scope.row._id)" type="text" size="small">删除</el-button>
31+
</template>
32+
</el-table-column>
33+
</el-table>
34+
35+
<!--分页器-->
36+
<div v-if="CommentTotal>10">
37+
<el-pagination layout="prev, pager, next,total"
38+
:total=CommentTotal
39+
:page-size=PageSize
40+
@current-change="ChangeCurPage"
41+
@next-click="NextPage"
42+
@prev-click="NextPage"
43+
>
44+
</el-pagination>
45+
</div>
46+
</div>
47+
</div>
48+
</template>
49+
50+
<script>
51+
export default {
52+
name: "Comment",
53+
data:function(){
54+
return {
55+
CommentList: [],
56+
dialogFormVisible: false,
57+
form: {
58+
ArticleCommentDate:'',
59+
ArticleCommentNickName:'',
60+
ArticleCommentText:''
61+
},
62+
CommentTotal: 0,
63+
PageSize: 10
64+
}
65+
},
66+
methods: {
67+
// 评论列表
68+
GetData: function () {
69+
var That = this;
70+
That.SQAjax({
71+
Url:'/api/CommentRead/backend',
72+
RequestData: {
73+
PagnationData: {
74+
Skip:0,
75+
Limit:11
76+
}
77+
},
78+
Success:function (data) {
79+
if(data.length > 10){
80+
data.pop();
81+
82+
That.SQAjax({
83+
Url:'/api/getCommentNum',
84+
Success: function (data) {
85+
That.CommentTotal = data;
86+
console.log(data);
87+
}
88+
});
89+
}
90+
91+
That.CommentList = data;
92+
}
93+
});
94+
},
95+
// 删除评论
96+
DeleteComment:function (Id) {
97+
var That = this;
98+
99+
That.SQAjax({
100+
Url:'/api/CommentDelete/backend',
101+
RequestData:{
102+
_id:Id
103+
},
104+
Success:function (data) {
105+
That.GetData();
106+
}
107+
});
108+
},
109+
// 翻页方法
110+
ChangeCurPage:function(CurPage){
111+
this.SkipTo(CurPage);
112+
},
113+
NextPage: function(CurPage){
114+
this.SkipTo(CurPage);
115+
},
116+
SkipTo:function (CurPage) {
117+
var That = this;
118+
That.SQAjax({
119+
Url:'/api/CommentRead/backend',
120+
RequestData: {
121+
PagnationData: {
122+
Skip:(CurPage-1) * 10,
123+
Limit:10
124+
}
125+
},
126+
Success:function (data) {
127+
That.CommentList = data;
128+
}
129+
});
130+
}
131+
},
132+
mounted() {
133+
this.GetData();
134+
this.bus.$emit('Topbar',{
135+
MenuHighLight:'7'
136+
});
137+
}
138+
}
139+
</script>
140+
141+
<style scoped>
142+
143+
</style>

src/components/TopBar.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
<i class="el-icon-star-off"></i>
4343
<span slot="title">留言管理</span>
4444
</el-menu-item>
45+
46+
<el-menu-item index="7" @click="ChangeHighLight('Comment')">
47+
<i class="el-icon-view"></i>
48+
<span slot="title">评论管理</span>
49+
</el-menu-item>
4550
</el-menu>
4651
</div>
4752
</template>

src/router/index.js

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import TimeLine from '@/components/TimeLine'
1010
import Heartfelt from '@/components/Heartfelt'
1111
import FriendUrlIndex from '@/components/FriendUrlIndex'
1212
import MessageLeave from '@/components/MessageLeave'
13+
import Comment from '@/components/Comment'
1314

1415
Vue.use(Router)
1516

@@ -19,51 +20,46 @@ export default new Router({
1920
path: '/',
2021
name: 'Article',
2122
component: Article
22-
},
23-
{
23+
}, {
2424
path: '/ArticleDetail',
2525
name: 'ArticleDetail',
2626
component: ArticleDetail
27-
},
28-
{
27+
}, {
2928
path:'/WriteArticle',
3029
name:'WriteArticle',
3130
component:WriteArticle
32-
},
33-
{
31+
}, {
3432
path:'/TagIndex',
3533
name:'TagIndex',
3634
component:TagIndex
37-
},
38-
{
35+
}, {
3936
path:'/TopBar',
4037
name:'TopBar',
4138
component:TopBar
42-
},
43-
{
39+
}, {
4440
path:'/LoginPage',
4541
name:'LoginPage',
4642
component:LoginPage
47-
},
48-
{
43+
}, {
4944
path:'/TimeLine',
5045
name:'TimeLine',
5146
component:TimeLine
52-
},
53-
{
47+
}, {
5448
path:'/Heartfelt',
5549
name:'Heartfelt',
5650
component:Heartfelt
57-
},
58-
{
51+
}, {
5952
path:'/FriendUrlIndex',
6053
name:'FriendUrlIndex',
6154
component:FriendUrlIndex
62-
},
63-
{
55+
}, {
6456
path:'/MessageLeave',
6557
name:'MessageLeave',
6658
component:MessageLeave
59+
},{
60+
path:'/Comment',
61+
name:'Comment',
62+
component:Comment
6763
},
6864
]
6965
})

0 commit comments

Comments
 (0)