123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423 |
- 'use strict';
- var app = angular.module('app', [
- 'angularUtils.directives.dirPagination'
- ]);
- app.controller("taizhangCtrl", ["$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");
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- }
- self.loading = false;
- self.search = JSON.parse($.cookie("GlWorkPlatform-hydbtz")) || { TITLE: "", QTBM: "", DBSX1: "", DBSX2: "", DENG: "", FLOWNAME: "", BANLI: "待办中" };
- self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
- self.pageno = 1;
- self.total_count = 0;
- self.itemsPerPage = 10;
- self.pageOptions = [10, 20, 30, 40, 100, 300, 500];
- self.getData = function (pageno) {
- self.list = [];
- self.loading = true;
- self.pageno = pageno;
- $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
- var sqlwhere = [];
- if (self.search.TITLE != "") {
- sqlwhere.push("and TITLE like '%" + self.search.TITLE + "%'")
- }
- if (self.search.QTBM != "") {
- sqlwhere.push("and DEPARTMENT like '%" + self.search.QTBM + "%'")
- }
- if (self.search.DENG != "") {
- sqlwhere.push("and DENG = '" + self.search.DENG + "'")
- }
- if (self.search.FLOWNAME != "") {
- sqlwhere.push("and FLOWNAME = '" + self.search.FLOWNAME + "'")
- }
- if (self.search.BANLI != "") {
- sqlwhere.push("and BANLI = '" + self.search.BANLI + "'")
- }
- if (self.search.DBSX1 != "" && self.search.DBSX2 != "") {
- sqlwhere.push("and TLDATE between '" + self.search.DBSX1 + " 00:00:00' and '" + self.search.DBSX2 + " 23:59:59'")
- }
- var data = {
- tablename: "SYS_ROUTE_INFO_DUBAN_VIEW",
- pagesize: self.itemsPerPage,
- pageno: self.pageno,
- colums: "*,TO_CHAR(TLDATE,'yyyy-mm-dd hh:mm:ss') as TLDATE1",
- order: "ROUTEINFOID",
- sqlwhere: sqlwhere.join(" ")
- };
- $http.post(apiurljs.login + "g2app/dubantaizhang/queryDataByColWithPage3", data, postCfg)
- .success(function (res) {
- self.loading = false;
- if (res.data == null || res.data == undefined || res.data == "") {
- self.noDataTip = 0;
- } else {
- self.noDataTip = 1;
- self.list = res.data;
- self.list.forEach(function (item) {
- item.TIXING1 = item.TIXING.split("\n");
- item.BANLI = item.BANLI=='待办中'?'正在办理':item.BANLI
- //item.TLDATE = sp.minsToDate("yyyy-MM-dd hh:mm:ss", new Date(item.TLDATE).getTime())
- //self.BLJG.forEach(function (item1) {
- // if (item.BLJG == item1.CODE)
- // item.BLJG = item1.CNAME
- //})
- //self.JBSXLY.forEach(function (item1) {
- // if (item.JBSXLY == item1.CODE)
- // item.JBSXLY = item1.CNAME
- //})
- //item.OPINION.forEach(function (item1) {
- // item1.OPINION1 = item1.OPINION + "(" + item1.CMANS + "——" + sp.format(item1.CDATE) + ")"
- //})
- //item.FILEATTACH.forEach(function (item1) {
- // item1.FILENAMES1 = item1.FILENAMES.length > 20 ? item1.FILENAMES.slice(0, 20) + "..." : item1.FILENAMES
- //})
- })
- self.total_count = res.totalCount;
- self.canExportExcel = true;
- }
- })
- }
- self.getBLJG = function () {
- var data = {
- ckey: "CODE_BLJG",
- routeinfoid: ""
- }
- $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.BLJG = res.data.CODE_BLJG;
- self.getJBSXLY()
- })
- }
- self.getJBSXLY = function () {
- var data = {
- ckey: "CODE_JBSXLY",
- routeinfoid: ""
- }
- $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.JBSXLY = res.data.CODE_JBSXLY;
- self.getData(1)
- })
- }
- self.getBLJG();
- self.checkedAll = false;
- self.checkAll = function () {
- self.list.forEach(function (item) {
- item.checked = self.checkedAll;
- })
- }
- self.DBTX = function () {
- var list = self.list.filter(function (item) {
- return item.checked == true;
- })
- if (list.length == 0) {
- sp.dialog("请选择要提醒的督办事项!");
- return
- }
- var array = [];
- list.forEach(function (item) {
- array.push(item.ROUTEINFOID)
- })
- $http.post(apiurljs.login + "g2app/dubantaizhang/addMessage", { data: s4.encryptData_CBC(JSON.stringify({ routeinfoids: array.join("|") })) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- self.getData(self.pageno)
- } else {
- sp.dialog(res.message);
- }
- })
- //list.forEach(function (item) {
- // array.push({
- // ROUTEINFOID: item.ROUTEINFOID,
- // CDATE: sp.getLocalDate(),
- // CONTENT: "督办提醒",
- // CMAN: item.CMAN,
- // CMANCAP: item.CMANCAP
- // })
- //})
- //var data = {
- // tablename: "ROUTEINFO_DENGMSG",
- // data: array
- //}
- //$http.post(apiurljs.login + "g2app/Data/insertChildDataList2", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- //.success(function (obj) {
- // var res = strToJson(s4.decryptData_CBC(obj.data));
- // if (res.success) {
- // self.getData(self.pageno)
- // } else {
- // sp.dialog(res.message);
- // }
- //})
- }
- self.openLayer = function () {
- sp.layer("#Search")
- }
- self.checkDENG = function (str) {
- self.search.DENG = str;
- //if (self.search.DENG.indexOf(str) == -1) {
- // self.search.DENG.push(str)
- //} else {
- // self.search.DENG = self.search.DENG.filter(function (item) {
- // return item != str;
- // })
- //}
- }
- self.doSearch = function () {
- if ((self.search.DBSX1 != "" && self.search.DBSX2 == "") ||(self.search.DBSX1 == "" && self.search.DBSX2 != "")) {
- sp.layerhide()
- sp.dialog("请输入正确时间区间!");
- $timeout(function () {
- sp.dialoghide();
- sp.layer("#Search")
- }, 2000)
- } else {
- $.cookie("GlWorkPlatform-hydbtz", JSON.stringify(self.search), { path: '/', expires: 1 });
- self.getData(self.pageno)
- sp.layerhide()
- }
- }
- self.cancal = function () {
- self.search = {
- TITLE: "",
- QTBM: "",
- DBSX1: "",
- DBSX2: "",
- DENG: "",
- FLOWNAME: "",
- BANLI: "待办中"
- }
- $.cookie("GlWorkPlatform-hydbtz", null, { path: '/', expires: 1 });
- self.getData(1)
- sp.layerhide()
- }
- self.refresh = function () {
- self.getData(self.pageno);
- }
- self.download = function (obj) {
- window.open(apiurljs.login + "g2work/files/" + obj.FILEURL.slice(7))
- }
- self.goUrl = function (item) {
- if (self.deviceType == "pad") {
- window.location.href = "../../" + item.DURL
- } else {
- sp.openNewWindow("../../" + item.DURL, item.TITLE)
- }
- }
-
- self.printEXCEL = function () {
- self.columns = [
- { header: "督办名称", key: "TITLE", width: 50 },
- { header: "来源", key: "FLOWNAME", width: 20 },
- { header: "主办处室", key: "DEPARTMENT", width: 20 },
- { header: "督办时限", key: "TLDATE1", width: 20 },
- { header: "办理结果", key: "BANLI", width: 20 },
- { header: "督办提醒记录", key: "TIXING", width: 100 }
- ]
- self.listExcel = self.list.map(function (item) {
- return {
- TITLE: item.TITLE,
- FLOWNAME: item.FLOWNAME,
- DEPARTMENT: item.DEPARTMENT,
- TLDATE1: item.TLDATE1,
- BANLI: item.BANLI,
- TIXING: item.TIXING
- }
- })
- // 创建工作簿
- var workbook = new ExcelJS.Workbook()
- // 添加工作表
- var worksheet = workbook.addWorksheet('sheet1')
- // 设置表头
- worksheet.columns = self.columns
- // 添加表体数据
- self.listExcel.forEach(function (item) {
- worksheet.addRow(item)
- })
- /**
- * 设置样式
- */
- // 1、设置标题行样式
- var headerRow = worksheet.getRow(1)
- // 连续遍历所有非空单元格
- headerRow.eachCell(function (cell) {
- // 边框 https://github.com/exceljs/exceljs/blob/HEAD/README_zh.md#%E8%BE%B9%E6%A1%86
- cell.border = {
- top: {
- style: 'thin'
- },
- left: {
- style: 'thin'
- },
- bottom: {
- style: 'thin'
- },
- right: {
- style: 'thin'
- },
- }
- // 填充 https://github.com/exceljs/exceljs/blob/HEAD/README_zh.md#%E5%A1%AB%E5%85%85
- cell.fill = {
- type: 'pattern',
- pattern: 'solid',
- fgColor: {
- argb: '4f81bd'
- }
- }
- // 字体 https://github.com/exceljs/exceljs/blob/HEAD/README_zh.md#%E5%AD%97%E4%BD%93
- cell.font = {
- name: '微软雅黑',
- size: 11,
- bold: true,
- color: { argb: '000000' }
- }
- // 对齐 https://github.com/exceljs/exceljs/blob/HEAD/README_zh.md#%E5%AF%B9%E9%BD%90
- cell.alignment = {
- vertical: 'middle',
- horizontal: 'center'
- }
- })
- // 2、设置内容行样式
- const bodyRow = worksheet.getRows(2, self.listExcel.length + 1)
- bodyRow.forEach(function (row) {
- //遍历此列中的所有当前单元格,包括空单元格
- row.eachCell({ includeEmpty: true }, function (cell) {
- // 边框
- cell.border = {
- top: {
- style: 'thin'
- },
- left: {
- style: 'thin'
- },
- bottom: {
- style: 'thin'
- },
- right: {
- style: 'thin'
- },
- }
- // 字体 https://github.com/exceljs/exceljs/blob/HEAD/README_zh.md#%E5%AD%97%E4%BD%93
- cell.font = {
- name: '微软雅黑',
- size: 11,
- color: { argb: '000000' }
- }
- // 对齐 https://github.com/exceljs/exceljs/blob/HEAD/README_zh.md#%E5%AF%B9%E9%BD%90
- cell.alignment = {
- vertical: 'middle',
- horizontal: 'center'
- }
- })
- })
- // 导出表格
- workbook.xlsx.writeBuffer().then(function (buffer) {
- const blob = new Blob([buffer], {
- type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
- })
- const link = document.createElement('a')
- link.href = URL.createObjectURL(blob)
- link.download = '督办台账' + sp.format(sp.getLocalDate()) + '.xlsx'
- link.click()
- URL.revokeObjectURL(link.href) // 下载完成释放掉blob对象
- })
- //})
- }
- self.printOut = function () {
- $.ajax({
- url: apiurljs.login + "g2app/dataabase/ExpExeclWithDataAndOpinion_ByParam",
- type: 'POST',
- cache: false,
- xhr: function () {
- var xhr = new XMLHttpRequest();
- xhr.onreadystatechange = function () {
- if (xhr.readyState == 2) {
- if (xhr.status == 200) {
- xhr.responseType = "blob";
- } else {
- xhr.responseType = "text";
- }
- }
- };
- return xhr;
- },
- headers: {
- "Content-Type": "application/json",
- "file-argument": s4.encryptData_CBC("execlCol|督办名称,主办处室,会办处室,督办时限,办理结果,办理情况,附件&tablename|DCDB_SXDBD&columns|ROUTEINFOID,DBSX1,QTBM,XZBM,DBSX,BLJG&opinion_col|ZBBMCLQK&pageno|" + self.pageno + "&pagesize|" + self.itemsPerPage + "&order|ROUTEINFOID&sqlwhere|and DBLX = 'C02'&dateform|yyyy-MM-dd&attachtype|单项督办")
- },
- success: function (res) {
- download(res, "会议督办" + sp.getLocalDate() + ".et")
- },
- })
- }
- //头部下滚冻结
- $(function () {
- //页面高度撑满
- setTimeout(function () {
- if ($(".ibox-content").height() < $(window).height() - 31) {
- $(".ibox-content").css("height", $(window).height() - 31)
- }
- }, 1)
- })
- }])
- function download(data, filename, mime, bom) {
- var blobData = typeof bom !== "undefined" ? [bom, data] : [data];
- var blob = new Blob(blobData, { type: mime || "application/octet-stream" });
- if (typeof window.navigator.msSaveBlob !== "undefined") {
- // IE workaround for "HTML7007: One or more blob URLs were
- // revoked by closing the blob for which they were created.
- // These URLs will no longer resolve as the data backing
- // the URL has been freed."
- window.navigator.msSaveBlob(blob, filename);
- } else {
- var blobURL =
- window.URL && window.URL.createObjectURL
- ? window.URL.createObjectURL(blob)
- : window.webkitURL.createObjectURL(blob);
- var tempLink = document.createElement("a");
- tempLink.style.display = "none";
- tempLink.href = blobURL;
- tempLink.setAttribute("download", filename);
- // Safari thinks _blank anchor are pop ups. We only want to set _blank
- // target if the browser does not support the HTML5 download attribute.
- // This allows you to download files in desktop safari if pop up blocking
- // is enabled.
- if (typeof tempLink.download === "undefined") {
- tempLink.setAttribute("target", "_blank");
- }
- document.body.appendChild(tempLink);
- tempLink.click();
- // Fixes "webkit blob resource error 1"
- setTimeout(function () {
- document.body.removeChild(tempLink);
- window.URL.revokeObjectURL(blobURL);
- }, 200);
- }
- }
|