servicePerformanceCtrl.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. "use strict";
  2. app.controller("servicePerformanceCtrl", [
  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. "$modal",
  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. $modal
  34. ) {
  35. $scope.parameters = {};
  36. $scope.category = {};
  37. $scope.reportName = "计费";
  38. $scope.allheight = 100;
  39. $scope.isMaskground = false;
  40. $scope.open = function ($event) {
  41. $event.preventDefault();
  42. $event.stopPropagation();
  43. $scope.opened = !$scope.opened;
  44. };
  45. $scope.endOpen = function ($event) {
  46. $event.preventDefault();
  47. $event.stopPropagation();
  48. $scope.startOpened = false;
  49. $scope.endOpened = !$scope.endOpened;
  50. };
  51. $scope.startOpen = function ($event) {
  52. $event.preventDefault();
  53. $event.stopPropagation();
  54. $scope.endOpened = false;
  55. $scope.startOpened = !$scope.startOpened;
  56. };
  57. $scope.starttimes = moment(
  58. new Date(moment().startOf("month")).setMonth(new Date().getMonth() - 1)
  59. ).format("YYYY-MM-DD HH:mm:ss");
  60. $scope.endtimes = moment(
  61. new Date(moment().startOf("month")).setMonth(new Date().getMonth()) - 1
  62. ).format("YYYY-MM-DD HH:mm:ss");
  63. $scope.parameters.paramDateFrom = $scope.starttimes;
  64. $scope.parameters.paramDateTo = $scope.endtimes;
  65. $scope.reshdata = function() {
  66. api_bpm_data
  67. .serviceCount({
  68. type: 'serviceCountList',
  69. startTime: $scope.starttimes,
  70. finishTime: $scope.endtimes,
  71. })
  72. .then(function (response) {
  73. if (response) {
  74. if ((response.status = 200)) {
  75. $scope.isMaskground = false;
  76. $scope.charginrow = response.data;
  77. var totalScore = $scope.charginrow.reduce((pre,cur)=>{
  78. return pre + cur.score;
  79. },0)
  80. angular.forEach($scope.charginrow, function(item) {
  81. if(totalScore){
  82. item.percent = (item.score * 100 / totalScore).toFixed(2) + '%';
  83. }else{
  84. item.percent = '0%';
  85. }
  86. })
  87. if (response.list && response.list.length == 0) {
  88. $scope.shows = true;
  89. $scope.empty = "数据为空!";
  90. }
  91. }
  92. }
  93. });
  94. }
  95. $scope.reshdata();
  96. $scope.reset = function () {
  97. $scope.parameters = {};
  98. $scope.starttimes = moment(
  99. new Date(moment().startOf("month")).setMonth(new Date().getMonth() - 1)
  100. ).format("YYYY-MM-DD HH:mm:ss");
  101. $scope.endtimes = moment(
  102. new Date(moment().startOf("month")).setMonth(new Date().getMonth()) - 1
  103. ).format("YYYY-MM-DD HH:mm:ss");
  104. $scope.parameters.paramDateFrom = $scope.starttimes;
  105. $scope.parameters.paramDateTo = $scope.endtimes;
  106. $scope.mdxquerym();
  107. };
  108. $scope.mdxquerym = function () {
  109. $scope.starttimes = moment($scope.parameters.paramDateFrom).format(
  110. "YYYY-MM-DD HH:mm:ss"
  111. );
  112. $scope.endtimes = moment($scope.parameters.paramDateTo).format(
  113. "YYYY-MM-DD HH:mm:ss"
  114. );
  115. $scope.isMaskground = true;
  116. $scope.shows = false;
  117. $scope.reshdata();
  118. };
  119. // 弹窗1
  120. $scope.servicePerformanceDetail = function(data){
  121. if(!data.incidentId){
  122. return;
  123. }
  124. $modal.open({
  125. resolve: {
  126. scope: function () {
  127. return $scope;
  128. },
  129. },
  130. size: "lg",
  131. templateUrl: 'assets/views/customform/tpl/servicePerformanceDetail1.html',
  132. controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert, api_wechatfile) {
  133. $scope.title = "提示";
  134. $scope.reshdata = function() {
  135. $scope.isMaskground = true;
  136. api_bpm_data
  137. .serviceCount({
  138. type: 'serviceDaysList',
  139. userId: data.userId,
  140. startTime: scope.starttimes,
  141. finishTime: scope.endtimes,
  142. })
  143. .then(function (response) {
  144. if (response) {
  145. if ((response.status = 200)) {
  146. $scope.isMaskground = false;
  147. $scope.charginrow = response.data;
  148. if (response.list && response.list.length == 0) {
  149. $scope.shows = true;
  150. $scope.empty = "数据为空!";
  151. }
  152. }
  153. }
  154. });
  155. }
  156. $scope.reshdata();
  157. $scope.cancel = function () {
  158. $modalInstance.dismiss('cancel');
  159. };
  160. // 弹窗2
  161. $scope.servicePerformanceDetail = function(data){
  162. $scope.cancel();
  163. $modal.open({
  164. resolve: {
  165. scope: function () {
  166. return scope;
  167. },
  168. },
  169. size: "lg",
  170. templateUrl: 'assets/views/customform/tpl/servicePerformanceDetail2.html',
  171. controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert, api_wechatfile) {
  172. $scope.title = "提示";
  173. $scope.reshdata = function() {
  174. $scope.isMaskground = true;
  175. api_bpm_data
  176. .serviceCount({
  177. type: 'serviceIncidentList',
  178. userId: data.userId,
  179. startTime: data.acceptdate,
  180. finishTime: data.acceptdate,
  181. })
  182. .then(function (response) {
  183. if (response) {
  184. if ((response.status = 200)) {
  185. $scope.isMaskground = false;
  186. $scope.charginrow = response.data;
  187. if (response.list && response.list.length == 0) {
  188. $scope.shows = true;
  189. $scope.empty = "数据为空!";
  190. }
  191. }
  192. }
  193. });
  194. }
  195. $scope.reshdata();
  196. $scope.cancel = function () {
  197. $modalInstance.dismiss('cancel');
  198. };
  199. // 弹窗3
  200. $scope.servicePerformanceDetail = function(data){
  201. $scope.cancel();
  202. $modal.open({
  203. resolve: {
  204. scope: function () {
  205. return scope;
  206. },
  207. },
  208. size: "lg",
  209. templateUrl: 'assets/views/customform/tpl/servicePerformanceDetail3.html',
  210. controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert, api_wechatfile) {
  211. $scope.title = data.category + "-" + data.score;
  212. $scope.reshdata = function() {
  213. $scope.isMaskground = true;
  214. api_bpm_data
  215. .serviceCount({
  216. type: 'serviceDetailsList',
  217. incidentId: data.incidentId,
  218. startTime: moment(data.acceptdate).format('YYYY-MM-DD'),
  219. finishTime: moment(data.acceptdate).format('YYYY-MM-DD'),
  220. })
  221. .then(function (response) {
  222. if (response) {
  223. if ((response.status = 200)) {
  224. $scope.isMaskground = false;
  225. $scope.charginrow = response.data;
  226. if (response.list && response.list.length == 0) {
  227. $scope.shows = true;
  228. $scope.empty = "数据为空!";
  229. }
  230. }
  231. }
  232. });
  233. }
  234. $scope.reshdata();
  235. $scope.cancel = function () {
  236. $modalInstance.dismiss('cancel');
  237. };
  238. },
  239. });
  240. }
  241. },
  242. });
  243. }
  244. },
  245. });
  246. }
  247. },
  248. ]);