chargingCtrl.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. "api_category",
  18. function (
  19. $scope,
  20. $rootScope,
  21. $state,
  22. $timeout,
  23. $interval,
  24. $http,
  25. $cookieStore,
  26. moment,
  27. SweetAlert,
  28. Restangular,
  29. api_report,
  30. api_statistic,
  31. api_bpm_data,
  32. api_user_data,
  33. api_category
  34. ) {
  35. // var ROWS = "ROWS";
  36. // var COLUMNS = "COLUMNS";
  37. // $scope.treeshow = true;
  38. // // $scope.headers = "请选择事件树形列表!";
  39. // api_report.getLicenseKey().then(function(response) {
  40. // $cookieStore.put('Auth-Token', response.token);
  41. // // $scope.try_async_load();
  42. // });
  43. // var apple_selected, tree, treedata_avm, treedata_geography;
  44. // var workspace = {};
  45. $scope.parameters = {};
  46. $scope.allMoney = 0;
  47. $scope.category = {};
  48. $scope.reportName = "计费";
  49. $scope.allheight = 100;
  50. $scope.isMaskground = false;
  51. $scope.open = function ($event) {
  52. $event.preventDefault();
  53. $event.stopPropagation();
  54. $scope.opened = !$scope.opened;
  55. };
  56. $scope.endOpen = function ($event) {
  57. $event.preventDefault();
  58. $event.stopPropagation();
  59. $scope.startOpened = false;
  60. $scope.endOpened = !$scope.endOpened;
  61. };
  62. $scope.startOpen = function ($event) {
  63. $event.preventDefault();
  64. $event.stopPropagation();
  65. $scope.endOpened = false;
  66. $scope.startOpened = !$scope.startOpened;
  67. };
  68. // var starttime, endtime
  69. // $scope.starttimes = moment().startOf('month').format('YYYYMMDD');
  70. // $scope.endtimes = moment().format('YYYYMMDD');
  71. $scope.starttimes = moment(
  72. new Date(moment().startOf("month")).setMonth(new Date().getMonth() - 1)
  73. ).format("YYYY-MM-DD HH:mm:ss");
  74. $scope.endtimes = moment(
  75. new Date(moment().startOf("month")).setMonth(new Date().getMonth()) - 1
  76. ).format("YYYY-MM-DD HH:mm:ss");
  77. $scope.parameters.paramDateFrom = $scope.starttimes;
  78. $scope.parameters.paramDateTo = $scope.endtimes;
  79. // $scope.charginrow = [{
  80. // complexity: 774,
  81. // incidentCount: 18,
  82. // name: "李晓峰"
  83. // }, {
  84. // complexity: 23,
  85. // incidentCount: 12,
  86. // name: "王磊"
  87. // }]
  88. // 切换院区
  89. $scope.changeBranch = function(){
  90. console.log($scope.parameters.branch);
  91. $scope.dutys = [];
  92. $scope.parameters.duty = null;
  93. $scope.parameters.branch && $scope.getOwnDuty($scope.parameters.branch.id);
  94. }
  95. // 切换责任科室
  96. $scope.changeDuty = function(){
  97. console.log($scope.parameters.duty);
  98. $scope.groups = [];
  99. $scope.parameters.group = null;
  100. $scope.parameters.duty && $scope.getGroups($scope.parameters.duty);
  101. }
  102. // 获取院区
  103. $scope.branchs = [];
  104. $scope.getOwnBranch = function(){
  105. api_category
  106. .getOwnBranch({})
  107. .then(function (response) {
  108. if (response) {
  109. if ((response.status = 200)) {
  110. $scope.branchs = response.data;
  111. if($rootScope.user.duty){
  112. $scope.parameters.branch = {id: $rootScope.user.duty.branch, hosName: $rootScope.user.duty.branchName};
  113. $scope.getOwnDuty($rootScope.user.duty.branch, true);
  114. }else if($rootScope.user.branch){
  115. $scope.parameters.branch = $rootScope.user.branch;
  116. $scope.getOwnDuty($rootScope.user.branch.id, true);
  117. $scope.mdxquerym($scope.parameters.group);
  118. }
  119. }
  120. }
  121. });
  122. }
  123. $scope.getOwnBranch();
  124. // 获取责任科室
  125. $scope.dutys = [];
  126. $scope.getOwnDuty = function(branchId, isFirst = false){
  127. api_category
  128. .getOwnDuty({branchId: branchId})
  129. .then(function (response) {
  130. if (response) {
  131. if ((response.status = 200)) {
  132. $scope.dutys = response.data;
  133. if(isFirst && $rootScope.user.duty){
  134. $scope.parameters.duty = $rootScope.user.duty;
  135. $scope.getGroups($scope.parameters.duty);
  136. $scope.mdxquerym($scope.parameters.group);
  137. }
  138. }
  139. }
  140. });
  141. }
  142. // 获取工作组
  143. $scope.groups = [];
  144. $scope.getGroups = function(duty){
  145. api_user_data
  146. .fetchDataList("group", {
  147. idx: 0,
  148. sum: 1000,
  149. group: { selectType: "nouser", duty: duty },
  150. })
  151. .then(function (response) {
  152. if (response) {
  153. if ((response.status = 200)) {
  154. $scope.groups = response.list;
  155. }
  156. }
  157. });
  158. }
  159. // 重置
  160. $scope.reset = function () {
  161. $scope.parameters = {};
  162. $scope.starttimes = moment(
  163. new Date(moment().startOf("month")).setMonth(new Date().getMonth() - 1)
  164. ).format("YYYY-MM-DD HH:mm:ss");
  165. $scope.endtimes = moment(
  166. new Date(moment().startOf("month")).setMonth(new Date().getMonth()) - 1
  167. ).format("YYYY-MM-DD HH:mm:ss");
  168. $scope.parameters.paramDateFrom = $scope.starttimes;
  169. $scope.parameters.paramDateTo = $scope.endtimes;
  170. $scope.allMoney = 0;
  171. if($rootScope.user.duty){
  172. $scope.parameters.branch = {id: $rootScope.user.duty.branch, hosName: $rootScope.user.duty.branchName};
  173. $scope.getOwnDuty($rootScope.user.duty.branch, true);
  174. }else if($rootScope.user.branch){
  175. $scope.parameters.branch = $rootScope.user.branch;
  176. $scope.getOwnDuty($rootScope.user.branch.id, true);
  177. $scope.mdxquerym($scope.parameters.group);
  178. }
  179. // $scope.mdxquerym($scope.parameters.group);
  180. };
  181. // var sumChargin = 0;
  182. // angular.forEach($scope.charginrow, function(item) {
  183. // sumChargin = sumChargin + item.complexity;
  184. // })
  185. // $scope.shareMoney = function(allMoney) {
  186. // $scope.allMoney = allMoney;
  187. // $scope.reportData = angular.copy($scope.manyData);
  188. // $scope.rRows = [];
  189. // $scope.rheaders = [];
  190. // checkmoney(allMoney)
  191. // }
  192. // $scope.shareMoney = function(key) {
  193. // $scope.mdxquerym($scope.parameters.group);
  194. // }
  195. $scope.mdxquerym = function (group) {
  196. $scope.starttimes = moment($scope.parameters.paramDateFrom).format(
  197. "YYYY-MM-DD HH:mm:ss"
  198. );
  199. $scope.endtimes = moment($scope.parameters.paramDateTo).format(
  200. "YYYY-MM-DD HH:mm:ss"
  201. );
  202. $scope.isMaskground = true;
  203. $scope.shows = false;
  204. if (group) {
  205. reshdata(group.id);
  206. } else {
  207. reshdata();
  208. }
  209. };
  210. function reshdata(group) {
  211. api_bpm_data
  212. .fetchDataByGroupId({
  213. dutyId: $scope.parameters.duty ? $scope.parameters.duty.id : undefined,
  214. branchId: $scope.parameters.branch ? $scope.parameters.branch.id : undefined,
  215. groupID: group,
  216. startTime: $scope.starttimes,
  217. finishTime: $scope.endtimes,
  218. weight: $scope.allMoney,
  219. })
  220. .then(function (response) {
  221. if (response) {
  222. if ((response.status = 200)) {
  223. $scope.isMaskground = false;
  224. $scope.charginrow = response.data;
  225. // var totalComplexity = 0;
  226. // totalComplexity = $scope.charginrow.reduce((pre,cur)=>pre + cur.complexity,0)
  227. angular.forEach($scope.charginrow, function(item) {
  228. // sumChargin = sumChargin + item.complexity;
  229. // item.complexityPercentage = (item.complexity / totalComplexity * 100).toFixed(2) + '%';
  230. item.percent += '%';
  231. })
  232. if (response.list && response.list.length == 0) {
  233. $scope.shows = true;
  234. $scope.empty = "数据为空!";
  235. }
  236. // if ($scope.allMoney != 0) {
  237. // $scope.shareMoney($scope.allMoney)
  238. // }
  239. }
  240. }
  241. });
  242. }
  243. },
  244. ]);