total.js 13 KB

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