taizhang.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("taizhangCtrl", ["$scope", "$http", "$timeout", "$interval", function ($scope, $http, $timeout, $interval) {
  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.type1st = 1;
  19. self.loading = false;
  20. self.search = {
  21. WJBT: "",
  22. WH: ""
  23. };
  24. self.pageno = 1;
  25. self.total_count = 0;
  26. self.itemsPerPage = 10;
  27. self.pageOptions = [10, 20, 30, 40];
  28. self.getData1 = function (pageno) {
  29. self.list = [];
  30. self.loading = false;
  31. self.pageno = pageno;
  32. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  33. var data = {
  34. tablename: "FW_GFXWJTZ",
  35. pagesize: self.itemsPerPage,
  36. pageno: self.pageno,
  37. colums: "*",
  38. order: "WJDQRQ",
  39. sqlwhere: { ZT: "0" },
  40. sqlorwhere: "",
  41. sqlinwhere: "",
  42. sqllikewhere: { WJBT: self.search.WJBT, WH: self.search.WH }
  43. };
  44. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  45. .success(function (obj) {
  46. var res = strToJson(s4.decryptData_CBC(obj.data));
  47. self.loading = false;
  48. self.list = res.data;
  49. self.total_count = res.totalCount;
  50. self.list.forEach(function (item) {
  51. item.WJSXRQ = sp.format(item.WJSXRQ)
  52. item.WJDQRQ = sp.format(item.WJDQRQ)
  53. if (item.WJDQRQ != "" && item.WJDQRQ != null) {
  54. item.DAYS = (new Date(item.WJDQRQ).getTime() - new Date(sp.dateCount(0)).getTime()) / 86400000
  55. item.DAYS1 = (item.DAYS < 0) ? "超期" + item.DAYS * -1 + "天" : item.DAYS + "天"
  56. item.LQTS = {
  57. //"background-color": item.DAYS <= 90 ? "red" : item.DAYS <= 365 && item.DAYS > 90 ? "yellow" : item.DAYS == 365 ? "blue" : "",
  58. "color": "black"
  59. }
  60. } else {
  61. item.DAYS1 = ""
  62. item.LQTS = {
  63. "color": "black"
  64. }
  65. }
  66. })
  67. })
  68. }
  69. self.getData1(self.pageno);
  70. self.openLayer = function () {
  71. if (self.type1st == 2) {
  72. if (self.search2 == null) {
  73. self.search2 = {
  74. FLOW: [],
  75. BT: "",
  76. USER: "",
  77. DATE1: "",
  78. DATE2: ""
  79. }
  80. } else {
  81. self.flowids.forEach(function (item) {
  82. item.checked = false;
  83. if (self.search2.FLOW.indexOf(item.ID) > -1) {
  84. item.checked = true;
  85. }
  86. })
  87. }
  88. }
  89. sp.layer("#Search")
  90. }
  91. self.doSearch = function () {
  92. if (self.type1st == 1) {
  93. self.getData1(self.pageno);
  94. } else {
  95. self.search2.FLOW = [];
  96. self.flowids.forEach(function (item) {
  97. if (item.checked == true) {
  98. self.search2.FLOW.push(item.ID)
  99. }
  100. })
  101. $.cookie("GlWorkPlatform-gfxwjtz", JSON.stringify(self.search2), { path: '/', expires: 1 });
  102. self.getData2(self.pageno)
  103. }
  104. sp.layerhide()
  105. }
  106. self.cancal = function () {
  107. if (self.type1st == 1) {
  108. self.search = {
  109. BT: "",
  110. FWZH: ""
  111. };
  112. self.getData1(1)
  113. } else {
  114. self.search2 = {
  115. FLOW: [],
  116. BT: "",
  117. USER: "",
  118. DATE1: "",
  119. DATE2: ""
  120. }
  121. $.cookie("GlWorkPlatform-gfxwjtz", null, { path: '/', expires: 1 });
  122. self.getData2(1)
  123. }
  124. sp.layerhide()
  125. }
  126. self.refresh = function () {
  127. if (self.type1st == 1) {
  128. self.getData1(self.pageno);
  129. } else {
  130. self.getData2(self.pageno);
  131. }
  132. }
  133. self.goUrl = function (obj) {
  134. console.log(obj)
  135. sp.openNewWindow("detail.html?id=" + obj.ID, obj.WJBT)
  136. }
  137. self.printOut = function () {
  138. if (self.canExportExcel) {
  139. $('#table td').attr('t', 's')
  140. var defaultCellStyle = {
  141. font: {
  142. name: 'Times New Roman',
  143. sz: 12,
  144. color: {
  145. rgb: "000000"
  146. },
  147. bold: false, italic: false,
  148. underline: false
  149. },
  150. alignment: {
  151. vertical: "center",
  152. horizontal: "center", indent: 0, wrapText: true
  153. },
  154. border: {
  155. top: {
  156. style: "thin",
  157. color: {
  158. rgb: "000000"
  159. }
  160. },
  161. right: {
  162. style: "thin",
  163. color: {
  164. rgb: "000000"
  165. }
  166. },
  167. bottom: {
  168. style: "thin",
  169. color: {
  170. rgb: "000000"
  171. }
  172. },
  173. left: {
  174. style: "thin",
  175. color: {
  176. rgb: "000000"
  177. }
  178. }
  179. }
  180. };
  181. var cell = { defaultCellStyle: defaultCellStyle };
  182. var wb = XLSX.utils.table_to_book_addtitle(document.querySelector('#table'), cell, "规范性文件台账")
  183. //设置表格的样式
  184. var wbout = XLSX.write(wb, {
  185. bookType: 'xlsx',
  186. bookSST: false,
  187. type: 'binary',
  188. cellStyles: true,
  189. defaultCellStyle: defaultCellStyle,
  190. showGridLines: false
  191. });
  192. var s2ab = function (s) {
  193. var buf = new ArrayBuffer(s.length);
  194. var view = new Uint8Array(buf);
  195. for (var i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
  196. return buf;
  197. };
  198. try {
  199. saveAs(new Blob([s2ab(wbout)], { type: 'application/octet-stream' }), '规范性文件台账.xlsx')
  200. } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) }
  201. return wbout
  202. } else {
  203. sp.dialog('数据还未加载完成,请稍等...')
  204. }
  205. }
  206. self.getData = function (pageno) {
  207. if (self.type1st == 1) {
  208. self.getData1(pageno)
  209. } else {
  210. self.getData2(pageno)
  211. }
  212. }
  213. self.type = "todo";
  214. self.Url = getUrl(self.type);
  215. self.search2 = JSON.parse($.cookie("GlWorkPlatform-gfxwjtz"));
  216. self.getZRBM = function () {
  217. var data = {
  218. ckey: "CODE_ZRBM",
  219. routeinfoid: self.routeinfoid
  220. }
  221. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  222. .success(function (obj) {
  223. var res = strToJson(s4.decryptData_CBC(obj.data));
  224. self.ZRBM = res.data.CODE_ZRBM;
  225. self.getLM()
  226. })
  227. }
  228. self.getLM = function () {
  229. var data = {
  230. ckey: "CODE_LM",
  231. routeinfoid: self.routeinfoid
  232. }
  233. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  234. .success(function (obj) {
  235. var res = strToJson(s4.decryptData_CBC(obj.data));
  236. self.LM = res.data.CODE_LM;
  237. })
  238. }
  239. self.flowids = [{ ID: "AA73", NAME: "规范性文件清理督办", checked: false }]
  240. self.getData2 = function (pageno) {
  241. if (self.search2 == null) {
  242. self.search2 = {
  243. FLOW: [],
  244. BT: "",
  245. USER: "",
  246. DATE1: "",
  247. DATE2: ""
  248. }
  249. }
  250. var flowids = self.search2.FLOW.join("|");
  251. var querycondition = [];
  252. if (self.search2.BT != "") {
  253. querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "TITLE", "VALUEA": self.search2.BT, "VALUEB": "" })
  254. }
  255. if (self.search2.USER != "") {
  256. querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "USERNAMEFROM", "VALUEA": self.search2.USER, "VALUEB": "" })
  257. }
  258. if (self.search2.DATE1 != "" && self.search2.DATE2 != "") {
  259. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": self.search2.DATE1, "VALUEB": self.search2.DATE2 })
  260. } else if (self.search2.DATE1 != "" && self.search2.DATE2 == "") {
  261. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": self.search2.DATE1, "VALUEB": "" })
  262. } else if (self.search2.DATE1 == "" && self.search2.DATE2 != "") {
  263. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": "", "VALUEB": self.search2.DATE2 })
  264. }
  265. self.list = [];
  266. self.pageno = pageno;
  267. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  268. var data = {
  269. flowid: flowids == "" ? "AA73" : flowids,
  270. userid: self.userId,
  271. pageno: self.pageno,
  272. pagesize: self.itemsPerPage,
  273. querycondition: JSON.stringify(querycondition)
  274. }
  275. //$http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  276. $http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, data, postCfg)
  277. .success(function (obj) {
  278. var res = obj;
  279. //var res = strToJson(s4.decryptData_CBC(obj.data));
  280. self.loading = false;
  281. if (res.data == null || res.data == undefined || res.data == "") {
  282. self.noDataTip = 0;
  283. } else {
  284. self.noDataTip = 1;
  285. self.list = res.data;
  286. self.total_count = res.totalCount;
  287. $.each(self.list, function (index, item) {
  288. self.LM.forEach(function (item1) {
  289. if (item[item.CODETABLE + ".LX"]) {
  290. if (item[item.CODETABLE + ".LX"] == item1.CODE)
  291. item.LX = item1.CNAME
  292. } else {
  293. if (item[item.CODETABLE + ".LM"] == item1.CODE)
  294. item.LX = item1.CNAME
  295. }
  296. })
  297. self.ZRBM.forEach(function (item2) {
  298. if (item[item.CODETABLE + ".FBBM"] == item2.CODE) {
  299. item.FBBM = item2.CNAME;
  300. }
  301. })
  302. if (item.FILEN != "") {
  303. item.FILEN = item.FILEN.indexOf("dotype") > -1 ? item.FILEN.replace("dotype=1", "dotype=" + getDoType(self.type)) + "&type=" + self.type + "&lastReturnPageno=" + self.pageno + "&flowid=" + item.FLOWID : item.FILEN + "&dotype=" + getDoType(self.type) + "&type=" + self.type + "&lastReturnPageno=" + self.pageno + "&flowid=" + item.FLOWID;
  304. } else {
  305. item.FILEN = "#";
  306. }
  307. if (self.type == "finish") {
  308. item.RECEIVEDATE = item.FINISHEDDATE;
  309. }
  310. })
  311. }
  312. })
  313. }
  314. self.getZRBM();
  315. self.goUrl1 = function (item) {
  316. sp.openNewWindow(item.FILEN + "&dotype=" + getDoType(self.type), item.TITLE)
  317. }
  318. self.btnDel = function (item) {
  319. var data = {
  320. routeinfoid: item.ROUTEINFOID,
  321. userid: self.userId
  322. }
  323. $http.post(apiurljs.login + "g2work/routeinfo/deleteDraftByRouteinfoid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  324. .success(function (obj) {
  325. var res = strToJson(s4.decryptData_CBC(obj.data));
  326. if (res.success == true) {
  327. self.getData2(self.pageno)
  328. } else {
  329. sp.dialog(res.message)
  330. }
  331. })
  332. }
  333. self.btnRecall = function (routeid) {
  334. var data = {
  335. routeid: routeid,
  336. userid: self.userId
  337. }
  338. $http.post(apiurljs.login + "g2work/routeinfo/queryDataRecallDoneByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  339. .success(function (obj) {
  340. var res = strToJson(s4.decryptData_CBC(obj.data));
  341. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  342. var dialogBody = "<div class=\"sp-dialog-body\">" + res.data.REMARK + "</div>";
  343. var dialogFoot = "<div class=\"sp-dialog-foot\"><input id='delDataTrue' type='button' value='撤 回' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
  344. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  345. sp.openCenter(".sp-dialog");
  346. ///取消按钮
  347. $('.sp-closeDialog').click(function (event) {
  348. sp.closeCenter(".sp-dialog");
  349. event.preventDefault();
  350. event.stopPropagation();
  351. });
  352. //post消息的id
  353. $("#delDataTrue").click(function () {
  354. $http.post(apiurljs.login + "g2work/routeinfo/recallDoneByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  355. .success(function (obj) {
  356. var res = strToJson(s4.decryptData_CBC(obj.data));
  357. sp.dialoghide()
  358. if (res.success == true) {
  359. self.getData2(self.pageno)
  360. } else {
  361. sp.dialog(res.message)
  362. }
  363. })
  364. });
  365. })
  366. }
  367. self.changeType = function (str) {
  368. if (self.type == str) {
  369. return;
  370. } else {
  371. self.type = str;
  372. self.Url = getUrl(self.type);
  373. self.getData2(1)
  374. }
  375. }
  376. self.getAddFlag = function () {
  377. var data = {
  378. userid: self.userId,
  379. ntops: 0
  380. }
  381. $http.post(apiurljs.login + "g2work/desktop/queryWorkflowCando", data, postCfg)
  382. .success(function (obj) {
  383. var res = strToJson(s4.decryptData_CBC(obj.data));
  384. self.lcList = [];
  385. self.activeLC = {};
  386. res.data.forEach(function (item) {
  387. if ("AA73".indexOf(item.FLOWID) > -1) {
  388. self.lcList.push(item);
  389. }
  390. })
  391. })
  392. }
  393. self.getAddFlag()
  394. self.addLC = function () {
  395. if (self.lcList.length == 1) {
  396. sp.openNewWindow(self.lcList[0].FILEN + "&dotype=1&GWCODE=" + self.lcList[0].CODE + "&flowid=" + self.lcList[0].FLOWID, self.lcList[0].FLOWNAME)
  397. } else {
  398. sp.layer("#addLC");
  399. }
  400. }
  401. self.seeLCT = function (item, event) {
  402. event.preventDefault();
  403. event.stopPropagation();
  404. }
  405. self.goAddUrl = function () {
  406. if (!self.activeLC.FILEN) {
  407. return
  408. }
  409. sp.openNewWindow(self.activeLC.FILEN + "&dotype=1&GWCODE=" + self.activeLC.CODE + "&flowid=" + self.activeLC.FLOWID, self.activeLC.FLOWNAME)
  410. sp.layerhide()
  411. }
  412. $interval(function () {
  413. if (localStorage.getItem("GlWorkPlatform-gfxwjtz-refresh") == 1) {
  414. localStorage.removeItem("GlWorkPlatform-gfxwjtz-refresh")
  415. self.refresh()
  416. }
  417. }, 1000)
  418. //头部下滚冻结
  419. $(function () {
  420. //页面高度撑满
  421. setTimeout(function () {
  422. if ($(".ibox-content").height() < $(window).height() - 31) {
  423. $(".ibox-content").css("height", $(window).height() - 31)
  424. }
  425. }, 1)
  426. })
  427. }])
  428. app.directive("repeatFinish", function () {
  429. return {
  430. link: function (scope) {
  431. if (scope.$last == true) {
  432. scope.$parent.ctl.canExportExcel = true;
  433. setTimeout(function () {
  434. //$("#table").rowspan(0)
  435. }, 10);
  436. }
  437. }
  438. };
  439. });
  440. jQuery.fn.rowspan = function (colIdx) { //封装的一个JQuery小插件
  441. return this.each(function () {
  442. var that;
  443. $('tr', this).each(function (row) {
  444. $('td:eq(' + colIdx + ')', this).filter(':visible').each(function (col) {
  445. if (that != null && $(this).html() == $(that).html()) {
  446. var rowspan = $(that).attr("rowSpan");
  447. if (rowspan == undefined) {
  448. $(that).attr("rowSpan", 1);
  449. rowspan = $(that).attr("rowSpan");
  450. }
  451. rowspan = Number(rowspan) + 1;
  452. $(that).attr("rowSpan", rowspan);
  453. $(this).remove();
  454. } else {
  455. that = this;
  456. }
  457. });
  458. });
  459. });
  460. }
  461. function getUrl(str) {
  462. switch (str) {
  463. case "todo":
  464. return "queryDataTodoWithPage";
  465. break;
  466. case "done":
  467. return "queryDataDoneWithPage";
  468. break;
  469. case "finish":
  470. return "queryDataFinishWithPage";
  471. break;
  472. }
  473. }
  474. function getDoType(str) {
  475. switch (str) {
  476. case "todo":
  477. return 1;
  478. break;
  479. case "finish":
  480. return 1;
  481. break;
  482. default:
  483. return 0;
  484. break;
  485. }
  486. }