list.js 16 KB

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