123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312 |
- 'use strict';
- var app = angular.module('app', [
- 'angularUtils.directives.dirPagination'
- ]);
- app.controller("listCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) {
- var self = this;
- var s4 = new SM4Util();
- self.userId = $.cookie("GlWorkPlatform-userid");
- self.userName = $.cookie("GlWorkPlatform-chineseName");
- self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
- self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
- self.get_type = sp.getUrlName("type");
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- }
- self.search = {
- DBLX: "",
- TYPE: "",
- CBBM: "",
- KSSJ: sp.currentYear() +"-"+"01-01",
- JSSJ: sp.format(sp.getLocalDate())
- }
- self.chart = {
- pie: 1,
- column: 1
- }
- self.getDBLX = function () {
- var data = {
- tablename: "CODE_DUBAN"
- }
- $http.post(apiurljs.login + "g2app/DangAn/queryCodeData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.DBLX = res.data;
- self.getDpList();
- })
- }
- self.getDpList = function () {
- var data = {
- nodekid: "AA82N04,AA16N08,AA17N08,AA18N08"
- }
- $http.post(apiurljs.login + "g2app/richang/querychengbanDp", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.CBBM = res.data;
- self.getData();
- })
- }
- self.noDataTip = 0;
- self.getData = function () {
- self.list = [];
- var data = {
- dblx: self.search.DBLX,
- gstype: self.search.TYPE,
- zbcscode: self.search.CBBM,
- begindate: self.search.KSSJ + " 00:00:00",
- enddate: self.search.JSSJ + " 23:59:59"
- }
- $http.post(apiurljs.login + "g2app/richang/queryDuBanStatistics", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.loading = false;
- self.canExportExcel = true;
- if (res.data == null || res.data == undefined || res.data == "") {
- self.noDataTip = 0;
- } else {
- self.noDataTip = 1;
- self.list = res.data;
- self.dataPie = [{ name: "一般督办", y: 0 }, { name: "重点督办", y: 0 }]
- self.column = {
- title: [],
- data: [{ name: "超期办结", data: [] }, { name: "按期办结", data: [] }, { name: "未超期未办结", data: [] }, { name: "超期未办结", data: [] }]
- }
- self.list.forEach(function (item) {
- self.dataPie.forEach(function (item1) {
- if (item.DBLX == item1.name) {
- item1.y = item1.y + numIsNull(item.CQBJ) + numIsNull(item.WCQBJ) + numIsNull(item.WCQWBJ) + numIsNull(item.CQWBJ)
- }
- })
- if (self.column.title.indexOf(item.SECTION) == -1) {
- self.column.title.push(item.SECTION)
- self.column.data.forEach(function (item1) {
- item1.data.push(0)
- })
- }
- })
- self.getPie()
- self.getColumn()
- }
- })
- }
- self.getDBLX()
- self.printOut = function () {
- if (self.canExportExcel) {
- $('#printOut td').attr('t', 's')
- var defaultCellStyle = {
- font: {
- name: 'Times New Roman',
- sz: 12,
- color: {
- rgb: "000000"
- },
- bold: false, italic: false,
- underline: false
- },
- alignment: {
- vertical: "center",
- horizontal: "center", indent: 0, wrapText: true
- },
- border: {
- top: {
- style: "thin",
- color: {
- rgb: "000000"
- }
- },
- right: {
- style: "thin",
- color: {
- rgb: "000000"
- }
- },
- bottom: {
- style: "thin",
- color: {
- rgb: "000000"
- }
- },
- left: {
- style: "thin",
- color: {
- rgb: "000000"
- }
- }
- }
- };
- var cell = { defaultCellStyle: defaultCellStyle };
- var wb = XLSX.utils.table_to_book_addtitle(document.querySelector('#printOut'), cell, "事项统计")
- //设置表格的样式
- var wbout = XLSX.write(wb, {
- bookType: 'xlsx',
- bookSST: false,
- type: 'binary',
- cellStyles: true,
- defaultCellStyle: defaultCellStyle,
- showGridLines: false
- });
- var s2ab = function (s) {
- var buf = new ArrayBuffer(s.length);
- var view = new Uint8Array(buf);
- for (var i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
- return buf;
- };
- try {
- saveAs(new Blob([s2ab(wbout)], { type: 'application/octet-stream' }), '事项统计.xlsx')
- } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) }
- return wbout
- } else {
- sp.dialog('数据还未加载完成,请稍等...')
- }
- }
- self.getPie = function () {
- var chart = new Highcharts.Chart({
- chart: {
- renderTo: "pie",
- type: 'pie',
- style: {
- position: 'relative',
- left: '-30px'
- }
- },
- title: {
- text: '', //图表的标题
- //margin: 80
- },
- tooltip: {
- pointFormat: '{series.name}: <b>{point.y}</b>'
- },
- legend: {
- floating: true,
- align: 'left',
- verticalAlign: 'middle',
- layout: 'vertical',
- backgroundColor: '#FFF',
- itemMarginTop: 5,
- itemMarginBottom: 5,
- itemStyle: {
- fontSize: 16
- },
- enabled: false,
- },
- plotOptions: {
- pie: {
- allowPointSelect: true,
- cursor: 'pointer',
- size: 300,
- dataLabels: {
- enabled: true,
- distance: -50,
- formatter: function () {
- return this.point.name + ":" + this.point.percentage.toFixed(2) + "%";
- }
- },
- showInLegend: true
- }
- },
- series: [{
- name: '',
- data: self.dataPie
- }],
- credits: {
- enabled: false//隐藏右下角网址
- },
- exporting: {
- enabled: false//隐藏右上角打印
- }
- })
- }
- self.getColumn = function () {
- self.column.title.forEach(function (item, index) {
- console.log(item)
- self.list.forEach(function (item1) {
- if (item1.SECTION == item) {
- console.log(self.column.data[0].data[index] + item1.CQBJ)
- self.column.data[0].data[index] = self.column.data[0].data[index] + numIsNull(item1.CQBJ)
- self.column.data[1].data[index] = self.column.data[0].data[index] + numIsNull(item1.WCQBJ)
- self.column.data[2].data[index] = self.column.data[0].data[index] + numIsNull(item1.WCQWBJ)
- self.column.data[3].data[index] = self.column.data[0].data[index] + numIsNull(item1.CQWBJ)
- }
- })
- })
- console.log(self.column)
- var chart = new Highcharts.Chart({
- chart: {
- renderTo: "column",
- type: 'column'
- },
- title: {
- text: '', //图表的标题
- //margin: 80
- },
- tooltip: {
- headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
- pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
- '<td style="padding:0"><b>{point.y}</b>{series.className}</td></tr>',
- footerFormat: '</table>',
- shared: true,
- useHTML: true
- },
- xAxis: {
- categories: self.column.title
- },
- yAxis: {
- title: {
- text: ''
- },
- lineWidth: 1,
- gridLineWidth: 1
- },
- legend: {
- enabled: true
- },
- plotOptions: {
- series: {
- turboThreshold: 0,
- cursor: 'pointer',
- pointWidth: 20,
- dataLabels: {
- enabled: true,
- }
- }
- },
- series: self.column.data,
- credits: {
- enabled: false//隐藏右下角网址
- },
- exporting: {
- enabled: false//隐藏右上角打印
- }
- })
- }
- //头部下滚冻结
- $(function () {
- //页面高度撑满
- setTimeout(function () {
- if ($(".ibox-content").height() < $(window).height() - 31) {
- $(".ibox-content").css("height", $(window).height() - 31)
- }
- }, 1)
- })
- }])
- function numIsNull(n) {
- if (n == "" || n == null || n == undefined) {
- return 0
- } else {
- return n
- }
- }
|