list.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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. TYPE: 1,
  21. KSSJ: sp.monthfirst(sp.getLocalDate()),
  22. JSSJ: sp.formatMonthLast(sp.getLocalDate())
  23. }
  24. self.changeType = function () {
  25. switch (self.search.TYPE) {
  26. case "1": self.search.KSSJ = sp.monthfirst(sp.getLocalDate()); self.search.JSSJ = sp.formatMonthLast(sp.getLocalDate()); break;
  27. case "2": self.search.KSSJ = sp.quarter(sp.getLocalDate(), 1); self.search.JSSJ = sp.quarter(sp.getLocalDate(), 2); break;
  28. case "3": self.search.KSSJ = sp.currentYear() + "-01-01"; self.search.JSSJ = sp.currentYear() + "-12-31"; break;
  29. case "4": self.search.KSSJ = sp.format(sp.getLocalDate()); self.search.JSSJ = sp.format(sp.getLocalDate()); break;
  30. }
  31. }
  32. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  33. self.getData = function () {
  34. self.list = [];
  35. var data = {
  36. begindate: self.search.KSSJ + " 00:00:00",
  37. enddate: self.search.JSSJ + " 23:59:59"
  38. }
  39. $http.post(apiurljs.login + "g2app/richang/RiChangShiWuStatistics", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  40. .success(function (obj) {
  41. var res = strToJson(s4.decryptData_CBC(obj.data));
  42. self.canExportExcel = true;
  43. if (res.data == null || res.data == undefined || res.data == "") {
  44. self.noDataTip = 0;
  45. } else {
  46. self.noDataTip = 1;
  47. self.list = res.data;
  48. self.getColumn()
  49. }
  50. })
  51. }
  52. self.printOut = function () {
  53. if (self.canExportExcel) {
  54. $('#printOut td').attr('t', 's')
  55. var defaultCellStyle = {
  56. font: {
  57. name: 'Times New Roman',
  58. sz: 12,
  59. color: {
  60. rgb: "000000"
  61. },
  62. bold: false, italic: false,
  63. underline: false
  64. },
  65. alignment: {
  66. vertical: "center",
  67. horizontal: "center", indent: 0, wrapText: true
  68. },
  69. border: {
  70. top: {
  71. style: "thin",
  72. color: {
  73. rgb: "000000"
  74. }
  75. },
  76. right: {
  77. style: "thin",
  78. color: {
  79. rgb: "000000"
  80. }
  81. },
  82. bottom: {
  83. style: "thin",
  84. color: {
  85. rgb: "000000"
  86. }
  87. },
  88. left: {
  89. style: "thin",
  90. color: {
  91. rgb: "000000"
  92. }
  93. }
  94. }
  95. };
  96. var cell = { defaultCellStyle: defaultCellStyle };
  97. var wb = XLSX.utils.table_to_book_addtitle(document.querySelector('#printOut'), cell, "日常管理统计")
  98. //设置表格的样式
  99. var wbout = XLSX.write(wb, {
  100. bookType: 'xlsx',
  101. bookSST: false,
  102. type: 'binary',
  103. cellStyles: true,
  104. defaultCellStyle: defaultCellStyle,
  105. showGridLines: false
  106. });
  107. var s2ab = function (s) {
  108. var buf = new ArrayBuffer(s.length);
  109. var view = new Uint8Array(buf);
  110. for (var i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
  111. return buf;
  112. };
  113. try {
  114. saveAs(new Blob([s2ab(wbout)], { type: 'application/octet-stream' }), '日常管理统计.xlsx')
  115. } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) }
  116. return wbout
  117. } else {
  118. sp.dialog('数据还未加载完成,请稍等...')
  119. }
  120. }
  121. self.getColumn = function () {
  122. var title = [], data1 = [], data2 = [], data3 = [], data4 = [], data5 = [], data6 = [], data7 = [], data8 = [], data9 = [], data10 = [];
  123. self.list5.forEach(function (item) {
  124. title.push(item.NAME);
  125. data1.push(item.DATA.DEAL_COUNT0_0 + item.DATA.STOP_COUNT0_0);
  126. data2.push(item.DATA.DEAL_COUNT1_0 + item.DATA.STOP_COUNT1_0);
  127. data3.push(item.DATA.DEAL_COUNT2_0 + item.DATA.STOP_COUNT2_0);
  128. data4.push(item.DATA.DEAL_COUNT3_0 + item.DATA.STOP_COUNT3_0);
  129. data5.push(item.DATA.DEAL_COUNT4_0 + item.DATA.STOP_COUNT4_0);
  130. data6.push(item.DATA.DEAL_COUNT5_0 + item.DATA.STOP_COUNT5_0);
  131. data7.push(item.DATA.DEAL_COUNT6_0 + item.DATA.STOP_COUNT6_0);
  132. data8.push(item.DATA.DEAL_COUNT7_0 + item.DATA.STOP_COUNT7_0);
  133. data9.push(item.DATA.DEAL_COUNT8_0 + item.DATA.STOP_COUNT8_0);
  134. data10.push(item.DATA.DEAL_COUNT9_0 + item.DATA.STOP_COUNT9_0);
  135. })
  136. var chart = new Highcharts.Chart({
  137. chart: {
  138. renderTo: "column",
  139. type: 'column'
  140. },
  141. title: {
  142. text: '', //图表的标题
  143. //margin: 80
  144. },
  145. colors: ["#6395F9", "#62DAAB"],
  146. tooltip: {
  147. headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
  148. pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
  149. '<td style="padding:0"><b>{point.y}</b>{series.className}</td></tr>',
  150. footerFormat: '</table>',
  151. shared: true,
  152. useHTML: true
  153. },
  154. xAxis: {
  155. categories: title
  156. },
  157. yAxis: {
  158. title: {
  159. text: ''
  160. },
  161. lineWidth: 1,
  162. gridLineWidth: 1
  163. },
  164. legend: {
  165. enabled: true
  166. },
  167. plotOptions: {
  168. series: {
  169. pointWidth: 30,
  170. turboThreshold: 0,
  171. cursor: 'pointer',
  172. dataLabels: {
  173. enabled: true,
  174. }
  175. },
  176. column: {
  177. stacking: 'normal'
  178. }
  179. },
  180. series: [{
  181. name: "请假",
  182. data:data1
  183. }, {
  184. name: "请假",
  185. data: data2
  186. }, {
  187. name: "请假",
  188. data: data3
  189. }, {
  190. name: "请假",
  191. data: data4
  192. }, {
  193. name: "请假",
  194. data: data5
  195. }, {
  196. name: "请假",
  197. data: data6
  198. }, {
  199. name: "请假",
  200. data: data7
  201. }, {
  202. name: "请假",
  203. data: data8
  204. }, {
  205. name: "请假",
  206. data: data9
  207. }, {
  208. name: "请假",
  209. data: data10
  210. }],
  211. credits: {
  212. enabled: false//隐藏右下角网址
  213. },
  214. exporting: {
  215. enabled: false//隐藏右上角打印
  216. }
  217. })
  218. chart.setSize(null, 400)
  219. }
  220. self.getData();
  221. //头部下滚冻结
  222. $(function () {
  223. //页面高度撑满
  224. setTimeout(function () {
  225. if ($(".ibox-content").height() < $(window).height() - 31) {
  226. $(".ibox-content").css("height", $(window).height() - 31)
  227. }
  228. }, 1)
  229. })
  230. }])