list.js 15 KB

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