list.js 10 KB

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