nxreportCtrl.js 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177
  1. 'use strict';
  2. app.controller('nxreportCtrl', ["$scope", "$rootScope", "$state", "$timeout", "$interval", "$http", "$cookieStore", "moment", "SweetAlert", "Restangular", "api_report_nx", "api_statistic", function ($scope, $rootScope, $state, $timeout, $interval, $http, $cookieStore, moment, SweetAlert, Restangular, api_report_nx, api_statistic) {
  3. $scope.parameters = {};
  4. $scope.hearderlist = [];
  5. $scope.pielenddata = [];
  6. $scope.piebodydata = [];
  7. $scope.barlenddata = [];
  8. $scope.barbodydata = [];
  9. $scope.categryid = 2;
  10. $scope.sum = 0;
  11. $scope.startlist = {
  12. id: 2,
  13. label: "事件总数&分类统计报告",
  14. title: "事件总数",
  15. key: "incidentClassify",
  16. selected: true
  17. };
  18. $scope.nowdata = moment(new Date()).format('YYYY/MM/DD HH:ss:mm');
  19. //时间搜索
  20. // $scope.starttimes = moment(new Date().getTime() - 86400000 * 7).format('YYYY-MM-DD'); //开始时间
  21. // $scope.endtimes = moment(new Date().getTime() - 86400000).format('YYYY-MM-DD'); //结束时间
  22. var weeks = new Date().getDay();
  23. $scope.starttimes = moment(new Date().getTime() - 86400000 * (weeks + 6)).format('YYYY-MM-DD');
  24. $scope.endtimes = moment(new Date().getTime() - 86400000 * (weeks)).format('YYYY-MM-DD');
  25. $scope.changeForm = function (paramDateFrom) {
  26. $scope.starttimes = moment(paramDateFrom).format('YYYY-MM-DD');
  27. }
  28. $scope.changeTo = function (paramDateTo) {
  29. $scope.endtimes = moment(paramDateTo).format('YYYY-MM-DD');
  30. }
  31. $scope.parameters.paramDateFrom = $scope.starttimes;
  32. $scope.parameters.paramDateTo = $scope.endtimes;
  33. //高度
  34. setInterval(function () {
  35. if (document.getElementById("DIV3")) {
  36. $scope.listheight = {
  37. "min-height": document.getElementById("DIV3").scrollHeight - 20 + "px"
  38. };
  39. }
  40. }, 1000)
  41. var downPdf = document.getElementById("exportToPdf");
  42. downPdf.onclick = function () {
  43. html2canvas(
  44. document.getElementById("export_content"), {
  45. dpi: 172, //导出pdf清晰度
  46. onrendered: function (canvas) {
  47. var contentWidth = canvas.width;
  48. var contentHeight = canvas.height;
  49. //一页pdf显示html页面生成的canvas高度;
  50. var pageHeight = contentWidth / 592.28 * 841.89;
  51. //未生成pdf的html页面高度
  52. var leftHeight = contentHeight;
  53. //pdf页面偏移
  54. var position = 0;
  55. //html页面生成的canvas在pdf中图片的宽高(a4纸的尺寸[595.28,841.89])
  56. var imgWidth = 595.28;
  57. var imgHeight = 592.28 / contentWidth * contentHeight;
  58. var pageData = canvas.toDataURL('image/jpeg', 1.0);
  59. var pdf = new jsPDF('', 'pt', 'a4');
  60. //有两个高度需要区分,一个是html页面的实际高度,和生成pdf的页面高度(841.89)
  61. //当内容未超过pdf一页显示的范围,无需分页
  62. if (leftHeight < pageHeight) {
  63. pdf.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight);
  64. } else {
  65. while (leftHeight > 0) {
  66. pdf.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight)
  67. leftHeight -= pageHeight;
  68. position -= 841.89;
  69. //避免添加空白页
  70. if (leftHeight > 0) {
  71. pdf.addPage();
  72. }
  73. }
  74. }
  75. pdf.save('content.pdf');
  76. },
  77. //背景设为白色(默认为黑色)
  78. background: "#fff"
  79. })
  80. }
  81. //上周
  82. $scope.week = function () {
  83. $scope.searchstate = "week";
  84. var weeks = new Date().getDay();
  85. $scope.starttimes = moment(new Date().getTime() - 86400000 * (weeks + 6)).format('YYYY-MM-DD');
  86. $scope.endtimes = moment(new Date().getTime() - 86400000 * (weeks)).format('YYYY-MM-DD');
  87. $scope.parameters.paramDateFrom = $scope.starttimes;
  88. $scope.parameters.paramDateTo = $scope.endtimes;
  89. // $scope.parameters = parseDateParameter($scope.parameters);
  90. $scope.mdxquery();
  91. }
  92. //上月
  93. $scope.month = function () {
  94. $scope.searchstate = "month";
  95. $scope.starttimes = moment((new Date(moment().startOf('month'))).setMonth((new Date()).getMonth() - 1)).format('YYYY-MM-DD');
  96. $scope.endtimes = moment((new Date(moment().startOf('month'))).setMonth((new Date()).getMonth()) - 86400000).format('YYYY-MM-DD');
  97. $scope.parameters.paramDateFrom = $scope.starttimes;
  98. $scope.parameters.paramDateTo = $scope.endtimes;
  99. // $scope.parameters = parseDateParameter($scope.parameters);
  100. $scope.mdxquery();
  101. }
  102. //上年
  103. $scope.year = function () {
  104. $scope.searchstate = "year";
  105. $scope.starttimes = moment().startOf('year').format('YYYY-MM-DD');
  106. $scope.endtimes = moment().format('YYYY-MM-DD');
  107. $scope.parameters.paramDateFrom = $scope.starttimes;
  108. $scope.parameters.paramDateTo = $scope.endtimes;
  109. // $scope.parameters = parseDateParameter($scope.parameters);
  110. $scope.mdxquery();
  111. }
  112. /**
  113. *日历
  114. */
  115. $scope.open = function ($event) {
  116. $event.preventDefault();
  117. $event.stopPropagation();
  118. $scope.opened = !$scope.opened;
  119. };
  120. $scope.endOpen = function ($event) {
  121. $event.preventDefault();
  122. $event.stopPropagation();
  123. $scope.startOpened = false;
  124. $scope.endOpened = !$scope.endOpened;
  125. };
  126. $scope.startOpen = function ($event) {
  127. $event.preventDefault();
  128. $event.stopPropagation();
  129. $scope.endOpened = false;
  130. $scope.startOpened = !$scope.startOpened;
  131. };
  132. /***
  133. * 导出
  134. */
  135. $scope.exportData = function () {
  136. // var modelData = $scope.startlist;
  137. // $state.go('childpape', { starttime: $scope.parameters.paramDateFrom, endtime: $scope.parameters.paramDateTo, model: JSON.stringify(modelData) });
  138. // api_report_nx.getPdf({ url: "http://localhost/#/childpape/2018-11-12/2018-11-18/%7B%22id%22:24,%22label%22:%22%E8%B5%84%E4%BA%A7%E5%9C%A8%E5%BA%93%E7%8A%B6%E6%80%81%E7%BB%9F%E8%AE%A1%E6%8A%A5%E5%91%8A%22,%22key%22:%22assetStatus%22,%22level%22:2,%22expanded%22:false,%22uid%22:%220.2409134734491598%22,%22parent_uid%22:%220.23149440146902256%22,%22children%22:%5B%5D,%22classes%22:%5B%22leaf%22%5D,%22selected%22:true%7D" }).then(function(response) {
  139. // var downUrl = api_report_nx.getPdf({ url: "http://localhost/#/childpape/2018-11-12/2018-11-18/%7B%22id%22:24,%22label%22:%22%E8%B5%84%E4%BA%A7%E5%9C%A8%E5%BA%93%E7%8A%B6%E6%80%81%E7%BB%9F%E8%AE%A1%E6%8A%A5%E5%91%8A%22,%22key%22:%22assetStatus%22,%22level%22:2,%22expanded%22:false,%22uid%22:%220.2409134734491598%22,%22parent_uid%22:%220.23149440146902256%22,%22children%22:%5B%5D,%22classes%22:%5B%22leaf%22%5D,%22selected%22:true%7D" }).getRequestedUrl();
  140. // var a = document.createElement('a');
  141. // a.href = downUrl;
  142. // a.target = '_blank';
  143. // // a.download = filename;
  144. // document.body.appendChild(a);
  145. // a.click();
  146. // });
  147. $http({
  148. url: api_report_nx.getPdf().getRequestedUrl(),
  149. method: 'post',
  150. data: {
  151. url: "http://localhost/#/childpape/2018-11-12/2018-11-18/%7B%22id%22:24,%22label%22:%22%E8%B5%84%E4%BA%A7%E5%9C%A8%E5%BA%93%E7%8A%B6%E6%80%81%E7%BB%9F%E8%AE%A1%E6%8A%A5%E5%91%8A%22,%22key%22:%22assetStatus%22,%22level%22:2,%22expanded%22:false,%22uid%22:%220.2409134734491598%22,%22parent_uid%22:%220.23149440146902256%22,%22children%22:%5B%5D,%22classes%22:%5B%22leaf%22%5D,%22selected%22:true%7D"
  152. },
  153. headers: {
  154. //'Content-type' : 'application/xls',
  155. 'Accept': '*/*'
  156. },
  157. responseType: 'arraybuffer'
  158. }).success(function (data, status, headers, config) {
  159. var file = new Blob([data], {
  160. type: 'application/octet-stream'
  161. });
  162. //trick to download store a file having its URL
  163. var fileURL = URL.createObjectURL(file);
  164. var a = document.createElement('a');
  165. a.href = fileURL;
  166. // window.open(a.href);
  167. a.target = '_blank';
  168. // a.download = filename;
  169. document.body.appendChild(a);
  170. a.click();
  171. }).error(function (data, status, headers, config) {
  172. // console.log(data);
  173. });
  174. }
  175. /**
  176. * 时间搜索
  177. */
  178. $scope.mdxquery = function () {
  179. $scope.parameters.paramDateFrom = moment($scope.parameters.paramDateFrom).format('YYYY-MM-DD');
  180. $scope.parameters.paramDateTo = moment($scope.parameters.paramDateTo).format('YYYY-MM-DD');
  181. if ($scope.startlist.id == 2) {
  182. incidentClassify()
  183. } else if ($scope.startlist.id == 3) {
  184. incidentHandler()
  185. } else if ($scope.startlist.id == 6) {
  186. problemClassify()
  187. } else if ($scope.startlist.id == 7) {
  188. problemHandler()
  189. } else if ($scope.startlist.id == 12) {
  190. changeClassify()
  191. } else if ($scope.startlist.id == 13) {
  192. changeHandler()
  193. } else if ($scope.startlist.id == 16) {
  194. releaseClassify()
  195. } else if ($scope.startlist.id == 17) {
  196. releaseHandler()
  197. } else if ($scope.startlist.id == 22) {
  198. assetClassify()
  199. } else if ($scope.startlist.id == 24) {
  200. assetStatus()
  201. }
  202. }
  203. /**
  204. * 树形列表
  205. */
  206. $scope.my_tree = {};
  207. $scope.my_data = [];
  208. $scope.try_async_load = function () {
  209. $scope.my_data = [{
  210. id: 1,
  211. label: "事件报表",
  212. children: [{
  213. id: 2,
  214. label: "事件总数&分类统计报告",
  215. title: "事件总数",
  216. key: "incidentClassify",
  217. selected: true,
  218. }, {
  219. id: 3,
  220. label: "处理完事件占比",
  221. tip1: "完成事件数量",
  222. tip2: "事件占比",
  223. key: "incidentHandler"
  224. }]
  225. },
  226. {
  227. id: 5,
  228. label: "问题报表",
  229. children: [{
  230. id: 6,
  231. label: "问题总数&分类统计报告",
  232. title: "问题总数",
  233. key: "problemClassify"
  234. }, {
  235. id: 7,
  236. label: "处理人完成问题占比",
  237. tip1: "完成问题数量",
  238. tip2: "问题占比",
  239. key: "problemHandler"
  240. }]
  241. }, {
  242. id: 11,
  243. label: "变更报表",
  244. children: [{
  245. id: 12,
  246. label: "变更总数&分类统计报告",
  247. title: "变更总数",
  248. key: "changeClassify"
  249. }, {
  250. id: 13,
  251. label: "处理人完成变更占比",
  252. tip1: "完成变更数量",
  253. tip2: "变更占比",
  254. key: "changeHandler"
  255. }]
  256. }, {
  257. id: 15,
  258. label: "发布报表",
  259. children: [{
  260. id: 16,
  261. label: "发布总数&分类统计报告",
  262. title: "发布总数",
  263. key: "releaseClassify"
  264. }, {
  265. id: 17,
  266. label: "处理人完成发布占比",
  267. tip1: "完成发布数量",
  268. tip2: "发布占比",
  269. key: "releaseHandler"
  270. }]
  271. },
  272. {
  273. id: 21,
  274. label: "资产报表",
  275. children: [{
  276. id: 22,
  277. label: "资产总金额&分类统计报告",
  278. title: "资产总金额",
  279. key: "assetClassify"
  280. }, {
  281. id: 24,
  282. label: "资产总量统计报告",
  283. title: "资产总量",
  284. key: "assetStatus"
  285. }]
  286. }
  287. ];
  288. $scope.my_tree = angular.copy($scope.my_data);
  289. };
  290. function convertListToTree(data, treeMap) {
  291. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  292. var root = null; //Initially set our loop to null
  293. var parentNode = null;
  294. //loop over data
  295. for (var i = 0; i < data.length; i++) {
  296. var datum = data[i];
  297. //each node will have children, so let's give it a "children" poperty
  298. datum.children = [];
  299. //add an entry for this node to the map so that any future children can
  300. //lookup the parent
  301. idToNodeMap[datum.id] = datum;
  302. //Does this node have a parent?
  303. if (typeof datum.parent === "undefined" || datum.parent == null) {
  304. //Doesn't look like it, so this node is the root of the tree
  305. root = datum;
  306. treeMap[datum.id] = root;
  307. } else {
  308. //This node has a parent, so let's look it up using the id
  309. parentNode = idToNodeMap[datum.parent.id];
  310. //We don't need this property, so let's delete it.
  311. delete datum.parent;
  312. //Let's add the current node as a child of the parent node.
  313. parentNode.children.push(datum);
  314. }
  315. }
  316. return root;
  317. console.log(root)
  318. }
  319. function convertParentToChildList(data) {
  320. var treeMap = {};
  321. var list = [];
  322. convertListToTree(data, treeMap);
  323. angular.forEach(treeMap, function (item) {
  324. list.push(item);
  325. });
  326. return list;
  327. }
  328. $scope.try_async_load();
  329. $scope.my_tree_handler = function (branch) {
  330. $scope.startlist = branch;
  331. if (branch.id == 2) {
  332. incidentClassify()
  333. } else if (branch.id == 3) {
  334. incidentHandler();
  335. $scope.my_data[0].children[0].selected = false;
  336. } else if (branch.id == 6) {
  337. problemClassify()
  338. $scope.my_data[0].children[0].selected = false;
  339. } else if (branch.id == 7) {
  340. problemHandler()
  341. $scope.my_data[0].children[0].selected = false;
  342. } else if (branch.id == 12) {
  343. changeClassify()
  344. $scope.my_data[0].children[0].selected = false;
  345. } else if (branch.id == 13) {
  346. changeHandler()
  347. $scope.my_data[0].children[0].selected = false;
  348. } else if (branch.id == 16) {
  349. releaseClassify()
  350. $scope.my_data[0].children[0].selected = false;
  351. } else if (branch.id == 17) {
  352. releaseHandler()
  353. $scope.my_data[0].children[0].selected = false;
  354. } else if (branch.id == 22) {
  355. assetClassify()
  356. $scope.my_data[0].children[0].selected = false;
  357. } else if (branch.id == 24) {
  358. assetStatus()
  359. $scope.my_data[0].children[0].selected = false;
  360. }
  361. }
  362. /***
  363. * 故障现象总数
  364. */
  365. // setTimeout(function() {
  366. function incidentClassify() {
  367. $scope.pielenddata = [];
  368. $scope.piebodydata = [];
  369. $scope.hearderlist = [{
  370. name: "事件类别(三级)",
  371. value: "type3"
  372. }, {
  373. name: "事件数量",
  374. value: "num"
  375. }, {
  376. name: "所属类型(二级)",
  377. value: "type2"
  378. }, {
  379. name: "所属类型(一级)",
  380. value: "type1"
  381. }, {
  382. name: "占比",
  383. value: "proportion"
  384. }];
  385. api_report_nx.fetchDataList("incidentClassify", {
  386. "startTime": $scope.parameters.paramDateFrom,
  387. "endTime": $scope.parameters.paramDateTo
  388. }).then(function (response) {
  389. if (response.code == 200) {
  390. $scope.sum = response.sum;
  391. $scope.rRows = response.incidentClassifyList;
  392. angular.forEach(response.incidentClassify, function (item) {
  393. $scope.pielenddata.push(item.type);
  394. $scope.piebodydata.push({
  395. "value": item.num,
  396. "name": item.type,
  397. "proportion": item.proportion
  398. });
  399. })
  400. pieechart()
  401. } else {
  402. }
  403. });
  404. }
  405. // setTimeout(function() {
  406. incidentClassify()
  407. // }, 500);
  408. /**
  409. * 处理事件占比
  410. */
  411. function incidentHandler() {
  412. $scope.barlenddata = [];
  413. $scope.barbodydata = [];
  414. $scope.hearderlist = [{
  415. name: "处理人",
  416. value: "name"
  417. }, {
  418. name: "完成事件数",
  419. value: "num"
  420. }, {
  421. name: "占比",
  422. value: "proportion"
  423. }];
  424. api_report_nx.fetchDataList("incidentHandler", {
  425. "startTime": $scope.parameters.paramDateFrom,
  426. "endTime": $scope.parameters.paramDateTo
  427. }).then(function (response) {
  428. if (response.code == 200) {
  429. $scope.sum = response.sum;
  430. $scope.rRows = response.incidentHandler;
  431. angular.forEach(response.incidentHandler, function (item) {
  432. $scope.barlenddata.push(item.name);
  433. $scope.barbodydata.push({
  434. "value": item.num,
  435. "name": item.name,
  436. "proportion": item.proportion
  437. });
  438. })
  439. barechart()
  440. } else {
  441. }
  442. });
  443. }
  444. // incidentHandler()
  445. /**
  446. * 问题总数
  447. */
  448. function problemClassify() {
  449. $scope.pielenddata = [];
  450. $scope.piebodydata = [];
  451. $scope.hearderlist = [{
  452. name: "问题类别(三级)",
  453. value: "type3"
  454. }, {
  455. name: "问题数量",
  456. value: "num"
  457. }, {
  458. name: "所属类型(二级)",
  459. value: "type2"
  460. }, {
  461. name: "所属类型(一级)",
  462. value: "type1"
  463. }, {
  464. name: "占比",
  465. value: "proportion"
  466. }];
  467. api_report_nx.fetchDataList("problemClassify", {
  468. "startTime": $scope.parameters.paramDateFrom,
  469. "endTime": $scope.parameters.paramDateTo
  470. }).then(function (response) {
  471. if (response.code == 200) {
  472. $scope.sum = response.sum;
  473. $scope.rRows = response.problemClassifyList;
  474. angular.forEach(response.problemClassify, function (item) {
  475. $scope.pielenddata.push(item.type);
  476. $scope.piebodydata.push({
  477. "value": item.num,
  478. "name": item.type,
  479. "proportion": item.proportion
  480. });
  481. })
  482. pieechart()
  483. } else {
  484. }
  485. });
  486. }
  487. /**
  488. * 处理问题占比
  489. */
  490. function problemHandler() {
  491. $scope.barlenddata = [];
  492. $scope.barbodydata = [];
  493. $scope.hearderlist = [{
  494. name: "主责人",
  495. value: "name"
  496. }, {
  497. name: "完成问题数",
  498. value: "num"
  499. }, {
  500. name: "占比",
  501. value: "proportion"
  502. }];
  503. api_report_nx.fetchDataList("problemHandler", {
  504. "startTime": $scope.parameters.paramDateFrom,
  505. "endTime": $scope.parameters.paramDateTo
  506. }).then(function (response) {
  507. if (response.code == 200) {
  508. $scope.sum = response.sum;
  509. $scope.rRows = response.problemHandler;
  510. angular.forEach(response.problemHandler, function (item) {
  511. $scope.barlenddata.push(item.name);
  512. $scope.barbodydata.push({
  513. "value": item.num,
  514. "name": item.name,
  515. "proportion": item.proportion
  516. });
  517. })
  518. barechart()
  519. } else {
  520. }
  521. });
  522. }
  523. /**
  524. * 变更总数
  525. */
  526. function changeClassify() {
  527. $scope.pielenddata = [];
  528. $scope.piebodydata = [];
  529. $scope.hearderlist = [{
  530. name: "变更类别(三级)",
  531. value: "type3"
  532. }, {
  533. name: "变更数量",
  534. value: "num"
  535. }, {
  536. name: "所属类型(二级)",
  537. value: "type2"
  538. }, {
  539. name: "所属类型(一级)",
  540. value: "type1"
  541. }, {
  542. name: "占比",
  543. value: "proportion"
  544. }];
  545. api_report_nx.fetchDataList("changeClassify", {
  546. "startTime": $scope.parameters.paramDateFrom,
  547. "endTime": $scope.parameters.paramDateTo
  548. }).then(function (response) {
  549. if (response.code == 200) {
  550. $scope.sum = response.sum;
  551. $scope.rRows = response.changeClassifyList;
  552. angular.forEach(response.changeClassify, function (item) {
  553. $scope.pielenddata.push(item.type);
  554. $scope.piebodydata.push({
  555. "value": item.num,
  556. "name": item.type,
  557. "proportion": item.proportion
  558. });
  559. })
  560. pieechart()
  561. } else {
  562. }
  563. });
  564. }
  565. /**
  566. * 完成变更占比
  567. */
  568. function changeHandler() {
  569. $scope.barlenddata = [];
  570. $scope.barbodydata = [];
  571. $scope.hearderlist = [{
  572. name: "主责人",
  573. value: "name"
  574. }, {
  575. name: "完成变更数",
  576. value: "num"
  577. }, {
  578. name: "占比",
  579. value: "proportion"
  580. }];
  581. api_report_nx.fetchDataList("changeHandler", {
  582. "startTime": $scope.parameters.paramDateFrom,
  583. "endTime": $scope.parameters.paramDateTo
  584. }).then(function (response) {
  585. if (response.code == 200) {
  586. $scope.sum = response.sum;
  587. $scope.rRows = response.changeHandler;
  588. angular.forEach(response.changeHandler, function (item) {
  589. $scope.barlenddata.push(item.name);
  590. $scope.barbodydata.push({
  591. "value": item.num,
  592. "name": item.name,
  593. "proportion": item.proportion
  594. });
  595. })
  596. barechart()
  597. } else {
  598. }
  599. });
  600. }
  601. /**
  602. * 发布总数
  603. */
  604. function releaseClassify() {
  605. $scope.pielenddata = [];
  606. $scope.piebodydata = [];
  607. api_report_nx.fetchDataList("releaseClassify", {
  608. "startTime": $scope.parameters.paramDateFrom,
  609. "endTime": $scope.parameters.paramDateTo
  610. }).then(function (response) {
  611. if (response.code == 200) {
  612. $scope.sum = response.sum;
  613. $scope.rRows = response.releaseClassifyList;
  614. angular.forEach(response.releaseClassify, function (item) {
  615. $scope.pielenddata.push(item.name);
  616. $scope.piebodydata.push({
  617. "value": item.num,
  618. "name": item.name,
  619. "proportion": item.proportion
  620. });
  621. })
  622. pieechart()
  623. } else {
  624. }
  625. });
  626. }
  627. /**
  628. * 完成发布占比
  629. */
  630. function releaseHandler() {
  631. $scope.barlenddata = [];
  632. $scope.barbodydata = [];
  633. api_report_nx.fetchDataList("releaseHandler", {
  634. "startTime": $scope.parameters.paramDateFrom,
  635. "endTime": $scope.parameters.paramDateTo
  636. }).then(function (response) {
  637. if (response.code == 200) {
  638. $scope.sum = response.sum;
  639. $scope.rRows = response.releaseHandler;
  640. angular.forEach(response.releaseHandler, function (item) {
  641. $scope.barlenddata.push(item.name);
  642. $scope.barbodydata.push({
  643. "value": item.num,
  644. "name": item.name,
  645. "proportion": item.proportion
  646. });
  647. })
  648. barechart()
  649. } else {
  650. }
  651. });
  652. }
  653. /**
  654. * 资产总额
  655. */
  656. function assetClassify() {
  657. $scope.pielenddata = [];
  658. $scope.piebodydata = [];
  659. $scope.hearderlist = [{
  660. name: "资产类别(三级)",
  661. value: "label3"
  662. }, {
  663. name: "资产金额",
  664. value: "money"
  665. }, {
  666. name: "资产类别(二级)",
  667. value: "label2"
  668. }, {
  669. name: "资产类别(一级)",
  670. value: "label1"
  671. }];
  672. api_report_nx.fetchDataList("assetClassify", {
  673. "startTime": $scope.parameters.paramDateFrom,
  674. "endTime": $scope.parameters.paramDateTo
  675. }).then(function (response) {
  676. if (response.code == 200) {
  677. $scope.sum = response.sumMoney;
  678. $scope.summap = response.sum;
  679. $scope.rRows = response.assetClassifyList;
  680. angular.forEach(response.assetClassify, function (item) {
  681. $scope.pielenddata.push(item.label);
  682. $scope.piebodydata.push({
  683. "value": item.money,
  684. "name": item.label,
  685. "proportion": item.proportion
  686. });
  687. })
  688. pieechart()
  689. } else {
  690. }
  691. });
  692. }
  693. /**
  694. *资产在库
  695. */
  696. $scope.summap = 0;
  697. function assetStatus() {
  698. $scope.pielenddata = [];
  699. $scope.piebodydata = [];
  700. $scope.hearderlist = [{
  701. name: "资产类别(三级)",
  702. value: "label3"
  703. }, {
  704. name: "数量",
  705. value: "sum"
  706. }, {
  707. name: "资产类别(二级)",
  708. value: "label2"
  709. }, {
  710. name: "资产类别(一级)",
  711. value: "label1"
  712. }];
  713. api_report_nx.fetchDataList("assetStatus", {
  714. "startTime": $scope.parameters.paramDateFrom,
  715. "endTime": $scope.parameters.paramDateTo
  716. }).then(function (response) {
  717. // if (response.code == 200) {
  718. $scope.sum = response.sum;
  719. // $scope.summap = response.sum;
  720. $scope.rRows = response.assetStatusList;
  721. angular.forEach(response.assetStatus, function (item) {
  722. $scope.pielenddata.push(item.state);
  723. $scope.piebodydata.push({
  724. "value": item.sum,
  725. "name": item.state,
  726. "proportion": item.proportion
  727. });
  728. })
  729. pieechart()
  730. // } else {
  731. // }
  732. });
  733. }
  734. /**
  735. * 环形图
  736. */
  737. function pieechart() {
  738. var dom = document.getElementById("report");
  739. var myChart = echarts.init(dom);
  740. var app = {};
  741. var option = null;
  742. myChart.showLoading({  
  743. text: '数据加载中...',
  744. color: '#c23531',
  745. textColor: '#fff',
  746. maskColor: 'rgba(255,255,255,0)',
  747. zlevel: 0
  748. });
  749. myChart.hideLoading();
  750. option = {
  751. // title: [{
  752. // text: [$scope.sum],
  753. // x: '15%',
  754. // y: '50%',
  755. // textStyle: {
  756. // fontSize: 42,
  757. // fontWeight: 'normal',
  758. // fontStyle: 'normal',
  759. // color: '#005395',
  760. // align: 'center',
  761. // }
  762. // },
  763. // {
  764. // text: $scope.startlist.title,
  765. // x: '15%',
  766. // y: '40%',
  767. // textStyle: {
  768. // fontSize: 16,
  769. // fontWeight: 'normal',
  770. // fontStyle: 'normal',
  771. // align: "center",
  772. // color: '#333'
  773. // }
  774. // }
  775. // ],
  776. title: {
  777. subtext: [$scope.sum],
  778. text: $scope.startlist.title,
  779. itemGap: 3,
  780. "x": '20%',
  781. "y": '40%',
  782. textAlign: "center",
  783. "textStyle": {
  784. "fontWeight": 'normal',
  785. "fontSize": 18,
  786. "color": '#333',
  787. },
  788. "subtextStyle": {
  789. "fontWeight": 'normal',
  790. "fontSize": 42,
  791. "color": '#005395',
  792. "lineHeight": 14
  793. },
  794. },
  795. tooltip: {
  796. "backgroundColor": "rgba(0,0,0,9)",
  797. "textStyle": {
  798. "fontSize": 12,
  799. "color": '#f9f9f9',
  800. },
  801. trigger: 'item',
  802. formatter: "{a} <br/>{b}: {c} ({d}%)"
  803. },
  804. legend: {
  805. orient: 'vertical',
  806. x: '40%',
  807. y: 'center',
  808. itemGap: 20,
  809. data: $scope.pielenddata,
  810. formatter: function (param) {
  811. for (var i = 0; i < $scope.pielenddata.length; i++) {
  812. if ($scope.piebodydata[i].name == param) {
  813. return ' ' + $scope.piebodydata[i].name + ' ' + $scope.piebodydata[i].value + ' ' + $scope.piebodydata[i].proportion;
  814. }
  815. }
  816. }
  817. },
  818. series: [{
  819. name: $scope.startlist.title,
  820. type: 'pie',
  821. radius: ['70%', '85%'],
  822. center: ['20%', '50%'],
  823. color: ['#315b7e', '#3370a1', '#1a3a53', '#61829d', '#8496A5', '#e6eef4', '#15598F', '#61829d', '#5F9FD1', '#7EAFD6'],
  824. hoverAnimation: true,
  825. label: {
  826. normal: {
  827. show: false,
  828. position: 'center'
  829. },
  830. formatter: [
  831. '{a|这段文本采用样式a}',
  832. '{b|这段文本采用样式b}这段用默认样式{x|这段用样式x}'
  833. ].join('\n'),
  834. rich: {
  835. a: {
  836. color: 'red',
  837. lineHeight: 10
  838. },
  839. b: {
  840. backgroundColor: {
  841. image: 'xxx/xxx.jpg'
  842. },
  843. height: 40
  844. },
  845. x: {
  846. fontSize: 18,
  847. fontFamily: 'Microsoft YaHei',
  848. borderColor: '#449933',
  849. borderRadius: 4
  850. },
  851. }
  852. },
  853. labelLine: {
  854. normal: {
  855. show: false
  856. }
  857. },
  858. data: $scope.piebodydata
  859. }]
  860. };
  861. if (option && typeof option === "object") {
  862. myChart.setOption(option, true);
  863. myChart.hideLoading();
  864. }
  865. // ///
  866. // var dom = document.getElementById("reportnext");
  867. // var myChartn = echarts.init(dom);
  868. // var app = {};
  869. // var optionn = null;
  870. // myChartn.showLoading({  
  871. // text: '数据加载中...',
  872. // color: '#c23531',
  873. // textColor: '#fff',
  874. // maskColor: 'rgba(255,255,255,0)',
  875. // zlevel: 0
  876. // });
  877. // myChartn.hideLoading();
  878. // optionn = {
  879. // title: [{
  880. // text: [$scope.sum],
  881. // x: 'center',
  882. // y: '50%',
  883. // textStyle: {
  884. // fontSize: 42,
  885. // fontWeight: 'normal',
  886. // fontStyle: 'normal',
  887. // color: '#005395',
  888. // align: 'center',
  889. // }
  890. // },
  891. // {
  892. // text: $scope.startlist.title,
  893. // x: 'center',
  894. // y: '40%',
  895. // textStyle: {
  896. // fontSize: 16,
  897. // fontWeight: 'normal',
  898. // fontStyle: 'normal',
  899. // align: "center",
  900. // color: '#333'
  901. // }
  902. // }
  903. // ],
  904. // tooltip: {
  905. // "backgroundColor": "rgba(0,0,0,9)",
  906. // "textStyle": {
  907. // "fontSize": 12,
  908. // "color": '#f9f9f9',
  909. // },
  910. // trigger: 'item',
  911. // formatter: "{a} <br/>{b}: {c} ({d}%)"
  912. // },
  913. // legend: {
  914. // orient: 'vertical',
  915. // x: '90%',
  916. // y: 'center',
  917. // itemGap: 40,
  918. // data: $scope.pielenddata,
  919. // formatter: function(param) {
  920. // for (var i = 0; i < $scope.pielenddata.length; i++) {
  921. // if ($scope.piebodydata[i].name == param) {
  922. // return ' ' + $scope.piebodydata[i].name + ' ' + $scope.piebodydata[i].value + ' ' + $scope.piebodydata[i].proportion;
  923. // }
  924. // }
  925. // }
  926. // },
  927. // series: [{
  928. // show: false,
  929. // name: $scope.startlist.title,
  930. // type: 'pie',
  931. // radius: ['70%', '85%'],
  932. // center: ['50%', '50%'],
  933. // color: ['#315b7e', '#3370a1', '#1a3a53', '#61829d', '#8496A5', '#e6eef4', '#15598F', '#61829d', '#5F9FD1', '#7EAFD6'],
  934. // hoverAnimation: true,
  935. // label: {
  936. // normal: {
  937. // show: false,
  938. // position: 'center'
  939. // },
  940. // formatter: [
  941. // '{a|这段文本采用样式a}',
  942. // '{b|这段文本采用样式b}这段用默认样式{x|这段用样式x}'
  943. // ].join('\n'),
  944. // rich: {
  945. // a: {
  946. // color: 'red',
  947. // lineHeight: 10
  948. // },
  949. // b: {
  950. // backgroundColor: {
  951. // image: 'xxx/xxx.jpg'
  952. // },
  953. // height: 40
  954. // },
  955. // x: {
  956. // fontSize: 18,
  957. // fontFamily: 'Microsoft YaHei',
  958. // borderColor: '#449933',
  959. // borderRadius: 4
  960. // },
  961. // }
  962. // },
  963. // labelLine: {
  964. // normal: {
  965. // show: false
  966. // }
  967. // },
  968. // data: $scope.piebodydata
  969. // }]
  970. // };
  971. // if (optionn && typeof optionn === "object") {
  972. // myChartn.setOption(optionn);
  973. // myChartn.hideLoading();
  974. // }
  975. }
  976. // }, 1000)
  977. /***
  978. * 柱状图
  979. */
  980. function hardDisks(data) {
  981. if ($scope.sum == 0) {
  982. return 0;
  983. } else {
  984. }
  985. return data / $scope.sum;
  986. }
  987. function barechart() {
  988. var dom = document.getElementById("barreport");
  989. var mybarChart = echarts.init(dom);
  990. var app = {};
  991. var optionbar = null;
  992. mybarChart.showLoading({  
  993. text: '数据加载中...',
  994. color: '#c23531',
  995. textColor: '#fff',
  996. maskColor: 'rgba(255,255,255,0)',
  997. zlevel: 0
  998. });
  999. mybarChart.hideLoading();
  1000. optionbar = {
  1001. title: {
  1002. // text: '(件)故障数量',
  1003. x: '10',
  1004. y: '0',
  1005. textStyle: {
  1006. fontWeight: 'normal',
  1007. fontSize: 12,
  1008. color: "#56c9ff",
  1009. }
  1010. },
  1011. xAxis: {
  1012. axisTick: {
  1013. alignWithLabel: true
  1014. },
  1015. splitLine: {
  1016. show: false
  1017. },
  1018. splitArea: {
  1019. show: false
  1020. },
  1021. // data: XData,
  1022. data: $scope.barlenddata,
  1023. axisLine: {
  1024. lineStyle: {
  1025. color: '#eaeaea'
  1026. }
  1027. },
  1028. axisLabel: {
  1029. interval: 0,
  1030. formatter: function (value) {
  1031. return value.split("").join("\n");
  1032. },
  1033. // rotate: 45,
  1034. // margin: 2,
  1035. textStyle: {
  1036. color: '#999',
  1037. fontSize: 14,
  1038. }
  1039. },
  1040. },
  1041. // grid: { // 控制图的大小,调整下面这些值就可以,
  1042. // x: 40,
  1043. // x2: 100,
  1044. // y2: 150, // y2可以控制 X轴跟Zoom控件之间的间隔,避免以为倾斜后造成 label重叠到zoom上
  1045. // },
  1046. yAxis: {
  1047. axisTick: {
  1048. show: false
  1049. },
  1050. splitLine: {
  1051. show: false
  1052. },
  1053. splitArea: {
  1054. show: false
  1055. },
  1056. minInterval: 1,
  1057. axisLabel: {
  1058. show: true,
  1059. textStyle: {
  1060. color: '#999',
  1061. fontSize: 14,
  1062. }
  1063. },
  1064. axisLine: {
  1065. show: false,
  1066. lineStyle: {
  1067. color: '#eaeaea'
  1068. }
  1069. },
  1070. splitLine: {
  1071. lineStyle: {
  1072. color: "#eaeaea"
  1073. }
  1074. }
  1075. },
  1076. grid: {
  1077. left: 10,
  1078. top: 25,
  1079. bottom: 20,
  1080. right: 10,
  1081. containLabel: true
  1082. },
  1083. "tooltip": {
  1084. "trigger": "item",
  1085. "backgroundColor": "rgba(0,0,0,9)",
  1086. "textStyle": {
  1087. "fontSize": 12,
  1088. "color": '#f9f9f9',
  1089. },
  1090. formatter: function (data) {
  1091. return $scope.startlist.tip1 + ':' + data.value + '<br />' + $scope.startlist.tip2 + ':' + data.data.proportion;
  1092. },
  1093. },
  1094. series: {
  1095. type: "bar",
  1096. itemStyle: {
  1097. normal: {
  1098. color: function (params) {
  1099. // type = 'linear';
  1100. // var colorList = [
  1101. // '#005395'
  1102. // ];
  1103. return '#005395'
  1104. },
  1105. }
  1106. },
  1107. label: {
  1108. normal: {
  1109. show: true,
  1110. position: 'top',
  1111. textStyle: {
  1112. // color: '#56c9ff'
  1113. }
  1114. }
  1115. },
  1116. barWidth: 18,
  1117. // barWidth: '30%',
  1118. // data: yData
  1119. data: $scope.barbodydata
  1120. }
  1121. };
  1122. if (optionbar && typeof optionbar === "object") {
  1123. mybarChart.setOption(optionbar, true);
  1124. mybarChart.hideLoading();
  1125. }
  1126. }
  1127. }])