发表于: 2020-03-05 22:24:02

1 1439


今天完成的事情:

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()//成功后求一下列表据刷新
       }
   })
}





返回列表 返回列表
评论

    分享到