list.js 16 KB

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