chargingCtrl.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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 = {userIds: []};
  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. var getUser = function (fieldatas) {
  90. api_user_data.fetchDataList('user', fieldatas).then(function (data) {
  91. $scope.userList = data.list;
  92. });
  93. }
  94. //处理人过滤
  95. $scope.onChangehandling = function (key = '') {
  96. var filuser = {
  97. "idx": 0,
  98. "sum": 10,
  99. "user": {
  100. "name": key,
  101. 'selectType': "pinyin_qs",
  102. engineer: 1,
  103. }
  104. }
  105. getUser(filuser);
  106. }
  107. // 切换院区
  108. $scope.changeBranch = function(){
  109. console.log($scope.parameters.branch);
  110. $scope.dutys = [];
  111. $scope.parameters.duty = null;
  112. $scope.parameters.branch && $scope.getOwnDuty($scope.parameters.branch.id);
  113. }
  114. // 切换责任科室
  115. $scope.changeDuty = function(){
  116. console.log($scope.parameters.duty);
  117. $scope.groups = [];
  118. $scope.parameters.group = null;
  119. $scope.parameters.duty && $scope.getGroups($scope.parameters.duty);
  120. }
  121. // 获取院区
  122. $scope.branchs = [];
  123. $scope.getOwnBranch = function(){
  124. api_category
  125. .getOwnBranch({})
  126. .then(function (response) {
  127. if (response) {
  128. if ((response.status = 200)) {
  129. $scope.branchs = response.data;
  130. if($rootScope.user.duty){
  131. $scope.parameters.branch = {id: $rootScope.user.duty.branch, hosName: $rootScope.user.duty.branchName};
  132. $scope.getOwnDuty($rootScope.user.duty.branch, true);
  133. }else if($rootScope.user.branch){
  134. $scope.parameters.branch = $rootScope.user.branch;
  135. $scope.getOwnDuty($rootScope.user.branch.id, true);
  136. $scope.mdxquerym($scope.parameters.group);
  137. }
  138. }
  139. }
  140. });
  141. }
  142. $scope.getOwnBranch();
  143. // 获取责任科室
  144. $scope.dutys = [];
  145. $scope.getOwnDuty = function(branchId, isFirst = false){
  146. api_category
  147. .getOwnDuty({branchId: branchId})
  148. .then(function (response) {
  149. if (response) {
  150. if ((response.status = 200)) {
  151. $scope.dutys = response.data;
  152. if(isFirst && $rootScope.user.duty){
  153. $scope.parameters.duty = $rootScope.user.duty;
  154. $scope.getGroups($scope.parameters.duty);
  155. $scope.mdxquerym($scope.parameters.group);
  156. }
  157. }
  158. }
  159. });
  160. }
  161. // 获取工作组
  162. $scope.groups = [];
  163. $scope.getGroups = function(duty){
  164. api_user_data
  165. .fetchDataList("group", {
  166. idx: 0,
  167. sum: 1000,
  168. group: { selectType: "nouser", duty: duty },
  169. })
  170. .then(function (response) {
  171. if (response) {
  172. if ((response.status = 200)) {
  173. $scope.groups = response.list;
  174. }
  175. }
  176. });
  177. }
  178. // 重置
  179. $scope.reset = function () {
  180. $scope.parameters = {userIds:[]};
  181. $scope.starttimes = moment(
  182. new Date(moment().startOf("month")).setMonth(new Date().getMonth() - 1)
  183. ).format("YYYY-MM-DD HH:mm:ss");
  184. $scope.endtimes = moment(
  185. new Date(moment().startOf("month")).setMonth(new Date().getMonth()) - 1
  186. ).format("YYYY-MM-DD HH:mm:ss");
  187. $scope.parameters.paramDateFrom = $scope.starttimes;
  188. $scope.parameters.paramDateTo = $scope.endtimes;
  189. $scope.allMoney = 0;
  190. if($rootScope.user.duty){
  191. $scope.parameters.branch = {id: $rootScope.user.duty.branch, hosName: $rootScope.user.duty.branchName};
  192. $scope.getOwnDuty($rootScope.user.duty.branch, true);
  193. }else if($rootScope.user.branch){
  194. $scope.parameters.branch = $rootScope.user.branch;
  195. $scope.getOwnDuty($rootScope.user.branch.id, true);
  196. $scope.mdxquerym($scope.parameters.group);
  197. }
  198. // $scope.mdxquerym($scope.parameters.group);
  199. };
  200. // var sumChargin = 0;
  201. // angular.forEach($scope.charginrow, function(item) {
  202. // sumChargin = sumChargin + item.complexity;
  203. // })
  204. // $scope.shareMoney = function(allMoney) {
  205. // $scope.allMoney = allMoney;
  206. // $scope.reportData = angular.copy($scope.manyData);
  207. // $scope.rRows = [];
  208. // $scope.rheaders = [];
  209. // checkmoney(allMoney)
  210. // }
  211. // $scope.shareMoney = function(key) {
  212. // $scope.mdxquerym($scope.parameters.group);
  213. // }
  214. $scope.mdxquerym = function (group) {
  215. $scope.starttimes = moment($scope.parameters.paramDateFrom).format(
  216. "YYYY-MM-DD HH:mm:ss"
  217. );
  218. $scope.endtimes = moment($scope.parameters.paramDateTo).format(
  219. "YYYY-MM-DD HH:mm:ss"
  220. );
  221. $scope.isMaskground = true;
  222. $scope.shows = false;
  223. if (group) {
  224. reshdata(group.id);
  225. } else {
  226. reshdata();
  227. }
  228. };
  229. function reshdata(group) {
  230. api_bpm_data
  231. .fetchDataByGroupId({
  232. dutyId: $scope.parameters.duty ? $scope.parameters.duty.id : undefined,
  233. branchId: $scope.parameters.branch ? $scope.parameters.branch.id : undefined,
  234. groupID: group,
  235. startTime: $scope.starttimes,
  236. finishTime: $scope.endtimes,
  237. weight: $scope.allMoney,
  238. userIds: $scope.parameters.userIds.length ? $scope.parameters.userIds.map(v => v.id).toString() : undefined
  239. })
  240. .then(function (response) {
  241. if (response) {
  242. if ((response.status = 200)) {
  243. $scope.isMaskground = false;
  244. $scope.charginrow = response.data;
  245. // var totalComplexity = 0;
  246. // totalComplexity = $scope.charginrow.reduce((pre,cur)=>pre + cur.complexity,0)
  247. angular.forEach($scope.charginrow, function(item) {
  248. // sumChargin = sumChargin + item.complexity;
  249. // item.complexityPercentage = (item.complexity / totalComplexity * 100).toFixed(2) + '%';
  250. item.percent += '%';
  251. })
  252. if (response.list && response.list.length == 0) {
  253. $scope.shows = true;
  254. $scope.empty = "数据为空!";
  255. }
  256. // if ($scope.allMoney != 0) {
  257. // $scope.shareMoney($scope.allMoney)
  258. // }
  259. }
  260. }
  261. });
  262. }
  263. },
  264. ]);