servicePerformanceCtrl.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  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.sort((a, b) => b.total - a.total);
  77. // 图表
  78. barechart6(response.data);
  79. barechart7(response.data);
  80. var totalScore = $scope.charginrow.reduce((pre,cur)=>{
  81. return pre + cur.score;
  82. },0)
  83. angular.forEach($scope.charginrow, function(item) {
  84. if(totalScore){
  85. item.percent = (item.score * 100 / totalScore).toFixed(2) + '%';
  86. }else{
  87. item.percent = '0%';
  88. }
  89. })
  90. if (response.list && response.list.length == 0) {
  91. $scope.shows = true;
  92. $scope.empty = "数据为空!";
  93. }
  94. }
  95. }
  96. });
  97. }
  98. $scope.reshdata();
  99. $scope.reset = function () {
  100. $scope.parameters = {};
  101. $scope.starttimes = moment(
  102. new Date(moment().startOf("month")).setMonth(new Date().getMonth() - 1)
  103. ).format("YYYY-MM-DD HH:mm:ss");
  104. $scope.endtimes = moment(
  105. new Date(moment().startOf("month")).setMonth(new Date().getMonth()) - 1
  106. ).format("YYYY-MM-DD HH:mm:ss");
  107. $scope.parameters.paramDateFrom = $scope.starttimes;
  108. $scope.parameters.paramDateTo = $scope.endtimes;
  109. $scope.mdxquerym();
  110. };
  111. $scope.mdxquerym = function () {
  112. $scope.starttimes = moment($scope.parameters.paramDateFrom).format(
  113. "YYYY-MM-DD HH:mm:ss"
  114. );
  115. $scope.endtimes = moment($scope.parameters.paramDateTo).format(
  116. "YYYY-MM-DD HH:mm:ss"
  117. );
  118. $scope.isMaskground = true;
  119. $scope.shows = false;
  120. $scope.reshdata();
  121. };
  122. // 弹窗1
  123. $scope.servicePerformanceDetail = function(data){
  124. if(!data.incidentId){
  125. return;
  126. }
  127. $modal.open({
  128. resolve: {
  129. scope: function () {
  130. return $scope;
  131. },
  132. },
  133. size: "lg",
  134. templateUrl: 'assets/views/customform/tpl/servicePerformanceDetail1.html',
  135. controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert, api_wechatfile) {
  136. $scope.title = "提示";
  137. $scope.reshdata = function() {
  138. $scope.isMaskground = true;
  139. api_bpm_data
  140. .serviceCount({
  141. type: 'serviceDaysList',
  142. userId: data.userId,
  143. startTime: scope.starttimes,
  144. finishTime: scope.endtimes,
  145. })
  146. .then(function (response) {
  147. if (response) {
  148. if ((response.status = 200)) {
  149. $scope.isMaskground = false;
  150. $scope.charginrow = response.data;
  151. if (response.list && response.list.length == 0) {
  152. $scope.shows = true;
  153. $scope.empty = "数据为空!";
  154. }
  155. }
  156. }
  157. });
  158. }
  159. $scope.reshdata();
  160. $scope.cancel = function () {
  161. $modalInstance.dismiss('cancel');
  162. };
  163. // 弹窗2
  164. $scope.servicePerformanceDetail = function(data){
  165. $scope.cancel();
  166. $modal.open({
  167. resolve: {
  168. scope: function () {
  169. return scope;
  170. },
  171. },
  172. size: "lg",
  173. templateUrl: 'assets/views/customform/tpl/servicePerformanceDetail2.html',
  174. controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert, api_wechatfile) {
  175. $scope.title = "提示";
  176. $scope.reshdata = function() {
  177. $scope.isMaskground = true;
  178. api_bpm_data
  179. .serviceCount({
  180. type: 'serviceIncidentList',
  181. userId: data.userId,
  182. startTime: data.acceptdate,
  183. finishTime: data.acceptdate,
  184. })
  185. .then(function (response) {
  186. if (response) {
  187. if ((response.status = 200)) {
  188. $scope.isMaskground = false;
  189. $scope.charginrow = response.data;
  190. if (response.list && response.list.length == 0) {
  191. $scope.shows = true;
  192. $scope.empty = "数据为空!";
  193. }
  194. }
  195. }
  196. });
  197. }
  198. $scope.reshdata();
  199. $scope.cancel = function () {
  200. $modalInstance.dismiss('cancel');
  201. };
  202. // 弹窗3
  203. $scope.servicePerformanceDetail = function(data){
  204. $scope.cancel();
  205. $modal.open({
  206. resolve: {
  207. scope: function () {
  208. return scope;
  209. },
  210. },
  211. size: "lg",
  212. templateUrl: 'assets/views/customform/tpl/servicePerformanceDetail3.html',
  213. controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert, api_wechatfile) {
  214. $scope.title = data.category + "-" + data.score;
  215. $scope.reshdata = function() {
  216. $scope.isMaskground = true;
  217. api_bpm_data
  218. .serviceCount({
  219. type: 'serviceDetailsList',
  220. categoryId: data.categoryId,
  221. userId: data.userId,
  222. startTime: moment(data.acceptdate).format('YYYY-MM-DD'),
  223. finishTime: moment(data.acceptdate).format('YYYY-MM-DD'),
  224. })
  225. .then(function (response) {
  226. if (response) {
  227. if ((response.status = 200)) {
  228. $scope.isMaskground = false;
  229. $scope.charginrow = response.data;
  230. if (response.list && response.list.length == 0) {
  231. $scope.shows = true;
  232. $scope.empty = "数据为空!";
  233. }
  234. }
  235. }
  236. });
  237. }
  238. $scope.reshdata();
  239. $scope.cancel = function () {
  240. $modalInstance.dismiss('cancel');
  241. };
  242. },
  243. });
  244. }
  245. },
  246. });
  247. }
  248. },
  249. });
  250. }
  251. // 饼图
  252. function barechart6(datas) {
  253. var dom = document.getElementById("XYSJ");
  254. var option = null;
  255. var myChart = echarts.init(dom);
  256. var data = datas.map(v=>({name: v.userName, value: v.score}));
  257. option = {
  258. color: ["#91c7ae", "#61a0a8", "#2f4554", "#c23531", "#d48265"],
  259. title: {
  260. text: "积分占比",
  261. // subtext: datas.pieChartSum,
  262. // textAlign: "center",
  263. textStyle: {
  264. color: "#333",
  265. fontSize: 16,
  266. align: 'center',
  267. },
  268. // subtextStyle: {
  269. // fontSize: 14,
  270. // color: ["#005395"],
  271. // fontWeight: "bolder",
  272. // // align: 'center'
  273. // },
  274. // x: "34.5%",
  275. // y: "50%",
  276. },
  277. tooltip: {
  278. trigger: "item",
  279. formatter: function (a) {
  280. return a["data"]["name"] + ":" + a["data"]["value"];
  281. },
  282. position: ["50%", "30%"],
  283. },
  284. grid: {
  285. bottom: 150,
  286. left: 100,
  287. right: "10%",
  288. },
  289. legend: {
  290. orient: "vertical",
  291. top: "middle",
  292. right: "5%",
  293. textStyle: {
  294. color: "#333",
  295. fontSize: 12,
  296. },
  297. itemWidth: 8,
  298. itemHeight: 8,
  299. icon: "roundRect",
  300. data: data,
  301. },
  302. series: [
  303. // 主要展示层的
  304. {
  305. radius: ["50%", "65%"],
  306. center: ["35%", "60%"],
  307. type: "pie",
  308. label: {
  309. normal: {
  310. show: true,
  311. formatter: "{d}%",
  312. textStyle: {
  313. fontSize: 14,
  314. },
  315. position: "outside",
  316. },
  317. emphasis: {
  318. show: true,
  319. },
  320. },
  321. labelLine: {
  322. normal: {
  323. show: true,
  324. length: 5,
  325. length2: 25,
  326. },
  327. emphasis: {
  328. show: true,
  329. },
  330. },
  331. name: "",
  332. data: data,
  333. },
  334. ],
  335. };
  336. if (option && typeof option === "object") {
  337. myChart.setOption(option);
  338. myChart.hideLoading();
  339. }
  340. }
  341. // 柱形图
  342. function barechart7(datas) {
  343. console.log(datas);
  344. var datas_obj = {name:[], '处理工单总数':[]};
  345. // 处理数据 start
  346. datas.forEach(v=>{
  347. datas_obj.name.push(v.userName);
  348. datas_obj['处理工单总数'].push(v.total);
  349. })
  350. datas = datas_obj;
  351. console.log(datas);
  352. // 处理数据 end
  353. var name = [];
  354. var series = [];
  355. for (var key in datas) {
  356. if (key !== "name") {
  357. name.push(key);
  358. series.push({
  359. name: key,
  360. type: "bar",
  361. stack: "1",
  362. // barWidth: 40,
  363. itemStyle: {
  364. normal: {},
  365. },
  366. data: datas[key],
  367. });
  368. }
  369. }
  370. var dom = document.getElementById("jjmyd");
  371. var myChart = echarts.init(dom);
  372. var option = null;
  373. myChart.showLoading({
  374. text: "数据加载中...",
  375. color: "#c23531",
  376. textColor: "#fff",
  377. maskColor: "rgba(255,255,255,0)",
  378. zlevel: 0,
  379. });
  380. myChart.hideLoading();
  381. option = {
  382. title: {
  383. text: "处理工单总数",
  384. // subtext: datas.pieChartSum,
  385. // textAlign: "center",
  386. textStyle: {
  387. color: "#333",
  388. fontSize: 16,
  389. align: 'center',
  390. },
  391. // subtextStyle: {
  392. // fontSize: 14,
  393. // color: ["#005395"],
  394. // fontWeight: "bolder",
  395. // // align: 'center'
  396. // },
  397. // x: "34.5%",
  398. // y: "50%",
  399. },
  400. tooltip: {
  401. trigger: "axis",
  402. axisPointer: {
  403. // 坐标轴指示器,坐标轴触发有效
  404. type: "shadow", // 默认为直线,可选为:'line' | 'shadow'
  405. },
  406. },
  407. // legend: {
  408. // data: name,
  409. // align: "left",
  410. // // itemWidth:10,
  411. // // itemHeight:10,
  412. // bottom: 0,
  413. // },
  414. grid: {
  415. top: "15%",
  416. left: "2%",
  417. right: "1.5%",
  418. bottom: "5%",
  419. containLabel: true,
  420. },
  421. xAxis: [
  422. {
  423. type: "category",
  424. axisTick: {
  425. alignWithLabel: true
  426. },
  427. axisLabel: {
  428. interval: 0,
  429. textStyle: {
  430. color: "#7B7B7B",
  431. // fontSize: '14',
  432. },
  433. },
  434. axisLine: {
  435. show: true,
  436. lineStyle: {
  437. color: "#7B7B7B",
  438. // type: 'dotted'
  439. },
  440. },
  441. data: datas.name,
  442. },
  443. ],
  444. yAxis: [
  445. {
  446. type: "value",
  447. scale: true,
  448. name: "处理工单总数",
  449. min: 0,
  450. boundaryGap: [0.2, 0.2],
  451. axisLabel: {
  452. formatter: "{value}",
  453. textStyle: {
  454. color: "#7B7B7B",
  455. // fontSize: '14',
  456. },
  457. },
  458. axisLine: {
  459. show: true,
  460. lineStyle: {
  461. color: "#7B7B7B",
  462. // type: 'dotted'
  463. },
  464. },
  465. },
  466. ],
  467. series: series,
  468. };
  469. if (option && typeof option === "object") {
  470. myChart.setOption(option);
  471. myChart.hideLoading();
  472. }
  473. }
  474. },
  475. ]);