list.js 13 KB

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