list.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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-shixiangdb"));
  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.getDBLX = function () {
  31. var data = {
  32. ckey: "CODE_DUBAN",
  33. routeinfoid: self.routeinfoid
  34. }
  35. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  36. .success(function (obj) {
  37. var res = strToJson(s4.decryptData_CBC(obj.data));
  38. self.DBLX = res.data.CODE_DUBAN;
  39. self.load()
  40. })
  41. }
  42. self.flowids = [{ ID: "AA95", NAME: "党委会议题呈报", checked: false }]
  43. self.getData = function (pageno) {
  44. if (self.search == null) {
  45. self.search = {
  46. FLOW: [],
  47. BT: "",
  48. USER: "",
  49. DATE1: "",
  50. DATE2: ""
  51. }
  52. }
  53. var flowids = self.search.FLOW.join("|");
  54. var querycondition = [];
  55. if (self.search.BT != "") {
  56. querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "TITLE", "VALUEA": self.search.BT, "VALUEB": "" })
  57. }
  58. if (self.search.USER != "") {
  59. querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "USERNAMEFROM", "VALUEA": self.search.USER, "VALUEB": "" })
  60. }
  61. if (self.params != "") {
  62. querycondition.push({ "CKIND": "VARLIST", "TABLEID": "SYS_ROUTE", "COLID": "ROUTEID", "VALUEA": self.params, "VALUEB": "" })
  63. }
  64. if (self.search.DATE1 != "" && self.search.DATE2 != "") {
  65. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": self.search.DATE1, "VALUEB": self.search.DATE2 })
  66. } else if (self.search.DATE1 != "" && self.search.DATE2 == "") {
  67. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": self.search.DATE1, "VALUEB": "" })
  68. } else if (self.search.DATE1 == "" && self.search.DATE2 != "") {
  69. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": "", "VALUEB": self.search.DATE2 })
  70. }
  71. self.list = [];
  72. self.loading = false;
  73. self.pageno = pageno;
  74. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  75. var data = {
  76. flowid: flowids == "" ? "AA95" : flowids,
  77. userid: self.userId,
  78. pageno: self.pageno,
  79. pagesize: self.itemsPerPage,
  80. querycondition: JSON.stringify(querycondition)
  81. }
  82. $http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  83. .success(function (obj) {
  84. var res = strToJson(s4.decryptData_CBC(obj.data));
  85. self.loading = false;
  86. if (res.data == null || res.data == undefined || res.data == "") {
  87. self.noDataTip = 0;
  88. if (self.params != "") {
  89. self.params = "";
  90. self.getData(1)
  91. }
  92. } else {
  93. self.noDataTip = 1;
  94. self.list = res.data;
  95. self.total_count = res.totalCount;
  96. $.each(self.list, function (index, item) {
  97. item.WCSX = sp.format(item[item.CODETABLE + ".WCSX"]);
  98. self.DBLX.forEach(function (item1) {
  99. if (item[item.CODETABLE + ".DBLX"] == item1.CODE)
  100. item.DBLX = item1.CNAME
  101. })
  102. if (item.FILEN != "") {
  103. 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;
  104. } else {
  105. item.FILEN = "#";
  106. }
  107. if (self.type == "finish") {
  108. item.RECEIVEDATE = item.FINISHEDDATE;
  109. }
  110. })
  111. }
  112. if (self.CrossPage.type == 0) {
  113. self.journalRecord(self.CrossPage.ctime, sp.getLocalDate1(), "", "接入日志", window.location.pathname)
  114. }
  115. })
  116. }
  117. self.load = function () {
  118. if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
  119. self.getData(self.pageno);
  120. } else {
  121. $timeout(function () {
  122. self.getData(self.get_lastReturnPageno);
  123. }, 1)
  124. }
  125. }
  126. self.getDBLX();
  127. self.openLayer = function () {
  128. self.params = "";
  129. if (self.search == null) {
  130. self.search = {
  131. FLOW: [],
  132. BT: "",
  133. USER: "",
  134. DATE1: "",
  135. DATE2: ""
  136. }
  137. } else {
  138. self.flowids.forEach(function (item) {
  139. item.checked = false;
  140. if (self.search.FLOW.indexOf(item.ID) > -1) {
  141. item.checked = true;
  142. }
  143. })
  144. }
  145. sp.layer("#Search")
  146. }
  147. self.doSearch = function () {
  148. self.search.FLOW = [];
  149. self.flowids.forEach(function (item) {
  150. if (item.checked == true) {
  151. self.search.FLOW.push(item.ID)
  152. }
  153. })
  154. $.cookie("GlWorkPlatform-shixiangdb", JSON.stringify(self.search), { path: '/', expires: 1 });
  155. self.getData(self.pageno)
  156. sp.layerhide()
  157. }
  158. self.cancal = function () {
  159. self.search = {
  160. FLOW: [],
  161. BT: "",
  162. USER: "",
  163. DATE1: "",
  164. DATE2: ""
  165. }
  166. $.cookie("GlWorkPlatform-shixiangdb", null, { path: '/', expires: 1 });
  167. self.getData(1)
  168. sp.layerhide()
  169. }
  170. self.refresh = function () {
  171. self.CrossPage.type = null;
  172. self.getData(self.pageno);
  173. }
  174. self.goUrl = function (item) {
  175. window.location.href = item.FILEN + "&dotype=" + getDoType(self.type)
  176. }
  177. self.btnDel = function (item) {
  178. var data = {
  179. routeinfoid: item.ROUTEINFOID,
  180. userid: self.userId
  181. }
  182. $http.post(apiurljs.login + "g2work/routeinfo/deleteDraftByRouteinfoid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  183. .success(function (obj) {
  184. var res = strToJson(s4.decryptData_CBC(obj.data));
  185. if (res.success == true) {
  186. self.getData(self.pageno)
  187. } else {
  188. sp.dialog(res.message)
  189. }
  190. })
  191. }
  192. self.btnRecall = function (routeid) {
  193. var data = {
  194. routeid: routeid,
  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 ("AA95".indexOf(item.FLOWID) > -1) {
  249. self.lcList.push(item);
  250. }
  251. })
  252. if (sp.getUrlName("routeinfoid") != "") {
  253. self.addLC()
  254. }
  255. })
  256. }
  257. self.getAddFlag()
  258. self.addLC = function () {
  259. if (self.lcList.length == 1) {
  260. window.location.href = self.lcList[0].FILEN + "&dotype=1&flowid=" + self.lcList[0].FLOWID
  261. } else {
  262. sp.layer("#addLC");
  263. }
  264. }
  265. self.seeLCT = function (item,event) {
  266. event.preventDefault();
  267. event.stopPropagation();
  268. }
  269. self.goAddUrl = function () {
  270. if (!self.activeLC.FILEN) {
  271. return
  272. }
  273. window.location.href = self.activeLC.FILEN + "&dotype=1&flowid=" + self.activeLC.FLOWID
  274. }
  275. //记录日志
  276. self.journalRecord = function (time1, time2, title, func, url) {
  277. if (!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. //头部下滚冻结
  302. $(function () {
  303. //页面高度撑满
  304. setTimeout(function () {
  305. if ($(".ibox-content").height() < $(window).height() - 31) {
  306. $(".ibox-content").css("height", $(window).height() - 31)
  307. }
  308. }, 1)
  309. })
  310. }])
  311. function getUrl(str) {
  312. switch (str) {
  313. case "todo":
  314. return "queryDataTodoWithPage";
  315. break;
  316. case "done":
  317. return "queryDataDoneWithPage";
  318. break;
  319. case "finish":
  320. return "queryDataFinishWithPage";
  321. break;
  322. }
  323. }
  324. function getDoType(str) {
  325. switch (str) {
  326. case "todo":
  327. return 1;
  328. break;
  329. default:
  330. return 0;
  331. break;
  332. }
  333. }