list1.js 14 KB

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