list.js 17 KB

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