taizhang.js 8.0 KB

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