search.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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 = parseInt(sp.getUrlName("type"));
  13. var postCfg = {
  14. headers: {
  15. 'Content-Type': 'application/json',
  16. 'Authorization': "Bearer " + self.get_AccessToken
  17. }
  18. }
  19. self.search = {
  20. FLOW: 1,
  21. TYPE: 1,
  22. KSSJ: sp.monthfirst(sp.getLocalDate()),
  23. JSSJ: sp.formatMonthLast(sp.getLocalDate())
  24. }
  25. self.changeType = function () {
  26. switch (self.search.TYPE) {
  27. case "1": self.search.KSSJ = sp.monthfirst(sp.getLocalDate()); self.search.JSSJ = sp.formatMonthLast(sp.getLocalDate()); break;
  28. case "2": self.search.KSSJ = sp.quarter(sp.getLocalDate(), 1); self.search.JSSJ = sp.quarter(sp.getLocalDate(), 2); break;
  29. case "3": self.search.KSSJ = sp.currentYear() + "-01-01"; self.search.JSSJ = sp.currentYear() + "-12-31"; break;
  30. case "4": self.search.KSSJ = sp.format(sp.getLocalDate()); self.search.JSSJ = sp.format(sp.getLocalDate()); break;
  31. }
  32. }
  33. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  34. self.getData = function () {
  35. self.list = []
  36. var data = {
  37. flowtype: self.search.FLOW == 1 ? "C01" : "C02",
  38. tablename: self.search.FLOW == 1 ? "SX_XF" : "SX_ZMLJL",
  39. begindate: self.search.KSSJ + " 00:00:00",
  40. enddate: self.search.JSSJ + " 23:59:59"
  41. }
  42. $http.post(apiurljs.login + "g2app/richang/XinFangStatistics", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  43. .success(function (obj) {
  44. var res = strToJson(s4.decryptData_CBC(obj.data));
  45. self.canExportExcel = true;
  46. if (res.data == null || res.data == undefined || res.data == "") {
  47. self.noDataTip = 0;
  48. } else {
  49. self.noDataTip = 1;
  50. self.list = res.data;
  51. if (self.search.FLOW == 1) {
  52. self.list.forEach(function (item) {
  53. if (!item.ITEM_LD || item.ITEM_LD == {}) {
  54. item.ITEM_LD = {
  55. JC_TOTAL: 0,
  56. LDQD_JC: 0,
  57. LDQD_RC: 0,
  58. RC_TOTAL: 0
  59. }
  60. }
  61. if (!item.ITEM_LF || item.ITEM_LF == {}) {
  62. item.ITEM_LF = {
  63. BMZ1_JC:0,
  64. BMZ1_RC:0,
  65. JC_TOTAL:0,
  66. JJFFZCF_JC:0,
  67. JJFFZCF_RC:0,
  68. JJFZCF_JC:0,
  69. JJFZCF_RC:0,
  70. RC_TOTAL:0,
  71. SJZ1_JC:0,
  72. SJZ1_RC:0,
  73. ZS1_JC: 0,
  74. ZS1_RC: 0
  75. }
  76. }
  77. if (!item.ITEM_LX || item.ITEM_LX == {}) {
  78. item.ITEM_LX = {
  79. BMZ_JC:0,
  80. BMZ_RC:0,
  81. JC_TOTAL:0,
  82. RC_TOTAL:0,
  83. SJZ_JC:0,
  84. SJZ_RC:0,
  85. SXFBZ_JC:0,
  86. SXFBZ_RC:0,
  87. ZS_JC: 0,
  88. ZS_RC: 0
  89. }
  90. }
  91. if (!item.ITEM_WL || item.ITEM_WL == {}) {
  92. item.ITEM_WL = {
  93. JC_TOTAL:0,
  94. QT_JC:0,
  95. QT_RC:0,
  96. RC_TOTAL:0,
  97. SXFBZ1_JC:0,
  98. SXFBZ1_RC:0,
  99. WLMT_JC:0,
  100. WLMT_RC:0,
  101. ZJWGW_JC: 0,
  102. ZJWGW_RC: 0
  103. }
  104. }
  105. })
  106. }
  107. }
  108. })
  109. }
  110. self.getData();
  111. self.printOut = function () {
  112. if (self.canExportExcel) {
  113. $('#printOut td').attr('t', 's')
  114. var defaultCellStyle = {
  115. font: {
  116. name: 'Times New Roman',
  117. sz: 12,
  118. color: {
  119. rgb: "000000"
  120. },
  121. bold: false, italic: false,
  122. underline: false
  123. },
  124. alignment: {
  125. vertical: "center",
  126. horizontal: "center", indent: 0, wrapText: true
  127. },
  128. border: {
  129. top: {
  130. style: "thin",
  131. color: {
  132. rgb: "000000"
  133. }
  134. },
  135. right: {
  136. style: "thin",
  137. color: {
  138. rgb: "000000"
  139. }
  140. },
  141. bottom: {
  142. style: "thin",
  143. color: {
  144. rgb: "000000"
  145. }
  146. },
  147. left: {
  148. style: "thin",
  149. color: {
  150. rgb: "000000"
  151. }
  152. }
  153. }
  154. };
  155. var cell = { defaultCellStyle: defaultCellStyle };
  156. var wb = XLSX.utils.table_to_book_addtitle(document.querySelector('#printOut'), cell, "信访统计")
  157. //设置表格的样式
  158. var wbout = XLSX.write(wb, {
  159. bookType: 'xlsx',
  160. bookSST: false,
  161. type: 'binary',
  162. cellStyles: true,
  163. defaultCellStyle: defaultCellStyle,
  164. showGridLines: false
  165. });
  166. var s2ab = function (s) {
  167. var buf = new ArrayBuffer(s.length);
  168. var view = new Uint8Array(buf);
  169. for (var i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
  170. return buf;
  171. };
  172. try {
  173. saveAs(new Blob([s2ab(wbout)], { type: 'application/octet-stream' }), '信访统计.xlsx')
  174. } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) }
  175. return wbout
  176. } else {
  177. sp.dialog('数据还未加载完成,请稍等...')
  178. }
  179. }
  180. //头部下滚冻结
  181. $(function () {
  182. //页面高度撑满
  183. setTimeout(function () {
  184. if ($(".ibox-content").height() < $(window).height() - 31) {
  185. $(".ibox-content").css("height", $(window).height() - 31)
  186. }
  187. $(".sp-table").parent().css("height", $(".ibox-content").height() - 50)
  188. }, 1)
  189. })
  190. }])