Переглянути джерело

服务台统计和事件统计增加导出

seimin 3 роки тому
батько
коміт
86f4673bbd

+ 88 - 5
assets/js/controllers/report/event_formCtrl.js

@@ -1,5 +1,5 @@
1 1
 'use strict';
2
-app.controller('event_formCtrl', ["$scope", "$rootScope", "$state", "$timeout", "$interval", "$http", "$cookieStore", "SweetAlert", "Restangular", "api_report", "api_statistic", "moment", "api_event_form", "api_user_data", function ($scope, $rootScope, $state, $timeout, $interval, $http, $cookieStore, SweetAlert, Restangular, api_report, api_statistic, moment, api_event_form, api_user_data) {
2
+app.controller('event_formCtrl', ["$scope", "$rootScope", "$state", "$timeout", "$interval", "$http", "$cookieStore", "SweetAlert", "Restangular", "api_report", "api_statistic", "moment", "api_event_form", "api_user_data", "api_bpm", function ($scope, $rootScope, $state, $timeout, $interval, $http, $cookieStore, SweetAlert, Restangular, api_report, api_statistic, moment, api_event_form, api_user_data, api_bpm) {
3 3
     //默认显示事件总数
4 4
     $scope.tap = 'SJZS';
5 5
     //默认无选中,选择日期
@@ -240,10 +240,10 @@ app.controller('event_formCtrl', ["$scope", "$rootScope", "$state", "$timeout",
240 240
      * @param {string} direction 箭头方向 top,bottom
241 241
      */
242 242
     $scope.tableSort = function (name, type, direction) {
243
-        if($scope.name == name){
244
-            $scope.type = $scope.type == 'desc'?'asc':'desc';
245
-            $scope.direction = $scope.direction == 'top'?'bottom':'top';
246
-        }else{
243
+        if ($scope.name == name) {
244
+            $scope.type = $scope.type == 'desc' ? 'asc' : 'desc';
245
+            $scope.direction = $scope.direction == 'top' ? 'bottom' : 'top';
246
+        } else {
247 247
             $scope.type = 'desc';
248 248
             $scope.direction = 'top';
249 249
         }
@@ -453,6 +453,89 @@ app.controller('event_formCtrl', ["$scope", "$rootScope", "$state", "$timeout",
453 453
     //         }
454 454
     //     }
455 455
     // })
456
+    //导出
457
+    $scope.export = function () {
458
+        var postData = {
459
+            "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
460
+            "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
461
+            "sortData": $scope.name,
462
+            "sortType": $scope.type,
463
+            report: {}
464
+        }
465
+        switch ($scope.tap) {
466
+            case 'SJZS'://事件总数
467
+                postData.type = $scope.dateItem;
468
+                postData.key = 'mdv2_incident_repot_sum';
469
+                postData.titles = ['时间', '事件数量', '平均响应时间', '平均解决时间', '完全解决', '部分解决', '其他', '满意度(%)'];
470
+                break;
471
+            case 'SJLX'://事件类型
472
+                postData.hierarchy = $scope.sjSelectedOne.value.id;
473
+                postData.key = 'mdv2_incident_repot_type';
474
+                postData.titles = ['事件类型', '类型数量', '类型占比', '平均响应时间', '平均解决时间', '完全解决', '部分解决', '其他'];
475
+                break;
476
+            case 'CLRZ'://处理人/组
477
+                if ($scope.groupSelectedOne.value.id == -2) {//按组
478
+                    postData.type = 1;
479
+                } else if ($scope.groupSelectedOne.value.id == -1) {//按人
480
+                    postData.type = 2;
481
+                } else {
482
+                    postData.type = 3;
483
+                }
484
+                postData.key = 'mdv2_incident_repot_handle';
485
+                postData.titles = ['处理组', '事件数量', '事件占比', '按时响应', '超时响应', '平均响应时间', '超时响应占比', '按时解决', '超时解决', '平均解决时间', '超时解决占比', '满意度(%)'];
486
+                break;
487
+            case 'QYDD'://区域地点
488
+                postData.type = $scope.areaSelectedOne.value.id;
489
+                postData.key = 'mdv2_incident_repot_area_place';
490
+                postData.titles = ['区域/地点', '事件数量', '事件占比'];
491
+                break;
492
+            case 'SJLY'://事件来源
493
+                postData.key = 'mdv2_incident_repot_source';
494
+                postData.titles = ['事件来源', '事件数量', '事件来源占比'];
495
+                break;
496
+        }
497
+        var wt_url = api_bpm.downDataModel('report', 1).getRequestedUrl()
498
+        $http({
499
+            url: wt_url,
500
+            method: 'POST',
501
+            data: JSON.stringify(postData),
502
+            headers: {
503
+                'Accept': '*/*'
504
+            },
505
+            responseType: 'arraybuffer'
506
+        }).success(function (data, status, headers, config) {
507
+            var fileName = '';
508
+            switch ($scope.tap) {
509
+                case 'SJZS'://事件总数
510
+                    fileName = '事件总数';
511
+                    break;
512
+                case 'SJLX'://事件类型
513
+                    fileName = '事件类型';
514
+                    break;
515
+                case 'CLRZ'://处理人/组
516
+                    fileName = '处理人/组';
517
+                    break;
518
+                case 'QYDD'://区域地点
519
+                    fileName = '区域地点';
520
+                    break;
521
+                case 'SJLY'://事件来源
522
+                    fileName = '事件来源';
523
+                    break;
524
+            }
525
+            // var fileName = headers("Content-Disposition").split(";")[1].split("filename=")[1];
526
+            var file = new Blob([data], {
527
+                type: 'application/vnd.ms-excel'
528
+            });
529
+            var fileURL = URL.createObjectURL(file);
530
+            var a = document.createElement('a');
531
+            a.href = fileURL;
532
+            a.target = '_blank';
533
+            a.download = fileName + '.xls';
534
+            document.body.appendChild(a);
535
+            a.click();
536
+        }).error(function (data, status, headers, config) {
537
+        });
538
+    };
456 539
     //初始化
457 540
     $scope.dateItemClick('day');
458 541
     $scope.mdxquery('accdate', 'desc');

+ 76 - 10
assets/js/controllers/report/service_formCtrl.js

@@ -1,5 +1,5 @@
1 1
 'use strict';
2
-app.controller('service_formCtrl', ["$scope", "$rootScope", "$state", "$timeout", "$interval", "$http", "$cookieStore", "SweetAlert", "Restangular", "api_report", "api_statistic", "moment", 'api_user_data','api_event_form', function ($scope, $rootScope, $state, $timeout, $interval, $http, $cookieStore, SweetAlert, Restangular, api_report, api_statistic, moment, api_user_data, api_event_form) {
2
+app.controller('service_formCtrl', ["$scope", "$rootScope", "$state", "$timeout", "$interval", "$http", "$cookieStore", "SweetAlert", "Restangular", "api_report", "api_statistic", "moment", 'api_user_data', 'api_event_form', 'api_bpm', function ($scope, $rootScope, $state, $timeout, $interval, $http, $cookieStore, SweetAlert, Restangular, api_report, api_statistic, moment, api_user_data, api_event_form, api_bpm) {
3 3
     //默认显示综合统计
4 4
     $scope.tap = 'ZHTJ';
5 5
     //默认显示上一周
@@ -26,7 +26,7 @@ app.controller('service_formCtrl', ["$scope", "$rootScope", "$state", "$timeout"
26 26
         $scope.endtimesModel = moment().endOf('year').add(-1, 'y').format('YYYY-MM-DD');
27 27
     }
28 28
     // 今天
29
-    $scope.today = function(){
29
+    $scope.today = function () {
30 30
         $scope.searchstate = "today";
31 31
         $scope.starttimesModel = moment().format('YYYY-MM-DD');
32 32
         $scope.endtimesModel = moment().format('YYYY-MM-DD');
@@ -75,9 +75,9 @@ app.controller('service_formCtrl', ["$scope", "$rootScope", "$state", "$timeout"
75 75
         $scope.endOpened = !$scope.endOpened;
76 76
     };
77 77
     //重置
78
-    $scope.reload = function(isReload){
78
+    $scope.reload = function (isReload) {
79 79
         //点击重置时传true,切换tab传false
80
-        if(isReload){
80
+        if (isReload) {
81 81
             $scope.day(7);
82 82
         }
83 83
         $scope.searchstate = 'none';
@@ -106,7 +106,7 @@ app.controller('service_formCtrl', ["$scope", "$rootScope", "$state", "$timeout"
106 106
         $scope.reload(false);
107 107
     };
108 108
     //综合统计,无限滚动加载
109
-    $scope.topEndComplete = function(){
109
+    $scope.topEndComplete = function () {
110 110
         console.log('滚动');
111 111
     };
112 112
     // 请求人
@@ -133,10 +133,10 @@ app.controller('service_formCtrl', ["$scope", "$rootScope", "$state", "$timeout"
133 133
      * @param {string} direction 箭头方向 top,bottom
134 134
      */
135 135
     $scope.tableSort = function (name) {
136
-        if($scope.name == name){
137
-            $scope.type = $scope.type == 'desc'?'asc':'desc';
138
-            $scope.direction = $scope.direction == 'top'?'bottom':'top';
139
-        }else{
136
+        if ($scope.name == name) {
137
+            $scope.type = $scope.type == 'desc' ? 'asc' : 'desc';
138
+            $scope.direction = $scope.direction == 'top' ? 'bottom' : 'top';
139
+        } else {
140 140
             $scope.type = 'desc';
141 141
             $scope.direction = 'top';
142 142
         }
@@ -187,7 +187,7 @@ app.controller('service_formCtrl', ["$scope", "$rootScope", "$state", "$timeout"
187 187
      * @param {string} name 排序字段
188 188
      * @param {string} type 排序方式 desc,asc
189 189
      */
190
-     $scope.mdxquery = function (name, type) {
190
+    $scope.mdxquery = function (name, type) {
191 191
         if (!name) {
192 192
             // name = $scope.tap == 'ZHTJ' ? 'accdate' : 'sum';
193 193
             name = 'total';
@@ -278,6 +278,72 @@ app.controller('service_formCtrl', ["$scope", "$rootScope", "$state", "$timeout"
278 278
                 break;
279 279
         }
280 280
     };
281
+    //导出
282
+    $scope.export = function () {
283
+        var postData = {
284
+            "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
285
+            "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
286
+            "sortData": $scope.name,
287
+            "sortType": $scope.type,
288
+            report: {}
289
+        }
290
+        switch ($scope.tap) {
291
+            case 'ZHTJ'://综合统计
292
+                postData.key = 'mdv2_service_repot_all';
293
+                postData.titles = ['人员', '建单数量', '直接处理数量', '处理工单数', '电话接听数', '微信/web报修处理数', '留言处理数', '柜台受理数'];
294
+                break;
295
+            case 'DHTJ'://电话统计
296
+                postData.key = 'mdv2_service_repot_phone';
297
+                postData.titles = ['人员', '接听数量', '建单数量', '直接解决', '派单数量'];
298
+                break;
299
+            case 'WEB'://微信/WEB统计
300
+                postData.key = 'mdv2_service_repot_wechat_web';
301
+                postData.titles = ['人员', '受理报修数', '不受理数', '转换数量', '直接解决数量', '派单数量'];
302
+                break;
303
+            case 'DHLYTJ'://电话留言统计
304
+                postData.key = 'mdv2_service_repot_msg';
305
+                postData.titles = ['人员', '受理总数', '不受理总数', '建单总数', '直接解决总数', '派单总数']
306
+                break;
307
+        }
308
+        var wt_url = api_bpm.downDataModel('report', 1).getRequestedUrl()
309
+        $http({
310
+            url: wt_url,
311
+            method: 'POST',
312
+            data: JSON.stringify(postData),
313
+            headers: {
314
+                'Accept': '*/*'
315
+            },
316
+            responseType: 'arraybuffer'
317
+        }).success(function (data, status, headers, config) {
318
+            var fileName = '';
319
+            switch ($scope.tap) {
320
+                case 'ZHTJ'://综合统计
321
+                    fileName = '综合统计';
322
+                    break;
323
+                case 'DHTJ'://电话统计
324
+                    fileName = '电话统计';
325
+                    break;
326
+                case 'WEB'://微信/WEB统计
327
+                    fileName = '微信/WEB统计';
328
+                    break;
329
+                case 'DHLYTJ'://电话留言统计
330
+                    fileName = '电话留言统计';
331
+                    break;
332
+            }
333
+            // var fileName = headers("Content-Disposition").split(";")[1].split("filename=")[1];
334
+            var file = new Blob([data], {
335
+                type: 'application/vnd.ms-excel'
336
+            });
337
+            var fileURL = URL.createObjectURL(file);
338
+            var a = document.createElement('a');
339
+            a.href = fileURL;
340
+            a.target = '_blank';
341
+            a.download = fileName + '.xls';
342
+            document.body.appendChild(a);
343
+            a.click();
344
+        }).error(function (data, status, headers, config) {
345
+        });
346
+    };
281 347
     //初始化
282 348
     $scope.mdxquery('total', 'desc');
283 349
     $scope.sortActive = 'totaltop';

+ 2 - 2
assets/views/report/event_form.html

@@ -123,8 +123,8 @@
123 123
                     <div class="col-xs-3 col-sm-3 pull-right P-0 searchBtnBox">
124 124
                         <div class="btn btn_search fl" ng-click="mdxquery()">搜索</div>
125 125
                         <div class="btn btn_reset fl" ng-click="reload()" ng-disabled="disabledParentGroup">重置</div>
126
-                        <!-- <div class="btn btn_export fl" ng-click="export()" id="exportToExcel"
127
-                            ng-disabled="disabledParentGroup">导出</div> -->
126
+                        <div class="btn btn_export fl" ng-click="export()" id="exportToExcel"
127
+                            ng-disabled="disabledParentGroup">导出</div>
128 128
                     </div>
129 129
                 </form>
130 130
             </div>

+ 2 - 2
assets/views/report/service_form.html

@@ -62,8 +62,8 @@
62 62
                     <div class="col-xs-3 col-sm-3 pull-right P-0 searchBtnBox">
63 63
                         <div class="btn btn_search fl" ng-click="mdxquery(name, type)">搜索</div>
64 64
                         <div class="btn btn_reset fl" ng-click="reload(true)" ng-disabled="disabledParentGroup">重置</div>
65
-                        <!-- <div class="btn btn_export fl" ng-click="export()" id="exportToExcel"
66
-                            ng-disabled="disabledParentGroup">导出</div> -->
65
+                        <div class="btn btn_export fl" ng-click="export()" id="exportToExcel"
66
+                            ng-disabled="disabledParentGroup">导出</div>
67 67
                     </div>
68 68
                 </form>
69 69
             </div>