search.js 12 KB

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