zoukankan      html  css  js  c++  java
  • 使用axios.all和axios.spread处理并发请求

    点击机构树查询人员信息和行政区域数据,但他们是两个接口。

    template结构

            <div class="organize-view">
                <el-tree
                    :data="treeData"
                    :props="defaultProps"
                    ref="tree"
                    :show-checkbox="false"
                    :load="loadSubOrg"
                    lazy
                    @node-click="getData"
                    :expand-on-click-node='false'
                    :default-expand-all='false'>
                        <span class="custom-tree-node" slot-scope="{ node}">
                            <span class="tree-node_left">{{node.label}}</span>
                        </span>
                </el-tree>
            </div>
    

      

            //点击机构获取某机构人员数据
            getData(node) {
                // let orgId = node.id;
                let that = this;
                this.paulId = node.id;
                this.$axios.all([ that.getHaveUser(), that.getDistrict()])
                    .then(that.$axios.spread((resUser, resDist) => {
                        console.log(resUser.users, '人员')
                        this.tableData = resUser.users;
                        console.log(resDist.district, '行政区域')
                    }))
            },
            getHaveUser() {
                return this.$axios({
                        method: 'post',
                        url: this.$api.personManage.findUsersHaveResources,
                        data: { "orgId" : this.paulId}
                    })
            },
            getDistrict() {
                return this.$axios({
                        method: 'get',
                        url: this.$api.organization.findByOrgId + '/' + this.paulId,
                    })
            },
    

      

      

  • 相关阅读:
    Codeforces Round #534 (Div. 2) D. Game with modulo 交互题
    传球游戏 dp
    欧拉通路和欧拉回路
    HDU 1116
    HDU 4970
    HDU 4557
    HDU 4864
    HDU 1565
    HDU 3046
    HDU 4240
  • 原文地址:https://www.cnblogs.com/theblogs/p/14109184.html
Copyright © 2011-2022 走看看