list.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. var postCfg = {
  12. headers: {
  13. 'Content-Type': 'application/json',
  14. 'Authorization': "Bearer " + self.get_AccessToken
  15. }
  16. }
  17. self.thead = [];
  18. self.getDP = function () {
  19. var data = {
  20. userid: self.userId
  21. }
  22. $http.post(apiurljs.login + "g2app/richang/queryDpInfo", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  23. .success(function (obj) {
  24. var res = strToJson(s4.decryptData_CBC(obj.data));
  25. self.SECTCODE = res.data.length == 0 ? "" : res.data[0].CODE;
  26. self.getDpList();
  27. })
  28. }
  29. self.getDP()
  30. self.getDpList = function () {
  31. var data = {
  32. unitid: "AA"
  33. }
  34. $http.post(apiurljs.login + "g2app/dataabase/querySectByCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  35. .success(function (obj) {
  36. var res = strToJson(s4.decryptData_CBC(obj.data));
  37. self.dpList = [];
  38. res.data.forEach(function (item) {
  39. if (item.CHILD_DATA.length == 0) {
  40. self.dpList.push(item)
  41. } else {
  42. item.CHILD_DATA.forEach(function (item1) {
  43. if (item1.CHILD_DATA.length == 0) {
  44. self.dpList.push(item1)
  45. } else {
  46. item1.CHILD_DATA.forEach(function (item2) {
  47. if (item2.CHILD_DATA.length == 0) {
  48. self.dpList.push(item2)
  49. }
  50. })
  51. }
  52. })
  53. }
  54. })
  55. self.dpList.forEach(function (item) {
  56. item.checked = false;
  57. })
  58. self.getData()
  59. })
  60. }
  61. self.getData = function () {
  62. self.list = [];
  63. var data = {
  64. userid: "",
  65. sectcode: self.SECTCODE
  66. }
  67. $http.post(apiurljs.login + "g2work/func/queryDataUserAuthList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  68. .success(function (obj) {
  69. var res = strToJson(s4.decryptData_CBC(obj.data));
  70. self.loading = false;
  71. if (res.data == null || res.data == undefined || res.data == "") {
  72. self.noDataTip = 0;
  73. } else {
  74. self.noDataTip = 1;
  75. var arr = [];
  76. for (var i in res.data[0]) {
  77. if (i.indexOf("FUNCTION") > -1) {
  78. self.thead.push(res.data[0][i])
  79. }
  80. }
  81. res.data.forEach(function (item) {
  82. var obj = { USHOWNAME: item.USHOWNAME, SECTION: item.SECTION, DUTYNAME: item.DUTYNAME, STATION: item.STATION }
  83. obj.line = Math.ceil(item.DUTYNAME.length / 6);//0;
  84. self.thead.forEach(function (x, y) {
  85. obj[x.PKID] = x.AUTHLIST.map(function (a) {
  86. return a.ZUM + "【" + a.VALUE + "】"
  87. })
  88. if (obj.line < x.AUTHLIST.length) {
  89. obj.line = x.AUTHLIST.length;
  90. }
  91. })
  92. obj.style = { "height": obj.line * 20 + 15 }//{ "width": "84px", "line-height": obj.line * 20 + "px", "overflow": "hidden", "white-space": "nowrap", "text-overflow": "ellipsis" }
  93. self.list.push(obj)
  94. })
  95. }
  96. })
  97. }
  98. self.checkDpItem = function (obj) {
  99. self.SECTCODE = obj.CODE;
  100. sp.layerhide()
  101. self.getData()
  102. }
  103. //头部下滚冻结
  104. $(function () {
  105. //页面高度撑满
  106. setTimeout(function () {
  107. if ($(".ibox-content").height() < $(window).height() - 31) {
  108. $(".ibox-content").css("height", $(window).height() - 31)
  109. }
  110. $(".table-body-left").css("height", $(".ibox-content").height() - 51)
  111. $(".table-body-right").css("height", $(".ibox-content").height() - 37)
  112. }, 1)
  113. })
  114. }])
  115. function scrollTableL() {
  116. $(".table-body-right").scrollTop($(".table-body-left").scrollTop())
  117. }
  118. function scrollTableR() {
  119. $(".table-head-right").scrollLeft($(".table-body-right").scrollLeft())
  120. $(".table-body-left").scrollTop($(".table-body-right").scrollTop())
  121. }