DBtaizhang.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  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 = JSON.parse($.cookie("GlWorkPlatform-hydbtz")) || { TITLE: "", QTBM: "", DBSX1: "", DBSX2: "", DENG: "", FLOWNAME: "", BANLI: "待办中" };
  20. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  21. self.pageno = 1;
  22. self.total_count = 0;
  23. self.itemsPerPage = 10;
  24. self.pageOptions = [10, 20, 30, 40, 100, 300, 500];
  25. self.getData = function (pageno) {
  26. self.list = [];
  27. self.loading = true;
  28. self.pageno = pageno;
  29. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  30. var sqlwhere = [];
  31. if (self.search.TITLE != "") {
  32. sqlwhere.push("and TITLE like '%" + self.search.TITLE + "%'")
  33. }
  34. if (self.search.QTBM != "") {
  35. sqlwhere.push("and DEPARTMENT like '%" + self.search.QTBM + "%'")
  36. }
  37. if (self.search.DENG != "") {
  38. sqlwhere.push("and DENG = '" + self.search.DENG + "'")
  39. }
  40. if (self.search.FLOWNAME != "") {
  41. sqlwhere.push("and FLOWNAME = '" + self.search.FLOWNAME + "'")
  42. }
  43. if (self.search.BANLI != "") {
  44. sqlwhere.push("and BANLI = '" + self.search.BANLI + "'")
  45. }
  46. if (self.search.DBSX1 != "" && self.search.DBSX2 != "") {
  47. sqlwhere.push("and TLDATE between '" + self.search.DBSX1 + " 00:00:00' and '" + self.search.DBSX2 + " 23:59:59'")
  48. }
  49. var data = {
  50. tablename: "SYS_ROUTE_INFO_DUBAN_VIEW",
  51. pagesize: self.itemsPerPage,
  52. pageno: self.pageno,
  53. colums: "*,TO_CHAR(TLDATE,'yyyy-mm-dd hh:mm:ss') as TLDATE1",
  54. order: "ROUTEINFOID",
  55. sqlwhere: sqlwhere.join(" ")
  56. };
  57. $http.post(apiurljs.login + "g2app/dubantaizhang/queryDataByColWithPage3", data, postCfg)
  58. .success(function (res) {
  59. self.loading = false;
  60. if (res.data == null || res.data == undefined || res.data == "") {
  61. self.noDataTip = 0;
  62. } else {
  63. self.noDataTip = 1;
  64. self.list = res.data;
  65. self.list.forEach(function (item) {
  66. item.TIXING1 = item.TIXING.split("\n");
  67. item.BANLI = item.BANLI=='待办中'?'正在办理':item.BANLI
  68. //item.TLDATE = sp.minsToDate("yyyy-MM-dd hh:mm:ss", new Date(item.TLDATE).getTime())
  69. //self.BLJG.forEach(function (item1) {
  70. // if (item.BLJG == item1.CODE)
  71. // item.BLJG = item1.CNAME
  72. //})
  73. //self.JBSXLY.forEach(function (item1) {
  74. // if (item.JBSXLY == item1.CODE)
  75. // item.JBSXLY = item1.CNAME
  76. //})
  77. //item.OPINION.forEach(function (item1) {
  78. // item1.OPINION1 = item1.OPINION + "(" + item1.CMANS + "——" + sp.format(item1.CDATE) + ")"
  79. //})
  80. //item.FILEATTACH.forEach(function (item1) {
  81. // item1.FILENAMES1 = item1.FILENAMES.length > 20 ? item1.FILENAMES.slice(0, 20) + "..." : item1.FILENAMES
  82. //})
  83. })
  84. self.total_count = res.totalCount;
  85. self.canExportExcel = true;
  86. }
  87. })
  88. }
  89. self.getBLJG = function () {
  90. var data = {
  91. ckey: "CODE_BLJG",
  92. routeinfoid: ""
  93. }
  94. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  95. .success(function (obj) {
  96. var res = strToJson(s4.decryptData_CBC(obj.data));
  97. self.BLJG = res.data.CODE_BLJG;
  98. self.getJBSXLY()
  99. })
  100. }
  101. self.getJBSXLY = function () {
  102. var data = {
  103. ckey: "CODE_JBSXLY",
  104. routeinfoid: ""
  105. }
  106. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  107. .success(function (obj) {
  108. var res = strToJson(s4.decryptData_CBC(obj.data));
  109. self.JBSXLY = res.data.CODE_JBSXLY;
  110. self.getData(1)
  111. })
  112. }
  113. self.getBLJG();
  114. self.checkedAll = false;
  115. self.checkAll = function () {
  116. self.list.forEach(function (item) {
  117. item.checked = self.checkedAll;
  118. })
  119. }
  120. self.DBTX = function () {
  121. var list = self.list.filter(function (item) {
  122. return item.checked == true;
  123. })
  124. if (list.length == 0) {
  125. sp.dialog("请选择要提醒的督办事项!");
  126. return
  127. }
  128. var array = [];
  129. list.forEach(function (item) {
  130. array.push(item.ROUTEINFOID)
  131. })
  132. $http.post(apiurljs.login + "g2app/dubantaizhang/addMessage", { data: s4.encryptData_CBC(JSON.stringify({ routeinfoids: array.join("|") })) }, postCfg)
  133. .success(function (obj) {
  134. var res = strToJson(s4.decryptData_CBC(obj.data));
  135. if (res.success) {
  136. self.getData(self.pageno)
  137. } else {
  138. sp.dialog(res.message);
  139. }
  140. })
  141. //list.forEach(function (item) {
  142. // array.push({
  143. // ROUTEINFOID: item.ROUTEINFOID,
  144. // CDATE: sp.getLocalDate(),
  145. // CONTENT: "督办提醒",
  146. // CMAN: item.CMAN,
  147. // CMANCAP: item.CMANCAP
  148. // })
  149. //})
  150. //var data = {
  151. // tablename: "ROUTEINFO_DENGMSG",
  152. // data: array
  153. //}
  154. //$http.post(apiurljs.login + "g2app/Data/insertChildDataList2", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  155. //.success(function (obj) {
  156. // var res = strToJson(s4.decryptData_CBC(obj.data));
  157. // if (res.success) {
  158. // self.getData(self.pageno)
  159. // } else {
  160. // sp.dialog(res.message);
  161. // }
  162. //})
  163. }
  164. self.openLayer = function () {
  165. sp.layer("#Search")
  166. }
  167. self.checkDENG = function (str) {
  168. self.search.DENG = str;
  169. //if (self.search.DENG.indexOf(str) == -1) {
  170. // self.search.DENG.push(str)
  171. //} else {
  172. // self.search.DENG = self.search.DENG.filter(function (item) {
  173. // return item != str;
  174. // })
  175. //}
  176. }
  177. self.doSearch = function () {
  178. if ((self.search.DBSX1 != "" && self.search.DBSX2 == "") ||(self.search.DBSX1 == "" && self.search.DBSX2 != "")) {
  179. sp.layerhide()
  180. sp.dialog("请输入正确时间区间!");
  181. $timeout(function () {
  182. sp.dialoghide();
  183. sp.layer("#Search")
  184. }, 2000)
  185. } else {
  186. $.cookie("GlWorkPlatform-hydbtz", JSON.stringify(self.search), { path: '/', expires: 1 });
  187. self.getData(self.pageno)
  188. sp.layerhide()
  189. }
  190. }
  191. self.cancal = function () {
  192. self.search = {
  193. TITLE: "",
  194. QTBM: "",
  195. DBSX1: "",
  196. DBSX2: "",
  197. DENG: "",
  198. FLOWNAME: "",
  199. BANLI: "待办中"
  200. }
  201. $.cookie("GlWorkPlatform-hydbtz", null, { path: '/', expires: 1 });
  202. self.getData(1)
  203. sp.layerhide()
  204. }
  205. self.refresh = function () {
  206. self.getData(self.pageno);
  207. }
  208. self.download = function (obj) {
  209. window.open(apiurljs.login + "g2work/files/" + obj.FILEURL.slice(7))
  210. }
  211. self.goUrl = function (item) {
  212. if (self.deviceType == "pad") {
  213. window.location.href = "../../" + item.DURL
  214. } else {
  215. sp.openNewWindow("../../" + item.DURL, item.TITLE)
  216. }
  217. }
  218. self.printEXCEL = function () {
  219. self.columns = [
  220. { header: "督办名称", key: "TITLE", width: 50 },
  221. { header: "来源", key: "FLOWNAME", width: 20 },
  222. { header: "主办处室", key: "DEPARTMENT", width: 20 },
  223. { header: "督办时限", key: "TLDATE1", width: 20 },
  224. { header: "办理结果", key: "BANLI", width: 20 },
  225. { header: "督办提醒记录", key: "TIXING", width: 100 }
  226. ]
  227. self.listExcel = self.list.map(function (item) {
  228. return {
  229. TITLE: item.TITLE,
  230. FLOWNAME: item.FLOWNAME,
  231. DEPARTMENT: item.DEPARTMENT,
  232. TLDATE1: item.TLDATE1,
  233. BANLI: item.BANLI,
  234. TIXING: item.TIXING
  235. }
  236. })
  237. // 创建工作簿
  238. var workbook = new ExcelJS.Workbook()
  239. // 添加工作表
  240. var worksheet = workbook.addWorksheet('sheet1')
  241. // 设置表头
  242. worksheet.columns = self.columns
  243. // 添加表体数据
  244. self.listExcel.forEach(function (item) {
  245. worksheet.addRow(item)
  246. })
  247. /**
  248. * 设置样式
  249. */
  250. // 1、设置标题行样式
  251. var headerRow = worksheet.getRow(1)
  252. // 连续遍历所有非空单元格
  253. headerRow.eachCell(function (cell) {
  254. // 边框 https://github.com/exceljs/exceljs/blob/HEAD/README_zh.md#%E8%BE%B9%E6%A1%86
  255. cell.border = {
  256. top: {
  257. style: 'thin'
  258. },
  259. left: {
  260. style: 'thin'
  261. },
  262. bottom: {
  263. style: 'thin'
  264. },
  265. right: {
  266. style: 'thin'
  267. },
  268. }
  269. // 填充 https://github.com/exceljs/exceljs/blob/HEAD/README_zh.md#%E5%A1%AB%E5%85%85
  270. cell.fill = {
  271. type: 'pattern',
  272. pattern: 'solid',
  273. fgColor: {
  274. argb: '4f81bd'
  275. }
  276. }
  277. // 字体 https://github.com/exceljs/exceljs/blob/HEAD/README_zh.md#%E5%AD%97%E4%BD%93
  278. cell.font = {
  279. name: '微软雅黑',
  280. size: 11,
  281. bold: true,
  282. color: { argb: '000000' }
  283. }
  284. // 对齐 https://github.com/exceljs/exceljs/blob/HEAD/README_zh.md#%E5%AF%B9%E9%BD%90
  285. cell.alignment = {
  286. vertical: 'middle',
  287. horizontal: 'center'
  288. }
  289. })
  290. // 2、设置内容行样式
  291. const bodyRow = worksheet.getRows(2, self.listExcel.length + 1)
  292. bodyRow.forEach(function (row) {
  293. //遍历此列中的所有当前单元格,包括空单元格
  294. row.eachCell({ includeEmpty: true }, function (cell) {
  295. // 边框
  296. cell.border = {
  297. top: {
  298. style: 'thin'
  299. },
  300. left: {
  301. style: 'thin'
  302. },
  303. bottom: {
  304. style: 'thin'
  305. },
  306. right: {
  307. style: 'thin'
  308. },
  309. }
  310. // 字体 https://github.com/exceljs/exceljs/blob/HEAD/README_zh.md#%E5%AD%97%E4%BD%93
  311. cell.font = {
  312. name: '微软雅黑',
  313. size: 11,
  314. color: { argb: '000000' }
  315. }
  316. // 对齐 https://github.com/exceljs/exceljs/blob/HEAD/README_zh.md#%E5%AF%B9%E9%BD%90
  317. cell.alignment = {
  318. vertical: 'middle',
  319. horizontal: 'center'
  320. }
  321. })
  322. })
  323. // 导出表格
  324. workbook.xlsx.writeBuffer().then(function (buffer) {
  325. const blob = new Blob([buffer], {
  326. type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  327. })
  328. const link = document.createElement('a')
  329. link.href = URL.createObjectURL(blob)
  330. link.download = '督办台账' + sp.format(sp.getLocalDate()) + '.xlsx'
  331. link.click()
  332. URL.revokeObjectURL(link.href) // 下载完成释放掉blob对象
  333. })
  334. //})
  335. }
  336. self.printOut = function () {
  337. $.ajax({
  338. url: apiurljs.login + "g2app/dataabase/ExpExeclWithDataAndOpinion_ByParam",
  339. type: 'POST',
  340. cache: false,
  341. xhr: function () {
  342. var xhr = new XMLHttpRequest();
  343. xhr.onreadystatechange = function () {
  344. if (xhr.readyState == 2) {
  345. if (xhr.status == 200) {
  346. xhr.responseType = "blob";
  347. } else {
  348. xhr.responseType = "text";
  349. }
  350. }
  351. };
  352. return xhr;
  353. },
  354. headers: {
  355. "Content-Type": "application/json",
  356. "file-argument": s4.encryptData_CBC("execlCol|督办名称,主办处室,会办处室,督办时限,办理结果,办理情况,附件&tablename|DCDB_SXDBD&columns|ROUTEINFOID,DBSX1,QTBM,XZBM,DBSX,BLJG&opinion_col|ZBBMCLQK&pageno|" + self.pageno + "&pagesize|" + self.itemsPerPage + "&order|ROUTEINFOID&sqlwhere|and DBLX = 'C02'&dateform|yyyy-MM-dd&attachtype|单项督办")
  357. },
  358. success: function (res) {
  359. download(res, "会议督办" + sp.getLocalDate() + ".et")
  360. },
  361. })
  362. }
  363. //头部下滚冻结
  364. $(function () {
  365. //页面高度撑满
  366. setTimeout(function () {
  367. if ($(".ibox-content").height() < $(window).height() - 31) {
  368. $(".ibox-content").css("height", $(window).height() - 31)
  369. }
  370. }, 1)
  371. })
  372. }])
  373. function download(data, filename, mime, bom) {
  374. var blobData = typeof bom !== "undefined" ? [bom, data] : [data];
  375. var blob = new Blob(blobData, { type: mime || "application/octet-stream" });
  376. if (typeof window.navigator.msSaveBlob !== "undefined") {
  377. // IE workaround for "HTML7007: One or more blob URLs were
  378. // revoked by closing the blob for which they were created.
  379. // These URLs will no longer resolve as the data backing
  380. // the URL has been freed."
  381. window.navigator.msSaveBlob(blob, filename);
  382. } else {
  383. var blobURL =
  384. window.URL && window.URL.createObjectURL
  385. ? window.URL.createObjectURL(blob)
  386. : window.webkitURL.createObjectURL(blob);
  387. var tempLink = document.createElement("a");
  388. tempLink.style.display = "none";
  389. tempLink.href = blobURL;
  390. tempLink.setAttribute("download", filename);
  391. // Safari thinks _blank anchor are pop ups. We only want to set _blank
  392. // target if the browser does not support the HTML5 download attribute.
  393. // This allows you to download files in desktop safari if pop up blocking
  394. // is enabled.
  395. if (typeof tempLink.download === "undefined") {
  396. tempLink.setAttribute("target", "_blank");
  397. }
  398. document.body.appendChild(tempLink);
  399. tempLink.click();
  400. // Fixes "webkit blob resource error 1"
  401. setTimeout(function () {
  402. document.body.removeChild(tempLink);
  403. window.URL.revokeObjectURL(blobURL);
  404. }, 200);
  405. }
  406. }