list.js 15 KB

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