list.js 14 KB

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