发表于: 2020-03-05 22:24:02
1 1444
今天完成的事情:
1.推进任务
明天计划的事情:
1.推进任务
遇到的问题和收获:
draft() {
//新增接口
if (this.$route.query.id === '') {
console.log('存为草稿!');
this.article.status = 1
this.$http({
method: 'post',
url: '/api/a/u/article',
data: this.$qs.stringify(this.article),
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).then(res => {
console.log(res);
if (res.data.code === 0) {
console.log(res);
this.$message.success('添加成功!');
// await this.$router.push({
this.$router.push({
path: '/home/admin'
})
this.article = {}
}
})
} else {
this.$http({
method: 'put',
url: '/api/a/u/article/' + this.$route.query.id,
data: this.$qs.stringify(this.article),
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).then(res => {
if (res.data.code === 0) {
this.$message.success('编辑成功!');
this.$router.push({
path: '/home/admin'
})
}
})
}
判断路由地址是否有id,为空则点击按钮请求新增,不为空则点击后请求编辑。
然后是删除按钮。可以删除
//删除操作
deleteData(row) {
this.$http({
method: 'delete',
url: '/api/a/u/article/' + row.id,
// data: this.$qs.stringify(this.article),
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).then(res => {
if (res.data.code === 0) {
this.$message.success('删除成功')
this.getArticleList()//成功后请求一下列表数据刷新
}
})
}
评论