list.js 14 KB

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