list.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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. self.params = sp.getUrlName("params");
  14. var postCfg = {
  15. headers: {
  16. 'Content-Type': 'application/json',
  17. 'Authorization': "Bearer " + self.get_AccessToken
  18. }
  19. }
  20. self.type = self.get_type != "" ? self.get_type : "todo";
  21. self.Url = getUrl(self.type);
  22. self.CrossPage = window.parent.CrossPage;
  23. self.loading = false;
  24. self.search = null//JSON.parse($.cookie("GlWorkPlatform-oabgmgr"));
  25. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  26. self.pageno = 1;
  27. self.total_count = 0;
  28. self.itemsPerPage = 10;
  29. self.pageOptions = [10, 20, 30, 40];
  30. self.ordercondition = []
  31. self.getData = function (pageno) {
  32. if (self.search == null) {
  33. self.search = {
  34. BT: "",
  35. DATE1: "",
  36. DATE2: ""
  37. }
  38. }
  39. var querycondition = [];
  40. if (self.search.BT != "") {
  41. querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "TITLE", "VALUEA": self.search.BT, "VALUEB": "" })
  42. }
  43. if (self.params != "") {
  44. querycondition.push({ "CKIND": "VARLIST", "TABLEID": "SYS_ROUTE", "COLID": "ROUTEID", "VALUEA": self.params, "VALUEB": "" })
  45. }
  46. if (self.search.DATE1 != "" && self.search.DATE2 != "") {
  47. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": self.search.DATE1, "VALUEB": self.search.DATE2 })
  48. } else if (self.search.DATE1 != "" && self.search.DATE2 == "") {
  49. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": self.search.DATE1, "VALUEB": "" })
  50. } else if (self.search.DATE1 == "" && self.search.DATE2 != "") {
  51. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": "", "VALUEB": self.search.DATE2 })
  52. }
  53. self.list = [];
  54. self.loading = false;
  55. self.pageno = pageno;
  56. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  57. var data = {
  58. flowid: "AA74",
  59. userid: self.userId,
  60. pageno: self.pageno,
  61. pagesize: self.itemsPerPage,
  62. querycondition: JSON.stringify(querycondition)
  63. }
  64. $http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  65. .success(function (obj) {
  66. var res = strToJson(s4.decryptData_CBC(obj.data));
  67. self.loading = false;
  68. if (res.data == null || res.data == undefined || res.data == "") {
  69. self.noDataTip = 0;
  70. if (self.params != "") {
  71. self.params = "";
  72. self.getData(1)
  73. }
  74. } else {
  75. self.noDataTip = 1;
  76. self.list = res.data;
  77. self.total_count = res.totalCount;
  78. $.each(self.list, function (index, item) {
  79. if (item.FILEN != "") {
  80. 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;
  81. } else {
  82. item.FILEN = "#";
  83. }
  84. if (self.type == "finish") {
  85. item.RECEIVEDATE = item.FINISHEDDATE;
  86. }
  87. })
  88. }
  89. if (self.CrossPage.type == 0) {
  90. self.journalRecord(self.CrossPage.ctime, sp.getLocalDate1(), "", "接入日志", window.location.pathname)
  91. }
  92. })
  93. }
  94. self.load = function () {
  95. if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
  96. self.getData(self.pageno);
  97. } else {
  98. $timeout(function () {
  99. self.getData(self.get_lastReturnPageno);
  100. }, 1)
  101. }
  102. }
  103. self.sortFiled = function (str) {
  104. var n = 0, obj, x = -1;
  105. self.ordercondition.forEach(function (item, index) {
  106. if (item.COLID == str) {
  107. n++
  108. item.SORTTYPE = item.SORTTYPE == "" || item.SORTTYPE == "asc" ? "desc" : "asc"
  109. obj = item; x = index
  110. }
  111. })
  112. if (n == 0) {
  113. self.ordercondition.unshift({ COLID: str, SORTTYPE: "desc" })
  114. }
  115. if (x != -1) {
  116. self.ordercondition.splice(x, 1)
  117. self.ordercondition.unshift(obj)
  118. }
  119. self.getData(1);
  120. }
  121. self.load();
  122. self.openLayer = function () {
  123. self.params = "";
  124. if (self.search == null) {
  125. self.search = {
  126. BT: "",
  127. DATE1: "",
  128. DATE2: ""
  129. }
  130. }
  131. sp.layer("#Search")
  132. }
  133. self.doSearch = function () {
  134. $.cookie("GlWorkPlatform-oabgmgr", JSON.stringify(self.search), { path: '/', expires: 1 });
  135. self.getData(self.pageno)
  136. sp.layerhide()
  137. }
  138. self.cancal = function () {
  139. self.search = {
  140. BT: "",
  141. DATE1: "",
  142. DATE2: ""
  143. }
  144. $.cookie("GlWorkPlatform-oabgmgr", null, { path: '/', expires: 1 });
  145. self.getData(1)
  146. sp.layerhide()
  147. }
  148. self.refresh = function () {
  149. self.CrossPage.type = null;
  150. self.getData(self.pageno);
  151. }
  152. self.goUrl = function (item) {
  153. if (item.TODOLIST && item.TODOLIST.length > 1) {
  154. self.todoTitle = item.TITLE;
  155. self.todoList = item.TODOLIST;
  156. sp.layer("#todolist")
  157. } else {
  158. if (self.deviceType == "pad") {
  159. window.location.href = item.FILEN + "&dotype=" + getDoType(self.type)
  160. } else {
  161. sp.openNewWindow(item.FILEN + "&dotype=" + getDoType(self.type), item.TITLE)
  162. }
  163. sp.layerhide();
  164. }
  165. }
  166. self.btnDel = function (item) {
  167. var data = {
  168. routeinfoid: item.ROUTEINFOID,
  169. userid: self.userId
  170. }
  171. $http.post(apiurljs.login + "g2work/routeinfo/deleteDraftByRouteinfoid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  172. .success(function (obj) {
  173. var res = strToJson(s4.decryptData_CBC(obj.data));
  174. if (res.success == true) {
  175. self.getData(self.pageno)
  176. } else {
  177. sp.dialog(res.message)
  178. }
  179. })
  180. }
  181. self.btnRecall = function (routeid, kind) {
  182. var data = {
  183. routeid: routeid,
  184. kind: kind,
  185. userid: self.userId
  186. }
  187. $http.post(apiurljs.login + "g2work/routeinfo/queryDataRecallDoneByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  188. .success(function (obj) {
  189. var res = strToJson(s4.decryptData_CBC(obj.data));
  190. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  191. var dialogBody = "<div class=\"sp-dialog-body\">" + res.data.REMARK + "</div>";
  192. 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>";
  193. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  194. sp.openCenter(".sp-dialog");
  195. ///取消按钮
  196. $('.sp-closeDialog').click(function (event) {
  197. sp.closeCenter(".sp-dialog");
  198. event.preventDefault();
  199. event.stopPropagation();
  200. });
  201. //post消息的id
  202. $("#delDataTrue").click(function () {
  203. $http.post(apiurljs.login + "g2work/routeinfo/recallDoneByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  204. .success(function (obj) {
  205. var res = strToJson(s4.decryptData_CBC(obj.data));
  206. sp.dialoghide()
  207. if (res.success == true) {
  208. self.getData(self.pageno)
  209. } else {
  210. sp.dialog(res.message)
  211. }
  212. })
  213. });
  214. })
  215. }
  216. self.changeType = function (str) {
  217. if (self.type == str) {
  218. return;
  219. } else {
  220. var time1 = sp.getLocalDate1();
  221. self.journalRecord(time1, sp.getLocalDate1(), "查询", "查询日志", "/g2work/routeinfo/" + self.Url)
  222. self.type = str;
  223. self.Url = getUrl(self.type);
  224. self.getData(1)
  225. }
  226. }
  227. self.getAddFlag = function () {
  228. var data = {
  229. userid: self.userId,
  230. ntops: 0
  231. }
  232. $http.post(apiurljs.login + "g2work/desktop/queryWorkflowCando", data, postCfg)
  233. .success(function (obj) {
  234. var res = strToJson(s4.decryptData_CBC(obj.data));
  235. self.lcList = [];
  236. self.activeLC = {};
  237. res.data.forEach(function (item) {
  238. if ("AA74".indexOf(item.FLOWID) > -1) {
  239. self.lcList.push(item);
  240. }
  241. })
  242. })
  243. }
  244. self.getAddFlag()
  245. self.addLC = function () {
  246. if (self.lcList.length == 1) {
  247. window.location.href = self.lcList[0].FILEN + "&dotype=1"
  248. } else {
  249. sp.layer("#addLC");
  250. }
  251. }
  252. self.seeLCT = function (item,event) {
  253. event.preventDefault();
  254. event.stopPropagation();
  255. }
  256. self.goAddUrl = function () {
  257. window.location.href = self.activeLC.FILEN + "&dotype=1"
  258. }
  259. //记录日志
  260. self.journalRecord = function (time1, time2, title, func, url) {
  261. if (!self.CrossPage || !self.CrossPage.cname) { return; }
  262. var data = {
  263. tablename: "SYS_CLICKLOG",
  264. data: {
  265. CTIME: time1 == null ? sp.getLocalDate1() : time1,
  266. TITLE: (title != "" ? self.CrossPage.cname + "/" + title : self.CrossPage.cname),
  267. REQUESTURL: url,
  268. REQUESTHEADERURL: window.location.origin,
  269. LOGTYPE: func,
  270. USERTYPE: $.cookie("GlWorkPlatform-userType"),
  271. ADMIN: $.cookie("GlWorkPlatform-userTypeEng"),
  272. CLIENTIP: sp.myIP(),
  273. PCNAME: sp.detectOS(),
  274. BROWSERNAME: sp.browser(),
  275. RESPONSETIME: time2 == null ? sp.getLocalDate1() : time2,
  276. USERID: self.userId,
  277. USERNAME: self.userName
  278. }
  279. }
  280. $http.post(apiurljs.login + "g2app/dataabase/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  281. .success(function (res) {
  282. self.CrossPage.type = 1;
  283. })
  284. }
  285. //头部下滚冻结
  286. $(function () {
  287. //页面高度撑满
  288. setTimeout(function () {
  289. if ($(".ibox-content").height() < $(window).height() - 31) {
  290. $(".ibox-content").css("height", $(window).height() - 31)
  291. }
  292. }, 1)
  293. })
  294. }])
  295. function getUrl(str) {
  296. switch (str) {
  297. case "todo":
  298. return "queryDataTodoWithPage";
  299. break;
  300. case "done":
  301. return "queryDataDoneWithPage";
  302. break;
  303. case "finish":
  304. return "queryDataFinishWithPage";
  305. break;
  306. }
  307. }
  308. function getDoType(str) {
  309. switch (str) {
  310. case "todo":
  311. return 1;
  312. break;
  313. default:
  314. return 0;
  315. break;
  316. }
  317. }