浏览代码

事件列表数量优化

seimin 1 年之前
父节点
当前提交
0d95130723
共有 1 个文件被更改,包括 34 次插入21 次删除
  1. 34 21
      assets/js/controllers/incident/incidentCtrl.js

+ 34 - 21
assets/js/controllers/incident/incidentCtrl.js

@@ -2209,27 +2209,45 @@ app.controller('incidentListCtrl', ["$scope", "$http", "i18nService", "$rootScop
2209
         }, function () {
2209
         }, function () {
2210
             $scope.ldloading[style.replace('-', '_')] = false;
2210
             $scope.ldloading[style.replace('-', '_')] = false;
2211
         });
2211
         });
2212
+        // 获取数量
2213
+        $scope.count(filterData.incident, isInit);
2212
     }, 500);
2214
     }, 500);
2213
 
2215
 
2214
     // 调用接口-查数量
2216
     // 调用接口-查数量
2215
-    $scope.count = function (){
2216
-        let numPostData = {
2217
-            incident: {
2218
-                queryTask: $scope.tabs.map(v => v.key).toString(),
2219
-                assignee: loginUser.id,
2220
-                candidateGroups: loginuserGroup,
2221
-            }
2222
-        }
2223
-        if($rootScope.user.duty){
2224
-            // 当前的所属责任科室
2225
-            numPostData.incident.dutyId = $rootScope.user.duty.id;
2226
-        }else if($rootScope.user.branch){
2227
-            // 当前的所属院区
2228
-            numPostData.incident.branchId = $rootScope.user.branch.id;
2217
+    $scope.count = function (incident = {}){
2218
+        let postData = {
2219
+            incidentList: [],
2229
         }
2220
         }
2230
-        api_flow.count(numPostData).then(function (data) {
2221
+        $scope.tabs.forEach(v => {
2222
+            postData.incidentList.push({...incident, ...{queryTask: v.key}});
2223
+        })
2224
+        postData.incidentList.forEach(incident => {
2225
+            // 请求参数调整
2226
+            if(!incident){
2227
+                incident = {};
2228
+            }
2229
+            if(incident.queryTask === 'all' || incident.queryTask === 'callback'){
2230
+                if($rootScope.user.duty){
2231
+                    // 当前的所属责任科室
2232
+                    incident.duty = $rootScope.user.duty;
2233
+                }else if($rootScope.user.branch){
2234
+                    // 当前的所属院区
2235
+                    incident.branch = $rootScope.user.branch.id;
2236
+                }
2237
+            }else{
2238
+                delete incident.duty;
2239
+                delete incident.branch;
2240
+            }
2241
+            incident.assignee = loginUser.id;
2242
+            if(incident.queryTask === 'todo' || incident.queryTask === 'owns'){
2243
+                incident.candidateGroups = loginuserGroup;
2244
+            }else{
2245
+                delete incident.candidateGroups;
2246
+            }
2247
+        })
2248
+        api_flow.count(postData).then(function (data) {
2231
             if (data.state == 200) {
2249
             if (data.state == 200) {
2232
-                let myData = data.data[0] || {};
2250
+                let myData = data.data || {};
2233
                 $scope.tabs.forEach(v => {
2251
                 $scope.tabs.forEach(v => {
2234
                     v.num = myData[v.key];
2252
                     v.num = myData[v.key];
2235
                 })
2253
                 })
@@ -2240,15 +2258,10 @@ app.controller('incidentListCtrl', ["$scope", "$http", "i18nService", "$rootScop
2240
                     type: "error"
2258
                     type: "error"
2241
                 });
2259
                 });
2242
             }
2260
             }
2243
-            $scope.ldloading[style.replace('-', '_')] = false;
2244
-
2245
-        }, function () {
2246
-            $scope.ldloading[style.replace('-', '_')] = false;
2247
         });
2261
         });
2248
     }
2262
     }
2249
     // 进入页面时
2263
     // 进入页面时
2250
     $scope.getIncidentStatus();
2264
     $scope.getIncidentStatus();
2251
-    $scope.count();
2252
 
2265
 
2253
     $scope.timer = $interval(function () {
2266
     $scope.timer = $interval(function () {
2254
         $scope.jry_refresh()
2267
         $scope.jry_refresh()