list.js 19 KB

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