list.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("listCtrl", ["$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.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
  12. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  13. self.get_type = sp.getUrlName("type");
  14. self.params = sp.getUrlName("params");
  15. self.getflowids = sp.getUrlName("flowids")
  16. var postCfg = {
  17. headers: {
  18. 'Content-Type': 'application/json',
  19. 'Authorization': "Bearer " + self.get_AccessToken
  20. }
  21. }
  22. self.type = self.get_type != "" ? self.get_type : "todo";
  23. self.Url = getUrl(self.type);
  24. self.CrossPage = window.parent.CrossPage;
  25. self.loading = false;
  26. self.search = null//JSON.parse($.cookie("GlWorkPlatform-fawendw"));
  27. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  28. self.pageno = 1;
  29. self.total_count = 0;
  30. self.itemsPerPage = 20;
  31. self.pageOptions = [20, 40, 60];
  32. self.getGWZL = function () {
  33. var data = {
  34. tablename: "CODE_GWTYPE",
  35. colums: "ID,CODE,CNAME,FLOWID",
  36. order: "ID desc",
  37. sqlwhere: {
  38. USEMARK: 1
  39. },
  40. sqlinwhere: { FLOWID: self.flowids.map(function (item) { return "'" + item.ID + "'" }).join(",") },
  41. sqllikewhere: ""
  42. }
  43. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  44. .success(function (obj) {
  45. var res = strToJson(s4.decryptData_CBC(obj.data));
  46. self.GWZL = res.data;
  47. self.getJJLB()
  48. })
  49. }
  50. self.getJJLB = function () {
  51. var data = {
  52. ckey: "CODE_JJLB",
  53. routeinfoid: self.routeinfoid
  54. }
  55. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  56. .success(function (obj) {
  57. var res = strToJson(s4.decryptData_CBC(obj.data));
  58. self.JJLB = res.data.CODE_JJLB;
  59. self.load()
  60. })
  61. }
  62. self.ordercondition = []
  63. self.flowids = [{ ID: "AA88", NAME: "党委正式文上行文", checked: false },
  64. { ID: "AA89", NAME: "党委正式文下行文", checked: false },
  65. { ID: "AA46", NAME: "党委会议纪要", checked: false },
  66. { ID: "AA22", NAME: "党委其他文件", checked: false },
  67. { ID: "AA54", NAME: "党委督查专报", checked: false }]
  68. if (self.getflowids != "") {
  69. self.flowids = self.flowids.filter(function (item) {
  70. if (self.getflowids.indexOf(item.ID) > -1) {
  71. return true
  72. }
  73. })
  74. }
  75. self.getData = function (pageno) {
  76. if (self.search == null) {
  77. self.search = {
  78. FLOW: [],
  79. JJLB: [],
  80. GWZL: [],
  81. TITLE: "",
  82. DATE1: "",
  83. DATE2: "",
  84. NGRBM: '',
  85. NGR: ''
  86. }
  87. }
  88. var urlflowids = self.flowids.map(function (item) { return item.ID }).join("|");
  89. var flowids = self.search.FLOW.join("|");
  90. var querycondition = [];
  91. var columnscondition = [
  92. { COLID: "JJLB", COLUMNS: "FW_DWDCZB.JJLB|FW_DWHYJY.JJLB|FW_DWQTWJ.JJLB|FW_DWZSWSXW.JJLB|FW_DWZSWXXW.JJLB" },
  93. { COLID: "GWZL", COLUMNS: "FW_DWDCZB.GWZL|FW_DWHYJY.GWZL|FW_DWQTWJ.GWZL|FW_DWZSWSXW.GWZL|FW_DWZSWXXW.GWZL" },
  94. { COLID: "NGRBM", COLUMNS: "FW_DWDCZB.NGRBM|FW_DWHYJY.NGRBM|FW_DWQTWJ.NGRBM|FW_DWZSWSXW.NGRBM|FW_DWZSWXXW.NGRBM" },
  95. { COLID: "NGR", COLUMNS: "FW_DWDCZB.NGR|FW_DWHYJY.NGR|FW_DWQTWJ.NGR|FW_DWZSWSXW.NGR|FW_DWZSWXXW.NGR" }
  96. ]
  97. if (self.search.JJLB != "") {
  98. querycondition.push({ "CKIND": "VARLIST", "TABLEID": "CODETABLE", "COLID": "TITLE", "VALUEA": self.search.JJLB.join(","), "VALUEB": "" })
  99. }
  100. if (self.search.GWZL != "") {
  101. querycondition.push({ "CKIND": "VARLIST", "TABLEID": "CODETABLE", "COLID": "GWZL", "VALUEA": self.search.GWZL.join(","), "VALUEB": "" })
  102. }
  103. if (self.search.TITLE != "") {
  104. querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "TITLE", "VALUEA": self.search.TITLE, "VALUEB": "" })
  105. }
  106. if (self.search.NGRBM != "") {
  107. querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "CODETABLE", "COLID": "NGRBM", "VALUEA": self.search.NGRBM, "VALUEB": "" })
  108. }
  109. if (self.search.NGR != "") {
  110. querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "CODETABLE", "COLID": "NGR", "VALUEA": self.search.NGR, "VALUEB": "" })
  111. }
  112. if (self.params != "") {
  113. querycondition.push({ "CKIND": "VARLIST", "TABLEID": "SYS_ROUTE", "COLID": "ROUTEID", "VALUEA": self.params, "VALUEB": "" })
  114. }
  115. if (self.search.DATE1 != "" && self.search.DATE2 != "") {
  116. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": self.search.DATE1, "VALUEB": self.search.DATE2 })
  117. } else if (self.search.DATE1 != "" && self.search.DATE2 == "") {
  118. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": self.search.DATE1, "VALUEB": "" })
  119. } else if (self.search.DATE1 == "" && self.search.DATE2 != "") {
  120. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": "", "VALUEB": self.search.DATE2 })
  121. }
  122. self.list = [];
  123. self.loading = true;
  124. self.pageno = pageno;
  125. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  126. var data = {
  127. //flowid: "AA05|AA22|AA44|AA45|AA46|AA47|AA48|AA54|AA58|AA59|AA60|AA61|AA62",
  128. //"AA88|AA89|AA46|AA22|AA54|AA58|AA98|AA99|AA0E"
  129. flowid: flowids != "" ? flowids : urlflowids != "" ? urlflowids : "AA88|AA89|AA46|AA22|AA54",
  130. userid: self.userId,
  131. pageno: self.pageno,
  132. pagesize: self.itemsPerPage,
  133. columnscondition: JSON.stringify(columnscondition),
  134. querycondition: JSON.stringify(querycondition),
  135. ordercondition: self.ordercondition.length == 0 ? "" : JSON.stringify(self.ordercondition)
  136. }
  137. //$http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  138. $http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, data, postCfg)
  139. .success(function (obj) {
  140. var res = obj;
  141. //var res = strToJson(s4.decryptData_CBC(obj.data));
  142. self.loading = false;
  143. if (res.data == null || res.data == undefined || res.data == "") {
  144. self.noDataTip = 0;
  145. if (self.params != "") {
  146. self.params = "";
  147. self.getData(1)
  148. }
  149. } else {
  150. self.noDataTip = 1;
  151. self.list = res.data;
  152. self.total_count = res.totalCount;
  153. $.each(self.list, function (index, item) {
  154. self.JJLB.forEach(function (item1) {
  155. if (item.JJLB == item1.CODE)
  156. item.JJLB = item1.CNAME
  157. })
  158. self.GWZL.forEach(function (item1) {
  159. if (item.GWZL == item1.CODE)
  160. item.GWZL = item1.CNAME
  161. })
  162. if (item.FILEN != "") {
  163. 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;
  164. } else {
  165. item.FILEN = "#";
  166. }
  167. if (item.TODOLIST) {
  168. item.TODOLIST.forEach(function (item1) {
  169. if (item1.FILEN != "") {
  170. item1.FILEN = item1.FILEN.indexOf("dotype") > -1 ? item1.FILEN.replace("dotype=1", "dotype=" + getDoType(self.type)) + "&type=" + self.type + "&lastReturnPageno=" + self.pageno + "&flowid=" + item.FLOWID : item1.FILEN + "&dotype=" + getDoType(self.type) + "&type=" + self.type + "&lastReturnPageno=" + self.pageno + "&flowid=" + item.FLOWID;
  171. } else {
  172. item1.FILEN = "#";
  173. }
  174. })
  175. }
  176. if (self.type == "finish") {
  177. item.RECEIVEDATE = item.FINISHEDDATE;
  178. }
  179. })
  180. }
  181. if (self.CrossPage.type == 0) {
  182. self.journalRecord(self.CrossPage.ctime, sp.getLocalDate1(), "", "接入日志", window.location.pathname)
  183. }
  184. })
  185. }
  186. self.load = function () {
  187. if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
  188. self.getData(self.pageno);
  189. } else {
  190. $timeout(function () {
  191. self.getData(self.get_lastReturnPageno);
  192. }, 1)
  193. }
  194. }
  195. self.sortFiled = function (str) {
  196. var n = 0, obj, x = -1;
  197. self.ordercondition.forEach(function (item, index) {
  198. if (item.COLID == str) {
  199. n++
  200. item.SORTTYPE = item.SORTTYPE == "" || item.SORTTYPE == "asc" ? "desc" : "asc"
  201. obj = item; x = index
  202. }
  203. })
  204. if (n == 0) {
  205. self.ordercondition.unshift({ COLID: str, SORTTYPE: "desc" })
  206. }
  207. if (x != -1) {
  208. self.ordercondition.splice(x, 1)
  209. self.ordercondition.unshift(obj)
  210. }
  211. self.getData(1);
  212. }
  213. self.getGWZL();
  214. self.openLayer = function () {
  215. self.params = "";
  216. if (self.search == null) {
  217. self.search = {
  218. FLOW: [],
  219. JJLB: [],
  220. GWZL: [],
  221. TITLE: "",
  222. DATE1: "",
  223. DATE2: "",
  224. NGRBM: '',
  225. NGR: ''
  226. }
  227. } else {
  228. self.flowids.forEach(function (item) {
  229. item.checked = false;
  230. if (self.search.FLOW.indexOf(item.ID) > -1) {
  231. item.checked = true;
  232. }
  233. })
  234. self.JJLB.forEach(function (item) {
  235. item.checked = false;
  236. if (self.search.JJLB.indexOf(item.CODE) > -1) {
  237. item.checked = true;
  238. }
  239. })
  240. self.GWZL.forEach(function (item) {
  241. item.checked = false;
  242. if (self.search.GWZL.indexOf(item.CODE) > -1) {
  243. item.checked = true;
  244. }
  245. })
  246. }
  247. sp.layer("#Search")
  248. }
  249. self.doSearch = function () {
  250. self.search.FLOW = [];
  251. self.flowids.forEach(function (item) {
  252. if (item.checked == true) {
  253. self.search.FLOW.push(item.ID)
  254. }
  255. })
  256. self.search.JJLB = [];
  257. self.JJLB.forEach(function (item) {
  258. if (item.checked == true) {
  259. self.search.JJLB.push(item.CODE)
  260. }
  261. })
  262. self.search.GWZL = [];
  263. self.GWZL.forEach(function (item) {
  264. if (item.checked == true) {
  265. self.search.GWZL.push(item.CODE)
  266. }
  267. })
  268. $.cookie("GlWorkPlatform-fawendw", JSON.stringify(self.search), { path: '/', expires: 1 });
  269. self.getData(self.pageno)
  270. sp.layerhide()
  271. }
  272. self.cancal = function () {
  273. self.search = {
  274. FLOW: [],
  275. JJLB: [],
  276. GWZL: [],
  277. TITLE: "",
  278. DATE1: "",
  279. DATE2: "",
  280. NGRBM: '',
  281. NGR: ''
  282. }
  283. $.cookie("GlWorkPlatform-fawendw", null, { path: '/', expires: 1 });
  284. self.getData(1)
  285. sp.layerhide()
  286. }
  287. self.refresh = function () {
  288. self.CrossPage.type = null;
  289. self.getData(self.pageno);
  290. }
  291. self.goUrl = function (item) {
  292. if (item.TODOLIST && item.TODOLIST.length > 1) {
  293. self.todoTitle = item.TITLE;
  294. self.todoList = item.TODOLIST;
  295. sp.layer("#todolist")
  296. } else {
  297. if (self.deviceType == "pad") {
  298. window.location.href = item.FILEN + "&dotype=" + getDoType(self.type)
  299. } else {
  300. sp.openNewWindow(item.FILEN + "&dotype=" + getDoType(self.type), item.TITLE)
  301. }
  302. sp.layerhide();
  303. }
  304. }
  305. self.btnDel = function (item) {
  306. var data = {
  307. routeinfoid: item.ROUTEINFOID,
  308. userid: self.userId
  309. }
  310. $http.post(apiurljs.login + "g2work/routeinfo/deleteDraftByRouteinfoid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  311. .success(function (obj) {
  312. var res = strToJson(s4.decryptData_CBC(obj.data));
  313. if (res.success == true) {
  314. self.getData(self.pageno)
  315. } else {
  316. sp.dialog(res.message)
  317. }
  318. })
  319. }
  320. self.btnRecall = function (routeid, kind) {
  321. var data = {
  322. routeid: routeid,
  323. kind: kind,
  324. userid: self.userId
  325. }
  326. $http.post(apiurljs.login + "g2work/routeinfo/queryDataRecallDoneByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  327. .success(function (obj) {
  328. var res = strToJson(s4.decryptData_CBC(obj.data));
  329. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  330. var dialogBody = "<div class=\"sp-dialog-body\">" + res.data.REMARK + "</div>";
  331. 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>";
  332. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  333. sp.openCenter(".sp-dialog");
  334. ///取消按钮
  335. $('.sp-closeDialog').click(function (event) {
  336. sp.closeCenter(".sp-dialog");
  337. event.preventDefault();
  338. event.stopPropagation();
  339. });
  340. //post消息的id
  341. $("#delDataTrue").click(function () {
  342. $http.post(apiurljs.login + "g2work/routeinfo/recallDoneByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  343. .success(function (obj) {
  344. var res = strToJson(s4.decryptData_CBC(obj.data));
  345. sp.dialoghide()
  346. if (res.success == true) {
  347. self.getData(self.pageno)
  348. } else {
  349. sp.dialog(res.message)
  350. }
  351. })
  352. });
  353. })
  354. }
  355. self.changeType = function (str) {
  356. if (self.type == str) {
  357. return;
  358. } else {
  359. var time1 = sp.getLocalDate1();
  360. self.journalRecord(time1, sp.getLocalDate1(), "查询", "查询日志", "/g2work/routeinfo/" + self.Url)
  361. self.type = str;
  362. self.Url = getUrl(self.type);
  363. self.getData(1)
  364. }
  365. }
  366. self.getAddFlag = function () {
  367. var data = {
  368. userid: self.userId,
  369. ntops: 0
  370. }
  371. $http.post(apiurljs.login + "g2work/desktop/queryWorkflowCando", data, postCfg)
  372. .success(function (obj) {
  373. var res = strToJson(s4.decryptData_CBC(obj.data));
  374. self.lcList = [];
  375. self.activeLC = {};
  376. var urlflowids = self.flowids.map(function (item) { return item.ID }).join("|");
  377. var flows = urlflowids != "" ? urlflowids : "AA88|AA89|AA46|AA22|AA54";
  378. res.data.forEach(function (item) {
  379. //if ("AA05|AA22|AA44|AA45|AA46|AA47|AA48|AA54|AA58|AA59|AA60|AA61|AA62".indexOf(item.FLOWID) > -1) {
  380. if (flows.indexOf(item.FLOWID) > -1) {
  381. self.lcList.push(item);
  382. }
  383. })
  384. })
  385. }
  386. self.getAddFlag()
  387. self.addLC = function () {
  388. if (self.lcList.length == 1) {
  389. sp.openNewWindow(self.lcList[0].FILEN + "&dotype=1&GWCODE=" + self.lcList[0].CODE + "&flowid=" + self.lcList[0].FLOWID, self.lcList[0].FLOWNAME)
  390. //window.location.href = self.lcList[0].FILEN + "&dotype=1&GWCODE=" + self.activeLC.CODE + "&flowid=" + self.activeLC.FLOWID
  391. } else {
  392. sp.layer("#addLC");
  393. }
  394. }
  395. self.seeLCT = function (item,event) {
  396. event.preventDefault();
  397. event.stopPropagation();
  398. }
  399. self.goAddUrl = function () {
  400. if (!self.activeLC.FILEN) {
  401. return
  402. }
  403. sp.openNewWindow(self.activeLC.FILEN + "&dotype=1&GWCODE=" + self.activeLC.CODE + "&flowid=" + self.activeLC.FLOWID, self.activeLC.FLOWNAME)
  404. //window.location.href = self.activeLC.FILEN + "&dotype=1&GWCODE=" + self.activeLC.CODE + "&flowid=" + self.activeLC.FLOWID
  405. sp.layerhide()
  406. }
  407. //记录日志
  408. self.journalRecord = function (time1, time2, title, func, url) {
  409. if (!self.CrossPage || !self.CrossPage.cname) { return; }
  410. var data = {
  411. tablename: "SYS_CLICKLOG",
  412. data: {
  413. CTIME: time1 == null ? sp.getLocalDate1() : time1,
  414. TITLE: (title != "" ? self.CrossPage.cname + "/" + title : self.CrossPage.cname),
  415. REQUESTURL: url,
  416. REQUESTHEADERURL: window.location.origin,
  417. LOGTYPE: func,
  418. USERTYPE: $.cookie("GlWorkPlatform-userType"),
  419. ADMIN: $.cookie("GlWorkPlatform-userTypeEng"),
  420. CLIENTIP: sp.myIP(),
  421. PCNAME: sp.detectOS(),
  422. BROWSERNAME: sp.browser(),
  423. RESPONSETIME: time2 == null ? sp.getLocalDate1() : time2,
  424. USERID: self.userId,
  425. USERNAME: self.userName
  426. }
  427. }
  428. $http.post(apiurljs.login + "g2app/dataabase/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  429. .success(function (res) {
  430. self.CrossPage.type = 1;
  431. })
  432. }
  433. $interval(function () {
  434. if (localStorage.getItem("GlWorkPlatform-fawendw-refresh") == 1) {
  435. localStorage.removeItem("GlWorkPlatform-fawendw-refresh")
  436. self.refresh()
  437. }
  438. }, 1000)
  439. //头部下滚冻结
  440. $(function () {
  441. //页面高度撑满
  442. setTimeout(function () {
  443. if ($(".ibox-content").height() < $(window).height() - 31) {
  444. $(".ibox-content").css("height", $(window).height() - 31)
  445. }
  446. }, 1)
  447. })
  448. }])
  449. function getUrl(str) {
  450. switch (str) {
  451. case "todo":
  452. return "queryDataTodoWithPage";
  453. break;
  454. case "done":
  455. return "queryDataDoneWithPage";
  456. break;
  457. case "finish":
  458. return "queryDataFinishWithPage";
  459. break;
  460. }
  461. }
  462. function getDoType(str) {
  463. switch (str) {
  464. case "todo":
  465. return 1;
  466. break;
  467. default:
  468. return 0;
  469. break;
  470. }
  471. }