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", 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-tongzhibg"));
  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.getGGLM = function () {
  33. var data = {
  34. ckey: "CODE_GGLM",
  35. routeinfoid: self.routeinfoid
  36. }
  37. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  38. .success(function (obj) {
  39. var res = strToJson(s4.decryptData_CBC(obj.data));
  40. self.GGLM = res.data.CODE_GGLM;
  41. self.load()
  42. })
  43. }
  44. self.getData = function (pageno) {
  45. if (self.search == null) {
  46. self.search = {
  47. BT: "",
  48. FBBM: "",
  49. DATE1: "",
  50. DATE2: ""
  51. }
  52. }
  53. var querycondition = [];
  54. var columnscondition = [
  55. { COLID: "GGLM", COLUMNS: "SX_TZGG.GGBK" },
  56. { COLID: "FBBM", COLUMNS: "SX_TZGG.FBBM" },
  57. { COLID: "FBFW", COLUMNS: "SX_TZGG.FBFW" },
  58. { COLID: "FBFW", COLUMNS: "SX_TZGG.FBFW" },
  59. { COLID: "FBZT", COLUMNS: "SX_TZGG.FBZT" },
  60. { COLID: "SQUSERID", COLUMNS: "SX_TZGG.SQUSERID" }
  61. ]
  62. if (self.search.BT != "") {
  63. querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "TITLE", "VALUEA": self.search.BT, "VALUEB": "" })
  64. }
  65. if (self.search.FBBM != "") {
  66. querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "CODETABLE", "COLID": "FBBM", "VALUEA": self.search.FBBM, "VALUEB": "" })
  67. }
  68. if (self.params != "") {
  69. querycondition.push({ "CKIND": "VARLIST", "TABLEID": "SYS_ROUTE", "COLID": "ROUTEID", "VALUEA": self.params, "VALUEB": "" })
  70. }
  71. if (self.search.DATE1 != "" && self.search.DATE2 != "") {
  72. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": self.search.DATE1, "VALUEB": self.search.DATE2 })
  73. } else if (self.search.DATE1 != "" && self.search.DATE2 == "") {
  74. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": self.search.DATE1, "VALUEB": "" })
  75. } else if (self.search.DATE1 == "" && self.search.DATE2 != "") {
  76. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": "", "VALUEB": self.search.DATE2 })
  77. }
  78. self.list = [];
  79. self.loading = false;
  80. self.pageno = pageno;
  81. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  82. var data = {
  83. flowid: "AA85",
  84. userid: self.userId,
  85. pageno: self.pageno,
  86. pagesize: self.itemsPerPage,
  87. columnscondition: JSON.stringify(columnscondition),
  88. querycondition: JSON.stringify(querycondition),
  89. ordercondition: self.ordercondition.length == 0 ? "" : JSON.stringify(self.ordercondition)
  90. }
  91. //$http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  92. $http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, data, postCfg)
  93. .success(function (obj) {
  94. var res = obj;
  95. //var res = strToJson(s4.decryptData_CBC(obj.data));
  96. self.loading = false;
  97. if (res.data == null || res.data == undefined || res.data == "") {
  98. self.noDataTip = 0;
  99. if (self.params != "") {
  100. self.params = "";
  101. self.getData(1)
  102. }
  103. } else {
  104. self.noDataTip = 1;
  105. self.list = res.data;
  106. self.total_count = res.totalCount;
  107. $.each(self.list, function (index, item) {
  108. self.GGLM.forEach(function (item1) {
  109. if (item.GGLM == item1.CODE)
  110. item.GGLM = item1.CNAME
  111. })
  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.getGGLM();
  155. self.openLayer = function () {
  156. self.params = "";
  157. if (self.search == null) {
  158. self.search = {
  159. BT: "",
  160. FBBM: "",
  161. DATE1: "",
  162. DATE2: ""
  163. }
  164. }
  165. sp.layer("#Search")
  166. }
  167. self.doSearch = function () {
  168. $.cookie("GlWorkPlatform-tongzhibg", JSON.stringify(self.search), { path: '/', expires: 1 });
  169. self.getData(self.pageno)
  170. sp.layerhide()
  171. }
  172. self.cancal = function () {
  173. self.search = {
  174. BT: "",
  175. FBBM: "",
  176. DATE1: "",
  177. DATE2: ""
  178. }
  179. $.cookie("GlWorkPlatform-tongzhibg", null, { path: '/', expires: 1 });
  180. self.getData(1)
  181. sp.layerhide()
  182. }
  183. self.refresh = function () {
  184. self.CrossPage.type = null;
  185. self.getData(self.pageno);
  186. }
  187. self.goUrl = function (item) {
  188. if (item.TODOLIST && item.TODOLIST.length > 1) {
  189. self.todoTitle = item.TITLE;
  190. self.todoList = item.TODOLIST;
  191. sp.layer("#todolist")
  192. } else {
  193. if (self.deviceType == "pad") {
  194. window.location.href = item.FILEN + "&dotype=" + getDoType(self.type)
  195. } else {
  196. sp.openNewWindow(item.FILEN + "&dotype=" + getDoType(self.type), item.TITLE)
  197. }
  198. sp.layerhide();
  199. }
  200. }
  201. self.btnDel = function (item) {
  202. var data = {
  203. routeinfoid: item.ROUTEINFOID,
  204. userid: self.userId
  205. }
  206. $http.post(apiurljs.login + "g2work/routeinfo/deleteDraftByRouteinfoid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  207. .success(function (obj) {
  208. var res = strToJson(s4.decryptData_CBC(obj.data));
  209. if (res.success == true) {
  210. self.getData(self.pageno)
  211. } else {
  212. sp.dialog(res.message)
  213. }
  214. })
  215. }
  216. self.btnRecall = function (routeid, kind) {
  217. var data = {
  218. routeid: routeid,
  219. kind: kind,
  220. userid: self.userId
  221. }
  222. $http.post(apiurljs.login + "g2work/routeinfo/queryDataRecallDoneByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  223. .success(function (obj) {
  224. var res = strToJson(s4.decryptData_CBC(obj.data));
  225. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  226. var dialogBody = "<div class=\"sp-dialog-body\">" + res.data.REMARK + "</div>";
  227. 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>";
  228. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  229. sp.openCenter(".sp-dialog");
  230. ///取消按钮
  231. $('.sp-closeDialog').click(function (event) {
  232. sp.closeCenter(".sp-dialog");
  233. event.preventDefault();
  234. event.stopPropagation();
  235. });
  236. //post消息的id
  237. $("#delDataTrue").click(function () {
  238. $http.post(apiurljs.login + "g2work/routeinfo/recallDoneByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  239. .success(function (obj) {
  240. var res = strToJson(s4.decryptData_CBC(obj.data));
  241. sp.dialoghide()
  242. if (res.success == true) {
  243. self.getData(self.pageno)
  244. } else {
  245. sp.dialog(res.message)
  246. }
  247. })
  248. });
  249. })
  250. }
  251. self.btnRecallFB = function (item) {
  252. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  253. var dialogBody = "<div class=\"sp-dialog-body\">您确定要撤回发布状态吗?</div>";
  254. 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>";
  255. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  256. sp.openCenter(".sp-dialog");
  257. ///取消按钮
  258. $('.sp-closeDialog').click(function (event) {
  259. sp.closeCenter(".sp-dialog");
  260. event.preventDefault();
  261. event.stopPropagation();
  262. });
  263. //post消息的id
  264. $("#delDataTrue").click(function () {
  265. var data = {
  266. tablename: item.CODETABLE,
  267. id: item[item.CODETABLE + ".ID"],
  268. data: {
  269. FBZT: 2//手动撤回状态
  270. }
  271. }
  272. $http.post(apiurljs.login + "g2app/dataabase/upFormData", { 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) {
  277. self.getData(self.pageno)
  278. } else {
  279. sp.dialog(res.message);
  280. }
  281. })
  282. })
  283. }
  284. self.changeType = function (str) {
  285. if (self.type == str) {
  286. return;
  287. } else {
  288. var time1 = sp.getLocalDate1();
  289. self.journalRecord(time1, sp.getLocalDate1(), "查询", "查询日志", "/g2work/routeinfo/" + self.Url)
  290. self.type = str;
  291. self.Url = getUrl(self.type);
  292. self.getData(1)
  293. }
  294. }
  295. self.getAddFlag = function () {
  296. var data = {
  297. userid: self.userId,
  298. ntops: 0
  299. }
  300. $http.post(apiurljs.login + "g2work/desktop/queryWorkflowCando", data, postCfg)
  301. .success(function (obj) {
  302. var res = strToJson(s4.decryptData_CBC(obj.data));
  303. self.lcList = [];
  304. self.activeLC = {};
  305. res.data.forEach(function (item) {
  306. if ("AA85".indexOf(item.FLOWID) > -1) {
  307. self.lcList.push(item);
  308. }
  309. })
  310. })
  311. }
  312. self.getAddFlag()
  313. self.addLC = function () {
  314. if (self.lcList.length == 1) {
  315. sp.openNewWindow(self.lcList[0].FILEN + "&dotype=1&GWCODE=" + self.lcList[0].CODE + "&flowid=" + self.lcList[0].FLOWID, self.lcList[0].FLOWNAME)
  316. //window.location.href = self.lcList[0].FILEN + "&dotype=1&GWCODE=" + self.activeLC.CODE + "&flowid=" + self.activeLC.FLOWID
  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. //window.location.href = self.activeLC.FILEN + "&dotype=1&GWCODE=" + self.activeLC.CODE + "&flowid=" + self.activeLC.FLOWID
  331. sp.layerhide()
  332. }
  333. //记录日志
  334. self.journalRecord = function (time1, time2, title, func, url) {
  335. if (!self.CrossPage || !self.CrossPage.cname) { return; }
  336. var data = {
  337. tablename: "SYS_CLICKLOG",
  338. data: {
  339. CTIME: time1 == null ? sp.getLocalDate1() : time1,
  340. TITLE: (title != "" ? self.CrossPage.cname + "/" + title : self.CrossPage.cname),
  341. REQUESTURL: url,
  342. REQUESTHEADERURL: window.location.origin,
  343. LOGTYPE: func,
  344. USERTYPE: $.cookie("GlWorkPlatform-userType"),
  345. ADMIN: $.cookie("GlWorkPlatform-userTypeEng"),
  346. CLIENTIP: sp.myIP(),
  347. PCNAME: sp.detectOS(),
  348. BROWSERNAME: sp.browser(),
  349. RESPONSETIME: time2 == null ? sp.getLocalDate1() : time2,
  350. USERID: self.userId,
  351. USERNAME: self.userName
  352. }
  353. }
  354. $http.post(apiurljs.login + "g2app/dataabase/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  355. .success(function (res) {
  356. self.CrossPage.type = 1;
  357. })
  358. }
  359. //头部下滚冻结
  360. $(function () {
  361. //页面高度撑满
  362. setTimeout(function () {
  363. if ($(".ibox-content").height() < $(window).height() - 31) {
  364. $(".ibox-content").css("height", $(window).height() - 31)
  365. }
  366. }, 1)
  367. })
  368. }])
  369. function getUrl(str) {
  370. switch (str) {
  371. case "todo":
  372. return "queryDataTodoWithPage";
  373. break;
  374. case "done":
  375. return "queryDataDoneWithPage";
  376. break;
  377. case "finish":
  378. return "queryDataFinishWithPage";
  379. break;
  380. }
  381. }
  382. function getDoType(str) {
  383. switch (str) {
  384. case "todo":
  385. return 1;
  386. break;
  387. case "finish":
  388. return 1;
  389. break;
  390. default:
  391. return 0;
  392. break;
  393. }
  394. }