"use strict"; app.controller("servicePerformanceCtrl", [ "$scope", "$rootScope", "$state", "$timeout", "$interval", "$http", "$cookieStore", "moment", "SweetAlert", "Restangular", "api_report", "api_statistic", "api_bpm_data", "api_user_data", "$modal", function ( $scope, $rootScope, $state, $timeout, $interval, $http, $cookieStore, moment, SweetAlert, Restangular, api_report, api_statistic, api_bpm_data, api_user_data, $modal ) { $scope.parameters = {}; $scope.category = {}; $scope.reportName = "计费"; $scope.allheight = 100; $scope.isMaskground = false; $scope.open = function ($event) { $event.preventDefault(); $event.stopPropagation(); $scope.opened = !$scope.opened; }; $scope.endOpen = function ($event) { $event.preventDefault(); $event.stopPropagation(); $scope.startOpened = false; $scope.endOpened = !$scope.endOpened; }; $scope.startOpen = function ($event) { $event.preventDefault(); $event.stopPropagation(); $scope.endOpened = false; $scope.startOpened = !$scope.startOpened; }; $scope.starttimes = moment( new Date(moment().startOf("month")).setMonth(new Date().getMonth() - 1) ).format("YYYY-MM-DD HH:mm:ss"); $scope.endtimes = moment( new Date(moment().startOf("month")).setMonth(new Date().getMonth()) - 1 ).format("YYYY-MM-DD HH:mm:ss"); $scope.parameters.paramDateFrom = $scope.starttimes; $scope.parameters.paramDateTo = $scope.endtimes; $scope.reshdata = function() { api_bpm_data .serviceCount({ type: 'serviceCountList', startTime: $scope.starttimes, finishTime: $scope.endtimes, }) .then(function (response) { if (response) { if ((response.status = 200)) { $scope.isMaskground = false; $scope.charginrow = response.data; var totalScore = $scope.charginrow.reduce((pre,cur)=>{ return pre + cur.score; },0) angular.forEach($scope.charginrow, function(item) { if(totalScore){ item.percent = (item.score * 100 / totalScore).toFixed(2) + '%'; }else{ item.percent = '0%'; } }) if (response.list && response.list.length == 0) { $scope.shows = true; $scope.empty = "数据为空!"; } } } }); } $scope.reshdata(); $scope.reset = function () { $scope.parameters = {}; $scope.starttimes = moment( new Date(moment().startOf("month")).setMonth(new Date().getMonth() - 1) ).format("YYYY-MM-DD HH:mm:ss"); $scope.endtimes = moment( new Date(moment().startOf("month")).setMonth(new Date().getMonth()) - 1 ).format("YYYY-MM-DD HH:mm:ss"); $scope.parameters.paramDateFrom = $scope.starttimes; $scope.parameters.paramDateTo = $scope.endtimes; $scope.mdxquerym(); }; $scope.mdxquerym = function () { $scope.starttimes = moment($scope.parameters.paramDateFrom).format( "YYYY-MM-DD HH:mm:ss" ); $scope.endtimes = moment($scope.parameters.paramDateTo).format( "YYYY-MM-DD HH:mm:ss" ); $scope.isMaskground = true; $scope.shows = false; $scope.reshdata(); }; // 弹窗1 $scope.servicePerformanceDetail = function(data){ if(!data.incidentId){ return; } $modal.open({ resolve: { scope: function () { return $scope; }, }, size: "lg", templateUrl: 'assets/views/customform/tpl/servicePerformanceDetail1.html', controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert, api_wechatfile) { $scope.title = "提示"; $scope.reshdata = function() { $scope.isMaskground = true; api_bpm_data .serviceCount({ type: 'serviceDaysList', userId: data.userId, startTime: scope.starttimes, finishTime: scope.endtimes, }) .then(function (response) { if (response) { if ((response.status = 200)) { $scope.isMaskground = false; $scope.charginrow = response.data; if (response.list && response.list.length == 0) { $scope.shows = true; $scope.empty = "数据为空!"; } } } }); } $scope.reshdata(); $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; // 弹窗2 $scope.servicePerformanceDetail = function(data){ $scope.cancel(); $modal.open({ resolve: { scope: function () { return scope; }, }, size: "lg", templateUrl: 'assets/views/customform/tpl/servicePerformanceDetail2.html', controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert, api_wechatfile) { $scope.title = "提示"; $scope.reshdata = function() { $scope.isMaskground = true; api_bpm_data .serviceCount({ type: 'serviceIncidentList', userId: data.userId, startTime: data.acceptdate, finishTime: data.acceptdate, }) .then(function (response) { if (response) { if ((response.status = 200)) { $scope.isMaskground = false; $scope.charginrow = response.data; if (response.list && response.list.length == 0) { $scope.shows = true; $scope.empty = "数据为空!"; } } } }); } $scope.reshdata(); $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; // 弹窗3 $scope.servicePerformanceDetail = function(data){ $scope.cancel(); $modal.open({ resolve: { scope: function () { return scope; }, }, size: "lg", templateUrl: 'assets/views/customform/tpl/servicePerformanceDetail3.html', controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert, api_wechatfile) { $scope.title = data.category + "-" + data.score; $scope.reshdata = function() { $scope.isMaskground = true; api_bpm_data .serviceCount({ type: 'serviceDetailsList', incidentId: data.incidentId, startTime: moment(data.acceptdate).format('YYYY-MM-DD'), finishTime: moment(data.acceptdate).format('YYYY-MM-DD'), }) .then(function (response) { if (response) { if ((response.status = 200)) { $scope.isMaskground = false; $scope.charginrow = response.data; if (response.list && response.list.length == 0) { $scope.shows = true; $scope.empty = "数据为空!"; } } } }); } $scope.reshdata(); $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; }, }); } }, }); } }, }); } }, ]);