chargingCtrl.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. 'use strict';
  2. 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) {
  3. // var ROWS = "ROWS";
  4. // var COLUMNS = "COLUMNS";
  5. // $scope.treeshow = true;
  6. // // $scope.headers = "请选择事件树形列表!";
  7. // api_report.getLicenseKey().then(function(response) {
  8. // $cookieStore.put('Auth-Token', response.token);
  9. // // $scope.try_async_load();
  10. // });
  11. // var apple_selected, tree, treedata_avm, treedata_geography;
  12. // var workspace = {};
  13. $scope.parameters = {};
  14. $scope.allMoney = 0;
  15. $scope.category = {};
  16. $scope.reportName = "计费";
  17. $scope.allheight = 100;
  18. $scope.isMaskground = false;
  19. $scope.open = function($event) {
  20. $event.preventDefault();
  21. $event.stopPropagation();
  22. $scope.opened = !$scope.opened;
  23. };
  24. $scope.endOpen = function($event) {
  25. $event.preventDefault();
  26. $event.stopPropagation();
  27. $scope.startOpened = false;
  28. $scope.endOpened = !$scope.endOpened;
  29. };
  30. $scope.startOpen = function($event) {
  31. $event.preventDefault();
  32. $event.stopPropagation();
  33. $scope.endOpened = false;
  34. $scope.startOpened = !$scope.startOpened;
  35. };
  36. // var starttime, endtime
  37. // $scope.starttimes = moment().startOf('month').format('YYYYMMDD');
  38. // $scope.endtimes = moment().format('YYYYMMDD');
  39. $scope.starttimes = moment((new Date(moment().startOf('month'))).setMonth((new Date()).getMonth() - 1)).format('YYYY-MM-DD HH:mm:ss');
  40. $scope.endtimes = moment((new Date(moment().startOf('month'))).setMonth((new Date()).getMonth()) - 1).format('YYYY-MM-DD HH:mm:ss')
  41. $scope.parameters.paramDateFrom = $scope.starttimes;
  42. $scope.parameters.paramDateTo = $scope.endtimes;
  43. $scope.parameters.group = { "id": 1, "groupName": "网络维修组" };
  44. // $scope.charginrow = [{
  45. // complexity: 774,
  46. // incidentCount: 18,
  47. // name: "李晓峰"
  48. // }, {
  49. // complexity: 23,
  50. // incidentCount: 12,
  51. // name: "王磊"
  52. // }]
  53. api_user_data.fetchDataList('group', { "idx": 0, "sum": 1000 }).then(function(response) {
  54. if (response) {
  55. if (response.status = 200) {
  56. $scope.groups = response.list;
  57. }
  58. }
  59. });
  60. reshdata(1);
  61. var sumChargin = 0;
  62. angular.forEach($scope.charginrow, function(item) {
  63. sumChargin = sumChargin + item.complexity;
  64. })
  65. // $scope.shareMoney = function(allMoney) {
  66. // $scope.allMoney = allMoney;
  67. // $scope.reportData = angular.copy($scope.manyData);
  68. // $scope.rRows = [];
  69. // $scope.rheaders = [];
  70. // checkmoney(allMoney)
  71. // }
  72. $scope.shareMoney = function(key) {
  73. $scope.allMoney = key;
  74. angular.forEach($scope.charginrow, function(item) {
  75. item.money = (key * item.complexity / sumChargin).toFixed(2);
  76. })
  77. }
  78. $scope.mdxquerym = function(group) {
  79. $scope.starttimes = moment($scope.parameters.paramDateFrom).format('YYYY-MM-DD HH:mm:ss');
  80. $scope.endtimes = moment($scope.parameters.paramDateTo).format('YYYY-MM-DD HH:mm:ss');
  81. $scope.isMaskground = true;
  82. $scope.shows = false;
  83. if (group) {
  84. reshdata(group.id);
  85. } else {
  86. reshdata();
  87. }
  88. // if (angular.isDefined(workspace.query)) {
  89. // if ($scope.rptUUID) {
  90. // // workspace.query.parameters = ConvertDateParameter($scope.parameters);
  91. // $scope.starttimes = workspace.query.parameters.paramDateFrom;
  92. // $scope.endtimes = workspace.query.parameters.paramDateTo;
  93. // reshdata();
  94. // } else {
  95. // // $scope.rptUUID = undefined;
  96. // // workspace.query.parameters = ConvertDateParameter($scope.parameters);
  97. // if (angular.isDefined($scope.parameters.paramDateFrom) && angular.isDefined($scope.parameters.paramDateTo)) {
  98. // $scope.starttimes = workspace.query.parameters.paramDateFrom;
  99. // $scope.endtimes = workspace.query.parameters.paramDateTo;
  100. // reshdata();
  101. // }
  102. // }
  103. // }
  104. }
  105. function reshdata(group) {
  106. api_bpm_data.fetchDataByGroupId({ "groupID": group, "startTime": $scope.starttimes, "finishTime": $scope.endtimes }).then(function(response) {
  107. if (response) {
  108. if (response.status = 200) {
  109. $scope.isMaskground = false;
  110. $scope.charginrow = response.data;
  111. angular.forEach($scope.charginrow, function(item) {
  112. sumChargin = sumChargin + item.complexity;
  113. })
  114. if (response.list && response.list.length == 0) {
  115. $scope.shows = true;
  116. $scope.empty = "数据为空!"
  117. }
  118. if ($scope.allMoney != 0) {
  119. $scope.shareMoney($scope.allMoney)
  120. }
  121. }
  122. }
  123. });
  124. }
  125. }]);