list.js 16 KB

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