"use strict"; app.controller("chartingCtrl", [ "$scope", "$rootScope", "$state", "$timeout", "$interval", "$http", "$cookieStore", "moment", "SweetAlert", "Restangular", "api_report", "api_statistic", "api_bpm_data", "api_user_data", "api_category", function ( $scope, $rootScope, $state, $timeout, $interval, $http, $cookieStore, moment, SweetAlert, Restangular, api_report, api_statistic, api_bpm_data, api_user_data, api_category ) { // var ROWS = "ROWS"; // var COLUMNS = "COLUMNS"; // $scope.treeshow = true; // // $scope.headers = "请选择事件树形列表!"; // api_report.getLicenseKey().then(function(response) { // $cookieStore.put('Auth-Token', response.token); // // $scope.try_async_load(); // }); // var apple_selected, tree, treedata_avm, treedata_geography; // var workspace = {}; $scope.parameters = {}; $scope.allMoney = 0; $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; }; // var starttime, endtime // $scope.starttimes = moment().startOf('month').format('YYYYMMDD'); // $scope.endtimes = moment().format('YYYYMMDD'); $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.charginrow = [{ // complexity: 774, // incidentCount: 18, // name: "李晓峰" // }, { // complexity: 23, // incidentCount: 12, // name: "王磊" // }] // 切换院区 $scope.changeBranch = function(){ console.log($scope.parameters.branch); $scope.dutys = []; $scope.parameters.duty = null; $scope.parameters.branch && $scope.getOwnDuty($scope.parameters.branch.id); } // 切换责任科室 $scope.changeDuty = function(){ console.log($scope.parameters.duty); $scope.groups = []; $scope.parameters.group = null; $scope.parameters.duty && $scope.getGroups($scope.parameters.duty); } // 获取院区 $scope.branchs = []; $scope.getOwnBranch = function(){ api_category .getOwnBranch({}) .then(function (response) { if (response) { if ((response.status = 200)) { $scope.branchs = response.data; if($rootScope.user.duty){ $scope.parameters.branch = {id: $rootScope.user.duty.branch, hosName: $rootScope.user.duty.branchName}; $scope.getOwnDuty($rootScope.user.duty.branch, true); }else if($rootScope.user.branch){ $scope.parameters.branch = $rootScope.user.branch; $scope.getOwnDuty($rootScope.user.branch.id, true); $scope.mdxquerym($scope.parameters.group); } } } }); } $scope.getOwnBranch(); // 获取责任科室 $scope.dutys = []; $scope.getOwnDuty = function(branchId, isFirst = false){ api_category .getOwnDuty({branchId: branchId}) .then(function (response) { if (response) { if ((response.status = 200)) { $scope.dutys = response.data; if(isFirst && $rootScope.user.duty){ $scope.parameters.duty = $rootScope.user.duty; $scope.getGroups($scope.parameters.duty); $scope.mdxquerym($scope.parameters.group); } } } }); } // 获取工作组 $scope.groups = []; $scope.getGroups = function(duty){ api_user_data .fetchDataList("group", { idx: 0, sum: 1000, group: { selectType: "nouser", duty: duty }, }) .then(function (response) { if (response) { if ((response.status = 200)) { $scope.groups = response.list; } } }); } // 重置 $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.allMoney = 0; if($rootScope.user.duty){ $scope.parameters.branch = {id: $rootScope.user.duty.branch, hosName: $rootScope.user.duty.branchName}; $scope.getOwnDuty($rootScope.user.duty.branch, true); }else if($rootScope.user.branch){ $scope.parameters.branch = $rootScope.user.branch; $scope.getOwnDuty($rootScope.user.branch.id, true); $scope.mdxquerym($scope.parameters.group); } // $scope.mdxquerym($scope.parameters.group); }; // var sumChargin = 0; // angular.forEach($scope.charginrow, function(item) { // sumChargin = sumChargin + item.complexity; // }) // $scope.shareMoney = function(allMoney) { // $scope.allMoney = allMoney; // $scope.reportData = angular.copy($scope.manyData); // $scope.rRows = []; // $scope.rheaders = []; // checkmoney(allMoney) // } // $scope.shareMoney = function(key) { // $scope.mdxquerym($scope.parameters.group); // } $scope.mdxquerym = function (group) { $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; if (group) { reshdata(group.id); } else { reshdata(); } }; function reshdata(group) { api_bpm_data .fetchDataByGroupId({ dutyId: $scope.parameters.duty ? $scope.parameters.duty.id : undefined, branchId: $scope.parameters.branch ? $scope.parameters.branch.id : undefined, groupID: group, startTime: $scope.starttimes, finishTime: $scope.endtimes, weight: $scope.allMoney, }) .then(function (response) { if (response) { if ((response.status = 200)) { $scope.isMaskground = false; $scope.charginrow = response.data; // var totalComplexity = 0; // totalComplexity = $scope.charginrow.reduce((pre,cur)=>pre + cur.complexity,0) angular.forEach($scope.charginrow, function(item) { // sumChargin = sumChargin + item.complexity; // item.complexityPercentage = (item.complexity / totalComplexity * 100).toFixed(2) + '%'; item.percent += '%'; }) if (response.list && response.list.length == 0) { $scope.shows = true; $scope.empty = "数据为空!"; } // if ($scope.allMoney != 0) { // $scope.shareMoney($scope.allMoney) // } } } }); } }, ]);