list.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  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-GWJDBXPZ"));
  26. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  27. self.pageno = 1;
  28. self.total_count = 0;
  29. self.itemsPerPage = 20;
  30. self.pageOptions = [20, 40, 60];
  31. self.ordercondition = [];
  32. self.getData = function (pageno) {
  33. if (self.search == null) {
  34. self.search = {
  35. JDBM: "",
  36. JDFY: "",
  37. JFYS: "",
  38. DATE1: "",
  39. DATE2: ""
  40. }
  41. }
  42. var querycondition = [];
  43. var columnscondition = [
  44. { COLID: "JDBM", COLUMNS: "SX_GWJD.JDBM" },
  45. { COLID: "JFYS", COLUMNS: "SX_GWJD.JFYS" },
  46. { COLID: "BKRS", COLUMNS: "SX_GWJD.BKRS" },
  47. { COLID: "PKRS", COLUMNS: "SX_GWJD.PKRS" },
  48. { COLID: "JDFY", COLUMNS: "SX_GWJD.JDFY" },
  49. { COLID: "BGMC", COLUMNS: "SX_GWJD.BGMC" },
  50. { COLID: "JDSJ", COLUMNS: "SX_GWJD.JDSJ" }
  51. ]
  52. if (self.search.JDBM != "") {
  53. querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "CODETABLE", "COLID": "JDBM", "VALUEA": self.search.JDBM, "VALUEB": "" })
  54. }
  55. if (self.search.JDFY != "") {
  56. querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "CODETABLE", "COLID": "JDFY", "VALUEA": self.search.JDFY, "VALUEB": "" })
  57. }
  58. if (self.search.JFYS != "") {
  59. querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "CODETABLE", "COLID": "JFYS", "VALUEA": self.search.JFYS, "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": "CODETABLE", "COLID": "JDSJ", "VALUEA": self.search.DATE1, "VALUEB": self.search.DATE2 })
  66. } else if (self.search.DATE1 != "" && self.search.DATE2 == "") {
  67. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "CODETABLE", "COLID": "JDSJ", "VALUEA": self.search.DATE1, "VALUEB": "" })
  68. } else if (self.search.DATE1 == "" && self.search.DATE2 != "") {
  69. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "CODETABLE", "COLID": "JDSJ", "VALUEA": "", "VALUEB": self.search.DATE2 })
  70. }
  71. self.list = [];
  72. self.loading = true
  73. ;
  74. self.pageno = pageno;
  75. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  76. var data = {
  77. flowid: "AA0W",
  78. userid: self.userId,
  79. pageno: self.pageno,
  80. pagesize: self.itemsPerPage,
  81. columnscondition: JSON.stringify(columnscondition),
  82. querycondition: JSON.stringify(querycondition),
  83. ordercondition: self.ordercondition.length == 0 ? "" : JSON.stringify(self.ordercondition)
  84. }
  85. //$http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  86. $http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, data, postCfg)
  87. .success(function (obj) {
  88. var res = obj;
  89. //var res = strToJson(s4.decryptData_CBC(obj.data));
  90. self.loading = false;
  91. if (res.data == null || res.data == undefined || res.data == "") {
  92. self.noDataTip = 0;
  93. } else {
  94. self.noDataTip = 1;
  95. self.list = res.data;
  96. self.total_count = res.totalCount;
  97. $.each(self.list, function (index, item) {
  98. item.JDSJ = sp.format(item.JDSJ);
  99. if (item.FILEN != "") {
  100. 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;
  101. } else {
  102. item.FILEN = "#";
  103. }
  104. if (self.type == "finish") {
  105. item.RECEIVEDATE = item.FINISHEDDATE;
  106. }
  107. })
  108. }
  109. if (self.CrossPage.type == 0) {
  110. self.journalRecord(self.CrossPage.ctime, sp.getLocalDate1(), "", "接入日志", window.location.pathname)
  111. }
  112. })
  113. }
  114. self.load = function () {
  115. if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
  116. self.getData(self.pageno);
  117. } else {
  118. $timeout(function () {
  119. self.getData(self.get_lastReturnPageno);
  120. }, 1)
  121. }
  122. }
  123. self.load();
  124. self.openLayer = function () {
  125. self.params = "";
  126. if (self.search == null) {
  127. self.search = {
  128. JDBM: "",
  129. JDFY: "",
  130. JFYS: "",
  131. DATE1: "",
  132. DATE2: ""
  133. }
  134. }
  135. sp.layer("#Search")
  136. }
  137. self.doSearch = function () {
  138. $.cookie("GlWorkPlatform-GWJDBXPZ", JSON.stringify(self.search), { path: '/', expires: 1 });
  139. self.getData(self.pageno)
  140. sp.layerhide()
  141. }
  142. self.cancal = function () {
  143. self.search = {
  144. JDBM: "",
  145. JDFY: "",
  146. JFYS: "",
  147. DATE1: "",
  148. DATE2: ""
  149. }
  150. $.cookie("GlWorkPlatform-GWJDBXPZ", null, { path: '/', expires: 1 });
  151. self.getData(1)
  152. sp.layerhide()
  153. }
  154. self.refresh = function () {
  155. self.CrossPage.type = null;
  156. self.getData(self.pageno);
  157. }
  158. self.goUrl = function (item) {
  159. if (item.TODOLIST && item.TODOLIST.length > 1) {
  160. self.todoTitle = item.TITLE;
  161. self.todoList = item.TODOLIST;
  162. sp.layer("#todolist")
  163. } else {
  164. if (self.deviceType == "pad") {
  165. window.location.href = item.FILEN + "&dotype=" + getDoType(self.type)
  166. } else {
  167. sp.openNewWindow(item.FILEN + "&dotype=" + getDoType(self.type), item.TITLE)
  168. }
  169. sp.layerhide();
  170. }
  171. }
  172. self.btnDel = function (item) {
  173. var data = {
  174. routeinfoid: item.ROUTEINFOID,
  175. userid: self.userId
  176. }
  177. $http.post(apiurljs.login + "g2work/routeinfo/deleteDraftByRouteinfoid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  178. .success(function (obj) {
  179. var res = strToJson(s4.decryptData_CBC(obj.data));
  180. if (res.success == true) {
  181. self.getData(self.pageno)
  182. } else {
  183. sp.dialog(res.message)
  184. }
  185. })
  186. }
  187. self.btnRecall = function (routeid, kind) {
  188. var data = {
  189. routeid: routeid,
  190. kind: kind,
  191. userid: self.userId
  192. }
  193. $http.post(apiurljs.login + "g2work/routeinfo/queryDataRecallDoneByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  194. .success(function (obj) {
  195. var res = strToJson(s4.decryptData_CBC(obj.data));
  196. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  197. var dialogBody = "<div class=\"sp-dialog-body\">" + res.data.REMARK + "</div>";
  198. 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>";
  199. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  200. sp.openCenter(".sp-dialog");
  201. ///取消按钮
  202. $('.sp-closeDialog').click(function (event) {
  203. sp.closeCenter(".sp-dialog");
  204. event.preventDefault();
  205. event.stopPropagation();
  206. });
  207. //post消息的id
  208. $("#delDataTrue").click(function () {
  209. $http.post(apiurljs.login + "g2work/routeinfo/recallDoneByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  210. .success(function (obj) {
  211. var res = strToJson(s4.decryptData_CBC(obj.data));
  212. sp.dialoghide()
  213. if (res.success == true) {
  214. self.getData(self.pageno)
  215. } else {
  216. sp.dialog(res.message)
  217. }
  218. })
  219. });
  220. })
  221. }
  222. self.changeType = function (str) {
  223. if (self.type == str) {
  224. return;
  225. } else {
  226. var time1 = sp.getLocalDate1();
  227. self.journalRecord(time1, sp.getLocalDate1(), "查询", "查询日志", "/g2work/routeinfo/" + self.Url)
  228. self.type = str;
  229. self.Url = getUrl(self.type);
  230. self.getData(1)
  231. }
  232. }
  233. self.getAddFlag = function () {
  234. var data = {
  235. userid: self.userId,
  236. ntops: 0
  237. }
  238. $http.post(apiurljs.login + "g2work/desktop/queryWorkflowCando", data, postCfg)
  239. .success(function (obj) {
  240. var res = strToJson(s4.decryptData_CBC(obj.data));
  241. self.lcList = [];
  242. self.activeLC = {};
  243. res.data.forEach(function (item) {
  244. if ("AA0W".indexOf(item.FLOWID) > -1) {
  245. self.lcList.push(item);
  246. }
  247. })
  248. })
  249. }
  250. self.getAddFlag()
  251. self.addLC = function () {
  252. if (self.lcList.length == 0) {
  253. sp.dialog("暂无权限!")
  254. } else if (self.lcList.length == 1) {
  255. sp.openNewWindow(self.lcList[0].FILEN + "&dotype=1&flowid=" + self.lcList[0].FLOWID, self.lcList[0].FLOWNAME)
  256. } else {
  257. sp.layer("#addLC");
  258. }
  259. //var data = {
  260. // userid: self.userId,
  261. // ntops: 0
  262. //}
  263. //$http.post(apiurljs.login + "g2work/desktop/queryWorkflowCandoGwtype", data, postCfg)
  264. //.success(function (obj) {
  265. // var res = strToJson(s4.decryptData_CBC(obj.data));
  266. // self.lcList = [];
  267. // self.activeLC = {};
  268. // res.data.forEach(function (item) {
  269. // if ("AA0W".indexOf(item.FLOWID) > -1) {
  270. // self.lcList.push(item);
  271. // }
  272. // })
  273. // if (self.lcList.length == 0) {
  274. // sp.dialog("暂无权限!")
  275. // } else if (self.lcList.length == 1) {
  276. // window.location.href = self.lcList[0].FILEN + "&dotype=1"
  277. // //var data = {
  278. // // gwtypecode: self.lcList[0].GWCODE,
  279. // // copyrightid: self.lcList[0].COPYRIGHTID,
  280. // // userid: self.userId
  281. // //}
  282. // //$http.post(apiurljs.login + "g2app/fawenfiles/createNewWorkFlowWithGwtype", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  283. // //.success(function (obj) {
  284. // // var res = strToJson(s4.decryptData_CBC(obj.data));
  285. // // var url = self.lcList[0].FILEN + "&dotype=1&GWCODE=" + self.lcList[0].GWCODE;
  286. // // var url1 = url.replace("routeid=0", "routeid=" + res.data.ROUTEID).replace("routeinfoid=0", "routeinfoid=" + res.data.ROUTEINFOID)
  287. // // console.log(url1)
  288. // // window.location.href = url1;
  289. // //})
  290. // } else {
  291. // sp.layer("#addLC");
  292. // }
  293. //})
  294. }
  295. self.seeLCT = function (item,event) {
  296. event.preventDefault();
  297. event.stopPropagation();
  298. }
  299. self.goAddUrl = function () {
  300. if (!self.activeLC.FILEN) {
  301. return
  302. }
  303. sp.openNewWindow(obj.FILEN + "&dotype=1&flowid=" + obj.FLOWID, obj.FLOWNAME)
  304. //var data = {
  305. // gwtypecode: self.activeLC.GWCODE,
  306. // copyrightid: self.activeLC.COPYRIGHTID,
  307. // userid: self.userId
  308. //}
  309. //$http.post(apiurljs.login + "g2app/fawenfiles/createNewWorkFlowWithGwtype",{ data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  310. //.success(function (obj) {
  311. // var res = strToJson(s4.decryptData_CBC(obj.data));
  312. // var url = self.activeLC.FILEN + "&dotype=1&GWCODE=" + self.activeLC.GWCODE;
  313. // var url1 = url.replace("routeid=0", "routeid=" + res.data.ROUTEID).replace("routeinfoid=0", "routeinfoid=" + res.data.ROUTEINFOID)
  314. // console.log(url1)
  315. // window.location.href = url1;
  316. //})
  317. }
  318. //记录日志
  319. self.journalRecord = function (time1, time2, title, func, url) {
  320. if (!self.CrossPage || !self.CrossPage.cname) { return; }
  321. var data = {
  322. tablename: "SYS_CLICKLOG",
  323. data: {
  324. CTIME: time1 == null ? sp.getLocalDate1() : time1,
  325. TITLE: (title != "" ? self.CrossPage.cname + "/" + title : self.CrossPage.cname),
  326. REQUESTURL: url,
  327. REQUESTHEADERURL: window.location.origin,
  328. LOGTYPE: func,
  329. USERTYPE: $.cookie("GlWorkPlatform-userType"),
  330. ADMIN: $.cookie("GlWorkPlatform-userTypeEng"),
  331. CLIENTIP: sp.myIP(),
  332. PCNAME: sp.detectOS(),
  333. BROWSERNAME: sp.browser(),
  334. RESPONSETIME: time2 == null ? sp.getLocalDate1() : time2,
  335. USERID: self.userId,
  336. USERNAME: self.userName
  337. }
  338. }
  339. $http.post(apiurljs.login + "g2app/DangJian/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  340. .success(function (res) {
  341. self.CrossPage.type = 1;
  342. })
  343. }
  344. $interval(function () {
  345. if (localStorage.getItem("GlWorkPlatform-GWJDBXPZ-refresh") == 1) {
  346. localStorage.removeItem("GlWorkPlatform-GWJDBXPZ-refresh")
  347. self.refresh()
  348. }
  349. }, 1000)
  350. //头部下滚冻结
  351. $(function () {
  352. //页面高度撑满
  353. setTimeout(function () {
  354. if ($(".ibox-content").height() < $(window).height() - 31) {
  355. $(".ibox-content").css("height", $(window).height() - 31)
  356. }
  357. }, 1)
  358. })
  359. }])
  360. function getUrl(str) {
  361. switch (str) {
  362. case "todo":
  363. return "queryDataTodoWithPage";
  364. break;
  365. case "done":
  366. return "queryDataDoneWithPage";
  367. break;
  368. case "finish":
  369. return "queryDataFinishWithPage";
  370. break;
  371. }
  372. }
  373. function getDoType(str) {
  374. switch (str) {
  375. case "todo":
  376. return 1;
  377. break;
  378. default:
  379. return 0;
  380. break;
  381. }
  382. }