list.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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. var postCfg = {
  14. headers: {
  15. 'Content-Type': 'application/json',
  16. 'Authorization': "Bearer " + self.get_AccessToken
  17. }
  18. }
  19. self.search = {
  20. DBLX: "",
  21. TYPE: "",
  22. CBBM: "",
  23. KSSJ: sp.format(sp.getLocalDate()),
  24. JSSJ: sp.format(sp.getLocalDate())
  25. }
  26. self.chart = {
  27. pie: 1,
  28. column: 1
  29. }
  30. self.getDBLX = function () {
  31. var data = {
  32. tablename: "CODE_DUBAN"
  33. }
  34. $http.post(apiurljs.login + "g2app/DangAn/queryCodeData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  35. .success(function (obj) {
  36. var res = strToJson(s4.decryptData_CBC(obj.data));
  37. self.DBLX = res.data;
  38. self.getDpList();
  39. })
  40. }
  41. self.getDpList = function () {
  42. var data = {
  43. nodekid: "AA82N04,AA16N08,AA17N08,AA18N08"
  44. }
  45. $http.post(apiurljs.login + "g2app/richang/querychengbanDp", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  46. .success(function (obj) {
  47. var res = strToJson(s4.decryptData_CBC(obj.data));
  48. self.CBBM = res.data;
  49. self.getData();
  50. })
  51. }
  52. self.noDataTip = 0;
  53. self.getData = function () {
  54. self.list = [];
  55. var data = {
  56. dblx: self.search.DBLX,
  57. gstype: self.search.TYPE,
  58. zbcscode: self.search.CBBM,
  59. begindate: self.search.KSSJ + " 00:00:00",
  60. enddate: self.search.JSSJ + "23:59:59"
  61. }
  62. $http.post(apiurljs.login + "g2app/richang/queryDuBanYanQiStatistics", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  63. .success(function (obj) {
  64. var res = strToJson(s4.decryptData_CBC(obj.data));
  65. self.loading = false;
  66. self.canExportExcel = true;
  67. if (res.data == null || res.data == undefined || res.data == "") {
  68. self.noDataTip = 0;
  69. } else {
  70. self.noDataTip = 1;
  71. self.list = res.data;
  72. self.dataPie = [{ name: "一般督办", y: 0 }, { name: "重点督办", y: 0 }]
  73. self.column = {
  74. title: [],
  75. data: [{ name: "超期办结", data: [] }, { name: "按期办结", data: [] }, { name: "未超期未办结", data: [] }, { name: "超期未办结", data: [] }]
  76. }
  77. self.list.forEach(function (item) {
  78. self.dataPie.forEach(function (item1) {
  79. if (item.DBLX == item1.name) {
  80. item1.y = item1.y + numIsNull(item.CQBJ_AVG) + numIsNull(item.WCQBJ_AVG) + numIsNull(item.WCQWBJ_AVG) + numIsNull(item.CQWBJ_AVG)
  81. }
  82. })
  83. if (self.column.title.indexOf(item.SECTION) == -1) {
  84. self.column.title.push(item.SECTION)
  85. self.column.data.forEach(function (item1) {
  86. item1.data.push(0)
  87. })
  88. }
  89. })
  90. self.getPie()
  91. self.getColumn()
  92. }
  93. })
  94. }
  95. self.getDBLX()
  96. self.printOut = function () {
  97. if (self.canExportExcel) {
  98. $('#printOut td').attr('t', 's')
  99. var defaultCellStyle = {
  100. font: {
  101. name: 'Times New Roman',
  102. sz: 12,
  103. color: {
  104. rgb: "000000"
  105. },
  106. bold: false, italic: false,
  107. underline: false
  108. },
  109. alignment: {
  110. vertical: "center",
  111. horizontal: "center", indent: 0, wrapText: true
  112. },
  113. border: {
  114. top: {
  115. style: "thin",
  116. color: {
  117. rgb: "000000"
  118. }
  119. },
  120. right: {
  121. style: "thin",
  122. color: {
  123. rgb: "000000"
  124. }
  125. },
  126. bottom: {
  127. style: "thin",
  128. color: {
  129. rgb: "000000"
  130. }
  131. },
  132. left: {
  133. style: "thin",
  134. color: {
  135. rgb: "000000"
  136. }
  137. }
  138. }
  139. };
  140. var cell = { defaultCellStyle: defaultCellStyle };
  141. var wb = XLSX.utils.table_to_book_addtitle(document.querySelector('#printOut'), cell, "事项统计")
  142. //设置表格的样式
  143. var wbout = XLSX.write(wb, {
  144. bookType: 'xlsx',
  145. bookSST: false,
  146. type: 'binary',
  147. cellStyles: true,
  148. defaultCellStyle: defaultCellStyle,
  149. showGridLines: false
  150. });
  151. var s2ab = function (s) {
  152. var buf = new ArrayBuffer(s.length);
  153. var view = new Uint8Array(buf);
  154. for (var i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
  155. return buf;
  156. };
  157. try {
  158. saveAs(new Blob([s2ab(wbout)], { type: 'application/octet-stream' }), '事项统计.xlsx')
  159. } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) }
  160. return wbout
  161. } else {
  162. sp.dialog('数据还未加载完成,请稍等...')
  163. }
  164. }
  165. self.getPie = function () {
  166. var chart = new Highcharts.Chart({
  167. chart: {
  168. renderTo: "pie",
  169. type: 'pie',
  170. style: {
  171. position: 'relative',
  172. left: '-30px'
  173. }
  174. },
  175. title: {
  176. text: '', //图表的标题
  177. //margin: 80
  178. },
  179. tooltip: {
  180. pointFormat: '{series.name}: <b>{point.y}</b>'
  181. },
  182. legend: {
  183. floating: true,
  184. align: 'left',
  185. verticalAlign: 'middle',
  186. layout: 'vertical',
  187. backgroundColor: '#FFF',
  188. itemMarginTop: 5,
  189. itemMarginBottom: 5,
  190. itemStyle: {
  191. fontSize: 16
  192. },
  193. enabled: false,
  194. },
  195. plotOptions: {
  196. pie: {
  197. allowPointSelect: true,
  198. cursor: 'pointer',
  199. size: 300,
  200. dataLabels: {
  201. enabled: true,
  202. distance: -50,
  203. formatter: function () {
  204. return this.point.name + ":" + this.point.percentage.toFixed(2) + "%";
  205. }
  206. },
  207. showInLegend: true
  208. }
  209. },
  210. series: [{
  211. name: '',
  212. data: self.dataPie
  213. }],
  214. credits: {
  215. enabled: false//隐藏右下角网址
  216. },
  217. exporting: {
  218. enabled: false//隐藏右上角打印
  219. }
  220. })
  221. }
  222. self.getColumn = function () {
  223. self.column.title.forEach(function (item, index) {
  224. console.log(item)
  225. self.list.forEach(function (item1) {
  226. if (item1.SECTION == item) {
  227. console.log(self.column.data[0].data[index] + item1.CQBJ)
  228. self.column.data[0].data[index] = self.column.data[0].data[index] + numIsNull(item1.CQBJ_AVG)
  229. self.column.data[1].data[index] = self.column.data[0].data[index] + numIsNull(item1.WCQBJ_AVG)
  230. self.column.data[2].data[index] = self.column.data[0].data[index] + numIsNull(item1.WCQWBJ_AVG)
  231. self.column.data[3].data[index] = self.column.data[0].data[index] + numIsNull(item1.CQWBJ_AVG)
  232. }
  233. })
  234. })
  235. console.log(self.column)
  236. var chart = new Highcharts.Chart({
  237. chart: {
  238. renderTo: "column",
  239. type: 'column'
  240. },
  241. title: {
  242. text: '', //图表的标题
  243. //margin: 80
  244. },
  245. tooltip: {
  246. headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
  247. pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
  248. '<td style="padding:0"><b>{point.y}</b>{series.className}</td></tr>',
  249. footerFormat: '</table>',
  250. shared: true,
  251. useHTML: true
  252. },
  253. xAxis: {
  254. categories: self.column.title
  255. },
  256. yAxis: {
  257. title: {
  258. text: ''
  259. },
  260. lineWidth: 1,
  261. gridLineWidth: 1
  262. },
  263. legend: {
  264. enabled: true
  265. },
  266. plotOptions: {
  267. series: {
  268. turboThreshold: 0,
  269. cursor: 'pointer',
  270. pointWidth: 20,
  271. dataLabels: {
  272. enabled: true,
  273. }
  274. }
  275. },
  276. series: self.column.data,
  277. credits: {
  278. enabled: false//隐藏右下角网址
  279. },
  280. exporting: {
  281. enabled: false//隐藏右上角打印
  282. }
  283. })
  284. }
  285. //头部下滚冻结
  286. $(function () {
  287. //页面高度撑满
  288. setTimeout(function () {
  289. if ($(".ibox-content").height() < $(window).height() - 31) {
  290. $(".ibox-content").css("height", $(window).height() - 31)
  291. }
  292. }, 1)
  293. })
  294. }])
  295. function numIsNull(n) {
  296. if (n == "" || n == null || n == undefined) {
  297. return 0
  298. } else {
  299. return n
  300. }
  301. }