list1.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("taizhangCtrl", ["$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. var postCfg = {
  13. headers: {
  14. 'Content-Type': 'application/json',
  15. 'Authorization': "Bearer " + self.get_AccessToken
  16. }
  17. }
  18. self.loading = false;
  19. self.search = { DATE1: sp.monthfirst(sp.getLocalDate()), DATE2: sp.formatMonthLast(sp.getLocalDate()), CPH: "" };
  20. self.getCX = function () {
  21. var data = {
  22. tablename: "CODE_CXDMB"
  23. }
  24. $http.post(apiurljs.login + "g2app/DangAn/queryCodeData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  25. .success(function (obj) {
  26. var res = strToJson(s4.decryptData_CBC(obj.data));
  27. self.cxList = res.data;
  28. self.getData(self.pageno);
  29. })
  30. }
  31. self.getCX()
  32. self.pageno = 1;
  33. self.total_count = 0;
  34. self.itemsPerPage = 10;
  35. self.pageOptions = [10, 20, 30, 40];
  36. self.getData = function (pageno) {
  37. self.list = [];
  38. self.loading = false;
  39. self.pageno = pageno;
  40. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  41. var data = {
  42. tablename: "SX_GWYCPQD",
  43. colums: "*,TO_CHAR(YCKSSJ,'yyyy-mm-dd')as YCKSSJ1,TO_CHAR(YCJSSJ,'yyyy-mm-dd')as YCJSSJ1",
  44. order: "SQSJ",
  45. sqlwhere: " and MARKFINISHED=1" + (self.search.CPH != "" ? " and CPH like'%" + self.search.CPH + "%'" : "") +
  46. (self.search.DATE1 != "" ? " and YCKSSJ BETWEEN '" + self.search.DATE1 + " 00:00:00' AND '" + self.search.DATE2 + " 23:59:59'" : ""),
  47. pageno: self.pageno,
  48. pagesize: self.itemsPerPage
  49. }
  50. $http.post(apiurljs.login + "g2app/dataabase/queryFormFlowWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  51. .success(function (obj) {
  52. var res = strToJson(s4.decryptData_CBC(obj.data));
  53. self.loading = false;
  54. self.list = res.data;
  55. self.list.forEach(function (item) {
  56. item.GLS = item.HDLC - item.CCLC;
  57. self.cxList.forEach(function (item1) {
  58. if (item.CXXQ == item1.CODE) {
  59. item.CX = item1.CNAME;
  60. }
  61. })
  62. })
  63. console.log(self.list)
  64. self.total_count = res.totalCount;
  65. })
  66. }
  67. self.openLayer = function () {
  68. sp.layer("#Search")
  69. }
  70. self.doSearch = function () {
  71. sp.layerhide()
  72. if (self.search.DATE1 == "" || self.search.DATE2 == "") {
  73. sp.dialog("时间不可为空!");
  74. return
  75. }
  76. self.getData(1);
  77. }
  78. self.cancal = function () {
  79. self.search = {
  80. DATE1: sp.monthfirst(sp.getLocalDate()),
  81. DATE2: sp.formatMonthLast(sp.getLocalDate()),
  82. CPH: ""
  83. }
  84. self.getData(1);
  85. sp.layerhide()
  86. }
  87. self.refresh = function () {
  88. self.getData(self.pageno);
  89. }
  90. self.changeGLS = function (obj) {
  91. self.edit = {
  92. ID: obj.ID,
  93. CCLC: obj.CCLC,
  94. HDLC: obj.HDLC
  95. }
  96. sp.layer("#GLS")
  97. }
  98. self.btnSaveGLS = function () {
  99. var data = {
  100. tablename: "SX_GWYCPQD",
  101. id: self.edit.ID,
  102. data: {
  103. CCLC: self.edit.CCLC,
  104. HDLC: self.edit.HDLC
  105. }
  106. }
  107. $http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  108. .success(function (obj) {
  109. var res = strToJson(s4.decryptData_CBC(obj.data));
  110. if (res.success) {
  111. sp.dialog("保存成功!");
  112. self.getData(self.pageno);
  113. $timeout(function () {
  114. sp.dialoghide();
  115. }, 1000)
  116. } else {
  117. sp.dialog(res.message);
  118. }
  119. })
  120. }
  121. self.printOut = function () {
  122. if (self.canExportExcel) {
  123. $('#table td').attr('t', 's')
  124. var defaultCellStyle = {
  125. font: {
  126. name: 'Times New Roman',
  127. sz: 12,
  128. color: {
  129. rgb: "000000"
  130. },
  131. bold: false, italic: false,
  132. underline: false
  133. },
  134. alignment: {
  135. vertical: "center",
  136. horizontal: "center", indent: 0, wrapText: true
  137. },
  138. border: {
  139. top: {
  140. style: "thin",
  141. color: {
  142. rgb: "000000"
  143. }
  144. },
  145. right: {
  146. style: "thin",
  147. color: {
  148. rgb: "000000"
  149. }
  150. },
  151. bottom: {
  152. style: "thin",
  153. color: {
  154. rgb: "000000"
  155. }
  156. },
  157. left: {
  158. style: "thin",
  159. color: {
  160. rgb: "000000"
  161. }
  162. }
  163. }
  164. };
  165. var cell = { defaultCellStyle: defaultCellStyle };
  166. var wb = XLSX.utils.table_to_book_addtitle(document.querySelector('#table'), cell, document.title)
  167. //设置表格的样式
  168. var wbout = XLSX.write(wb, {
  169. bookType: 'xlsx',
  170. bookSST: false,
  171. type: 'binary',
  172. cellStyles: true,
  173. defaultCellStyle: defaultCellStyle,
  174. showGridLines: false
  175. });
  176. var s2ab = function (s) {
  177. var buf = new ArrayBuffer(s.length);
  178. var view = new Uint8Array(buf);
  179. for (var i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
  180. return buf;
  181. };
  182. try {
  183. saveAs(new Blob([s2ab(wbout)], { type: 'application/octet-stream' }), document.title + '.xlsx')
  184. } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) }
  185. return wbout
  186. } else {
  187. sp.dialog('数据还未加载完成,请稍等...')
  188. }
  189. }
  190. //头部下滚冻结
  191. $(function () {
  192. //页面高度撑满
  193. setTimeout(function () {
  194. if ($(".ibox-content").height() < $(window).height() - 31) {
  195. $(".ibox-content").css("height", $(window).height() - 31)
  196. }
  197. }, 1)
  198. })
  199. }])