list.js 14 KB

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