list.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("listCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) {
  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.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  12. self.get_type = sp.getUrlName("type");
  13. var postCfg = {
  14. headers: {
  15. 'Content-Type': 'application/json',
  16. 'Authorization': "Bearer " + self.get_AccessToken
  17. }
  18. }
  19. self.type = self.get_type != "" ? self.get_type : "todo";
  20. self.Url = getUrl(self.type);
  21. self.CrossPage = window.parent.CrossPage;
  22. self.loading = false;
  23. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  24. self.pageno = 1;
  25. self.total_count = 0;
  26. self.itemsPerPage = 10;
  27. self.pageOptions = [10, 20, 30, 40];
  28. self.getMIJI = function () {
  29. var data = {
  30. ckey: "CODE_SECRET",
  31. routeinfoid: self.routeinfoid
  32. }
  33. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  34. .success(function (obj) {
  35. var res = strToJson(s4.decryptData_CBC(obj.data));
  36. self.MIJI = res.data.CODE_SECRET;
  37. self.getJJQK()
  38. })
  39. }
  40. self.getJJQK = function () {
  41. var data = {
  42. ckey: "CODE_EMERGENCY",
  43. routeinfoid: self.routeinfoid
  44. }
  45. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  46. .success(function (obj) {
  47. var res = strToJson(s4.decryptData_CBC(obj.data));
  48. self.JJQK = res.data.CODE_EMERGENCY;
  49. self.load()
  50. })
  51. }
  52. self.getData = function (pageno) {
  53. self.list = [];
  54. self.loading = false;
  55. self.pageno = pageno;
  56. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  57. var data = {
  58. flowid: "",
  59. userid: self.userId,
  60. pageno: self.pageno,
  61. pagesize: self.itemsPerPage
  62. }
  63. $http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  64. .success(function (obj) {
  65. var res = strToJson(s4.decryptData_CBC(obj.data));
  66. self.loading = false;
  67. if (res.data == null || res.data == undefined || res.data == "") {
  68. self.noDataTip = 0;
  69. } else {
  70. self.noDataTip = 1;
  71. self.list = res.data;
  72. self.total_count = res.totalCount;
  73. $.each(self.list, function (index, item) {
  74. item.LWWH = item[item.CODETABLE + ".WH"] ? item[item.CODETABLE + ".WH"] : item[item.CODETABLE + ".LWWH"];
  75. self.JJQK.forEach(function (item1) {
  76. if (item[item.CODETABLE + ".JJCD"]) {
  77. if (item[item.CODETABLE + ".JJCD"] == item1.CODE)
  78. item.JJCD = item1.CNAME
  79. } else {
  80. if (item[item.CODETABLE + ".JJQK"] == item1.CODE)
  81. item.JJCD = item1.CNAME
  82. }
  83. })
  84. self.MIJI.forEach(function (item1) {
  85. if (item[item.CODETABLE + ".MJ"] == item1.CODE)
  86. item.MIJI = item1.CNAME
  87. })
  88. if (item.FILEN != "") {
  89. 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;
  90. } else {
  91. item.FILEN = "#";
  92. }
  93. if (self.type == "finish") {
  94. item.RECEIVEDATE = item.FINISHEDDATE;
  95. }
  96. })
  97. }
  98. if (self.CrossPage.type == 0) {
  99. self.journalRecord(self.CrossPage.ctime, sp.getLocalDate1(), "", "接入日志", window.location.pathname)
  100. }
  101. })
  102. }
  103. self.load = function () {
  104. if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
  105. self.getData(self.pageno);
  106. } else {
  107. $timeout(function () {
  108. self.getData(self.get_lastReturnPageno);
  109. }, 1)
  110. }
  111. }
  112. self.getMIJI();
  113. self.refresh = function () {
  114. self.CrossPage.type = null;
  115. self.getData(self.pageno);
  116. }
  117. self.goUrl = function (item) {
  118. window.location.href = item.FILEN
  119. }
  120. self.changeType = function (str) {
  121. if (self.type == str) {
  122. return;
  123. } else {
  124. var time1 = sp.getLocalDate1();
  125. self.journalRecord(time1, sp.getLocalDate1(), "查询", "查询日志", "/g2work/routeinfo/" + self.Url)
  126. self.type = str;
  127. self.Url = getUrl(self.type);
  128. self.getData(1)
  129. }
  130. }
  131. self.addLC = function () {
  132. var data = {
  133. userid: self.userId,
  134. ntops: 0
  135. }
  136. $http.post(apiurljs.login + "g2work/desktop/queryWorkflowCando", data, postCfg)
  137. .success(function (obj) {
  138. var res = strToJson(s4.decryptData_CBC(obj.data));
  139. self.lcList = [];
  140. self.activeLC = {};
  141. res.data.forEach(function (item) {
  142. if ("".indexOf(item.FLOWID) > -1) {
  143. self.lcList.push(item);
  144. }
  145. })
  146. if (self.lcList.length == 0) {
  147. sp.dialog("暂无权限!")
  148. } else if (self.lcList.length == 1) {
  149. window.location.href = self.lcList[0].FILEN
  150. } else {
  151. sp.layer("#addLC");
  152. }
  153. })
  154. }
  155. self.seeLCT = function (item,event) {
  156. event.preventDefault();
  157. event.stopPropagation();
  158. }
  159. self.goAddUrl = function () {
  160. window.location.href = self.activeLC.FILEN
  161. }
  162. //记录日志
  163. self.journalRecord = function (time1, time2, title, func, url) {
  164. if (!self.CrossPage.cname) { return; }
  165. var data = {
  166. tablename: "SYS_CLICKLOG",
  167. data: {
  168. CTIME: time1 == null ? sp.getLocalDate1() : time1,
  169. TITLE: (title != "" ? self.CrossPage.cname + "/" + title : self.CrossPage.cname),
  170. REQUESTURL: url,
  171. REQUESTHEADERURL: window.location.origin,
  172. LOGTYPE: func,
  173. USERTYPE: $.cookie("GlWorkPlatform-userType"),
  174. ADMIN: $.cookie("GlWorkPlatform-userTypeEng"),
  175. CLIENTIP: sp.myIP(),
  176. PCNAME: sp.detectOS(),
  177. BROWSERNAME: sp.browser(),
  178. RESPONSETIME: time2 == null ? sp.getLocalDate1() : time2,
  179. USERID: self.userId,
  180. USERNAME: self.userName
  181. }
  182. }
  183. $http.post(apiurljs.login + "g2app/dataabase/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  184. .success(function (res) {
  185. self.CrossPage.type = 1;
  186. })
  187. }
  188. //头部下滚冻结
  189. $(function () {
  190. //页面高度撑满
  191. setTimeout(function () {
  192. if ($(".ibox-content").height() < $(window).height() - 31) {
  193. $(".ibox-content").css("height", $(window).height() - 31)
  194. }
  195. }, 1)
  196. })
  197. }])
  198. function getUrl(str) {
  199. switch (str) {
  200. case "todo":
  201. return "queryDataTodoWithPage";
  202. break;
  203. case "done":
  204. return "queryDataDoneWithPage";
  205. break;
  206. case "finish":
  207. return "queryDataFinishWithPage";
  208. break;
  209. }
  210. }
  211. function getDoType(str) {
  212. switch (str) {
  213. case "todo":
  214. return 1;
  215. break;
  216. default:
  217. return 0;
  218. break;
  219. }
  220. }