childpapeCtrl.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. // 'use strict';
  2. // var appchild = angular.module("myAppchild", []);
  3. app.controller('childpapeCtrl', ["$scope", "api_report_nx", "$rootScope", "$stateParams", function($scope, api_report_nx, $rootScope, $stateParams) {
  4. $scope.hearderlist = [];
  5. $scope.mapheaderdata = [];
  6. $scope.mapbodydata = [];
  7. $scope.parameters = {};
  8. $scope.starttimes = $scope.parameters.paramDateFrom = $stateParams.starttime;
  9. $scope.endtimes = $scope.parameters.paramDateTo = $stateParams.endtime;
  10. $scope.startlist = JSON.parse($stateParams.model)
  11. $scope.nowdata = moment(new Date()).format('YYYY/MM/DD HH:ss:mm');
  12. /***
  13. * 故障现象总数
  14. */
  15. function incidentClassify() {
  16. $scope.pielenddata = [];
  17. $scope.piebodydata = [];
  18. $scope.hearderlist = [{ name: "事件类别(三级)", value: "type3" }, { name: "事件数量", value: "num" }, { name: "所属类型(二级)", value: "type2" }, { name: "所属类型(一级)", value: "type1" }, { name: "占比", value: "proportion" }];
  19. api_report_nx.fetchDataList("incidentClassify", { "startTime": $scope.parameters.paramDateFrom, "endTime": $scope.parameters.paramDateTo }).then(function(response) {
  20. if (response.code == 200) {
  21. $scope.sum = response.sum;
  22. $scope.rRows = response.incidentClassifyList;
  23. angular.forEach(response.incidentClassify, function(item) {
  24. $scope.pielenddata.push(item.type);
  25. $scope.piebodydata.push({ "value": item.num, "name": item.type, "proportion": item.proportion });
  26. })
  27. pieechart()
  28. } else {
  29. }
  30. });
  31. }
  32. incidentClassify()
  33. /**
  34. * 处理事件占比
  35. */
  36. function incidentHandler() {
  37. $scope.barlenddata = [];
  38. $scope.barbodydata = [];
  39. $scope.hearderlist = [{ name: "处理人", value: "name" }, { name: "完成事件数", value: "num" }, { name: "占比", value: "proportion" }];
  40. api_report_nx.fetchDataList("incidentHandler", { "startTime": $scope.parameters.paramDateFrom, "endTime": $scope.parameters.paramDateTo }).then(function(response) {
  41. if (response.code == 200) {
  42. $scope.rRows = response.incidentHandler;
  43. angular.forEach(response.incidentHandler, function(item) {
  44. $scope.barlenddata.push(item.name);
  45. $scope.barbodydata.push({ "value": item.num, "name": item.name, "proportion": item.proportion });
  46. })
  47. barechart()
  48. } else {
  49. }
  50. });
  51. }
  52. // incidentHandler()
  53. /**
  54. * 问题总数
  55. */
  56. function problemClassify() {
  57. $scope.pielenddata = [];
  58. $scope.piebodydata = [];
  59. $scope.hearderlist = [{ name: "问题类别(三级)", value: "type3" }, { name: "问题数量", value: "num" }, { name: "所属类型(二级)", value: "type2" }, { name: "所属类型(一级)", value: "type1" }, { name: "占比", value: "proportion" }];
  60. api_report_nx.fetchDataList("problemClassify", { "startTime": $scope.parameters.paramDateFrom, "endTime": $scope.parameters.paramDateTo }).then(function(response) {
  61. if (response.code == 200) {
  62. $scope.sum = response.sum;
  63. $scope.rRows = response.problemClassifyList;
  64. angular.forEach(response.problemClassify, function(item) {
  65. $scope.pielenddata.push(item.type);
  66. $scope.piebodydata.push({ "value": item.num, "name": item.type, "proportion": item.proportion });
  67. })
  68. pieechart()
  69. } else {
  70. }
  71. });
  72. }
  73. /**
  74. * 处理问题占比
  75. */
  76. function problemHandler() {
  77. $scope.barlenddata = [];
  78. $scope.barbodydata = [];
  79. $scope.hearderlist = [{ name: "主责人", value: "name" }, { name: "完成问题数", value: "num" }, { name: "占比", value: "proportion" }];
  80. api_report_nx.fetchDataList("problemHandler", { "startTime": $scope.parameters.paramDateFrom, "endTime": $scope.parameters.paramDateTo }).then(function(response) {
  81. if (response.code == 200) {
  82. $scope.rRows = response.problemHandler;
  83. angular.forEach(response.problemHandler, function(item) {
  84. $scope.barlenddata.push(item.name);
  85. $scope.barbodydata.push({ "value": item.num, "name": item.name, "proportion": item.proportion });
  86. })
  87. barechart()
  88. } else {
  89. }
  90. });
  91. }
  92. /**
  93. * 变更总数
  94. */
  95. function changeClassify() {
  96. $scope.pielenddata = [];
  97. $scope.piebodydata = [];
  98. $scope.hearderlist = [{ name: "变更类别(三级)", value: "type3" }, { name: "变更数量", value: "num" }, { name: "所属类型(二级)", value: "type2" }, { name: "所属类型(一级)", value: "type1" }, { name: "占比", value: "proportion" }];
  99. api_report_nx.fetchDataList("changeClassify", { "startTime": $scope.parameters.paramDateFrom, "endTime": $scope.parameters.paramDateTo }).then(function(response) {
  100. if (response.code == 200) {
  101. $scope.sum = response.sum;
  102. $scope.rRows = response.changeClassifyList;
  103. angular.forEach(response.changeClassify, function(item) {
  104. $scope.pielenddata.push(item.type);
  105. $scope.piebodydata.push({ "value": item.num, "name": item.type, "proportion": item.proportion });
  106. })
  107. pieechart()
  108. } else {
  109. }
  110. });
  111. }
  112. /**
  113. * 完成变更占比
  114. */
  115. function changeHandler() {
  116. $scope.barlenddata = [];
  117. $scope.barbodydata = [];
  118. $scope.hearderlist = [{ name: "主责人", value: "name" }, { name: "完成变更数", value: "num" }, { name: "占比", value: "proportion" }];
  119. api_report_nx.fetchDataList("changeHandler", { "startTime": $scope.parameters.paramDateFrom, "endTime": $scope.parameters.paramDateTo }).then(function(response) {
  120. if (response.code == 200) {
  121. $scope.rRows = response.changeHandler;
  122. angular.forEach(response.changeHandler, function(item) {
  123. $scope.barlenddata.push(item.name);
  124. $scope.barbodydata.push({ "value": item.num, "name": item.name, "proportion": item.proportion });
  125. })
  126. barechart()
  127. } else {
  128. }
  129. });
  130. }
  131. /**
  132. * 发布总数
  133. */
  134. function releaseClassify() {
  135. $scope.pielenddata = [];
  136. $scope.piebodydata = [];
  137. api_report_nx.fetchDataList("releaseClassify", { "startTime": $scope.parameters.paramDateFrom, "endTime": $scope.parameters.paramDateTo }).then(function(response) {
  138. if (response.code == 200) {
  139. $scope.sum = response.sum;
  140. $scope.rRows = response.releaseClassifyList;
  141. angular.forEach(response.releaseClassify, function(item) {
  142. $scope.pielenddata.push(item.name);
  143. $scope.piebodydata.push({ "value": item.num, "name": item.name, "proportion": item.proportion });
  144. })
  145. pieechart()
  146. } else {
  147. }
  148. });
  149. }
  150. /**
  151. * 完成发布占比
  152. */
  153. function releaseHandler() {
  154. $scope.barlenddata = [];
  155. $scope.barbodydata = [];
  156. api_report_nx.fetchDataList("releaseHandler", { "startTime": $scope.parameters.paramDateFrom, "endTime": $scope.parameters.paramDateTo }).then(function(response) {
  157. if (response.code == 200) {
  158. $scope.rRows = response.releaseHandler;
  159. angular.forEach(response.releaseHandler, function(item) {
  160. $scope.barlenddata.push(item.name);
  161. $scope.barbodydata.push({ "value": item.num, "name": item.name, "proportion": item.proportion });
  162. })
  163. barechart()
  164. } else {
  165. }
  166. });
  167. }
  168. /**
  169. * 环形图
  170. */
  171. function pieechart() {
  172. var dom = document.getElementById("report");
  173. var myChart = echarts.init(dom);
  174. var app = {};
  175. var option = null;
  176. myChart.showLoading({  
  177. text: '数据加载中...',
  178. color: '#c23531',
  179. textColor: '#fff',
  180. maskColor: 'rgba(255,255,255,0)',
  181. zlevel: 0
  182. });
  183. myChart.hideLoading();
  184. option = {
  185. // graphic: {
  186. // elements: [{
  187. // type: 'text',
  188. // // position: ['20%', '35%'],
  189. // style: {
  190. // text: $scope.sum,
  191. // font: {
  192. // color: '#005395',
  193. // fontSize: '42px',
  194. // },
  195. // },
  196. // left: '20%',
  197. // top: '50%'
  198. // }]
  199. // },
  200. // title: {
  201. // text: $scope.startlist.title,
  202. // left: '15%',
  203. // top: '35%',
  204. // // position: ['20%', '35%'],
  205. // textStyle: {
  206. // color: '#333',
  207. // fontSize: 16,
  208. // align: 'center'
  209. // }
  210. // },
  211. title: [{
  212. text: $scope.sum,
  213. x: '16%',
  214. y: '50%',
  215. textStyle: {
  216. fontSize: 42,
  217. fontWeight: 'normal',
  218. fontStyle: 'normal',
  219. color: '#005395'
  220. }
  221. }, {
  222. text: $scope.startlist.title,
  223. x: '15%',
  224. y: '40%',
  225. textStyle: {
  226. fontSize: 16,
  227. fontWeight: 'normal',
  228. fontStyle: 'normal',
  229. align: 'center',
  230. color: '#333'
  231. }
  232. }],
  233. tooltip: {
  234. "backgroundColor": "rgba(0,0,0,9)",
  235. "textStyle": {
  236. "fontSize": 12,
  237. "color": '#f9f9f9',
  238. },
  239. trigger: 'item',
  240. formatter: "{a} <br/>{b}: {c} ({d}%)"
  241. },
  242. legend: {
  243. orient: 'vertical',
  244. x: '40%',
  245. y: 'center',
  246. itemGap: 40,
  247. data: $scope.pielenddata,
  248. formatter: function(param) {
  249. for (var i = 0; i < $scope.pielenddata.length; i++) {
  250. if ($scope.piebodydata[i].name == param) {
  251. return ' ' + $scope.piebodydata[i].name + ' ' + $scope.piebodydata[i].value + ' ' + $scope.piebodydata[i].proportion;
  252. }
  253. }
  254. }
  255. },
  256. series: [{
  257. name: $scope.startlist.title,
  258. type: 'pie',
  259. radius: ['70%', '85%'],
  260. center: ['20%', '50%'],
  261. color: ['#315b7e', '#3370a1', '#1a3a53', '#61829d', '#8496A5', '#e6eef4', '#15598F', '#61829d', '#5F9FD1', '#7EAFD6'],
  262. hoverAnimation: true,
  263. label: {
  264. normal: {
  265. show: false,
  266. position: 'center'
  267. },
  268. // emphasis: {
  269. // show: true,
  270. // textStyle: {
  271. // fontSize: '30',
  272. // fontWeight: 'bold'
  273. // }
  274. // }
  275. },
  276. labelLine: {
  277. normal: {
  278. show: false
  279. }
  280. },
  281. data: $scope.piebodydata
  282. }]
  283. };
  284. if (option && typeof option === "object") {
  285. myChart.setOption(option, true);
  286. myChart.hideLoading();
  287. }
  288. }
  289. // }, 1000)
  290. /***
  291. * 柱状图
  292. */
  293. function hardDisks(data) {
  294. if ($scope.sum == 0) {
  295. return 0;
  296. } else {
  297. }
  298. return data / $scope.sum;
  299. }
  300. function barechart() {
  301. var dom = document.getElementById("barreport");
  302. var mybarChart = echarts.init(dom);
  303. var app = {};
  304. var optionbar = null;
  305. mybarChart.showLoading({  
  306. text: '数据加载中...',
  307. color: '#c23531',
  308. textColor: '#fff',
  309. maskColor: 'rgba(255,255,255,0)',
  310. zlevel: 0
  311. });
  312. mybarChart.hideLoading();
  313. optionbar = {
  314. title: {
  315. // text: '(件)故障数量',
  316. x: '10',
  317. y: '0',
  318. textStyle: {
  319. fontWeight: 'normal',
  320. fontSize: 12,
  321. color: "#56c9ff",
  322. }
  323. },
  324. xAxis: {
  325. axisTick: {
  326. show: false
  327. },
  328. splitLine: {
  329. show: false
  330. },
  331. splitArea: {
  332. show: false
  333. },
  334. // data: XData,
  335. data: $scope.barlenddata,
  336. axisLine: {
  337. lineStyle: {
  338. color: '#eaeaea'
  339. }
  340. },
  341. axisLabel: {
  342. textStyle: {
  343. color: '#999',
  344. fontSize: 14,
  345. }
  346. },
  347. },
  348. yAxis: {
  349. axisTick: {
  350. show: false
  351. },
  352. splitLine: {
  353. show: false
  354. },
  355. splitArea: {
  356. show: false
  357. },
  358. minInterval: 1,
  359. axisLabel: {
  360. show: true,
  361. textStyle: {
  362. color: '#999',
  363. fontSize: 14,
  364. }
  365. },
  366. axisLine: {
  367. show: false,
  368. lineStyle: {
  369. color: '#eaeaea'
  370. }
  371. },
  372. splitLine: {
  373. lineStyle: {
  374. color: "#eaeaea"
  375. }
  376. }
  377. },
  378. grid: {
  379. left: 10,
  380. top: 25,
  381. bottom: 0,
  382. right: 10,
  383. containLabel: true
  384. },
  385. "tooltip": {
  386. "trigger": "item",
  387. "backgroundColor": "rgba(0,0,0,9)",
  388. "textStyle": {
  389. "fontSize": 12,
  390. "color": '#f9f9f9',
  391. },
  392. formatter: function(data) {
  393. return $scope.startlist.tip1 + ':' + data.value + '<br />' + $scope.startlist.tip2 + ':' + data.data.proportion + '%';
  394. },
  395. },
  396. series: {
  397. type: "bar",
  398. itemStyle: {
  399. normal: {
  400. color: function(params) {
  401. // type = 'linear';
  402. // var colorList = [
  403. // '#005395'
  404. // ];
  405. return '#005395'
  406. },
  407. }
  408. },
  409. label: {
  410. normal: {
  411. show: true,
  412. position: 'top',
  413. textStyle: {
  414. // color: '#56c9ff'
  415. }
  416. }
  417. },
  418. barWidth: 18,
  419. // barWidth: '30%',
  420. // data: yData
  421. data: $scope.barbodydata
  422. }
  423. };
  424. if (optionbar && typeof optionbar === "object") {
  425. mybarChart.setOption(optionbar, true);
  426. mybarChart.hideLoading();
  427. }
  428. }
  429. }])