123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- '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-shemidb")) || { BT: "", ZBCS: "", LMRQ1: "", LMRQ2: "", DBSX1: "", DBSX2: "" };
- 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 = [];//["and DBLX = 'C02' "];
- if (self.search.BT != "") {
- sqlwhere.push("and BT like '%" + self.search.BT + "%'")
- }
- if (self.search.ZBCS != "") {
- sqlwhere.push("and ZBCS like '%" + self.search.ZBCS + "%'")
- }
- if (self.search.LMRQ1 != "" && self.search.LMRQ2 != "") {
- sqlwhere.push("and LMRQ between '" + self.search.LMRQ1 + " 00:00:00' and '" + self.search.LMRQ2 + " 23:59:59'")
- }
- if (self.search.DBSX1 != "" && self.search.DBSX2 != "") {
- sqlwhere.push("and DBSX between '" + self.search.DBSX1 + " 00:00:00' and '" + self.search.DBSX2 + " 23:59:59'")
- }
- var data = {
- tablename: "DCDB_SMDBD",
- pagesize: self.itemsPerPage,
- pageno: self.pageno,
- columns: "ROUTEINFOID,BH,BT,ZBCS,BZ,to_char(DBSX,'yyyy-MM-dd') as DBSX,to_char(LMRQ,'yyyy-MM-dd') as LMRQ",
- opinion_col: "BLQK",
- order: "ROUTEINFOID",
- sqlwhere: sqlwhere.join(" "),
- attachtype: "涉密督办单"
- }
- $http.post(apiurljs.login + "g2app/dataabase/queryDataAndOpinionWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- 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) {
- self.BLJG.forEach(function (item1) {
- if (item.BLJG == item1.CODE)
- item.BLJG = 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: self.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.getData(1)
- })
- }
- self.getBLJG();
- self.openLayer = function () {
- sp.layer("#Search")
- }
- self.doSearch = function () {
- if ((self.search.LMRQ1 != "" && self.search.LMRQ2 == "") || (self.search.LMRQ1 == "" && self.search.LMRQ2 != "")) {
- sp.layerhide()
- sp.dialog("请输入正确时间区间!");
- $timeout(function () {
- sp.dialoghide();
- sp.layer("#Search")
- }, 2000)
- } else 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-shemidb", JSON.stringify(self.search), { path: '/', expires: 1 });
- self.getData(self.pageno)
- sp.layerhide()
- }
- }
- self.cancal = function () {
- self.search = {
- BT: "",
- ZBCS: "",
- LMRQ1: "",
- LMRQ2: "",
- DBSX1: "",
- DBSX2: ""
- }
- $.cookie("GlWorkPlatform-shemidb", 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.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_SMDBD&columns|ROUTEINFOID,BH,BT,LMRQ,DBSX,ZBCS,DBSX,BZ&opinion_col|BLQK&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);
- }
- }
|