list.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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-huiyishibg"));
  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: "AA27", NAME: "会议申请表(知会物业)", checked: false }, { ID: "AA71", NAME: "会议通知单", checked: false }, { ID: "AA72", NAME: "会议通知(对外)", checked: false }]
  32. self.ordercondition = []
  33. self.getData = function (pageno) {
  34. if (self.search == null) {
  35. self.search = {
  36. FLOW: [],
  37. BT: "",
  38. CBBM: "",
  39. HYS: "",
  40. DATE1: "",
  41. DATE2: ""
  42. }
  43. }
  44. var flowids = self.search.FLOW.join("|");
  45. var querycondition = [];
  46. var columnscondition = [
  47. { COLID: "CBBM", COLUMNS: "SX_HYSQBZHWY.CBBM|SX_HYTZD.CSZB" },
  48. { COLID: "HYS", COLUMNS: "SX_HYSQBZHWY.HYS|SX_HYTZD.HYDD|SX_HYTZDW.DD" },
  49. { COLID: "CHRS", COLUMNS: "SX_HYSQBZHWY.CHRS" }
  50. ]
  51. if (self.search.BT != "") {
  52. querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "TITLE", "VALUEA": self.search.BT, "VALUEB": "" })
  53. }
  54. if (self.search.CBBM != "") {
  55. querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "CODETABLE", "COLID": "CBBM", "VALUEA": self.search.CBBM, "VALUEB": "" })
  56. }
  57. if (self.search.HYS != "") {
  58. querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "CODETABLE", "COLID": "HYS", "VALUEA": self.search.HYS, "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.DATE1 != "" && self.search.DATE2 != "") {
  64. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": self.search.DATE1, "VALUEB": self.search.DATE2 })
  65. } else if (self.search.DATE1 != "" && self.search.DATE2 == "") {
  66. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": self.search.DATE1, "VALUEB": "" })
  67. } else if (self.search.DATE1 == "" && self.search.DATE2 != "") {
  68. querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": "", "VALUEB": self.search.DATE2 })
  69. }
  70. self.list = [];
  71. self.loading = false;
  72. self.pageno = pageno;
  73. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  74. var data = {
  75. flowid: flowids == "" ? "AA27|AA71|AA72" : flowids,
  76. userid: self.userId,
  77. pageno: self.pageno,
  78. pagesize: self.itemsPerPage,
  79. columnscondition: JSON.stringify(columnscondition),
  80. querycondition: JSON.stringify(querycondition),
  81. ordercondition: self.ordercondition.length == 0 ? "" : JSON.stringify(self.ordercondition)
  82. }
  83. //$http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  84. $http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, data, postCfg)
  85. .success(function (obj) {
  86. var res = obj;
  87. //var res = strToJson(s4.decryptData_CBC(obj.data));
  88. self.loading = false;
  89. if (res.data == null || res.data == undefined || res.data == "") {
  90. self.noDataTip = 0;
  91. if (self.params != "") {
  92. self.params = "";
  93. self.getData(1)
  94. }
  95. } else {
  96. self.noDataTip = 1;
  97. self.list = res.data;
  98. self.total_count = res.totalCount;
  99. $.each(self.list, function (index, item) {
  100. if (item.FILEN != "") {
  101. item.FILEN = item.FILEN.indexOf("dotype") > -1 ? item.FILEN.replace("dotype=1", "dotype=" + getDoType(self.type)) + "&type=" + self.type + "&lastReturnPageno=" + self.pageno + "&flowid=" + item.FLOWID : item.FILEN + "&dotype=" + getDoType(self.type) + "&type=" + self.type + "&lastReturnPageno=" + self.pageno + "&flowid=" + item.FLOWID;
  102. } else {
  103. item.FILEN = "#";
  104. }
  105. if (self.type == "finish") {
  106. item.RECEIVEDATE = item.FINISHEDDATE;
  107. }
  108. })
  109. }
  110. if (self.CrossPage.type == 0) {
  111. self.journalRecord(self.CrossPage.ctime, sp.getLocalDate1(), "", "接入日志", window.location.pathname)
  112. }
  113. })
  114. }
  115. self.load = function () {
  116. if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
  117. self.getData(self.pageno);
  118. } else {
  119. $timeout(function () {
  120. self.getData(self.get_lastReturnPageno);
  121. }, 1)
  122. }
  123. }
  124. self.sortFiled = function (str) {
  125. var n = 0, obj, x = -1;
  126. self.ordercondition.forEach(function (item, index) {
  127. if (item.COLID == str) {
  128. n++
  129. item.SORTTYPE = item.SORTTYPE == "" || item.SORTTYPE == "asc" ? "desc" : "asc"
  130. obj = item; x = index
  131. }
  132. })
  133. if (n == 0) {
  134. self.ordercondition.unshift({ COLID: str, SORTTYPE: "desc" })
  135. }
  136. if (x != -1) {
  137. self.ordercondition.splice(x, 1)
  138. self.ordercondition.unshift(obj)
  139. }
  140. self.getData(1);
  141. }
  142. self.load();
  143. self.openLayer = function () {
  144. self.params = "";
  145. if (self.search == null) {
  146. self.search = {
  147. FLOW: [],
  148. BT: "",
  149. CBBM: "",
  150. HYS: "",
  151. DATE1: "",
  152. DATE2: ""
  153. }
  154. } else {
  155. self.flowids.forEach(function (item) {
  156. item.checked = false;
  157. if (self.search.FLOW.indexOf(item.ID) > -1) {
  158. item.checked = true;
  159. }
  160. })
  161. }
  162. sp.layer("#Search")
  163. }
  164. self.doSearch = function () {
  165. self.search.FLOW = [];
  166. self.flowids.forEach(function (item) {
  167. if (item.checked == true) {
  168. self.search.FLOW.push(item.ID)
  169. }
  170. })
  171. $.cookie("GlWorkPlatform-huiyishibg", JSON.stringify(self.search), { path: '/', expires: 1 });
  172. self.getData(self.pageno)
  173. sp.layerhide()
  174. }
  175. self.cancal = function () {
  176. self.search = {
  177. FLOW: [],
  178. BT: "",
  179. CBBM: "",
  180. HYS: "",
  181. DATE1: "",
  182. DATE2: ""
  183. }
  184. $.cookie("GlWorkPlatform-huiyishibg", null, { path: '/', expires: 1 });
  185. self.getData(1)
  186. sp.layerhide()
  187. }
  188. self.refresh = function () {
  189. self.CrossPage.type = null;
  190. self.getData(self.pageno);
  191. }
  192. self.goUrl = function (item) {
  193. if (item.TODOLIST && item.TODOLIST.length > 1) {
  194. self.todoTitle = item.TITLE;
  195. self.todoList = item.TODOLIST;
  196. sp.layer("#todolist")
  197. } else {
  198. if (self.deviceType == "pad") {
  199. window.location.href = item.FILEN + "&dotype=" + getDoType(self.type)
  200. } else {
  201. sp.openNewWindow(item.FILEN + "&dotype=" + getDoType(self.type), item.TITLE)
  202. }
  203. sp.layerhide();
  204. }
  205. }
  206. self.btnDel = function (item) {
  207. var data = {
  208. routeinfoid: item.ROUTEINFOID,
  209. userid: self.userId
  210. }
  211. $http.post(apiurljs.login + "g2work/routeinfo/deleteDraftByRouteinfoid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  212. .success(function (obj) {
  213. var res = strToJson(s4.decryptData_CBC(obj.data));
  214. if (res.success == true) {
  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 ("AA27|AA71|AA72".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&flowid=" + self.lcList[0].FLOWID, self.lcList[0].FLOWNAME)
  288. //window.location.href = self.lcList[0].FILEN + "&dotype=1"
  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&flowid=" + self.activeLC.FLOWID, self.activeLC.FLOWNAME)
  302. sp.layerhide()
  303. }
  304. //记录日志
  305. self.journalRecord = function (time1, time2, title, func, url) {
  306. if (!self.CrossPage || !self.CrossPage.cname) { return; }
  307. var data = {
  308. tablename: "SYS_CLICKLOG",
  309. data: {
  310. CTIME: time1 == null ? sp.getLocalDate1() : time1,
  311. TITLE: (title != "" ? self.CrossPage.cname + "/" + title : self.CrossPage.cname),
  312. REQUESTURL: url,
  313. REQUESTHEADERURL: window.location.origin,
  314. LOGTYPE: func,
  315. USERTYPE: $.cookie("GlWorkPlatform-userType"),
  316. ADMIN: $.cookie("GlWorkPlatform-userTypeEng"),
  317. CLIENTIP: sp.myIP(),
  318. PCNAME: sp.detectOS(),
  319. BROWSERNAME: sp.browser(),
  320. RESPONSETIME: time2 == null ? sp.getLocalDate1() : time2,
  321. USERID: self.userId,
  322. USERNAME: self.userName
  323. }
  324. }
  325. $http.post(apiurljs.login + "g2app/dataabase/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  326. .success(function (res) {
  327. self.CrossPage.type = 1;
  328. })
  329. }
  330. $interval(function () {
  331. if (localStorage.getItem("GlWorkPlatform-huiyishibg-refresh") == 1) {
  332. localStorage.removeItem("GlWorkPlatform-huiyishibg-refresh")
  333. self.refresh()
  334. }
  335. }, 1000)
  336. //头部下滚冻结
  337. $(function () {
  338. //页面高度撑满
  339. setTimeout(function () {
  340. if ($(".ibox-content").height() < $(window).height() - 31) {
  341. $(".ibox-content").css("height", $(window).height() - 31)
  342. }
  343. }, 1)
  344. })
  345. }])
  346. function getUrl(str) {
  347. switch (str) {
  348. case "todo":
  349. return "queryDataTodoWithPage";
  350. break;
  351. case "done":
  352. return "queryDataDoneWithPage";
  353. break;
  354. case "finish":
  355. return "queryDataFinishWithPage";
  356. break;
  357. }
  358. }
  359. function getDoType(str) {
  360. switch (str) {
  361. case "todo":
  362. return 1;
  363. break;
  364. default:
  365. return 0;
  366. break;
  367. }
  368. }