list.js 19 KB

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