list.js 13 KB

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