list.js 15 KB

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