list.js 13 KB

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