list.js 15 KB

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