index.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("indexCtrl", ["$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.get_type = sp.getUrlName("type");
  13. var postCfg = {
  14. headers: {
  15. 'Content-Type': 'application/json',
  16. 'Authorization': "Bearer " + self.get_AccessToken
  17. }
  18. }
  19. //根据选择的底稿目录获取当前目录下的文件
  20. self.noDataTip = 1;
  21. self.rows = [];
  22. self.pageno = 1;
  23. self.total_count = 0;
  24. self.itemsPerPage = 10;
  25. self.pageOptions = [10, 15, 20, 25, 30];
  26. self.search = {
  27. WZBT: ""
  28. }
  29. self.getData = function (pageno) {
  30. self.pageno = pageno;
  31. $scope.__default__currentPage = self.pageno;
  32. // let postData = {
  33. // "pageno": self.pageno,
  34. // "pagesize": self.itemsPerPage,
  35. // "code": self.nowNodeCode,
  36. // "data_col": "YPBH",
  37. // "tablename_code": "CODE_YPTYPE",
  38. // "tablename_data": "SX_BGYPMGR",
  39. // "order": "id",
  40. // "sqlwhere": {},
  41. // "sqllikewhere": {
  42. // "YPMC": self.search.YPMC
  43. // }
  44. // }
  45. let postData = {
  46. tablename: "SX_SCJLB",
  47. pagesize: self.itemsPerPage,
  48. pageno: self.pageno,
  49. colums: "*",
  50. order: "ID",
  51. sqlwhere: {
  52. YHID: self.userId
  53. },
  54. sqlorwhere: "",
  55. sqlinwhere: "",
  56. sqllikewhere: {
  57. WZBT: self.search.WZBT
  58. }
  59. }
  60. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg)
  61. .success(function (res) {
  62. var res = strToJson(s4.decryptData_CBC(res.data));
  63. console.log(res);
  64. if (sp.isval(res.data)) {
  65. res.data.forEach(function (item) {
  66. item.YDSJ = sp.dateFtt("yyyy-MM-dd hh:mm:ss", new Date(item.YDSJ));
  67. })
  68. self.noDataTip = 1;
  69. self.rows = res.data;
  70. self.total_count = res.totalCount;
  71. } else {
  72. self.rows = [];
  73. self.noDataTip = 0;
  74. }
  75. }).error(function (err) {
  76. sp.dialog(JSON.stringify(err));
  77. });
  78. }
  79. self.getData(1);
  80. //弹出筛选框
  81. self.openSearchLayer = function () {
  82. sp.layer("#layer_search");
  83. }
  84. self.doSearch = function () {
  85. sp.closeCenter('.sp-layer');
  86. self.pageno = 1; // 初始化 当前页为 1
  87. self.getData(self.pageno);
  88. }
  89. self.deleteData = function ($item) {
  90. var getDelID = $item.ID;
  91. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  92. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  93. var dialogFoot = "<div class=\"sp-dialog-foot\"><input data-id=" + getDelID + " id='delDataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
  94. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  95. sp.openCenter(".sp-dialog");
  96. ///取消按钮
  97. $('.sp-closeDialog').click(function (event) {
  98. sp.closeCenter(".sp-dialog");
  99. event.preventDefault();
  100. event.stopPropagation();
  101. });
  102. //post消息的id
  103. $("#delDataTrue").click(function () {
  104. var getid = $(this).attr("data-id");
  105. sp.dialoghide();
  106. var data = {"id": $item.ID, "tablename": "SX_SCJLB"}
  107. //console.log(data);
  108. $http.post(apiurljs.login + "g2app/richang/delDataById", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  109. .success(function (obj) {
  110. var res = strToJson(s4.decryptData_CBC(obj.data));
  111. if (res.success) {
  112. self.getData(1);
  113. } else {
  114. sp.dialog(res.message);
  115. }
  116. })
  117. .error(function (XMLHttpRequest, textStatus, errorThrown) {
  118. })
  119. });
  120. }
  121. self.itemCheck = function (item) {
  122. console.log(item);
  123. if (item.WZMK == "文件发布") {
  124. let url='tpl/wenjianbg/WJFBB/detail.html?id=' + item.WZID + '&formPage=wenjianshow&tablename=WJFB_CB&code=LX&val=' + item.WZZMK;
  125. parent.sp.addTabNav('FZE02', '发布一览', url);
  126. } else if (item.WZMK == "图片新闻") {
  127. let url = 'tpl/wenjianbg/WJFBB1/detail.html?id=' + item.WZID + '&formPage=wenjianshow'
  128. parent.sp.addTabNav('FZE02', '发布一览', url);
  129. } else if (item.WZMK == "通知公告") {
  130. let url = 'tpl/tongzhibg/TZGG/detail.html?id=' + item.WZID + '&formPage=wenjianshow&tablename=SX_TZGG&code=GGBK&val=' + item.WZZMK;
  131. parent.sp.addTabNav('FZE02', '发布一览', url);
  132. }
  133. }
  134. }])