123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- '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 = {
- TYPE: 1,
- KSSJ: sp.monthfirst(sp.getLocalDate()),
- JSSJ: sp.formatMonthLast(sp.getLocalDate())
- }
- self.changeType = function () {
- switch (self.search.TYPE) {
- case "1": self.search.KSSJ = sp.monthfirst(sp.getLocalDate()); self.search.JSSJ = sp.formatMonthLast(sp.getLocalDate()); break;
- case "2": self.search.KSSJ = sp.quarter(sp.getLocalDate(), 1); self.search.JSSJ = sp.quarter(sp.getLocalDate(), 2); break;
- case "3": self.search.KSSJ = sp.currentYear() + "-01-01"; self.search.JSSJ = sp.currentYear() + "-12-31"; break;
- case "4": self.search.KSSJ = sp.format(sp.getLocalDate()); self.search.JSSJ = sp.format(sp.getLocalDate()); break;
- }
- }
- self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
- self.getData = function () {
- self.list = [];
- var data = {
- begindate: self.search.KSSJ + " 00:00:00",
- enddate: self.search.JSSJ + " 23:59:59"
- }
- $http.post(apiurljs.login + "g2app/richang/RiChangShiWuStatistics", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.canExportExcel = true;
- if (res.data == null || res.data == undefined || res.data == "") {
- self.noDataTip = 0;
- } else {
- self.noDataTip = 1;
- self.list = res.data;
- self.getColumn()
- }
- })
- }
- 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.getColumn = function () {
- var title = [], data1 = [], data2 = [], data3 = [], data4 = [], data5 = [], data6 = [], data7 = [], data8 = [], data9 = [], data10 = [];
- self.list5.forEach(function (item) {
- title.push(item.NAME);
- data1.push(item.DATA.DEAL_COUNT0_0 + item.DATA.STOP_COUNT0_0);
- data2.push(item.DATA.DEAL_COUNT1_0 + item.DATA.STOP_COUNT1_0);
- data3.push(item.DATA.DEAL_COUNT2_0 + item.DATA.STOP_COUNT2_0);
- data4.push(item.DATA.DEAL_COUNT3_0 + item.DATA.STOP_COUNT3_0);
- data5.push(item.DATA.DEAL_COUNT4_0 + item.DATA.STOP_COUNT4_0);
- data6.push(item.DATA.DEAL_COUNT5_0 + item.DATA.STOP_COUNT5_0);
- data7.push(item.DATA.DEAL_COUNT6_0 + item.DATA.STOP_COUNT6_0);
- data8.push(item.DATA.DEAL_COUNT7_0 + item.DATA.STOP_COUNT7_0);
- data9.push(item.DATA.DEAL_COUNT8_0 + item.DATA.STOP_COUNT8_0);
- data10.push(item.DATA.DEAL_COUNT9_0 + item.DATA.STOP_COUNT9_0);
- })
- var chart = new Highcharts.Chart({
- chart: {
- renderTo: "column",
- type: 'column'
- },
- title: {
- text: '', //图表的标题
- //margin: 80
- },
- colors: ["#6395F9", "#62DAAB"],
- 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: title
- },
- yAxis: {
- title: {
- text: ''
- },
- lineWidth: 1,
- gridLineWidth: 1
- },
- legend: {
- enabled: true
- },
- plotOptions: {
- series: {
- pointWidth: 30,
- turboThreshold: 0,
- cursor: 'pointer',
- dataLabels: {
- enabled: true,
- }
- },
- column: {
- stacking: 'normal'
- }
- },
- series: [{
- name: "请假",
- data:data1
- }, {
- name: "请假",
- data: data2
- }, {
- name: "请假",
- data: data3
- }, {
- name: "请假",
- data: data4
- }, {
- name: "请假",
- data: data5
- }, {
- name: "请假",
- data: data6
- }, {
- name: "请假",
- data: data7
- }, {
- name: "请假",
- data: data8
- }, {
- name: "请假",
- data: data9
- }, {
- name: "请假",
- data: data10
- }],
- credits: {
- enabled: false//隐藏右下角网址
- },
- exporting: {
- enabled: false//隐藏右上角打印
- }
- })
- chart.setSize(null, 400)
- }
-
- self.getData();
- //头部下滚冻结
- $(function () {
- //页面高度撑满
- setTimeout(function () {
- if ($(".ibox-content").height() < $(window).height() - 31) {
- $(".ibox-content").css("height", $(window).height() - 31)
- }
- }, 1)
- })
- }])
|