1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177 |
- 'use strict';
- 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) {
- $scope.parameters = {};
- $scope.hearderlist = [];
- $scope.pielenddata = [];
- $scope.piebodydata = [];
- $scope.barlenddata = [];
- $scope.barbodydata = [];
- $scope.categryid = 2;
- $scope.sum = 0;
- $scope.startlist = {
- id: 2,
- label: "事件总数&分类统计报告",
- title: "事件总数",
- key: "incidentClassify",
- selected: true
- };
- $scope.nowdata = moment(new Date()).format('YYYY/MM/DD HH:ss:mm');
- //时间搜索
- // $scope.starttimes = moment(new Date().getTime() - 86400000 * 7).format('YYYY-MM-DD'); //开始时间
- // $scope.endtimes = moment(new Date().getTime() - 86400000).format('YYYY-MM-DD'); //结束时间
- var weeks = new Date().getDay();
- $scope.starttimes = moment(new Date().getTime() - 86400000 * (weeks + 6)).format('YYYY-MM-DD');
- $scope.endtimes = moment(new Date().getTime() - 86400000 * (weeks)).format('YYYY-MM-DD');
- $scope.changeForm = function (paramDateFrom) {
- $scope.starttimes = moment(paramDateFrom).format('YYYY-MM-DD');
- }
- $scope.changeTo = function (paramDateTo) {
- $scope.endtimes = moment(paramDateTo).format('YYYY-MM-DD');
- }
- $scope.parameters.paramDateFrom = $scope.starttimes;
- $scope.parameters.paramDateTo = $scope.endtimes;
- //高度
- setInterval(function () {
- if (document.getElementById("DIV3")) {
- $scope.listheight = {
- "min-height": document.getElementById("DIV3").scrollHeight - 20 + "px"
- };
- }
- }, 1000)
- var downPdf = document.getElementById("exportToPdf");
- downPdf.onclick = function () {
- html2canvas(
- document.getElementById("export_content"), {
- dpi: 172, //导出pdf清晰度
- onrendered: function (canvas) {
- var contentWidth = canvas.width;
- var contentHeight = canvas.height;
- //一页pdf显示html页面生成的canvas高度;
- var pageHeight = contentWidth / 592.28 * 841.89;
- //未生成pdf的html页面高度
- var leftHeight = contentHeight;
- //pdf页面偏移
- var position = 0;
- //html页面生成的canvas在pdf中图片的宽高(a4纸的尺寸[595.28,841.89])
- var imgWidth = 595.28;
- var imgHeight = 592.28 / contentWidth * contentHeight;
- var pageData = canvas.toDataURL('image/jpeg', 1.0);
- var pdf = new jsPDF('', 'pt', 'a4');
- //有两个高度需要区分,一个是html页面的实际高度,和生成pdf的页面高度(841.89)
- //当内容未超过pdf一页显示的范围,无需分页
- if (leftHeight < pageHeight) {
- pdf.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight);
- } else {
- while (leftHeight > 0) {
- pdf.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight)
- leftHeight -= pageHeight;
- position -= 841.89;
- //避免添加空白页
- if (leftHeight > 0) {
- pdf.addPage();
- }
- }
- }
- pdf.save('content.pdf');
- },
- //背景设为白色(默认为黑色)
- background: "#fff"
- })
- }
- //上周
- $scope.week = function () {
- $scope.searchstate = "week";
- var weeks = new Date().getDay();
- $scope.starttimes = moment(new Date().getTime() - 86400000 * (weeks + 6)).format('YYYY-MM-DD');
- $scope.endtimes = moment(new Date().getTime() - 86400000 * (weeks)).format('YYYY-MM-DD');
- $scope.parameters.paramDateFrom = $scope.starttimes;
- $scope.parameters.paramDateTo = $scope.endtimes;
- // $scope.parameters = parseDateParameter($scope.parameters);
- $scope.mdxquery();
- }
- //上月
- $scope.month = function () {
- $scope.searchstate = "month";
- $scope.starttimes = moment((new Date(moment().startOf('month'))).setMonth((new Date()).getMonth() - 1)).format('YYYY-MM-DD');
- $scope.endtimes = moment((new Date(moment().startOf('month'))).setMonth((new Date()).getMonth()) - 86400000).format('YYYY-MM-DD');
- $scope.parameters.paramDateFrom = $scope.starttimes;
- $scope.parameters.paramDateTo = $scope.endtimes;
- // $scope.parameters = parseDateParameter($scope.parameters);
- $scope.mdxquery();
- }
- //上年
- $scope.year = function () {
- $scope.searchstate = "year";
- $scope.starttimes = moment().startOf('year').format('YYYY-MM-DD');
- $scope.endtimes = moment().format('YYYY-MM-DD');
- $scope.parameters.paramDateFrom = $scope.starttimes;
- $scope.parameters.paramDateTo = $scope.endtimes;
- // $scope.parameters = parseDateParameter($scope.parameters);
- $scope.mdxquery();
- }
- /**
- *日历
- */
- $scope.open = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.opened = !$scope.opened;
- };
- $scope.endOpen = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.startOpened = false;
- $scope.endOpened = !$scope.endOpened;
- };
- $scope.startOpen = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.endOpened = false;
- $scope.startOpened = !$scope.startOpened;
- };
- /***
- * 导出
- */
- $scope.exportData = function () {
- // var modelData = $scope.startlist;
- // $state.go('childpape', { starttime: $scope.parameters.paramDateFrom, endtime: $scope.parameters.paramDateTo, model: JSON.stringify(modelData) });
- // 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) {
- // 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();
- // var a = document.createElement('a');
- // a.href = downUrl;
- // a.target = '_blank';
- // // a.download = filename;
- // document.body.appendChild(a);
- // a.click();
- // });
- $http({
- url: api_report_nx.getPdf().getRequestedUrl(),
- method: 'post',
- data: {
- 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"
- },
- headers: {
- //'Content-type' : 'application/xls',
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function (data, status, headers, config) {
- var file = new Blob([data], {
- type: 'application/octet-stream'
- });
- //trick to download store a file having its URL
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- // window.open(a.href);
- a.target = '_blank';
- // a.download = filename;
- document.body.appendChild(a);
- a.click();
- }).error(function (data, status, headers, config) {
- // console.log(data);
- });
- }
- /**
- * 时间搜索
- */
- $scope.mdxquery = function () {
- $scope.parameters.paramDateFrom = moment($scope.parameters.paramDateFrom).format('YYYY-MM-DD');
- $scope.parameters.paramDateTo = moment($scope.parameters.paramDateTo).format('YYYY-MM-DD');
- if ($scope.startlist.id == 2) {
- incidentClassify()
- } else if ($scope.startlist.id == 3) {
- incidentHandler()
- } else if ($scope.startlist.id == 6) {
- problemClassify()
- } else if ($scope.startlist.id == 7) {
- problemHandler()
- } else if ($scope.startlist.id == 12) {
- changeClassify()
- } else if ($scope.startlist.id == 13) {
- changeHandler()
- } else if ($scope.startlist.id == 16) {
- releaseClassify()
- } else if ($scope.startlist.id == 17) {
- releaseHandler()
- } else if ($scope.startlist.id == 22) {
- assetClassify()
- } else if ($scope.startlist.id == 24) {
- assetStatus()
- }
- }
- /**
- * 树形列表
- */
- $scope.my_tree = {};
- $scope.my_data = [];
- $scope.try_async_load = function () {
- $scope.my_data = [{
- id: 1,
- label: "事件报表",
- children: [{
- id: 2,
- label: "事件总数&分类统计报告",
- title: "事件总数",
- key: "incidentClassify",
- selected: true,
- }, {
- id: 3,
- label: "处理完事件占比",
- tip1: "完成事件数量",
- tip2: "事件占比",
- key: "incidentHandler"
- }]
- },
- {
- id: 5,
- label: "问题报表",
- children: [{
- id: 6,
- label: "问题总数&分类统计报告",
- title: "问题总数",
- key: "problemClassify"
- }, {
- id: 7,
- label: "处理人完成问题占比",
- tip1: "完成问题数量",
- tip2: "问题占比",
- key: "problemHandler"
- }]
- }, {
- id: 11,
- label: "变更报表",
- children: [{
- id: 12,
- label: "变更总数&分类统计报告",
- title: "变更总数",
- key: "changeClassify"
- }, {
- id: 13,
- label: "处理人完成变更占比",
- tip1: "完成变更数量",
- tip2: "变更占比",
- key: "changeHandler"
- }]
- }, {
- id: 15,
- label: "发布报表",
- children: [{
- id: 16,
- label: "发布总数&分类统计报告",
- title: "发布总数",
- key: "releaseClassify"
- }, {
- id: 17,
- label: "处理人完成发布占比",
- tip1: "完成发布数量",
- tip2: "发布占比",
- key: "releaseHandler"
- }]
- },
- {
- id: 21,
- label: "资产报表",
- children: [{
- id: 22,
- label: "资产总金额&分类统计报告",
- title: "资产总金额",
- key: "assetClassify"
- }, {
- id: 24,
- label: "资产总量统计报告",
- title: "资产总量",
- key: "assetStatus"
- }]
- }
- ];
- $scope.my_tree = angular.copy($scope.my_data);
- };
- function convertListToTree(data, treeMap) {
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = null; //Initially set our loop to null
- var parentNode = null;
- //loop over data
- for (var i = 0; i < data.length; i++) {
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- datum.children = [];
- //add an entry for this node to the map so that any future children can
- //lookup the parent
- idToNodeMap[datum.id] = datum;
- //Does this node have a parent?
- if (typeof datum.parent === "undefined" || datum.parent == null) {
- //Doesn't look like it, so this node is the root of the tree
- root = datum;
- treeMap[datum.id] = root;
- } else {
- //This node has a parent, so let's look it up using the id
- parentNode = idToNodeMap[datum.parent.id];
- //We don't need this property, so let's delete it.
- delete datum.parent;
- //Let's add the current node as a child of the parent node.
- parentNode.children.push(datum);
- }
- }
- return root;
- console.log(root)
- }
- function convertParentToChildList(data) {
- var treeMap = {};
- var list = [];
- convertListToTree(data, treeMap);
- angular.forEach(treeMap, function (item) {
- list.push(item);
- });
- return list;
- }
- $scope.try_async_load();
- $scope.my_tree_handler = function (branch) {
- $scope.startlist = branch;
- if (branch.id == 2) {
- incidentClassify()
- } else if (branch.id == 3) {
- incidentHandler();
- $scope.my_data[0].children[0].selected = false;
- } else if (branch.id == 6) {
- problemClassify()
- $scope.my_data[0].children[0].selected = false;
- } else if (branch.id == 7) {
- problemHandler()
- $scope.my_data[0].children[0].selected = false;
- } else if (branch.id == 12) {
- changeClassify()
- $scope.my_data[0].children[0].selected = false;
- } else if (branch.id == 13) {
- changeHandler()
- $scope.my_data[0].children[0].selected = false;
- } else if (branch.id == 16) {
- releaseClassify()
- $scope.my_data[0].children[0].selected = false;
- } else if (branch.id == 17) {
- releaseHandler()
- $scope.my_data[0].children[0].selected = false;
- } else if (branch.id == 22) {
- assetClassify()
- $scope.my_data[0].children[0].selected = false;
- } else if (branch.id == 24) {
- assetStatus()
- $scope.my_data[0].children[0].selected = false;
- }
- }
- /***
- * 故障现象总数
- */
- // setTimeout(function() {
- function incidentClassify() {
- $scope.pielenddata = [];
- $scope.piebodydata = [];
- $scope.hearderlist = [{
- name: "事件类别(三级)",
- value: "type3"
- }, {
- name: "事件数量",
- value: "num"
- }, {
- name: "所属类型(二级)",
- value: "type2"
- }, {
- name: "所属类型(一级)",
- value: "type1"
- }, {
- name: "占比",
- value: "proportion"
- }];
- api_report_nx.fetchDataList("incidentClassify", {
- "startTime": $scope.parameters.paramDateFrom,
- "endTime": $scope.parameters.paramDateTo
- }).then(function (response) {
- if (response.code == 200) {
- $scope.sum = response.sum;
- $scope.rRows = response.incidentClassifyList;
- angular.forEach(response.incidentClassify, function (item) {
- $scope.pielenddata.push(item.type);
- $scope.piebodydata.push({
- "value": item.num,
- "name": item.type,
- "proportion": item.proportion
- });
- })
- pieechart()
- } else {
- }
- });
- }
- // setTimeout(function() {
- incidentClassify()
- // }, 500);
- /**
- * 处理事件占比
- */
- function incidentHandler() {
- $scope.barlenddata = [];
- $scope.barbodydata = [];
- $scope.hearderlist = [{
- name: "处理人",
- value: "name"
- }, {
- name: "完成事件数",
- value: "num"
- }, {
- name: "占比",
- value: "proportion"
- }];
- api_report_nx.fetchDataList("incidentHandler", {
- "startTime": $scope.parameters.paramDateFrom,
- "endTime": $scope.parameters.paramDateTo
- }).then(function (response) {
- if (response.code == 200) {
- $scope.sum = response.sum;
- $scope.rRows = response.incidentHandler;
- angular.forEach(response.incidentHandler, function (item) {
- $scope.barlenddata.push(item.name);
- $scope.barbodydata.push({
- "value": item.num,
- "name": item.name,
- "proportion": item.proportion
- });
- })
- barechart()
- } else {
- }
- });
- }
- // incidentHandler()
- /**
- * 问题总数
- */
- function problemClassify() {
- $scope.pielenddata = [];
- $scope.piebodydata = [];
- $scope.hearderlist = [{
- name: "问题类别(三级)",
- value: "type3"
- }, {
- name: "问题数量",
- value: "num"
- }, {
- name: "所属类型(二级)",
- value: "type2"
- }, {
- name: "所属类型(一级)",
- value: "type1"
- }, {
- name: "占比",
- value: "proportion"
- }];
- api_report_nx.fetchDataList("problemClassify", {
- "startTime": $scope.parameters.paramDateFrom,
- "endTime": $scope.parameters.paramDateTo
- }).then(function (response) {
- if (response.code == 200) {
- $scope.sum = response.sum;
- $scope.rRows = response.problemClassifyList;
- angular.forEach(response.problemClassify, function (item) {
- $scope.pielenddata.push(item.type);
- $scope.piebodydata.push({
- "value": item.num,
- "name": item.type,
- "proportion": item.proportion
- });
- })
- pieechart()
- } else {
- }
- });
- }
- /**
- * 处理问题占比
- */
- function problemHandler() {
- $scope.barlenddata = [];
- $scope.barbodydata = [];
- $scope.hearderlist = [{
- name: "主责人",
- value: "name"
- }, {
- name: "完成问题数",
- value: "num"
- }, {
- name: "占比",
- value: "proportion"
- }];
- api_report_nx.fetchDataList("problemHandler", {
- "startTime": $scope.parameters.paramDateFrom,
- "endTime": $scope.parameters.paramDateTo
- }).then(function (response) {
- if (response.code == 200) {
- $scope.sum = response.sum;
- $scope.rRows = response.problemHandler;
- angular.forEach(response.problemHandler, function (item) {
- $scope.barlenddata.push(item.name);
- $scope.barbodydata.push({
- "value": item.num,
- "name": item.name,
- "proportion": item.proportion
- });
- })
- barechart()
- } else {
- }
- });
- }
- /**
- * 变更总数
- */
- function changeClassify() {
- $scope.pielenddata = [];
- $scope.piebodydata = [];
- $scope.hearderlist = [{
- name: "变更类别(三级)",
- value: "type3"
- }, {
- name: "变更数量",
- value: "num"
- }, {
- name: "所属类型(二级)",
- value: "type2"
- }, {
- name: "所属类型(一级)",
- value: "type1"
- }, {
- name: "占比",
- value: "proportion"
- }];
- api_report_nx.fetchDataList("changeClassify", {
- "startTime": $scope.parameters.paramDateFrom,
- "endTime": $scope.parameters.paramDateTo
- }).then(function (response) {
- if (response.code == 200) {
- $scope.sum = response.sum;
- $scope.rRows = response.changeClassifyList;
- angular.forEach(response.changeClassify, function (item) {
- $scope.pielenddata.push(item.type);
- $scope.piebodydata.push({
- "value": item.num,
- "name": item.type,
- "proportion": item.proportion
- });
- })
- pieechart()
- } else {
- }
- });
- }
- /**
- * 完成变更占比
- */
- function changeHandler() {
- $scope.barlenddata = [];
- $scope.barbodydata = [];
- $scope.hearderlist = [{
- name: "主责人",
- value: "name"
- }, {
- name: "完成变更数",
- value: "num"
- }, {
- name: "占比",
- value: "proportion"
- }];
- api_report_nx.fetchDataList("changeHandler", {
- "startTime": $scope.parameters.paramDateFrom,
- "endTime": $scope.parameters.paramDateTo
- }).then(function (response) {
- if (response.code == 200) {
- $scope.sum = response.sum;
- $scope.rRows = response.changeHandler;
- angular.forEach(response.changeHandler, function (item) {
- $scope.barlenddata.push(item.name);
- $scope.barbodydata.push({
- "value": item.num,
- "name": item.name,
- "proportion": item.proportion
- });
- })
- barechart()
- } else {
- }
- });
- }
- /**
- * 发布总数
- */
- function releaseClassify() {
- $scope.pielenddata = [];
- $scope.piebodydata = [];
- api_report_nx.fetchDataList("releaseClassify", {
- "startTime": $scope.parameters.paramDateFrom,
- "endTime": $scope.parameters.paramDateTo
- }).then(function (response) {
- if (response.code == 200) {
- $scope.sum = response.sum;
- $scope.rRows = response.releaseClassifyList;
- angular.forEach(response.releaseClassify, function (item) {
- $scope.pielenddata.push(item.name);
- $scope.piebodydata.push({
- "value": item.num,
- "name": item.name,
- "proportion": item.proportion
- });
- })
- pieechart()
- } else {
- }
- });
- }
- /**
- * 完成发布占比
- */
- function releaseHandler() {
- $scope.barlenddata = [];
- $scope.barbodydata = [];
- api_report_nx.fetchDataList("releaseHandler", {
- "startTime": $scope.parameters.paramDateFrom,
- "endTime": $scope.parameters.paramDateTo
- }).then(function (response) {
- if (response.code == 200) {
- $scope.sum = response.sum;
- $scope.rRows = response.releaseHandler;
- angular.forEach(response.releaseHandler, function (item) {
- $scope.barlenddata.push(item.name);
- $scope.barbodydata.push({
- "value": item.num,
- "name": item.name,
- "proportion": item.proportion
- });
- })
- barechart()
- } else {
- }
- });
- }
- /**
- * 资产总额
- */
- function assetClassify() {
- $scope.pielenddata = [];
- $scope.piebodydata = [];
- $scope.hearderlist = [{
- name: "资产类别(三级)",
- value: "label3"
- }, {
- name: "资产金额",
- value: "money"
- }, {
- name: "资产类别(二级)",
- value: "label2"
- }, {
- name: "资产类别(一级)",
- value: "label1"
- }];
- api_report_nx.fetchDataList("assetClassify", {
- "startTime": $scope.parameters.paramDateFrom,
- "endTime": $scope.parameters.paramDateTo
- }).then(function (response) {
- if (response.code == 200) {
- $scope.sum = response.sumMoney;
- $scope.summap = response.sum;
- $scope.rRows = response.assetClassifyList;
- angular.forEach(response.assetClassify, function (item) {
- $scope.pielenddata.push(item.label);
- $scope.piebodydata.push({
- "value": item.money,
- "name": item.label,
- "proportion": item.proportion
- });
- })
- pieechart()
- } else {
- }
- });
- }
- /**
- *资产在库
- */
- $scope.summap = 0;
- function assetStatus() {
- $scope.pielenddata = [];
- $scope.piebodydata = [];
- $scope.hearderlist = [{
- name: "资产类别(三级)",
- value: "label3"
- }, {
- name: "数量",
- value: "sum"
- }, {
- name: "资产类别(二级)",
- value: "label2"
- }, {
- name: "资产类别(一级)",
- value: "label1"
- }];
- api_report_nx.fetchDataList("assetStatus", {
- "startTime": $scope.parameters.paramDateFrom,
- "endTime": $scope.parameters.paramDateTo
- }).then(function (response) {
- // if (response.code == 200) {
- $scope.sum = response.sum;
- // $scope.summap = response.sum;
- $scope.rRows = response.assetStatusList;
- angular.forEach(response.assetStatus, function (item) {
- $scope.pielenddata.push(item.state);
- $scope.piebodydata.push({
- "value": item.sum,
- "name": item.state,
- "proportion": item.proportion
- });
- })
- pieechart()
- // } else {
- // }
- });
- }
- /**
- * 环形图
- */
- function pieechart() {
- var dom = document.getElementById("report");
- var myChart = echarts.init(dom);
- var app = {};
- var option = null;
- myChart.showLoading({
- text: '数据加载中...',
- color: '#c23531',
- textColor: '#fff',
- maskColor: 'rgba(255,255,255,0)',
- zlevel: 0
- });
- myChart.hideLoading();
- option = {
- // title: [{
- // text: [$scope.sum],
- // x: '15%',
- // y: '50%',
- // textStyle: {
- // fontSize: 42,
- // fontWeight: 'normal',
- // fontStyle: 'normal',
- // color: '#005395',
- // align: 'center',
- // }
- // },
- // {
- // text: $scope.startlist.title,
- // x: '15%',
- // y: '40%',
- // textStyle: {
- // fontSize: 16,
- // fontWeight: 'normal',
- // fontStyle: 'normal',
- // align: "center",
- // color: '#333'
- // }
- // }
- // ],
- title: {
- subtext: [$scope.sum],
- text: $scope.startlist.title,
- itemGap: 3,
- "x": '20%',
- "y": '40%',
- textAlign: "center",
- "textStyle": {
- "fontWeight": 'normal',
- "fontSize": 18,
- "color": '#333',
- },
- "subtextStyle": {
- "fontWeight": 'normal',
- "fontSize": 42,
- "color": '#005395',
- "lineHeight": 14
- },
- },
- tooltip: {
- "backgroundColor": "rgba(0,0,0,9)",
- "textStyle": {
- "fontSize": 12,
- "color": '#f9f9f9',
- },
- trigger: 'item',
- formatter: "{a} <br/>{b}: {c} ({d}%)"
- },
- legend: {
- orient: 'vertical',
- x: '40%',
- y: 'center',
- itemGap: 20,
- data: $scope.pielenddata,
- formatter: function (param) {
- for (var i = 0; i < $scope.pielenddata.length; i++) {
- if ($scope.piebodydata[i].name == param) {
- return ' ' + $scope.piebodydata[i].name + ' ' + $scope.piebodydata[i].value + ' ' + $scope.piebodydata[i].proportion;
- }
- }
- }
- },
- series: [{
- name: $scope.startlist.title,
- type: 'pie',
- radius: ['70%', '85%'],
- center: ['20%', '50%'],
- color: ['#315b7e', '#3370a1', '#1a3a53', '#61829d', '#8496A5', '#e6eef4', '#15598F', '#61829d', '#5F9FD1', '#7EAFD6'],
- hoverAnimation: true,
- label: {
- normal: {
- show: false,
- position: 'center'
- },
- formatter: [
- '{a|这段文本采用样式a}',
- '{b|这段文本采用样式b}这段用默认样式{x|这段用样式x}'
- ].join('\n'),
- rich: {
- a: {
- color: 'red',
- lineHeight: 10
- },
- b: {
- backgroundColor: {
- image: 'xxx/xxx.jpg'
- },
- height: 40
- },
- x: {
- fontSize: 18,
- fontFamily: 'Microsoft YaHei',
- borderColor: '#449933',
- borderRadius: 4
- },
- }
- },
- labelLine: {
- normal: {
- show: false
- }
- },
- data: $scope.piebodydata
- }]
- };
- if (option && typeof option === "object") {
- myChart.setOption(option, true);
- myChart.hideLoading();
- }
- // ///
- // var dom = document.getElementById("reportnext");
- // var myChartn = echarts.init(dom);
- // var app = {};
- // var optionn = null;
- // myChartn.showLoading({
- // text: '数据加载中...',
- // color: '#c23531',
- // textColor: '#fff',
- // maskColor: 'rgba(255,255,255,0)',
- // zlevel: 0
- // });
- // myChartn.hideLoading();
- // optionn = {
- // title: [{
- // text: [$scope.sum],
- // x: 'center',
- // y: '50%',
- // textStyle: {
- // fontSize: 42,
- // fontWeight: 'normal',
- // fontStyle: 'normal',
- // color: '#005395',
- // align: 'center',
- // }
- // },
- // {
- // text: $scope.startlist.title,
- // x: 'center',
- // y: '40%',
- // textStyle: {
- // fontSize: 16,
- // fontWeight: 'normal',
- // fontStyle: 'normal',
- // align: "center",
- // color: '#333'
- // }
- // }
- // ],
- // tooltip: {
- // "backgroundColor": "rgba(0,0,0,9)",
- // "textStyle": {
- // "fontSize": 12,
- // "color": '#f9f9f9',
- // },
- // trigger: 'item',
- // formatter: "{a} <br/>{b}: {c} ({d}%)"
- // },
- // legend: {
- // orient: 'vertical',
- // x: '90%',
- // y: 'center',
- // itemGap: 40,
- // data: $scope.pielenddata,
- // formatter: function(param) {
- // for (var i = 0; i < $scope.pielenddata.length; i++) {
- // if ($scope.piebodydata[i].name == param) {
- // return ' ' + $scope.piebodydata[i].name + ' ' + $scope.piebodydata[i].value + ' ' + $scope.piebodydata[i].proportion;
- // }
- // }
- // }
- // },
- // series: [{
- // show: false,
- // name: $scope.startlist.title,
- // type: 'pie',
- // radius: ['70%', '85%'],
- // center: ['50%', '50%'],
- // color: ['#315b7e', '#3370a1', '#1a3a53', '#61829d', '#8496A5', '#e6eef4', '#15598F', '#61829d', '#5F9FD1', '#7EAFD6'],
- // hoverAnimation: true,
- // label: {
- // normal: {
- // show: false,
- // position: 'center'
- // },
- // formatter: [
- // '{a|这段文本采用样式a}',
- // '{b|这段文本采用样式b}这段用默认样式{x|这段用样式x}'
- // ].join('\n'),
- // rich: {
- // a: {
- // color: 'red',
- // lineHeight: 10
- // },
- // b: {
- // backgroundColor: {
- // image: 'xxx/xxx.jpg'
- // },
- // height: 40
- // },
- // x: {
- // fontSize: 18,
- // fontFamily: 'Microsoft YaHei',
- // borderColor: '#449933',
- // borderRadius: 4
- // },
- // }
- // },
- // labelLine: {
- // normal: {
- // show: false
- // }
- // },
- // data: $scope.piebodydata
- // }]
- // };
- // if (optionn && typeof optionn === "object") {
- // myChartn.setOption(optionn);
- // myChartn.hideLoading();
- // }
- }
- // }, 1000)
- /***
- * 柱状图
- */
- function hardDisks(data) {
- if ($scope.sum == 0) {
- return 0;
- } else {
- }
- return data / $scope.sum;
- }
- function barechart() {
- var dom = document.getElementById("barreport");
- var mybarChart = echarts.init(dom);
- var app = {};
- var optionbar = null;
- mybarChart.showLoading({
- text: '数据加载中...',
- color: '#c23531',
- textColor: '#fff',
- maskColor: 'rgba(255,255,255,0)',
- zlevel: 0
- });
- mybarChart.hideLoading();
- optionbar = {
- title: {
- // text: '(件)故障数量',
- x: '10',
- y: '0',
- textStyle: {
- fontWeight: 'normal',
- fontSize: 12,
- color: "#56c9ff",
- }
- },
- xAxis: {
- axisTick: {
- alignWithLabel: true
- },
- splitLine: {
- show: false
- },
- splitArea: {
- show: false
- },
- // data: XData,
- data: $scope.barlenddata,
- axisLine: {
- lineStyle: {
- color: '#eaeaea'
- }
- },
- axisLabel: {
- interval: 0,
- formatter: function (value) {
- return value.split("").join("\n");
- },
- // rotate: 45,
- // margin: 2,
- textStyle: {
- color: '#999',
- fontSize: 14,
- }
- },
- },
- // grid: { // 控制图的大小,调整下面这些值就可以,
- // x: 40,
- // x2: 100,
- // y2: 150, // y2可以控制 X轴跟Zoom控件之间的间隔,避免以为倾斜后造成 label重叠到zoom上
- // },
- yAxis: {
- axisTick: {
- show: false
- },
- splitLine: {
- show: false
- },
- splitArea: {
- show: false
- },
- minInterval: 1,
- axisLabel: {
- show: true,
- textStyle: {
- color: '#999',
- fontSize: 14,
- }
- },
- axisLine: {
- show: false,
- lineStyle: {
- color: '#eaeaea'
- }
- },
- splitLine: {
- lineStyle: {
- color: "#eaeaea"
- }
- }
- },
- grid: {
- left: 10,
- top: 25,
- bottom: 20,
- right: 10,
- containLabel: true
- },
- "tooltip": {
- "trigger": "item",
- "backgroundColor": "rgba(0,0,0,9)",
- "textStyle": {
- "fontSize": 12,
- "color": '#f9f9f9',
- },
- formatter: function (data) {
- return $scope.startlist.tip1 + ':' + data.value + '<br />' + $scope.startlist.tip2 + ':' + data.data.proportion;
- },
- },
- series: {
- type: "bar",
- itemStyle: {
- normal: {
- color: function (params) {
- // type = 'linear';
- // var colorList = [
- // '#005395'
- // ];
- return '#005395'
- },
- }
- },
- label: {
- normal: {
- show: true,
- position: 'top',
- textStyle: {
- // color: '#56c9ff'
- }
- }
- },
- barWidth: 18,
- // barWidth: '30%',
- // data: yData
- data: $scope.barbodydata
- }
- };
- if (optionbar && typeof optionbar === "object") {
- mybarChart.setOption(optionbar, true);
- mybarChart.hideLoading();
- }
- }
- }])
|