list.js 15 KB

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