detail.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. 'use strict';
  2. var app = angular.module('app', [
  3. ]);
  4. app.controller("formeditCtrl", ["$scope", "$http", "$timeout", '$sce', function ($scope, $http, $timeout, $sce) {
  5. var self = this;
  6. var s4 = new SM4Util();
  7. self.userId = $.cookie("GlWorkPlatform-userid");
  8. self.userName = $.cookie("GlWorkPlatform-chineseName");
  9. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  10. self.get_id = sp.getUrlName("id");
  11. self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
  12. var postCfg = {
  13. headers: {
  14. 'Content-Type': 'application/json',
  15. 'Authorization': "Bearer " + self.get_AccessToken
  16. }
  17. };
  18. self.FormTitle = $.cookie("GlWorkPlatform-SYSNAME");
  19. self.getYF = function () {
  20. var data = {
  21. ckey: "CODE_ZBYF",
  22. routeinfoid: self.routeinfoid
  23. }
  24. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  25. .success(function (obj) {
  26. var res = strToJson(s4.decryptData_CBC(obj.data));
  27. self.YF = res.data.CODE_ZBYF;
  28. self.getZBSJ()
  29. })
  30. }
  31. self.getYF()
  32. self.getZBSJ = function () {
  33. var data = {
  34. ckey: "CODE_ZHIBANTIMEZSDW",
  35. routeinfoid: self.routeinfoid
  36. }
  37. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  38. .success(function (obj) {
  39. var res = strToJson(s4.decryptData_CBC(obj.data));
  40. self.ZBSJ = res.data.CODE_ZHIBANTIMEZSDW;
  41. self.getData()
  42. })
  43. }
  44. //获取数据
  45. self.getData = function () {
  46. var data = {
  47. tablename: "SX_YFZBB",
  48. colums: "*",
  49. order: "ID",
  50. sqlwhere: { ID: self.get_id },
  51. sqlinwhere: "",
  52. sqllikewhere: ""
  53. }
  54. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  55. .success(function (obj) {
  56. var res = strToJson(s4.decryptData_CBC(obj.data));
  57. self.data = {
  58. ID: res.data[0].ID,
  59. NF: res.data[0].NF,
  60. YF: res.data[0].YF,
  61. SQDW: res.data[0].SQDW,
  62. LSH: res.data[0].LSH,
  63. ZBSJREMARK: res.data[0].ZBSJREMARK,
  64. ZBDH: res.data[0].ZBDH,
  65. ZBCZ: res.data[0].ZBCZ,
  66. YJJJRZBDH: res.data[0].YJJJRZBDH,
  67. YJJJRZBCZ: res.data[0].YJJJRZBCZ,
  68. ZBDD: res.data[0].ZBDD,
  69. TBR: res.data[0].TBR,
  70. REMARK: res.data[0].REMARK
  71. };
  72. self.YF.forEach(function (item) {
  73. if (self.data.YF == item.CODE) {
  74. self.data.YF1 = item.CNAME;
  75. }
  76. })
  77. self.getChildList()
  78. })
  79. }
  80. self.getChildList = function () {
  81. var data = {
  82. tablename: "SX_YFZBB_01",
  83. colums: "*",
  84. order: "ID",
  85. sqlwhere: { PID: self.data.ID },
  86. sqlinwhere: "",
  87. sqllikewhere: ""
  88. }
  89. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  90. .success(function (obj) {
  91. var res = strToJson(s4.decryptData_CBC(obj.data));
  92. self.list = res.data;
  93. self.AddFlag = false;
  94. self.EditFlag = false;
  95. self.list.forEach(function (item) {
  96. item.editFlag = false;
  97. item.RIQI = formate(item.RIQI);
  98. self.ZBSJ.forEach(function (item1) {
  99. if (item.ZBSJ == item1.CODE) {
  100. item.ZBSJ2 = item1.CNAME
  101. }
  102. })
  103. })
  104. })
  105. }
  106. self.downLoadT = function () {
  107. var eleLink = document.createElement('a');
  108. eleLink.download = "";
  109. eleLink.style.display = 'none';
  110. eleLink.href = apiurljs.login + "g2app/zhiban/ExpZhiBanMoBanT?data=" + encodeURIComponent(s4.encryptData_CBC("mobanname=zsdwzb.xlsx&code_table=CODE_ZHIBANTIMEZSDW&title=市住房城乡建设委直属单位" + self.data.NF + "年" + self.data.YF1 + "月份值班表&id=" + self.data.ID + "&cyear=" + self.data.NF + "&cmonth=" + formate(self.data.YF1) + "&sqdw=" + self.data.SQDW + "&lsh=" + self.data.LSH + "&bssj=" + sp.minsToDate("yyyy-MM-dd hh:mm:ss", parseFloat(sp.getUrlName("bssj")))));
  111. // 触发点击
  112. document.body.appendChild(eleLink);
  113. eleLink.click();
  114. // 然后移除
  115. document.body.removeChild(eleLink);
  116. }
  117. //前端导出
  118. self.printOut = function () {
  119. if (self.canExportExcel) {
  120. $('#printOut td').attr('t', 's')
  121. var defaultCellStyle = {
  122. font: {
  123. name: 'Times New Roman',
  124. sz: 12,
  125. color: {
  126. rgb: "000000"
  127. },
  128. bold: false, italic: false,
  129. underline: false
  130. },
  131. alignment: {
  132. vertical: "center",
  133. horizontal: "center", indent: 0, wrapText: true
  134. },
  135. border: {
  136. top: {
  137. style: "thin",
  138. color: {
  139. rgb: "000000"
  140. }
  141. },
  142. right: {
  143. style: "thin",
  144. color: {
  145. rgb: "000000"
  146. }
  147. },
  148. bottom: {
  149. style: "thin",
  150. color: {
  151. rgb: "000000"
  152. }
  153. },
  154. left: {
  155. style: "thin",
  156. color: {
  157. rgb: "000000"
  158. }
  159. }
  160. }
  161. };
  162. var cell = { defaultCellStyle: defaultCellStyle };
  163. var wb = XLSX.utils.table_to_book_addtitle(document.querySelector('#printOut'), cell, "市住房城乡建设委机关" + self.data.NF + "年" + self.data.YF1 + "月份值班表")
  164. //设置表格的样式
  165. var wbout = XLSX.write(wb, {
  166. bookType: 'xlsx',
  167. bookSST: false,
  168. type: 'binary',
  169. cellStyles: true,
  170. defaultCellStyle: defaultCellStyle,
  171. showGridLines: false
  172. });
  173. var s2ab = function (s) {
  174. var buf = new ArrayBuffer(s.length);
  175. var view = new Uint8Array(buf);
  176. for (var i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
  177. return buf;
  178. };
  179. try {
  180. saveAs(new Blob([s2ab(wbout)], { type: 'application/octet-stream' }), '市住房城乡建设委机关' + self.data.NF + '年' + self.data.YF1 + '月份值班表.et')
  181. } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) }
  182. return wbout
  183. } else {
  184. sp.dialog('数据还未加载完成,请稍等...')
  185. }
  186. }
  187. //头部下滚冻结
  188. $(function () {
  189. $(".sp-page-center").eq(0).css("max-height", $("#topDiv").height()).css("height", $("#topDiv").height())
  190. $(".formedit center").css("height", $(".formedit center").next("div").height()).css("line-height", $(".formedit center").next("div").height() / 6 + "px")
  191. //页面高度撑满
  192. setTimeout(function () {
  193. if ($(".ibox-content").height() < $(window).height() - 31) {
  194. $(".ibox-content").css("height", $(window).height() - 31)
  195. }
  196. }, 1)
  197. })
  198. }])
  199. app.directive("repeatFinish", function () {
  200. return {
  201. link: function (scope) {
  202. if (scope.$last == true) {
  203. setTimeout(function () {
  204. $(".zb-table").rowspan(1)
  205. $(".zb-table").rowspan(0)
  206. }, 10);
  207. }
  208. }
  209. };
  210. });
  211. function formate(n) {
  212. return n * 1 > 9 ? n * 1 : "0" + n * 1;
  213. }
  214. function getNum(arr, name) {
  215. var n = -1;
  216. $.each(arr, function (index, item) {
  217. if (item.CNAME == name) {
  218. n = index
  219. }
  220. })
  221. return n
  222. }
  223. function isNull(str) {
  224. if (str == "" || str == null || str == undefined) {
  225. return false
  226. } else {
  227. return true
  228. }
  229. }
  230. jQuery.fn.rowspan = function (colIdx) { //封装的一个JQuery小插件
  231. return this.each(function () {
  232. var that;
  233. $('tr', this).each(function (row) {
  234. $('td:eq(' + colIdx + ')', this).filter(':visible').each(function (col) {
  235. if (that != null && $(this).html() == $(that).html()) {
  236. var rowspan = $(that).attr("rowSpan");
  237. if (rowspan == undefined) {
  238. $(that).attr("rowSpan", 1);
  239. rowspan = $(that).attr("rowSpan");
  240. }
  241. rowspan = Number(rowspan) + 1;
  242. $(that).attr("rowSpan", rowspan);
  243. $(this).remove();
  244. } else {
  245. that = this;
  246. }
  247. });
  248. });
  249. });
  250. }