完善文章状态管理

This commit is contained in:
LittleBoy 2022-05-26 09:56:55 +08:00
parent 2ef57d2cdc
commit 84037e376c
2 changed files with 17 additions and 2 deletions

View File

@ -84,5 +84,12 @@ export default {
// })
// .catch(() => {});
},
async updateArticleStatus(art){
await request("/api/article/admin/update", {
id:art.id,
status: art.status == 1?2:1
});
this.loadArticleList(); // 重新加载文章列表
}
},
};

View File

@ -5,7 +5,7 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>登录</title>
<title>文章管理</title>
<link rel="stylesheet" href="./element-ui/lib/theme-chalk/index.css">
<style>
* {
@ -59,7 +59,8 @@
<th width="180">发表时间</th>
<th width="60">阅读数</th>
<th width="60">评论数</th>
<th width="80">操作</th>
<th width="60">状态</th>
<th width="140">操作</th>
</tr>
</thead>
<tbody>
@ -70,6 +71,7 @@
<td>{{art.publish_time}}</td>
<td>{{art.view_count}}</td>
<td>{{art.comment_count}}</td>
<td>{{art.status == 1?'已发布':'草稿'}}</td>
<td>
<!-- 不需要传参则可以不写方法后的小括号 -->
<el-link @click="showEdit(art)">修改</el-link>
@ -78,6 +80,12 @@
@confirm="deleteArticlebyId(art.id)">
<el-link slot="reference">删除</el-link>
</el-popconfirm>
<el-popconfirm
title="此操作将会更改文章状态,是否继续?"
@confirm="updateArticleStatus(art)">
<el-link slot="reference">{{art.status==1?'设为草稿':'发布文章'}}</el-link>
</el-popconfirm>
</td>
</tr>
</tbody>