list.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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.getGWZL = function () {
  29. var data = {
  30. tablename: "CODE_GWTYPE",
  31. colums: "ID,CODE,CNAME,FLOWID",
  32. order: "ID desc",
  33. sqlwhere: {
  34. USEMARK: 1
  35. },
  36. sqlinwhere: "",
  37. sqllikewhere: ""
  38. }
  39. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  40. .success(function (obj) {
  41. var res = strToJson(s4.decryptData_CBC(obj.data));
  42. console.log(res.data)
  43. self.GWZL = res.data;
  44. self.getJJQK()
  45. })
  46. }
  47. self.getJJQK = function () {
  48. var data = {
  49. ckey: "CODE_EMERGENCY",
  50. routeinfoid: self.routeinfoid
  51. }
  52. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  53. .success(function (obj) {
  54. var res = strToJson(s4.decryptData_CBC(obj.data));
  55. self.JJQK = res.data.CODE_EMERGENCY;
  56. self.load()
  57. })
  58. }
  59. self.getData = function (pageno) {
  60. self.list = [];
  61. self.loading = true;
  62. self.pageno = pageno;
  63. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  64. var data = {
  65. //flowid: "AA00|AA00",
  66. flowid: "$JS-FLOWID$",
  67. userid: self.userId,
  68. pageno: self.pageno,
  69. pagesize: self.itemsPerPage
  70. }
  71. console.log(JSON.stringify(data));
  72. $http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  73. .success(function (obj) {
  74. var res = strToJson(s4.decryptData_CBC(obj.data));
  75. self.loading = false;
  76. if (res.data == null || res.data == undefined || res.data == "") {
  77. self.noDataTip = 0;
  78. } else {
  79. self.noDataTip = 1;
  80. self.list = res.data;
  81. //console.log(JSON.stringify(self.list));
  82. self.total_count = res.totalCount;
  83. $.each(self.list, function (index, item) {
  84. item.TITLE_set = item.FLOWNAME + " - " + item.APPCODE;
  85. item.LWWH = item[item.CODETABLE + ".WH"] ? item[item.CODETABLE + ".WH"] : item[item.CODETABLE + ".LWWH"];
  86. self.JJQK.forEach(function (item1) {
  87. if (item[item.CODETABLE + ".JJCD"]) {
  88. if (item[item.CODETABLE + ".JJCD"] == item1.CODE)
  89. item.JJCD = item1.CNAME
  90. } else {
  91. if (item[item.CODETABLE + ".JJQK"] == item1.CODE)
  92. item.JJCD = item1.CNAME
  93. }
  94. })
  95. self.GWZL.forEach(function (item1) {
  96. if (item[item.CODETABLE + ".GWZL"] == item1.CODE)
  97. item.GWZL = item1.CNAME
  98. })
  99. //console.log(item.FILEN);
  100. if (item.FILEN != "") {
  101. 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;
  102. var get_canshu = item.FILEN.split("?")[1];
  103. item.FILEN = "formedit.html?" + get_canshu;
  104. } else {
  105. item.FILEN = "#";
  106. }
  107. if (self.type == "finish") {
  108. item.RECEIVEDATE = item.FINISHEDDATE;
  109. }
  110. })
  111. }
  112. //if (self.CrossPage.type == 0) {
  113. // self.journalRecord(self.CrossPage.ctime, sp.getLocalDate1(), "", "接入日志", window.location.pathname)
  114. //}
  115. }).error(function (err) {
  116. //错误代码
  117. self.list = [];
  118. self.noDataTip = 0;
  119. self.loading = false;
  120. console.log(err);
  121. });
  122. }
  123. self.load = function () {
  124. if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
  125. self.getData(self.pageno);
  126. } else {
  127. $timeout(function () {
  128. self.getData(self.get_lastReturnPageno);
  129. }, 1)
  130. }
  131. }
  132. self.getGWZL();
  133. self.refresh = function () {
  134. self.CrossPage.type = null;
  135. self.getData(self.pageno);
  136. }
  137. self.goUrl = function (item) {
  138. window.location.href = item.FILEN + "&dotype=" + getDoType(self.type)
  139. }
  140. self.btnDel = function (item) {
  141. var data = {
  142. routeinfoid: item.ROUTEINFOID,
  143. userid: self.userId
  144. }
  145. $http.post(apiurljs.login + "g2work/routeinfo/deleteDraftByRouteinfoid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  146. .success(function (obj) {
  147. var res = strToJson(s4.decryptData_CBC(obj.data));
  148. if (res.success == true) {
  149. self.getData(self.pageno)
  150. } else {
  151. sp.dialog(res.message)
  152. }
  153. })
  154. }
  155. self.btnRecall = function (routeid) {
  156. var data = {
  157. routeid: routeid,
  158. userid: self.userId
  159. }
  160. $http.post(apiurljs.login + "g2work/routeinfo/recallDoneByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  161. .success(function (obj) {
  162. var res = strToJson(s4.decryptData_CBC(obj.data));
  163. if (res.success == true) {
  164. self.getData(self.pageno)
  165. } else {
  166. sp.dialog(res.message)
  167. }
  168. })
  169. }
  170. self.changeType = function (str) {
  171. if (self.type == str) {
  172. return;
  173. } else {
  174. var time1 = sp.getLocalDate1();
  175. self.journalRecord(time1, sp.getLocalDate1(), "查询", "查询日志", "/g2work/routeinfo/" + self.Url)
  176. self.type = str;
  177. self.Url = getUrl(self.type);
  178. self.getData(1)
  179. }
  180. }
  181. self.getAddFlag = function () {
  182. var data = {
  183. userid: self.userId,
  184. ntops: 0
  185. }
  186. $http.post(apiurljs.login + "g2work/desktop/queryWorkflowCando", data, postCfg)
  187. .success(function (obj) {
  188. var res = strToJson(s4.decryptData_CBC(obj.data));
  189. self.lcList = [];
  190. self.activeLC = {};
  191. res.data.forEach(function (item) {
  192. if ("$JS-FLOWID$".indexOf(item.FLOWID) > -1) {
  193. self.lcList.push(item);
  194. }
  195. })
  196. })
  197. }
  198. self.getAddFlag()
  199. self.addLC = function () {
  200. if (self.lcList.length == 1) {
  201. window.location.href = self.lcList[0].FILEN + "&dotype=1"
  202. } else {
  203. sp.layer("#addLC");
  204. }
  205. }
  206. self.seeLCT = function (item, event) {
  207. event.preventDefault();
  208. event.stopPropagation();
  209. }
  210. self.goAddUrl = function () {
  211. if (!self.activeLC.FILEN) {
  212. return
  213. }
  214. window.location.href = self.activeLC.FILEN + "&dotype=1"
  215. }
  216. //记录日志
  217. self.journalRecord = function (time1, time2, title, func, url) {
  218. if (!self.CrossPage.cname) { return; }
  219. var data = {
  220. tablename: "SYS_CLICKLOG",
  221. data: {
  222. CTIME: time1 == null ? sp.getLocalDate1() : time1,
  223. TITLE: (title != "" ? self.CrossPage.cname + "/" + title : self.CrossPage.cname),
  224. REQUESTURL: url,
  225. REQUESTHEADERURL: window.location.origin,
  226. LOGTYPE: func,
  227. USERTYPE: $.cookie("GlWorkPlatform-userType"),
  228. ADMIN: $.cookie("GlWorkPlatform-userTypeEng"),
  229. CLIENTIP: sp.myIP(),
  230. PCNAME: sp.detectOS(),
  231. BROWSERNAME: sp.browser(),
  232. RESPONSETIME: time2 == null ? sp.getLocalDate1() : time2,
  233. USERID: self.userId,
  234. USERNAME: self.userName
  235. }
  236. }
  237. $http.post(apiurljs.login + "g2app/dataabase/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  238. .success(function (res) {
  239. self.CrossPage.type = 1;
  240. })
  241. }
  242. //头部下滚冻结
  243. $(function () {
  244. //页面高度撑满
  245. setTimeout(function () {
  246. if ($(".ibox-content").height() < $(window).height() - 31) {
  247. $(".ibox-content").css("height", $(window).height() - 31)
  248. }
  249. }, 1)
  250. })
  251. }])
  252. function getUrl(str) {
  253. switch (str) {
  254. case "todo":
  255. return "queryDataTodoWithPage";
  256. break;
  257. case "done":
  258. return "queryDataDoneWithPage";
  259. break;
  260. case "finish":
  261. return "queryDataFinishWithPage";
  262. break;
  263. }
  264. }
  265. function getDoType(str) {
  266. switch (str) {
  267. case "todo":
  268. return 1;
  269. break;
  270. default:
  271. return 0;
  272. break;
  273. }
  274. }