"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", function ( $scope, $rootScope, $state, $timeout, $interval, $http, $cookieStore, moment, SweetAlert, Restangular, api_report, api_statistic, api_bpm_data, api_user_data ) { // 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: "王磊" // }] api_user_data .fetchDataList("group", { idx: 0, sum: 1000, group: { selectType: "nouser" }, }) .then(function (response) { if (response) { if ((response.status = 200)) { $scope.groups = response.list; } } }); 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.allMoney = 0; $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(); } // if (angular.isDefined(workspace.query)) { // if ($scope.rptUUID) { // // workspace.query.parameters = ConvertDateParameter($scope.parameters); // $scope.starttimes = workspace.query.parameters.paramDateFrom; // $scope.endtimes = workspace.query.parameters.paramDateTo; // reshdata(); // } else { // // $scope.rptUUID = undefined; // // workspace.query.parameters = ConvertDateParameter($scope.parameters); // if (angular.isDefined($scope.parameters.paramDateFrom) && angular.isDefined($scope.parameters.paramDateTo)) { // $scope.starttimes = workspace.query.parameters.paramDateFrom; // $scope.endtimes = workspace.query.parameters.paramDateTo; // reshdata(); // } // } // } }; function reshdata(group) { api_bpm_data .fetchDataByGroupId({ 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) // } } } }); } }, ]);