'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"); self.page=sp.getUrlName("from") self.loading = false; sp.fitHeight("#div_table_part", 155); var postCfg = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } } self.type = self.get_type != "" ? self.get_type : 1; if (self.type == 1) { self.flows = flowid_f; } else { self.flows = flowid_s; } self.search = { type: "", title: "", gwtype: "", gwwh: "", ngr: "", lwdw: "", ngtype: 0, ngkssj: "", ngjssj: "", lwtype: 0, lwkssj: "", lwjssj: "", bjtype: 0, bjkssj: "", bjjssj: "" } self.noDataTip = 1;//没有数据时赋变量为0,先默认为1 self.pageno = 1; self.total_count = 0; self.itemsPerPage = 10; self.pageOptions = [10, 20, 30, 40]; self.getData = function () { self.list = []; if (self.type == 1) { var sqlwhere = (self.search.type == "" ? "" : " and STATUS='" + self.search.type + "'") + (self.search.title == "" ? "" : " and TITLE LIKE'%" + self.search.title + "%'") + (self.search.gwwh == "" ? "" : " and gwwh LIKE'%" + self.search.gwwh + "%'") + (self.search.ngr == "" ? "" : " and ngr LIKE'%" + self.search.ngr + "%'") + (self.search.ngkssj == "" ? "" : " and ngsj>='" + self.search.ngkssj + "' and ngsj<='" + self.search.ngjssj + "'") + (self.search.bjkssj == "" ? "" : " and finisheddate>='" + self.search.bjkssj + "' and finisheddate<='" + self.search.bjjssj + "'") + (self.search.gwtype == "" ? "" : " and flowid='" + self.search.gwtype + "'"); } else { var sqlwhere = (self.search.type == "" ? "" : " and STATUS='" + self.search.type + "'") + (self.search.title == "" ? "" : " and TITLE LIKE'%" + self.search.title + "%'") + (self.search.gwwh == "" ? "" : " and gwwh LIKE'%" + self.search.gwwh + "%'") + (self.search.lwdw == "" ? "" : " and ngr LIKE'%" + self.search.lwdw + "%'") + (self.search.lwkssj == "" ? "" : " and lwrq>='" + self.search.lwkssj + "' and lwrq<='" + self.search.lwkssj + "'") + (self.search.bjkssj == "" ? "" : " and finisheddate>='" + self.search.bjkssj + "' and finisheddate<='" + self.search.bjjssj + "'") + (self.search.gwtype == "" ? "" : " and flowid='" + self.search.gwtype + "'"); } var data = { tablename: self.type == 1 ? "GONGWENSTATICTICS_FW_VIEW" : "GONGWENSTATICTICS_SW_VIEW", sqlwhere: sqlwhere, colums: "*", order: "FLOWID", pageno: self.pageno, pagesize: self.itemsPerPage } //console.log(data) self.loading = true; $http.post(apiurljs.login + "g2app/statisticsmanage/queryGongWenDataByColStrWithPage", { 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; self.loading = false; } else { self.noDataTip = 1; self.list = res.data; self.total_count = res.totalCount; self.list.forEach(function (item) { if ("AA20|AA03|AA10|AA55|AA56|AA57|AA08|AA23|AA77|AA06".indexOf(item.FLOWID) > -1) { item.FILEN = "tpl/fawenbg/" + item.FILEN; } else if ("AA88|AA89|AA46|AA22|AA54".indexOf(item.FLOWID) > -1) { item.FILEN = "tpl/fawendw/" + item.FILEN; } else { item.FILEN = "tpl/shouwenbg/" + item.FILEN; } item.STATUS1 = item.STATUS == "START" ? "拟稿" : item.STATUS == "DEAL" ? "待审" : "办结"; if (item.NGSJ) { item.NGSJ1 = sp.format(item.NGSJ) } if (item.LWRQ) { item.LWRQ1 = sp.format(item.LWRQ) } }) self.loading = false; } }) } self.getData(); self.goUrl = function (item) { sp.openNewWindow("../../" + item.FILEN + "&dotype=0", item.TITLE) } self.changeNg = function (n) { if (self.search.ngtype == n) { return; } else { self.search.ngtype = n } switch (self.search.ngtype) { case 0: self.search.ngkssj = ""; self.search.ngjssj = ""; break; case 1: self.search.ngkssj = getWeek(1); self.search.ngjssj = getWeek(2); break; case 2: self.search.ngkssj = sp.monthfirst(sp.getLocalDate()); self.search.ngjssj = sp.formatMonthLast(sp.getLocalDate()); break; case 3: self.search.ngkssj = sp.quarter(sp.getLocalDate(), 1); self.search.ngjssj = sp.quarter(sp.getLocalDate(), 2); break; case 4: self.search.ngkssj = getYearB(1); self.search.ngjssj = getYearB(2); break; } self.getData() } self.changeLw = function (n) { if (self.search.lwtype == n) { return; } else { self.search.lwtype = n } switch (self.search.lwtype) { case 0: self.search.lwkssj = ""; self.search.lwjssj = ""; break; case 1: self.search.lwkssj = getWeek(1); self.search.lwjssj = getWeek(2); break; case 2: self.search.lwkssj = sp.monthfirst(sp.getLocalDate()); self.search.lwjssj = sp.formatMonthLast(sp.getLocalDate()); break; case 3: self.search.lwkssj = sp.quarter(sp.getLocalDate(), 1); self.search.lwjssj = sp.quarter(sp.getLocalDate(), 2); break; case 4: self.search.lwkssj = getYearB(1); self.search.lwjssj = getYearB(2); break; } self.getData() } self.changeBj = function (n) { if (self.search.bjtype == n) { return; } else { self.search.bjtype = n } switch (self.search.bjtype) { case 0: self.search.bjkssj = ""; self.search.bjjssj = ""; break; case 1: self.search.bjkssj = getWeek(1); self.search.bjjssj = getWeek(2); break; case 2: self.search.bjkssj = sp.monthfirst(sp.getLocalDate()); self.search.bjjssj = sp.formatMonthLast(sp.getLocalDate()); break; case 3: self.search.bjkssj = sp.quarter(sp.getLocalDate(), 1); self.search.bjjssj = sp.quarter(sp.getLocalDate(), 2); break; case 4: self.search.bjkssj = getYearB(1); self.search.bjjssj = getYearB(2); break; } self.getData() } self.changeType = function (n) { if (self.type == n) { return; } else { self.type = n; if (self.type == 1) { self.flows = flowid_f; } else { self.flows = flowid_s; } self.search = { type: "", title: "", gwtype: "", gwwh: "", ngr: "", lwdw: "", ngtype: 0, ngkssj: "", ngjssj: "", lwtype: 0, lwkssj: "", lwjssj: "", bjtype: 0, bjkssj: "", bjjssj: "" } self.getData() } } 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, (self.type == 1 ? "发文" : "收文") + "统计") //设置表格的样式 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' }), (self.type == 1 ? '发文' : '收文') + '统计.xlsx') } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) } return wbout } else { sp.dialog('数据还未加载完成,请稍等...') } } //头部下滚冻结 $(function () { //页面高度撑满 setTimeout(function () { if ($(".ibox-content").height() < $(window).height() - 31) { $(".ibox-content").css("height", $(window).height() - 31) } }, 1) }) }]) var flowid_f = [{ name: "党委正式文上行文", flowid: "AA88" }, { name: "党委正式文下行文", flowid: "AA89" }, { name: "党委会议纪要", flowid: "AA46" }, { name: "住房公积金发文处理单", flowid: "AA80" }, { name: "党委其他文件", flowid: "AA22" }, { name: "党委督查专报", flowid: "AA54" }, { name: "机关党委非正式文", flowid: "AA58" }, { name: "正式文-上行文", flowid: "AA20" }, { name: "正式文-平、下行文", flowid: "AA03" }, { name: "专报", flowid: "AA10" }, { name: "规范性文件", flowid: "AA57" }, { name: "委发函", flowid: "AA08" }, { name: "审批件", flowid: "AA23" }, { name: "主任办公会议纪要", flowid: "AA77" }, { name: "会议纪要", flowid: "AA06" }, { name: "例会简报", flowid: "AA63" }] var flowid_s = [{ name: "行政公文", flowid: "AA18" }, { name: "领导批示", flowid: "AA16" }, { name: "党委公文", flowid: "AA02" }, { name: "领导批示党口", flowid: "AA17" }] function showToggle() { $(".toggle").toggle() } function formate(d) { return d > 9 ? d : "0" + d; } function getWeek(n) { var week = new Date().getDay(); week = week == 0 ? 7 : week; if (n == 1) { return sp.dateCount((week - 1) * -1) } else { return sp.dateCount(7 - week) } } function getYearB(n) { if (sp.format(sp.getLocalDate()) < sp.currentYear() + "-06-30") { if (n == 1) { return sp.currentYear() + "-01-01" } else { return sp.currentYear() + "-06-30" } } else { if (n == 1) { return sp.currentYear() + "-07-01" } else { return sp.currentYear() + "-12-31" } } }