list.js 13 KB

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