list1.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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.code = sp.getUrlName("code");
  13. self.code1 = sp.getUrlName("code1");
  14. self.leaf = sp.getUrlName("leaf") | 0;
  15. self.returnHtml = "list1.html?code=" + self.code1 + "&lastReturnPageno=" + self.get_lastReturnPageno + (self.leaf ? "&leaf=" + (self.leaf - 1) : "")
  16. var postCfg = {
  17. headers: {
  18. 'Content-Type': 'application/json',
  19. 'Authorization': "Bearer " + self.get_AccessToken
  20. }
  21. }
  22. self.CrossPage = window.parent.CrossPage;
  23. self.loading = false;
  24. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  25. self.pageno = 1;
  26. self.total_count = 0;
  27. self.itemsPerPage = 10;
  28. self.pageOptions = [10, 20, 30, 40];
  29. self.getLM = function () {
  30. var data = {
  31. tablename: "CODE_LM"
  32. }
  33. $http.post(apiurljs.login + "g2app/filepublishing/getTreeListByTablename", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  34. .success(function (obj) {
  35. var res = strToJson(s4.decryptData_CBC(obj.data));
  36. self.LM = res.data[0].C_H_I_L_D_DATA;
  37. self.ZD = [];//置顶专栏
  38. self.ZT = [];//普通专栏
  39. self.PT = [];//普通栏目
  40. self.LM.forEach(function (item) {
  41. if (self.leaf == 0) {
  42. if (item.CODE == self.code) {
  43. self.Title = item.CNAME;
  44. item.C_H_I_L_D_DATA.forEach(function (item1) {
  45. item1.IMGURL = item1.IMGURL != null && item1.IMGURL != undefined ? sp.ipChange(item1.IMGURL) : ""
  46. if (item1.COLUMNTYPE == 0) {
  47. self.ZD.push(item1)
  48. } else if (item1.COLUMNTYPE == 1) {
  49. self.ZT.push(item1)
  50. } else {
  51. self.PT.push(item1)
  52. }
  53. })
  54. }
  55. } else {
  56. item.C_H_I_L_D_DATA.forEach(function (item1) {
  57. item1.IMGURL = item1.IMGURL != null && item1.IMGURL != undefined ? sp.ipChange(item1.IMGURL) : ""
  58. if (item1.CODE == self.code) {
  59. self.Title = item1.CNAME;
  60. item1.C_H_I_L_D_DATA.forEach(function (item2) {
  61. if (item2.COLUMNTYPE == 0) {
  62. self.ZD.push(item2)
  63. }else if (item2.COLUMNTYPE == 1) {
  64. self.ZT.push(item2)
  65. } else {
  66. self.PT.push(item2)
  67. }
  68. })
  69. }
  70. })
  71. }
  72. })
  73. self.getZRBM()
  74. })
  75. }
  76. self.getLM();
  77. self.getZRBM = function () {
  78. var data = {
  79. ckey: "CODE_ZRBM",
  80. routeinfoid: self.routeinfoid
  81. }
  82. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  83. .success(function (obj) {
  84. var res = strToJson(s4.decryptData_CBC(obj.data));
  85. self.ZRBM = res.data.CODE_ZRBM;
  86. self.load()
  87. })
  88. }
  89. self.today = sp.format(sp.getLocalDate());
  90. self.getData = function (pageno) {
  91. var CODE = ["'" + self.code + "'"];
  92. self.PT.forEach(function (item) {
  93. CODE.push("'" + item.CODE + "'")
  94. })
  95. self.list = [];
  96. self.loading = false;
  97. self.pageno = pageno;
  98. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  99. var sqlwhere = { FBZT: "1" };
  100. var data = {
  101. tablename: "SX_FBLIST",
  102. pagesize: self.itemsPerPage,
  103. pageno: self.pageno,
  104. colums: "*",
  105. order: "FBRQ",
  106. sqlwhere: " and LM in(" + CODE.join(",") + ") and gkfw ISNULL OR gkfw LIKE '" + self.userId + "'"
  107. };
  108. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage3", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  109. .success(function (obj) {
  110. var res = strToJson(s4.decryptData_CBC(obj.data));
  111. self.loading = false;
  112. if (res.data == null || res.data == undefined || res.data == "") {
  113. self.noDataTip = 0;
  114. } else {
  115. self.noDataTip = 1;
  116. self.list = res.data;
  117. self.total_count = res.totalCount;
  118. self.list.forEach(function (item) {
  119. self.ZRBM.forEach(function (item1) {
  120. if (item.FBBM == item1.CODE) {
  121. item.FBBM1 = item1.CNAME;
  122. }
  123. })
  124. })
  125. }
  126. })
  127. }
  128. self.load = function () {
  129. if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
  130. self.getData(self.pageno);
  131. } else {
  132. $timeout(function () {
  133. self.getData(self.get_lastReturnPageno);
  134. }, 1)
  135. }
  136. }
  137. self.goUrl = function (item) {
  138. //if (self.tablename == "WJFB_CB") {
  139. // window.location.href = "../../tpl/wenjianbg/WJFBB/detail.html?id=" + item.ID + "&formPage=wenjianshow&&tablename=" + self.tablename + "&code=" + self.code + "&val=" + self.val
  140. //} else {
  141. // window.location.href = "../../tpl/tongzhibg/TZGG/detail.html?id=" + item.ID + "&formPage=wenjianshow&&tablename=" + self.tablename + "&code=" + self.code + "&val=" + self.val
  142. //}
  143. sp.openNewWindow("detail.html?id=" + item.ID + "&code=" + self.code + "&code1=" + self.code1 + "&lastReturnPageno=" + self.pageno + (self.leaf ? "&leaf=1" : ""), item.WJBT)
  144. //window.location.href = "detail.html?id=" + item.ID + "&code=" + self.code + "&code1=" + self.code1 + "&lastReturnPageno=" + self.pageno + (self.leaf ? "&leaf=1" : "");
  145. }
  146. self.goZL = function (item) {
  147. window.location.href = "list1.html?code=" + item.CODE + "&leaf=" + (self.leaf + 1) + "&code1=" + self.code;
  148. }
  149. //头部下滚冻结
  150. $(function () {
  151. //页面高度撑满
  152. setTimeout(function () {
  153. if ($(".ibox-content").height() < $(window).height() - 31) {
  154. $(".ibox-content").css("height", $(window).height() - 31)
  155. }
  156. }, 1)
  157. })
  158. }])