123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- '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: "" };
- 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.TITLE != "") {
- sqlwhere.push("and DBSX1 like '%" + self.search.TITLE + "%'")
- }
- if (self.search.QTBM != "") {
- sqlwhere.push("and QTBM like '%" + self.search.QTBM + "%'")
- }
- 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_SXDBD",
- pagesize: self.itemsPerPage,
- pageno: self.pageno,
- //colums: "ID,DBSX1,QTBM,DBSX,BLJD",
- columns: "ROUTEINFOID,DBSX1,QTBM,XZBM,to_char(DBSX,'yyyy-MM-dd') as DBSX,BLJG",
- opinion_col: "ZBBMCLQK",
- 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.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: ""
- }
- $.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.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);
- }
- }
|