list.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  12. var postCfg = {
  13. headers: {
  14. 'Content-Type': 'application/json',
  15. 'Authorization': "Bearer " + self.get_AccessToken
  16. }
  17. }
  18. self.loading = false;
  19. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  20. self.listTotal1 = [];
  21. self.listTotal2 = [];
  22. self.list = [];
  23. self.pageno = 1;
  24. self.total_count = 0;
  25. self.itemsPerPage = 10;
  26. self.pageOptions = [10, 20, 30, 40];
  27. self.search = JSON.parse($.cookie("ygdlist-search"));
  28. //1为已提交、2为退回、3为合并提交、4为合并草稿、5为封装、6为已整理提交
  29. self.getData = function (pageno, type) {
  30. if (self.search == null) {
  31. self.search = {
  32. title: "",
  33. dah: ""
  34. }
  35. }
  36. $.cookie("ygdlist-search", JSON.stringify(self.search), { path: '/', expires: 1 });
  37. self.loading = true;
  38. self.pageno = pageno;
  39. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  40. self.list = [];
  41. var data = {
  42. tablename: "DA_YGD",
  43. pagesize: self.itemsPerPage,
  44. pageno: self.pageno,
  45. colums: "ID,ROUTEINFOID,TITLE_PROPER,OFFICE_ARCHIVAL_CODE,RETENTION_PERIOD,TO_CHAR(DATE_OF_CREATION,'yyyy-mm-dd')as DATE_OF_CREATION",
  46. order: "ID",
  47. sqlwhere: "",
  48. sqlorwhere: "",
  49. sqlinwhere: "",
  50. sqllikewhere: {
  51. TITLE_PROPER: self.search.title,
  52. OFFICE_ARCHIVAL_CODE: self.search.dah
  53. }
  54. };
  55. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  56. .success(function (obj) {
  57. var res = strToJson(s4.decryptData_CBC(obj.data));
  58. self.loading = false;
  59. if (res.totalCount == 0) {
  60. self.noDataTip = 0;
  61. } else if (res.data == null || res.data == undefined || res.data == "") {
  62. self.noDataTip = 0;
  63. self.getData(self.pageno - 1)
  64. } else {
  65. self.noDataTip = 1;
  66. self.list = res.data;
  67. self.list.forEach(function (item) {
  68. item.RETENTION_PERIOD1 = item.RETENTION_PERIOD == "D10" ? "10年" : item.RETENTION_PERIOD == "D30" ? "30年" : item.RETENTION_PERIOD == "Y" ? "永久" : item.RETENTION_PERIOD
  69. })
  70. }
  71. })
  72. }
  73. self.load = function () {
  74. if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
  75. self.getData(self.pageno);
  76. } else {
  77. $timeout(function () {
  78. self.getData(parseInt(self.get_lastReturnPageno));
  79. }, 1)
  80. }
  81. }
  82. self.load();
  83. self.refresh = function () {
  84. self.CrossPage.type = null;
  85. self.getData(self.pageno);
  86. }
  87. ///查询-打开弹出层
  88. self.openSearchLayer = function () {
  89. if (self.search == null) {
  90. self.search = {
  91. title: "",
  92. dah: ""
  93. }
  94. }
  95. sp.layer("#search");
  96. }
  97. self.btnSearch = function () {
  98. self.getData(1);
  99. sp.layerhide()
  100. }
  101. self.closeSeach = function () {
  102. self.search = {
  103. title: "",
  104. dah: ""
  105. }
  106. sp.layerhide();
  107. $.cookie("ygdlist-search", null, { path: '/', expires: -1 });
  108. self.getData(1);
  109. };
  110. self.Edit = function (item) {
  111. window.location.href = "yuguidang.html?ID=" + item.ID + "&routeinfoid=" + item.ROUTEINFOID + "&lastReturn=list&lastReturnPageno=" + self.pageno
  112. event.stopPropagation()
  113. }
  114. self.Delete = function (id) {
  115. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  116. var dialogBody = "<div class=\"sp-dialog-body\">您确认要删除此记录吗?</div>";
  117. var dialogFoot = "<div class=\"sp-dialog-foot\"><input id='upDataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
  118. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  119. sp.openCenter(".sp-dialog");
  120. $('.sp-closeDialog').click(function (event) {
  121. sp.dialoghide();
  122. event.preventDefault();
  123. event.stopPropagation();
  124. });
  125. $("#upDataTrue").click(function () {
  126. sp.dialoghide();
  127. var data = {
  128. tablename: "DA_YGD",
  129. id: id
  130. };
  131. $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  132. .success(function (obj) {
  133. var res = strToJson(s4.decryptData_CBC(obj.data));
  134. if (res.success) {
  135. self.getData(self.pageno);
  136. }
  137. })
  138. })
  139. }
  140. //头部下滚冻结
  141. $(function () {
  142. //页面高度撑满
  143. setTimeout(function () {
  144. if ($(".ibox-content").height() < $(window).height() - 31) {
  145. $(".ibox-content").css("height", $(window).height() - 31)
  146. }
  147. }, 1)
  148. })
  149. }])