list.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("listCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) {
  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.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  12. self.get_type = sp.getUrlName("type");
  13. self.params = sp.getUrlName("params");
  14. var postCfg = {
  15. headers: {
  16. 'Content-Type': 'application/json',
  17. 'Authorization': "Bearer " + self.get_AccessToken
  18. }
  19. }
  20. self.type = self.get_type != "" ? self.get_type : "todo";
  21. self.Url = getUrl(self.type);
  22. self.CrossPage = window.parent.CrossPage;
  23. self.loading = false;
  24. self.search = JSON.parse($.cookie("GlWorkPlatform-gdlc"));
  25. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  26. self.pageno = 1;
  27. self.total_count = 0;
  28. self.itemsPerPage = 10;
  29. self.pageOptions = [10, 20, 30, 40];
  30. self.getData = function (pageno) {
  31. if (self.search == null) {
  32. self.search = {
  33. BT: "",
  34. USER: "",
  35. DATE1: "",
  36. DATE2: ""
  37. }
  38. }
  39. var querycondition = [];
  40. if (self.search.BT != "") {
  41. querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "TITLE", "VALUEA": self.search.BT, "VALUEB": "" })
  42. }
  43. if (self.search.USER != "") {
  44. querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "USERNAMEFROM", "VALUEA": self.search.USER, "VALUEB": "" })
  45. }
  46. if (self.params != "") {
  47. querycondition.push({ "CKIND": "VARLIST", "TABLEID": "SYS_ROUTE", "COLID": "ROUTEID", "VALUEA": self.params, "VALUEB": "" })
  48. }
  49. if (self.search.DATE1 != "" && self.search.DATE2 != "") {
  50. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": self.search.DATE1, "VALUEB": self.search.DATE2 })
  51. } else if (self.search.DATE1 != "" && self.search.DATE2 == "") {
  52. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": self.search.DATE1, "VALUEB": "" })
  53. } else if (self.search.DATE1 == "" && self.search.DATE2 != "") {
  54. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": "", "VALUEB": self.search.DATE2 })
  55. }
  56. self.list = [];
  57. self.loading = false;
  58. self.pageno = pageno;
  59. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  60. var data = {
  61. flowid: "AA94",
  62. userid: self.userId,
  63. pageno: self.pageno,
  64. pagesize: self.itemsPerPage,
  65. querycondition: JSON.stringify(querycondition)
  66. }
  67. //$http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  68. $http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, data, postCfg)
  69. .success(function (obj) {
  70. var res = obj;
  71. //var res = strToJson(s4.decryptData_CBC(obj.data));
  72. self.loading = false;
  73. if (res.data == null || res.data == undefined || res.data == "") {
  74. self.noDataTip = 0;
  75. if (self.params != "") {
  76. self.params = "";
  77. self.getData(1)
  78. }
  79. } else {
  80. self.noDataTip = 1;
  81. self.list = res.data;
  82. self.total_count = res.totalCount;
  83. $.each(self.list, function (index, item) {
  84. if (item.FILEN != "") {
  85. 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;
  86. } else {
  87. item.FILEN = "#";
  88. }
  89. if (self.type == "finish") {
  90. item.RECEIVEDATE = item.FINISHEDDATE;
  91. }
  92. })
  93. }
  94. if (self.CrossPage.type == 0) {
  95. self.journalRecord(self.CrossPage.ctime, sp.getLocalDate1(), "", "接入日志", window.location.pathname)
  96. }
  97. })
  98. }
  99. self.load = function () {
  100. if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
  101. self.getData(self.pageno);
  102. } else {
  103. $timeout(function () {
  104. self.getData(self.get_lastReturnPageno);
  105. }, 1)
  106. }
  107. }
  108. self.getDP = function () {
  109. var data = {
  110. userid: self.userId
  111. }
  112. $http.post(apiurljs.login + "g2app/richang/queryDpInfo", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  113. .success(function (obj) {
  114. var res = strToJson(s4.decryptData_CBC(obj.data));
  115. self.userDpName = res.data.length == 0 ? "" : res.data[0].SECTION;
  116. self.userDpCode = res.data.length == 0 ? "" : res.data[0].CODE;
  117. self.load();
  118. })
  119. }
  120. self.getDP()
  121. self.openLayer = function () {
  122. self.params = "";
  123. if (self.search == null) {
  124. self.search = {
  125. BT: "",
  126. USER: "",
  127. DATE1: "",
  128. DATE2: ""
  129. }
  130. }
  131. sp.layer("#Search")
  132. }
  133. self.doSearch = function () {
  134. $.cookie("GlWorkPlatform-gdlc", JSON.stringify(self.search), { path: '/', expires: 1 });
  135. self.getData(self.pageno)
  136. sp.layerhide()
  137. }
  138. self.cancal = function () {
  139. self.search = {
  140. BT: "",
  141. USER: "",
  142. DATE1: "",
  143. DATE2: ""
  144. }
  145. $.cookie("GlWorkPlatform-gdlc", null, { path: '/', expires: 1 });
  146. self.getData(1)
  147. sp.layerhide()
  148. }
  149. self.refresh = function () {
  150. self.CrossPage.type = null;
  151. self.getData(self.pageno);
  152. }
  153. self.goUrl = function (item) {
  154. window.location.href = item.FILEN + "&dotype=" + getDoType(self.type)
  155. }
  156. self.btnDel = function (item) {
  157. var data = {
  158. routeinfoid: item.ROUTEINFOID,
  159. userid: self.userId
  160. }
  161. $http.post(apiurljs.login + "g2work/routeinfo/deleteDraftByRouteinfoid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  162. .success(function (obj) {
  163. var res = strToJson(s4.decryptData_CBC(obj.data));
  164. if (res.success == true) {
  165. self.getData(self.pageno)
  166. } else {
  167. sp.dialog(res.message)
  168. }
  169. })
  170. }
  171. self.btnRecall = function (routeid) {
  172. var data = {
  173. routeid: routeid,
  174. userid: self.userId
  175. }
  176. $http.post(apiurljs.login + "g2work/routeinfo/queryDataRecallDoneByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  177. .success(function (obj) {
  178. var res = strToJson(s4.decryptData_CBC(obj.data));
  179. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  180. var dialogBody = "<div class=\"sp-dialog-body\">" + res.data.REMARK + "</div>";
  181. 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>";
  182. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  183. sp.openCenter(".sp-dialog");
  184. ///取消按钮
  185. $('.sp-closeDialog').click(function (event) {
  186. sp.closeCenter(".sp-dialog");
  187. event.preventDefault();
  188. event.stopPropagation();
  189. });
  190. //post消息的id
  191. $("#delDataTrue").click(function () {
  192. $http.post(apiurljs.login + "g2work/routeinfo/recallDoneByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  193. .success(function (obj) {
  194. var res = strToJson(s4.decryptData_CBC(obj.data));
  195. sp.dialoghide()
  196. if (res.success == true) {
  197. self.getData(self.pageno)
  198. } else {
  199. sp.dialog(res.message)
  200. }
  201. })
  202. });
  203. })
  204. }
  205. self.changeType = function (str) {
  206. if (self.type == str) {
  207. return;
  208. } else {
  209. var time1 = sp.getLocalDate1();
  210. self.journalRecord(time1, sp.getLocalDate1(), "查询", "查询日志", "/g2work/routeinfo/" + self.Url)
  211. self.type = str;
  212. self.Url = getUrl(self.type);
  213. self.getData(1)
  214. }
  215. }
  216. self.getAddFlag = function () {
  217. var data = {
  218. userid: self.userId,
  219. ntops: 0
  220. }
  221. $http.post(apiurljs.login + "g2work/desktop/queryWorkflowCando", data, postCfg)
  222. .success(function (obj) {
  223. var res = strToJson(s4.decryptData_CBC(obj.data));
  224. self.lcList = [];
  225. self.activeLC = {};
  226. res.data.forEach(function (item) {
  227. if ("AA94".indexOf(item.FLOWID) > -1) {
  228. self.lcList.push(item);
  229. }
  230. })
  231. if (self.lcList.length == 1) {
  232. self.activeLC = self.lcList[0]
  233. }
  234. })
  235. }
  236. self.getAddFlag()
  237. self.addLC = function () {
  238. var data = {
  239. tablename: "DANGANFLOW",
  240. colums: "*",
  241. order: "ID",
  242. sqlwhere: {
  243. DPCODE: self.userDpCode,
  244. STATUS: "启用"
  245. },
  246. sqlorwhere: "",
  247. sqlinwhere: "",
  248. sqllikewhere: ""
  249. };
  250. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  251. .success(function (obj) {
  252. var res = strToJson(s4.decryptData_CBC(obj.data));
  253. self.FlowList = res.data;
  254. self.seeLC(self.FlowList[0])
  255. sp.layer("#addLC");
  256. })
  257. }
  258. self.seeLC = function (item) {
  259. self.active = item;
  260. var data = {
  261. flowid: self.active.FLOWID,
  262. pageno: 0,
  263. pagesize: 0,
  264. currentflowid: "AA94",
  265. colums: "A.TITLE,A.FLOWID,A.FLOWNAME,A.ROUTEINFOID,A.FINISHEDDATE,B.MOBANNAME,B.TABLENAME",
  266. order: "finisheddate"
  267. }
  268. $http.post(apiurljs.login + "g2app/DangAn/queryYJYGDDataWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  269. .success(function (obj) {
  270. var res = strToJson(s4.decryptData_CBC(obj.data));
  271. self.GuiDangList = res.data;
  272. self.addItem = null;
  273. })
  274. }
  275. self.goAddUrl = function () {
  276. if (self.addItem == null) {
  277. return
  278. }
  279. $.cookie("GlWorkPlatform-gdsp", JSON.stringify(self.addItem), { path: '/', expires: 1 });
  280. window.location.href = self.activeLC.FILEN + "&dotype=1"
  281. }
  282. //记录日志
  283. self.journalRecord = function (time1, time2, title, func, url) {
  284. if (!self.CrossPage.cname) { return; }
  285. var data = {
  286. tablename: "SYS_CLICKLOG",
  287. data: {
  288. CTIME: time1 == null ? sp.getLocalDate1() : time1,
  289. TITLE: (title != "" ? self.CrossPage.cname + "/" + title : self.CrossPage.cname),
  290. REQUESTURL: url,
  291. REQUESTHEADERURL: window.location.origin,
  292. LOGTYPE: func,
  293. USERTYPE: $.cookie("GlWorkPlatform-userType"),
  294. ADMIN: $.cookie("GlWorkPlatform-userTypeEng"),
  295. CLIENTIP: sp.myIP(),
  296. PCNAME: sp.detectOS(),
  297. BROWSERNAME: sp.browser(),
  298. RESPONSETIME: time2 == null ? sp.getLocalDate1() : time2,
  299. USERID: self.userId,
  300. USERNAME: self.userName
  301. }
  302. }
  303. $http.post(apiurljs.login + "g2app/dataabase/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  304. .success(function (res) {
  305. self.CrossPage.type = 1;
  306. })
  307. }
  308. //头部下滚冻结
  309. $(function () {
  310. //页面高度撑满
  311. setTimeout(function () {
  312. if ($(".ibox-content").height() < $(window).height() - 31) {
  313. $(".ibox-content").css("height", $(window).height() - 31)
  314. }
  315. }, 1)
  316. })
  317. }])
  318. function getUrl(str) {
  319. switch (str) {
  320. case "todo":
  321. return "queryDataTodoWithPage";
  322. break;
  323. case "done":
  324. return "queryDataDoneWithPage";
  325. break;
  326. case "finish":
  327. return "queryDataFinishWithPage";
  328. break;
  329. }
  330. }
  331. function getDoType(str) {
  332. switch (str) {
  333. case "todo":
  334. return 1;
  335. break;
  336. default:
  337. return 0;
  338. break;
  339. }
  340. }