taizhang.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("taizhangCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) {
  6. var self = this;
  7. var s4 = new SM4Util();
  8. self.userId = $.cookie("GlWorkPlatform-userid");
  9. self.userName = $.cookie("GlWorkPlatform-chineseName");
  10. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  11. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  12. var postCfg = {
  13. headers: {
  14. 'Content-Type': 'application/json',
  15. 'Authorization': "Bearer " + self.get_AccessToken
  16. }
  17. }
  18. self.loading = false;
  19. self.search = JSON.parse($.cookie("GlWorkPlatform-shemidb")) || { BT: "", ZBCS: "", LMRQ1: "", LMRQ2: "", DBSX1: "", DBSX2: "" };
  20. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  21. self.pageno = 1;
  22. self.total_count = 0;
  23. self.itemsPerPage = 10;
  24. self.pageOptions = [10, 20, 30, 40, 100, 300, 500];
  25. self.getData = function (pageno) {
  26. self.list = [];
  27. self.loading = true;
  28. self.pageno = pageno;
  29. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  30. var sqlwhere = [];//["and DBLX = 'C02' "];
  31. if (self.search.BT != "") {
  32. sqlwhere.push("and BT like '%" + self.search.BT + "%'")
  33. }
  34. if (self.search.ZBCS != "") {
  35. sqlwhere.push("and ZBCS like '%" + self.search.ZBCS + "%'")
  36. }
  37. if (self.search.LMRQ1 != "" && self.search.LMRQ2 != "") {
  38. sqlwhere.push("and LMRQ between '" + self.search.LMRQ1 + " 00:00:00' and '" + self.search.LMRQ2 + " 23:59:59'")
  39. }
  40. if (self.search.DBSX1 != "" && self.search.DBSX2 != "") {
  41. sqlwhere.push("and DBSX between '" + self.search.DBSX1 + " 00:00:00' and '" + self.search.DBSX2 + " 23:59:59'")
  42. }
  43. var data = {
  44. tablename: "DCDB_SMDBD",
  45. pagesize: self.itemsPerPage,
  46. pageno: self.pageno,
  47. columns: "ROUTEINFOID,BH,BT,ZBCS,BZ,to_char(DBSX,'yyyy-MM-dd') as DBSX,to_char(LMRQ,'yyyy-MM-dd') as LMRQ",
  48. opinion_col: "BLQK",
  49. order: "ROUTEINFOID",
  50. sqlwhere: sqlwhere.join(" "),
  51. attachtype: "涉密督办单"
  52. }
  53. $http.post(apiurljs.login + "g2app/dataabase/queryDataAndOpinionWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  54. .success(function (obj) {
  55. var res = strToJson(s4.decryptData_CBC(obj.data));
  56. self.loading = false;
  57. if (res.data == null || res.data == undefined || res.data == "") {
  58. self.noDataTip = 0;
  59. } else {
  60. self.noDataTip = 1;
  61. self.list = res.data;
  62. self.list.forEach(function (item) {
  63. self.BLJG.forEach(function (item1) {
  64. if (item.BLJG == item1.CODE)
  65. item.BLJG = item1.CNAME
  66. })
  67. item.OPINION.forEach(function (item1) {
  68. item1.OPINION1 = item1.OPINION + "(" + item1.CMANS + "——" + sp.format(item1.CDATE) + ")"
  69. })
  70. item.FILEATTACH.forEach(function (item1) {
  71. item1.FILENAMES1 = item1.FILENAMES.length > 20 ? item1.FILENAMES.slice(0, 20) + "..." : item1.FILENAMES
  72. })
  73. })
  74. self.total_count = res.totalCount;
  75. self.canExportExcel = true;
  76. }
  77. })
  78. }
  79. self.getBLJG = function () {
  80. var data = {
  81. ckey: "CODE_BLJG",
  82. routeinfoid: self.routeinfoid
  83. }
  84. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  85. .success(function (obj) {
  86. var res = strToJson(s4.decryptData_CBC(obj.data));
  87. self.BLJG = res.data.CODE_BLJG;
  88. self.getData(1)
  89. })
  90. }
  91. self.getBLJG();
  92. self.openLayer = function () {
  93. sp.layer("#Search")
  94. }
  95. self.doSearch = function () {
  96. if ((self.search.LMRQ1 != "" && self.search.LMRQ2 == "") || (self.search.LMRQ1 == "" && self.search.LMRQ2 != "")) {
  97. sp.layerhide()
  98. sp.dialog("请输入正确时间区间!");
  99. $timeout(function () {
  100. sp.dialoghide();
  101. sp.layer("#Search")
  102. }, 2000)
  103. } else if ((self.search.DBSX1 != "" && self.search.DBSX2 == "") || (self.search.DBSX1 == "" && self.search.DBSX2 != "")) {
  104. sp.layerhide()
  105. sp.dialog("请输入正确时间区间!");
  106. $timeout(function () {
  107. sp.dialoghide();
  108. sp.layer("#Search")
  109. }, 2000)
  110. } else {
  111. $.cookie("GlWorkPlatform-shemidb", JSON.stringify(self.search), { path: '/', expires: 1 });
  112. self.getData(self.pageno)
  113. sp.layerhide()
  114. }
  115. }
  116. self.cancal = function () {
  117. self.search = {
  118. BT: "",
  119. ZBCS: "",
  120. LMRQ1: "",
  121. LMRQ2: "",
  122. DBSX1: "",
  123. DBSX2: ""
  124. }
  125. $.cookie("GlWorkPlatform-shemidb", null, { path: '/', expires: 1 });
  126. self.getData(1)
  127. sp.layerhide()
  128. }
  129. self.refresh = function () {
  130. self.getData(self.pageno);
  131. }
  132. self.download = function (obj) {
  133. window.open(apiurljs.login + "g2work/files/" + obj.FILEURL.slice(7))
  134. }
  135. self.printOut = function () {
  136. $.ajax({
  137. url: apiurljs.login + "g2app/dataabase/ExpExeclWithDataAndOpinion_ByParam",
  138. type: 'POST',
  139. cache: false,
  140. xhr: function () {
  141. var xhr = new XMLHttpRequest();
  142. xhr.onreadystatechange = function () {
  143. if (xhr.readyState == 2) {
  144. if (xhr.status == 200) {
  145. xhr.responseType = "blob";
  146. } else {
  147. xhr.responseType = "text";
  148. }
  149. }
  150. };
  151. return xhr;
  152. },
  153. headers: {
  154. "Content-Type": "application/json",
  155. "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|涉密督办单")
  156. },
  157. success: function (res) {
  158. download(res, "会议督办" + sp.getLocalDate() + ".et")
  159. },
  160. })
  161. }
  162. //头部下滚冻结
  163. $(function () {
  164. //页面高度撑满
  165. setTimeout(function () {
  166. if ($(".ibox-content").height() < $(window).height() - 31) {
  167. $(".ibox-content").css("height", $(window).height() - 31)
  168. }
  169. }, 1)
  170. })
  171. }])
  172. function download(data, filename, mime, bom) {
  173. var blobData = typeof bom !== "undefined" ? [bom, data] : [data];
  174. var blob = new Blob(blobData, { type: mime || "application/octet-stream" });
  175. if (typeof window.navigator.msSaveBlob !== "undefined") {
  176. // IE workaround for "HTML7007: One or more blob URLs were
  177. // revoked by closing the blob for which they were created.
  178. // These URLs will no longer resolve as the data backing
  179. // the URL has been freed."
  180. window.navigator.msSaveBlob(blob, filename);
  181. } else {
  182. var blobURL =
  183. window.URL && window.URL.createObjectURL
  184. ? window.URL.createObjectURL(blob)
  185. : window.webkitURL.createObjectURL(blob);
  186. var tempLink = document.createElement("a");
  187. tempLink.style.display = "none";
  188. tempLink.href = blobURL;
  189. tempLink.setAttribute("download", filename);
  190. // Safari thinks _blank anchor are pop ups. We only want to set _blank
  191. // target if the browser does not support the HTML5 download attribute.
  192. // This allows you to download files in desktop safari if pop up blocking
  193. // is enabled.
  194. if (typeof tempLink.download === "undefined") {
  195. tempLink.setAttribute("target", "_blank");
  196. }
  197. document.body.appendChild(tempLink);
  198. tempLink.click();
  199. // Fixes "webkit blob resource error 1"
  200. setTimeout(function () {
  201. document.body.removeChild(tempLink);
  202. window.URL.revokeObjectURL(blobURL);
  203. }, 200);
  204. }
  205. }