Browse Source

市场客户资料并发处理

yuanrf 3 days ago
parent
commit
44e43c4086
1 changed files with 35 additions and 30 deletions
  1. 35 30
      src/components/MCR/MarketCustomerResourcesHome.vue

+ 35 - 30
src/components/MCR/MarketCustomerResourcesHome.vue

@@ -533,53 +533,58 @@ export default {
             })
         },
         pageload() {
-
             var that = this;
-            this.$axios.post('/api/MarketCustomerResources/QueryUnlockDropList', {}, {
-                headers: {
-                    'Authorization': that.token,
-                    // 'Accept-Encoding': 'gzip'
-                },
-            }).then(resp => {
-                if (resp.data.code == 200) {
-                    if (resp.data.data.includes(that.userId)) {
+            // 将两个请求改为并发执行
+            Promise.all([
+                this.$axios.post('/api/MarketCustomerResources/QueryUnlockDropList', {}, {
+                    headers: {
+                        'Authorization': that.token,
+                    },
+                }),
+                this.$axios.post('/api/MarketCustomerResources/QueryNewClientData', {
+                    ...that.pageloadData,
+                    operationUserId: that.userId
+                }, {
+                    headers: {
+                        'Authorization': that.token,
+                    },
+                })
+            ]).then(responses => {
+                const [unlockResp, clientResp] = responses;
+
+                // 处理第一个请求结果
+                if (unlockResp.data.code == 200) {
+                    if (unlockResp.data.data.includes(that.userId)) {
                         that.isSelect = false;
                     }
                 }
-            })
 
-            that.pageloadData.operationUserId = that.userId;
-            //初始化界面数据
-            //console.log(that.pageloadData)
-            this.$axios.post('/api/MarketCustomerResources/QueryNewClientData', that.pageloadData, {
-                headers: {
-                    'Authorization': that.token,
-                },
-            }).then(resp => {
-                if (resp.data.code == 200) {
-                    if (resp.data.data == null) {
+                // 处理第二个请求结果
+                if (clientResp.data.code == 200) {
+                    if (clientResp.data.data == null) {
                         that.PageList = [];
                         that.total = 0;
-                        this.$message.error(resp.data.msg);
+                        this.$message.error(clientResp.data.msg);
                     } else {
-                        that.principalList = resp.data.data.users; //负责人
-                        that.clientLvList = resp.data.data.level;//客户级别
-                        that.clientTypeList = resp.data.data.customerClass;//客户类别
-                        that.territoryList = resp.data.data.province; //省域数据
-                        that.businessClassList = resp.data.data.serviceClass; //业务归属
-                        that.PageList = resp.data.data.clientTableData.pageSource; //table数据
-                        that.total = resp.data.data.clientTableData.pageCount; //总数
-                        that.groupNumber = resp.data.data.groupNumber; //团组出团总数
+                        that.principalList = clientResp.data.data.users; //负责人
+                        that.clientLvList = clientResp.data.data.level;//客户级别
+                        that.clientTypeList = clientResp.data.data.customerClass;//客户类别
+                        that.territoryList = clientResp.data.data.province; //省域数据
+                        that.businessClassList = clientResp.data.data.serviceClass; //业务归属
+                        that.PageList = clientResp.data.data.clientTableData.pageSource; //table数据
+                        that.total = clientResp.data.data.clientTableData.pageCount; //总数
+                        that.groupNumber = clientResp.data.data.groupNumber; //团组出团总数
                         console.log(that.pageloadData.pageIndex, parseInt(that.pageloadData.pageIndex), 'that.pageloadData.pageIndex')
                         that.currentPage = parseInt(that.pageloadData.pageIndex);
                     }
                     this.loading = false;
                     that.territoryChange();
-                } else if (resp.data.code == 400) {
+                } else if (clientResp.data.code == 400) {
                     that.PageList = [];
                     that.total = 0;
                     that.$message.error('暂无数据!');
                 }
+
             }).catch(err => {
                 this.$message.error('网络异常!');
             }).finally(() => {