list.js 15 KB

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