search.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("listCtrl", ["$scope", "$http", "$timeout", "$sce", function ($scope, $http, $timeout, $sce) {
  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.dateParam = sp.getUrlName("date");
  12. var postCfg = {
  13. headers: {
  14. 'Content-Type': 'application/json',
  15. 'Authorization': "Bearer " + self.get_AccessToken
  16. }
  17. }
  18. self.type = 2;
  19. self.searchDWMC = "";
  20. self.searchYear = sp.currentYear() * 1;
  21. self.years = [sp.currentYear() * 1 - 2, sp.currentYear() * 1 - 1, sp.currentYear() * 1, sp.currentYear() * 1 + 1, sp.currentYear() * 1 + 2]
  22. self.getType = function () {
  23. var data = {
  24. userid: self.userId
  25. }
  26. $http.post(apiurljs.login + "g2app/dataabase/queryDPParentName", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  27. .success(function (obj) {
  28. var res = strToJson(s4.decryptData_CBC(obj.data));
  29. for (var i in res.data[0]) {
  30. if (res.data[0][i][0].PARENT_DATA.length > 0) {
  31. self.type = res.data[0][i][0].PARENT_DATA[0].SECTION != "直属单位" ? 1 : 2;
  32. } else {
  33. self.type = 1;
  34. }
  35. }
  36. self.getDP()
  37. })
  38. }
  39. self.getDP = function () {
  40. var data = {
  41. userid: self.userId
  42. }
  43. $http.post(apiurljs.login + "g2app/richang/queryDpInfo", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  44. .success(function (obj) {
  45. var res = strToJson(s4.decryptData_CBC(obj.data));
  46. self.userDpCode = res.data.length == 0 ? "" : res.data[0].CODE;
  47. self.getData();
  48. })
  49. }
  50. self.getData = function () {
  51. var sqlwhere = ["AND NF='" + self.searchYear + "'"]
  52. if (self.searchDWMC != "") {
  53. sqlwhere.push("and DWMC like '%" + self.searchDWMC + "%'")
  54. }
  55. var data = {
  56. pageno: 0,
  57. pagesize: 0,
  58. tztablename: "SX_CYZDXMTZ",
  59. tzcolums: "ID,DWMC,XMMC,WCSX",
  60. colums: "ID",
  61. order: "DWMC",
  62. sqlwhere: sqlwhere.join(" "),
  63. childtopnum: "",
  64. childcolumns: "ID,BH,WCQK,SJWCSJ",
  65. childorder: "sortid"
  66. }
  67. $http.post(apiurljs.login + "g2app/xinxifabu/queryXXFBDataWithChildAndAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  68. .success(function (obj) {
  69. var res = strToJson(s4.decryptData_CBC(obj.data));
  70. self.list = res.data;
  71. })
  72. }
  73. self.getType()
  74. self.openLayer = function () {
  75. self.searchDWMC = "";
  76. self.searchYear = sp.currentYear() * 1;
  77. sp.layer("#Search")
  78. }
  79. self.doSearch = function () {
  80. self.getData()
  81. sp.layerhide()
  82. }
  83. self.initSearch = function () {
  84. self.searchYear = sp.currentYear() * 1;
  85. self.searchDWMC = "";
  86. self.getData()
  87. sp.layerhide()
  88. }
  89. self.download = function (obj) {
  90. window.open(apiurljs.login + "g2work/files/" + obj.FILEURL.slice(7))
  91. }
  92. }])
  93. app.directive("repeatFinish", function () {
  94. return {
  95. link: function (scope) {
  96. if (scope.$last == true) {
  97. setTimeout(function () {
  98. $("#table").rowspan(0)
  99. }, 10);
  100. }
  101. }
  102. };
  103. });
  104. jQuery.fn.rowspan = function (colIdx) { //封装的一个JQuery小插件
  105. return this.each(function () {
  106. var that;
  107. $('tr', this).each(function (row) {
  108. $('td:eq(' + colIdx + ')', this).filter(':visible').each(function (col) {
  109. if (that != null && $(this).html() == $(that).html()) {
  110. var rowspan = $(that).attr("rowSpan");
  111. if (rowspan == undefined) {
  112. $(that).attr("rowSpan", 1);
  113. rowspan = $(that).attr("rowSpan");
  114. }
  115. rowspan = Number(rowspan) + 1;
  116. $(that).attr("rowSpan", rowspan);
  117. $(this).hide();
  118. } else {
  119. that = this;
  120. }
  121. });
  122. });
  123. });
  124. }