VUE get请求与post请求

   // get请求获取数据(有参数)
    getDataList: function () {
      this.$http.get('/api/edu_classroom', {
        params: {
          page: this.pageIndex,
          size: this.pageSize,
          sort: "createDate desc"
        }
      }).then((response) => {
        this.dataList = response.data.data.records
        this.total = response.data.data.total
      })
    },
 
 //post请求查询 事例
    findDate: function () {
      this.$http.post('/api/edu_classroom/findByEntity?page=' + this.pageIndex + '&size=' + this.pageSize, this.searchInfo).then((response) => {
        this.dataList = response.data.data.records
        this.total = response.data.data.total

      })
    },
 
//post请求新增
   this.$http.post('/api/edu_classroom/add', this.info).then((response) => {
              if (response.data.success) {
                this.showDialog = false
                this.getDataList()
                this.$notify({
                  title: 'ok',
                  message: response.data.msg
                })
              } else {
                this.$notify.error({
                  title: '错误',
                  message: response.data.msg
                })
              }
            })
//post请求修改
 this.$http.post('/api/edu_classroom/updateById', this.info).then((response) => {
              if (response.data.success) {
                this.showDialog = false
                this.getDataList()
                this.$notify({
                  title: 'ok',
                  message: response.data.msg
                })
              } else {
                this.$notify.error({
                  title: '错误',
                  message: response.data.msg
                })
              }
            })
          }
 
 
 // get请求 删除操作
    deleteHandle: function (id) {
      // 处理IDS
      var uuids = id ? [id] : this.dataListSelections.map(item => {
        return item.uuid
      })
      // 提示用户删除
      this.$confirm(`确定删除操作?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http.get('/api/edu_classroom/removeByIds', {
          params: {
            uuids: uuids.join(',')
          }
        }).then((response) => {
          this.$notify({
            title: 'OK',
            message: '删除成功!'
          })
          this.getDataList()
        })
      }).catch(() => { })
    },
posted @ 2021-11-15 14:12  吴登峰  阅读(1076)  评论(0)    收藏  举报