search.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("listCtrl", ["$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. self.get_type = sp.getUrlName("type");
  13. self.page=sp.getUrlName("from")
  14. self.loading = false;
  15. sp.fitHeight("#div_table_part", 155);
  16. var postCfg = {
  17. headers: {
  18. 'Content-Type': 'application/json',
  19. 'Authorization': "Bearer " + self.get_AccessToken
  20. }
  21. }
  22. self.type = self.get_type != "" ? self.get_type : 1;
  23. if (self.type == 1) {
  24. self.flows = flowid_f;
  25. } else {
  26. self.flows = flowid_s;
  27. }
  28. self.search = {
  29. type: "",
  30. title: "",
  31. gwtype: "",
  32. gwwh: "",
  33. ngr: "",
  34. lwdw: "",
  35. ngtype: 0,
  36. ngkssj: "",
  37. ngjssj: "",
  38. lwtype: 0,
  39. lwkssj: "",
  40. lwjssj: "",
  41. bjtype: 0,
  42. bjkssj: "",
  43. bjjssj: ""
  44. }
  45. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  46. self.getData = function () {
  47. self.list = [];
  48. if (self.type == 1) {
  49. var sqlwhere = (self.search.type == "" ? "" : " and STATUS='" + self.search.type + "'") + (self.search.title == "" ? "" : " and TITLE LIKE'%" + self.search.title + "%'") + (self.search.gwwh == "" ? "" : " and gwwh LIKE'%" + self.search.gwwh + "%'") + (self.search.ngr == "" ? "" : " and ngr LIKE'%" + self.search.ngr + "%'") +
  50. (self.search.ngkssj == "" ? "" : " and ngsj>='" + self.search.ngkssj + "' and ngsj<='" + self.search.ngjssj + "'") + (self.search.bjkssj == "" ? "" : " and finisheddate>='" + self.search.bjkssj + "' and finisheddate<='" + self.search.bjjssj + "'") +
  51. (self.search.gwtype == "" ? "" : " and flowid='" + self.search.gwtype + "'");
  52. } else {
  53. var sqlwhere = (self.search.type == "" ? "" : " and STATUS='" + self.search.type + "'") + (self.search.title == "" ? "" : " and TITLE LIKE'%" + self.search.title + "%'") + (self.search.gwwh == "" ? "" : " and gwwh LIKE'%" + self.search.gwwh + "%'") + (self.search.lwdw == "" ? "" : " and ngr LIKE'%" + self.search.lwdw + "%'") +
  54. (self.search.lwkssj == "" ? "" : " and lwrq>='" + self.search.lwkssj + "' and lwrq<='" + self.search.lwkssj + "'") + (self.search.bjkssj == "" ? "" : " and finisheddate>='" + self.search.bjkssj + "' and finisheddate<='" + self.search.bjjssj + "'") +
  55. (self.search.gwtype == "" ? "" : " and flowid='" + self.search.gwtype + "'");
  56. }
  57. var data = {
  58. tablename: self.type == 1 ? "GONGWENSTATICTICS_FW_VIEW" : "GONGWENSTATICTICS_SW_VIEW",
  59. sqlwhere: sqlwhere,
  60. colums: "*",
  61. order: "FLOWID",
  62. pagesize: 0,
  63. pageno: 0
  64. }
  65. //console.log(data)
  66. self.loading = true;
  67. $http.post(apiurljs.login + "g2app/statisticsmanage/queryGongWenDataByColStrWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  68. .success(function (obj) {
  69. var res = strToJson(s4.decryptData_CBC(obj.data));
  70. self.canExportExcel = true;
  71. if (res.data == null || res.data == undefined || res.data == "") {
  72. self.noDataTip = 0;
  73. self.loading = false;
  74. } else {
  75. self.noDataTip = 1;
  76. self.list = res.data;
  77. self.list.forEach(function (item) {
  78. if ("AA20|AA03|AA10|AA55|AA56|AA57|AA08|AA23|AA77|AA06".indexOf(item.FLOWID) > -1) {
  79. item.FILEN = "tpl/fawenbg/" + item.FILEN;
  80. } else if ("AA88|AA89|AA46|AA22|AA54".indexOf(item.FLOWID) > -1) {
  81. item.FILEN = "tpl/fawendw/" + item.FILEN;
  82. } else {
  83. item.FILEN = "tpl/shouwenbg/" + item.FILEN;
  84. }
  85. item.STATUS1 = item.STATUS == "START" ? "拟稿" : item.STATUS == "DEAL" ? "待审" : "办结";
  86. if (item.NGSJ) {
  87. item.NGSJ1 = sp.format(item.NGSJ)
  88. }
  89. if (item.LWRQ) {
  90. item.LWRQ1 = sp.format(item.LWRQ)
  91. }
  92. })
  93. self.loading = false;
  94. }
  95. })
  96. }
  97. self.getData();
  98. self.goUrl = function (item) {
  99. sp.openNewWindow("../../" + item.FILEN + "&dotype=0", item.TITLE)
  100. }
  101. self.changeNg = function (n) {
  102. if (self.search.ngtype == n) { return; }
  103. else { self.search.ngtype = n }
  104. switch (self.search.ngtype) {
  105. case 0: self.search.ngkssj = ""; self.search.ngjssj = ""; break;
  106. case 1: self.search.ngkssj = getWeek(1); self.search.ngjssj = getWeek(2); break;
  107. case 2: self.search.ngkssj = sp.monthfirst(sp.getLocalDate()); self.search.ngjssj = sp.formatMonthLast(sp.getLocalDate()); break;
  108. case 3: self.search.ngkssj = sp.quarter(sp.getLocalDate(), 1); self.search.ngjssj = sp.quarter(sp.getLocalDate(), 2); break;
  109. case 4: self.search.ngkssj = getYearB(1); self.search.ngjssj = getYearB(2); break;
  110. }
  111. self.getData()
  112. }
  113. self.changeLw = function (n) {
  114. if (self.search.lwtype == n) { return; }
  115. else { self.search.lwtype = n }
  116. switch (self.search.lwtype) {
  117. case 0: self.search.lwkssj = ""; self.search.lwjssj = ""; break;
  118. case 1: self.search.lwkssj = getWeek(1); self.search.lwjssj = getWeek(2); break;
  119. case 2: self.search.lwkssj = sp.monthfirst(sp.getLocalDate()); self.search.lwjssj = sp.formatMonthLast(sp.getLocalDate()); break;
  120. case 3: self.search.lwkssj = sp.quarter(sp.getLocalDate(), 1); self.search.lwjssj = sp.quarter(sp.getLocalDate(), 2); break;
  121. case 4: self.search.lwkssj = getYearB(1); self.search.lwjssj = getYearB(2); break;
  122. }
  123. self.getData()
  124. }
  125. self.changeBj = function (n) {
  126. if (self.search.bjtype == n) { return; }
  127. else { self.search.bjtype = n }
  128. switch (self.search.bjtype) {
  129. case 0: self.search.bjkssj = ""; self.search.bjjssj = ""; break;
  130. case 1: self.search.bjkssj = getWeek(1); self.search.bjjssj = getWeek(2); break;
  131. case 2: self.search.bjkssj = sp.monthfirst(sp.getLocalDate()); self.search.bjjssj = sp.formatMonthLast(sp.getLocalDate()); break;
  132. case 3: self.search.bjkssj = sp.quarter(sp.getLocalDate(), 1); self.search.bjjssj = sp.quarter(sp.getLocalDate(), 2); break;
  133. case 4: self.search.bjkssj = getYearB(1); self.search.bjjssj = getYearB(2); break;
  134. }
  135. self.getData()
  136. }
  137. self.changeType = function (n) {
  138. if (self.type == n) {
  139. return;
  140. } else {
  141. self.type = n;
  142. if (self.type == 1) {
  143. self.flows = flowid_f;
  144. } else {
  145. self.flows = flowid_s;
  146. }
  147. self.search = {
  148. type: "",
  149. title: "",
  150. gwtype: "",
  151. gwwh: "",
  152. ngr: "",
  153. lwdw: "",
  154. ngtype: 0,
  155. ngkssj: "",
  156. ngjssj: "",
  157. lwtype: 0,
  158. lwkssj: "",
  159. lwjssj: "",
  160. bjtype: 0,
  161. bjkssj: "",
  162. bjjssj: ""
  163. }
  164. self.getData()
  165. }
  166. }
  167. self.printOut = function () {
  168. if (self.canExportExcel) {
  169. $('#printOut td').attr('t', 's')
  170. var defaultCellStyle = {
  171. font: {
  172. name: 'Times New Roman',
  173. sz: 12,
  174. color: {
  175. rgb: "000000"
  176. },
  177. bold: false, italic: false,
  178. underline: false
  179. },
  180. alignment: {
  181. vertical: "center",
  182. horizontal: "center", indent: 0, wrapText: true
  183. },
  184. border: {
  185. top: {
  186. style: "thin",
  187. color: {
  188. rgb: "000000"
  189. }
  190. },
  191. right: {
  192. style: "thin",
  193. color: {
  194. rgb: "000000"
  195. }
  196. },
  197. bottom: {
  198. style: "thin",
  199. color: {
  200. rgb: "000000"
  201. }
  202. },
  203. left: {
  204. style: "thin",
  205. color: {
  206. rgb: "000000"
  207. }
  208. }
  209. }
  210. };
  211. var cell = { defaultCellStyle: defaultCellStyle };
  212. var wb = XLSX.utils.table_to_book_addtitle(document.querySelector('#printOut'), cell, (self.type == 1 ? "发文" : "收文") + "统计")
  213. //设置表格的样式
  214. var wbout = XLSX.write(wb, {
  215. bookType: 'xlsx',
  216. bookSST: false,
  217. type: 'binary',
  218. cellStyles: true,
  219. defaultCellStyle: defaultCellStyle,
  220. showGridLines: false
  221. });
  222. var s2ab = function (s) {
  223. var buf = new ArrayBuffer(s.length);
  224. var view = new Uint8Array(buf);
  225. for (var i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
  226. return buf;
  227. };
  228. try {
  229. saveAs(new Blob([s2ab(wbout)], { type: 'application/octet-stream' }), (self.type == 1 ? '发文' : '收文') + '统计.xlsx')
  230. } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) }
  231. return wbout
  232. } else {
  233. sp.dialog('数据还未加载完成,请稍等...')
  234. }
  235. }
  236. //头部下滚冻结
  237. $(function () {
  238. //页面高度撑满
  239. setTimeout(function () {
  240. if ($(".ibox-content").height() < $(window).height() - 31) {
  241. $(".ibox-content").css("height", $(window).height() - 31)
  242. }
  243. }, 1)
  244. })
  245. }])
  246. var flowid_f = [{ name: "党委正式文上行文", flowid: "AA88" }, { name: "党委正式文下行文", flowid: "AA89" }, { name: "党委会议纪要", flowid: "AA46" }, { name: "住房公积金发文处理单", flowid: "AA80" },
  247. { name: "党委其他文件", flowid: "AA22" }, { name: "党委督查专报", flowid: "AA54" }, { name: "机关党委非正式文", flowid: "AA58" }, { name: "正式文-上行文", flowid: "AA20" },
  248. { name: "正式文-平、下行文", flowid: "AA03" }, { name: "专报", flowid: "AA10" }, { name: "规范性文件", flowid: "AA57" }, { name: "委发函", flowid: "AA08" },
  249. { name: "审批件", flowid: "AA23" }, { name: "主任办公会议纪要", flowid: "AA77" }, { name: "会议纪要", flowid: "AA06" }, { name: "例会简报", flowid: "AA63" }]
  250. var flowid_s = [{ name: "行政公文", flowid: "AA18" }, { name: "领导批示", flowid: "AA16" }, { name: "党委公文", flowid: "AA02" }, { name: "领导批示党口", flowid: "AA17" }]
  251. function showToggle() {
  252. $(".toggle").toggle()
  253. }
  254. function formate(d) {
  255. return d > 9 ? d : "0" + d;
  256. }
  257. function getWeek(n) {
  258. var week = new Date().getDay();
  259. week = week == 0 ? 7 : week;
  260. if (n == 1) {
  261. return sp.dateCount((week - 1) * -1)
  262. } else {
  263. return sp.dateCount(7 - week)
  264. }
  265. }
  266. function getYearB(n) {
  267. if (sp.format(sp.getLocalDate()) < sp.currentYear() + "-06-30") {
  268. if (n == 1) {
  269. return sp.currentYear() + "-01-01"
  270. } else {
  271. return sp.currentYear() + "-06-30"
  272. }
  273. } else {
  274. if (n == 1) {
  275. return sp.currentYear() + "-07-01"
  276. } else {
  277. return sp.currentYear() + "-12-31"
  278. }
  279. }
  280. }