美文网首页
vue在一个方法中调用另一个方法

vue在一个方法中调用另一个方法

作者: 大风过岗 | 来源:发表于2021-01-14 18:58 被阅读0次

代码如下

methods: {
    accountAdd() {
      //新增用户
      this.editVisible = true
      this.title = '新增账号'
      this.getId = -1
    },
    accountEdit(index, row) {
      this.getId = row.id
      this.editVisible = true
      this.title = '修改账号'
      this.action = 1

      //this.$router.push({path: 'account_detail', query: {action: 1, id: id}})
    },
    accountDetail(index, row) {
      this.getId = row.id
      this.editVisible = true
      this.title = '账号详情'
      this.action = 2
    },
    deviceSearch(index, row) {
      this.$router.push({ path: 'device_search', query: { id: row.id } })
    },
    childEditVisible: function(childValue) {
      //弹框点击取消,关闭弹框
      // childValue就是子组件传过来的值
      this.editVisible = childValue
    },
    getAccountList() {
      var _self = this;
      let obj = {}
      if (this.userType === 1 || this.userType === 4) {
        //当前登陆的用户的userType = 2 和 3 的时候 没有代理商列表(通过权限控制)
        obj = {
          userType: 2
        }
      }
      for (let item in this.searchForm) {
        //过滤空的值
        if (this.searchForm[item] != '' && this.searchForm[item] != null) {
          obj[item] = this.searchForm[item]
        }
      }
      // obj['pageNo'] = this.pageNo;
      // obj['pageSize'] = this.pageSize;
      this.$axios
        .post(
          this.$Api.getAccountList +
            '?pageNo=' +
            this.pageNo +
            '&pageSize=' +
            this.pageSize,
          obj
        )
        .then(response => {
          if (response.data.code === 200) {
            this.tableData = response.data.content.data
            this.totalRows = response.data.content.totalRows
          }
        })

        console.log("===========好吧==============")
        this.$options.methods.getNothing();
    },

    getNothing: function(){

      console.log("===========第二个方法调用==============")
      this.$axios.get('http://127.0.0.1/your_url')
        .then(res => {

          console.log(res)

        }).catch( err => {
             console.log(err)
        }
        
        )
    },


    getNodeList() {
      let obj = {
        params: {
          resourceId: 'agent_list'
        }
      }

      this.$axios
        .get(this.$Api.getSubResourceNodeList, obj)
        .then(response => {
          if (response !== '') {
            response.data.content.forEach(value => {
              if (this.nodeNames.indexOf(value.page) == -1) {
                this.nodeNames.push(value.page)
              }
            })
          }
        })
        .catch(error => {})
    },
    openConfirm(id) {
      this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.deletePartner(id)
        })
        .catch(() => {})
    },
    deletePartner(id) {
      let obj = {
        params: {
          id: id
        }
      }
      this.$axios.get(this.$Api.removeAccount, obj).then(response => {
        if (response !== '') {
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
          this.getAccountList()
        }
      })
    },
    handleCurrentChange(val) {
      this.pageNo = val
      this.getAccountList()
    },
    onSearch() {
      this.getAccountList()
    }
  }
}
</script>

相关文章

网友评论

      本文标题:vue在一个方法中调用另一个方法

      本文链接:https://www.haomeiwen.com/subject/mhtbaktx.html