ledger.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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, kind) {
  194. var data = {
  195. routeid: routeid,
  196. kind: kind,
  197. userid: self.userId
  198. }
  199. $http.post(apiurljs.login + "g2work/routeinfo/queryDataRecallDoneByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  200. .success(function (obj) {
  201. var res = strToJson(s4.decryptData_CBC(obj.data));
  202. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  203. var dialogBody = "<div class=\"sp-dialog-body\">" + res.data.REMARK + "</div>";
  204. 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>";
  205. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  206. sp.openCenter(".sp-dialog");
  207. ///取消按钮
  208. $('.sp-closeDialog').click(function (event) {
  209. sp.closeCenter(".sp-dialog");
  210. event.preventDefault();
  211. event.stopPropagation();
  212. });
  213. //post消息的id
  214. $("#delDataTrue").click(function () {
  215. $http.post(apiurljs.login + "g2work/routeinfo/recallDoneByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  216. .success(function (obj) {
  217. var res = strToJson(s4.decryptData_CBC(obj.data));
  218. sp.dialoghide()
  219. if (res.success == true) {
  220. self.getData(self.pageno)
  221. } else {
  222. sp.dialog(res.message)
  223. }
  224. })
  225. });
  226. })
  227. }
  228. self.changeType = function (str) {
  229. if (self.type == str) {
  230. return;
  231. } else {
  232. var time1 = sp.getLocalDate1();
  233. self.journalRecord(time1, sp.getLocalDate1(), "查询", "查询日志", "/g2work/routeinfo/" + self.Url)
  234. self.type = str;
  235. self.Url = getUrl(self.type);
  236. self.getData(1)
  237. }
  238. }
  239. self.getAddFlag = function () {
  240. var data = {
  241. userid: self.userId,
  242. ntops: 0
  243. }
  244. $http.post(apiurljs.login + "g2work/desktop/queryWorkflowCando", data, postCfg)
  245. .success(function (obj) {
  246. var res = strToJson(s4.decryptData_CBC(obj.data));
  247. self.lcList = [];
  248. self.activeLC = {};
  249. res.data.forEach(function (item) {
  250. if ("AA12".indexOf(item.FLOWID) > -1) {
  251. self.lcList.push(item);
  252. }
  253. })
  254. })
  255. }
  256. self.getAddFlag()
  257. self.addLC = function () {
  258. if (self.lcList.length == 1) {
  259. window.location.href = self.lcList[0].FILEN + "&dotype=1"
  260. } else {
  261. sp.layer("#addLC");
  262. }
  263. }
  264. self.seeLCT = function (item,event) {
  265. event.preventDefault();
  266. event.stopPropagation();
  267. }
  268. self.goAddUrl = function () {
  269. window.location.href = self.activeLC.FILEN + "&dotype=1"
  270. }
  271. //记录日志
  272. self.journalRecord = function (time1, time2, title, func, url) {
  273. if (!self.CrossPage || !self.CrossPage.cname) { return; }
  274. var data = {
  275. tablename: "SYS_CLICKLOG",
  276. data: {
  277. CTIME: time1 == null ? sp.getLocalDate1() : time1,
  278. TITLE: (title != "" ? self.CrossPage.cname + "/" + title : self.CrossPage.cname),
  279. REQUESTURL: url,
  280. REQUESTHEADERURL: window.location.origin,
  281. LOGTYPE: func,
  282. USERTYPE: $.cookie("GlWorkPlatform-userType"),
  283. ADMIN: $.cookie("GlWorkPlatform-userTypeEng"),
  284. CLIENTIP: sp.myIP(),
  285. PCNAME: sp.detectOS(),
  286. BROWSERNAME: sp.browser(),
  287. RESPONSETIME: time2 == null ? sp.getLocalDate1() : time2,
  288. USERID: self.userId,
  289. USERNAME: self.userName
  290. }
  291. }
  292. $http.post(apiurljs.login + "g2app/dataabase/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  293. .success(function (res) {
  294. self.CrossPage.type = 1;
  295. })
  296. }
  297. //头部下滚冻结
  298. $(function () {
  299. //页面高度撑满
  300. setTimeout(function () {
  301. if ($(".ibox-content").height() < $(window).height() - 31) {
  302. $(".ibox-content").css("height", $(window).height() - 31)
  303. }
  304. }, 1)
  305. })
  306. }])
  307. function getUrl(str) {
  308. switch (str) {
  309. case "todo":
  310. return "queryDataTodoWithPage";
  311. break;
  312. case "done":
  313. return "queryDataDoneWithPage";
  314. break;
  315. case "finish":
  316. return "queryDataFinishWithPage";
  317. break;
  318. }
  319. }
  320. function getDoType(str) {
  321. switch (str) {
  322. case "todo":
  323. return 1;
  324. break;
  325. default:
  326. return 0;
  327. break;
  328. }
  329. }