首页
学习
活动
专区
圈层
工具
发布

【VIDEO_Parent】-创作者前端-逻辑删除创作者

代码实现

监听删除按钮的点击,然后传入当前删除记录的 id 进行逻辑删除

代码语言:html
复制
<el-table-column label="操作" align="center">
  <template slot-scope="scope">
    <el-button type="primary" size="mini" icon="el-icon-edit">修改</el-button>
    <el-button type="danger" size="mini" icon="el-icon-delete"
               @click="deleteAuthorWithId(scope.row.id)">删除
    </el-button>
  </template>
</el-table-column>

实现删除的方法

编写删除的前端 api

代码语言:javascript
复制
// 2.删除作者
deleteAuthorWithId(id) {
  return request({
    // 路由参数拼接
    url: `/service_video/author/deleteAuthor/${id}/`,
    method: 'delete'
  })
}

修改后端的接口

实现前端删除的方法

代码语言:javascript
复制
// 删除创作者
deleteAuthorWithId(id) {
  // 用户提示
  this.$confirm('此操作将永久删除该创作者!, 是否继续?', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(() => {
    // 调用删除的api
    author.deleteAuthorWithId(id).then(response => {
      this.$message({
        type: 'success',
        message: response.message
      });
      // 重新加载数据
      this.getAuthorList();
    }).catch(error => {
      this.$message.error('删除失败!');
    })
  }).catch(() => {
    this.$message({
      type: 'info',
      message: '已取消删除'
    });
  });
}

最后

我正在参与2023腾讯技术创作特训营第三期有奖征文,组队打卡瓜分大奖!

下一篇
举报
领券