sqgs.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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") ? sp.getUrlName("token") : localStorage.getItem("GlWorkPlatform-AccessToken");
  11. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  12. self.type = sp.getUrlName("type");
  13. var postCfg = {
  14. headers: {
  15. 'Content-Type': 'application/json',
  16. 'Authorization': "Bearer " + self.get_AccessToken
  17. }
  18. }
  19. self.search = {
  20. type: 1,
  21. ctype: "行政许可"
  22. }
  23. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  24. self.pageno = 1;
  25. self.total_count = 0;
  26. self.itemsPerPage = 10;
  27. self.pageOptions = [10, 20, 30, 40];
  28. self.getData = function (pageno) {
  29. self.list = [];
  30. self.loading = true;
  31. self.pageno = pageno;
  32. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  33. var data = {
  34. tablename: "XQGONGSHI",
  35. pagesize: self.itemsPerPage,
  36. pageno: self.pageno,
  37. colums: "*",
  38. order: "ID",
  39. sqlwhere: { CTYPE: self.search.ctype},
  40. sqlorwhere: "",
  41. sqlinwhere: "",
  42. sqllikewhere: ""
  43. };
  44. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  45. .success(function (obj) {
  46. var res = strToJson(s4.decryptData_CBC(obj.data));
  47. if (res.data == null || res.data == undefined || res.data == "") {
  48. self.noDataTip = 0;
  49. } else {
  50. self.noDataTip = 1;
  51. self.list = res.data;
  52. self.total_count = res.totalCount;
  53. }
  54. })
  55. }
  56. self.load = function () {
  57. if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
  58. self.getData(self.pageno);
  59. } else {
  60. $timeout(function () {
  61. self.getData(self.get_lastReturnPageno);
  62. }, 1)
  63. }
  64. }
  65. self.load()
  66. self.getInfo = function (item) {
  67. var set_convertType = 0;
  68. //if (item.CODE.indexOf("pdf") > -1) {
  69. // set_convertType = 20;
  70. //} else if (item.CODE.indexOf("ofd") > -1) {
  71. // set_convertType = 570;
  72. //} else if (/(jpg|png|gif|bmp)$/i.test(item.CODE) == true) {
  73. // set_convertType = 23;
  74. //} else {
  75. // set_convertType = 0;
  76. //}
  77. //let postData = {
  78. // convertType: set_convertType,
  79. // fileUrl: apiurljs.login + "g2work/files2/inline/" + item.CODE
  80. //};
  81. let postData = {
  82. convertType: 20,
  83. fileUrl: apiurljs.login.split("glwork")[0] + "glworkweb/tpl/deskunit/0e3084aa21ac379410aa07ab29bd9381.pdf"
  84. };
  85. var postCfg_transfer = {
  86. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  87. transformRequest: function (data) {
  88. return $.param(data);
  89. }
  90. };
  91. $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
  92. .success(function (res) {
  93. //console.log(res);
  94. if (res.errorcode === 0) {
  95. let rst = res.data;
  96. if (self.type == "phone") {
  97. window.location.href = rst.viewUrl
  98. } else {
  99. window.open(rst.viewUrl);
  100. }
  101. } else {
  102. sp.dialog(res.message);
  103. }
  104. });
  105. }
  106. self.changeType = function (n) {
  107. if (self.search.type == n) {
  108. return;
  109. } else {
  110. self.search.type = n;
  111. switch(self.search.type){
  112. case 1:self.search.ctype="行政许可";break;
  113. case 2:self.search.ctype="行政处罚";break;
  114. case 3:self.search.ctype="行政强制";break;
  115. case 4:self.search.ctype="行政检查";break;
  116. case 5:self.search.ctype="行政奖励";break;
  117. case 6:self.search.ctype="其他类别";break;
  118. }
  119. self.getData(1)
  120. }
  121. }
  122. }])