chargingCtrl.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. "use strict";
  2. app.controller("chartingCtrl", [
  3. "$scope",
  4. "$rootScope",
  5. "$state",
  6. "$timeout",
  7. "$interval",
  8. "$http",
  9. "$cookieStore",
  10. "moment",
  11. "SweetAlert",
  12. "Restangular",
  13. "api_report",
  14. "api_statistic",
  15. "api_bpm_data",
  16. "api_user_data",
  17. function (
  18. $scope,
  19. $rootScope,
  20. $state,
  21. $timeout,
  22. $interval,
  23. $http,
  24. $cookieStore,
  25. moment,
  26. SweetAlert,
  27. Restangular,
  28. api_report,
  29. api_statistic,
  30. api_bpm_data,
  31. api_user_data
  32. ) {
  33. // var ROWS = "ROWS";
  34. // var COLUMNS = "COLUMNS";
  35. // $scope.treeshow = true;
  36. // // $scope.headers = "请选择事件树形列表!";
  37. // api_report.getLicenseKey().then(function(response) {
  38. // $cookieStore.put('Auth-Token', response.token);
  39. // // $scope.try_async_load();
  40. // });
  41. // var apple_selected, tree, treedata_avm, treedata_geography;
  42. // var workspace = {};
  43. $scope.parameters = {};
  44. $scope.allMoney = 0;
  45. $scope.category = {};
  46. $scope.reportName = "计费";
  47. $scope.allheight = 100;
  48. $scope.isMaskground = false;
  49. $scope.open = function ($event) {
  50. $event.preventDefault();
  51. $event.stopPropagation();
  52. $scope.opened = !$scope.opened;
  53. };
  54. $scope.endOpen = function ($event) {
  55. $event.preventDefault();
  56. $event.stopPropagation();
  57. $scope.startOpened = false;
  58. $scope.endOpened = !$scope.endOpened;
  59. };
  60. $scope.startOpen = function ($event) {
  61. $event.preventDefault();
  62. $event.stopPropagation();
  63. $scope.endOpened = false;
  64. $scope.startOpened = !$scope.startOpened;
  65. };
  66. // var starttime, endtime
  67. // $scope.starttimes = moment().startOf('month').format('YYYYMMDD');
  68. // $scope.endtimes = moment().format('YYYYMMDD');
  69. $scope.starttimes = moment(
  70. new Date(moment().startOf("month")).setMonth(new Date().getMonth() - 1)
  71. ).format("YYYY-MM-DD HH:mm:ss");
  72. $scope.endtimes = moment(
  73. new Date(moment().startOf("month")).setMonth(new Date().getMonth()) - 1
  74. ).format("YYYY-MM-DD HH:mm:ss");
  75. $scope.parameters.paramDateFrom = $scope.starttimes;
  76. $scope.parameters.paramDateTo = $scope.endtimes;
  77. // $scope.charginrow = [{
  78. // complexity: 774,
  79. // incidentCount: 18,
  80. // name: "李晓峰"
  81. // }, {
  82. // complexity: 23,
  83. // incidentCount: 12,
  84. // name: "王磊"
  85. // }]
  86. api_user_data
  87. .fetchDataList("group", {
  88. idx: 0,
  89. sum: 1000,
  90. group: { selectType: "nouser" },
  91. })
  92. .then(function (response) {
  93. if (response) {
  94. if ((response.status = 200)) {
  95. $scope.groups = response.list;
  96. }
  97. }
  98. });
  99. reshdata();
  100. $scope.reset = function () {
  101. $scope.parameters = {};
  102. $scope.starttimes = moment(
  103. new Date(moment().startOf("month")).setMonth(new Date().getMonth() - 1)
  104. ).format("YYYY-MM-DD HH:mm:ss");
  105. $scope.endtimes = moment(
  106. new Date(moment().startOf("month")).setMonth(new Date().getMonth()) - 1
  107. ).format("YYYY-MM-DD HH:mm:ss");
  108. $scope.parameters.paramDateFrom = $scope.starttimes;
  109. $scope.parameters.paramDateTo = $scope.endtimes;
  110. $scope.allMoney = 0;
  111. $scope.mdxquerym($scope.parameters.group);
  112. };
  113. // var sumChargin = 0;
  114. // angular.forEach($scope.charginrow, function(item) {
  115. // sumChargin = sumChargin + item.complexity;
  116. // })
  117. // $scope.shareMoney = function(allMoney) {
  118. // $scope.allMoney = allMoney;
  119. // $scope.reportData = angular.copy($scope.manyData);
  120. // $scope.rRows = [];
  121. // $scope.rheaders = [];
  122. // checkmoney(allMoney)
  123. // }
  124. // $scope.shareMoney = function(key) {
  125. // $scope.mdxquerym($scope.parameters.group);
  126. // }
  127. $scope.mdxquerym = function (group) {
  128. $scope.starttimes = moment($scope.parameters.paramDateFrom).format(
  129. "YYYY-MM-DD HH:mm:ss"
  130. );
  131. $scope.endtimes = moment($scope.parameters.paramDateTo).format(
  132. "YYYY-MM-DD HH:mm:ss"
  133. );
  134. $scope.isMaskground = true;
  135. $scope.shows = false;
  136. if (group) {
  137. reshdata(group.id);
  138. } else {
  139. reshdata();
  140. }
  141. // if (angular.isDefined(workspace.query)) {
  142. // if ($scope.rptUUID) {
  143. // // workspace.query.parameters = ConvertDateParameter($scope.parameters);
  144. // $scope.starttimes = workspace.query.parameters.paramDateFrom;
  145. // $scope.endtimes = workspace.query.parameters.paramDateTo;
  146. // reshdata();
  147. // } else {
  148. // // $scope.rptUUID = undefined;
  149. // // workspace.query.parameters = ConvertDateParameter($scope.parameters);
  150. // if (angular.isDefined($scope.parameters.paramDateFrom) && angular.isDefined($scope.parameters.paramDateTo)) {
  151. // $scope.starttimes = workspace.query.parameters.paramDateFrom;
  152. // $scope.endtimes = workspace.query.parameters.paramDateTo;
  153. // reshdata();
  154. // }
  155. // }
  156. // }
  157. };
  158. function reshdata(group) {
  159. api_bpm_data
  160. .fetchDataByGroupId({
  161. groupID: group,
  162. startTime: $scope.starttimes,
  163. finishTime: $scope.endtimes,
  164. weight: $scope.allMoney,
  165. })
  166. .then(function (response) {
  167. if (response) {
  168. if ((response.status = 200)) {
  169. $scope.isMaskground = false;
  170. $scope.charginrow = response.data;
  171. // var totalComplexity = 0;
  172. // totalComplexity = $scope.charginrow.reduce((pre,cur)=>pre + cur.complexity,0)
  173. angular.forEach($scope.charginrow, function(item) {
  174. // sumChargin = sumChargin + item.complexity;
  175. // item.complexityPercentage = (item.complexity / totalComplexity * 100).toFixed(2) + '%';
  176. item.percent += '%';
  177. })
  178. if (response.list && response.list.length == 0) {
  179. $scope.shows = true;
  180. $scope.empty = "数据为空!";
  181. }
  182. // if ($scope.allMoney != 0) {
  183. // $scope.shareMoney($scope.allMoney)
  184. // }
  185. }
  186. }
  187. });
  188. }
  189. },
  190. ]);