list3.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. self.val = sp.getUrlName("val");
  13. var postCfg = {
  14. headers: {
  15. 'Content-Type': 'application/json',
  16. 'Authorization': "Bearer " + self.get_AccessToken
  17. }
  18. }
  19. self.loading = false;
  20. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  21. self.pageno = 1;
  22. self.total_count = 0;
  23. self.itemsPerPage = 10;
  24. self.pageOptions = [10, 20, 30, 40];
  25. self.getGGBK = function () {
  26. var data = {
  27. ckey: "CODE_GGLM",
  28. routeinfoid: self.routeinfoid
  29. }
  30. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  31. .success(function (obj) {
  32. var res = strToJson(s4.decryptData_CBC(obj.data));
  33. self.GGBK = res.data.CODE_GGLM;
  34. if (self.tablename == "SX_TZGG") {
  35. self.GGBK.forEach(function (item) {
  36. if (item.CODE == self.val) {
  37. self.Title = item.CNAME;
  38. }
  39. })
  40. }
  41. self.getZRBM()
  42. })
  43. }
  44. self.getGGBK();
  45. self.getZRBM = function () {
  46. var data = {
  47. ckey: "CODE_ZRBM",
  48. routeinfoid: self.routeinfoid
  49. }
  50. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  51. .success(function (obj) {
  52. var res = strToJson(s4.decryptData_CBC(obj.data));
  53. self.ZRBM = res.data.CODE_ZRBM;
  54. self.load()
  55. })
  56. }
  57. self.getData = function (pageno) {
  58. self.list = [];
  59. self.loading = false;
  60. self.pageno = pageno;
  61. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  62. var data = {
  63. tablename: "SX_TZGG",
  64. pagesize: self.itemsPerPage,
  65. pageno: self.pageno,
  66. colums: "ID,GGBT,FBSJ,FBBM",
  67. order: "ID",
  68. sqlwhere: "and FBZT=1 and GGBK='"+self.val+"' and (FBFWMANUSERID like '%" + self.userId + "%' or FBFWMANUSERID='全部')"
  69. };
  70. $http.post(apiurljs.login + "g2app/DangJian/queryDataByColWithPage3", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  71. .success(function (obj) {
  72. var res = strToJson(s4.decryptData_CBC(obj.data));
  73. self.loading = false;
  74. if (res.data == null || res.data == undefined || res.data == "") {
  75. self.noDataTip = 0;
  76. } else {
  77. self.noDataTip = 1;
  78. self.list = res.data;
  79. self.total_count = res.totalCount;
  80. self.list.forEach(function (item) {
  81. if (item.FBBM.indexOf("C") > -1) {
  82. self.ZRBM.forEach(function (item1) {
  83. if (item.FBBM == item1.CODE) {
  84. item.FBBM1 = item1.CNAME;
  85. }
  86. })
  87. } else {
  88. item.FBBM1 = item.FBBM;
  89. }
  90. })
  91. }
  92. })
  93. }
  94. self.load = function () {
  95. if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
  96. self.getData(self.pageno);
  97. } else {
  98. $timeout(function () {
  99. self.getData(self.get_lastReturnPageno);
  100. }, 1)
  101. }
  102. }
  103. self.goUrl = function (item) {
  104. sp.openNewWindow("../../tpl/tongzhibg/TZGG/detail.html?id=" + item.ID + "&formPage=wenjianshow&val=" + self.val + "&lastReturnPageno=" + self.pageno, item.GGBT)
  105. }
  106. //头部下滚冻结
  107. $(function () {
  108. //页面高度撑满
  109. setTimeout(function () {
  110. if ($(".ibox-content").height() < $(window).height() - 31) {
  111. $(".ibox-content").css("height", $(window).height() - 31)
  112. }
  113. }, 1)
  114. })
  115. }])