list1.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
  12. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  13. var postCfg = {
  14. headers: {
  15. 'Content-Type': 'application/json',
  16. 'Authorization': "Bearer " + self.get_AccessToken
  17. }
  18. }
  19. var weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
  20. self.role = false;
  21. self.getROLE = function () {
  22. var data = {
  23. userid: self.userId
  24. };
  25. $http.post(apiurljs.login + "g2work/datazu/queryDataUserAuth", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  26. .success(function (obj) {
  27. var res = strToJson(s4.decryptData_CBC(obj.data));
  28. for (var i = 0; i < res.data[0].auths.length; i++) {
  29. if (res.data[0].auths[i].ZID == "AA82" && res.data[0].auths[i].AUTH == 1) {
  30. self.role = true;
  31. }
  32. }
  33. self.getJJQK();
  34. });
  35. }
  36. self.getROLE()
  37. self.search = {
  38. HYZZDW: "",
  39. HYMC: "",
  40. HYRQ: "",//sp.format(sp.getLocalDate())
  41. CHLD: "",
  42. CHWLD: ""
  43. }
  44. self.getJJQK = function () {
  45. var data = {
  46. ckey: "CODE_EMERGENCY",
  47. routeinfoid: self.routeinfoid
  48. }
  49. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  50. .success(function (obj) {
  51. var res = strToJson(s4.decryptData_CBC(obj.data));
  52. self.JJQK = res.data.CODE_EMERGENCY;
  53. self.load()
  54. })
  55. }
  56. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  57. self.pageno = 1;
  58. self.total_count = 0;
  59. self.itemsPerPage = 10;
  60. self.pageOptions = [10, 20, 30, 40];
  61. self.getData = function (pageno) {
  62. self.list = [];
  63. self.loading = false;
  64. self.pageno = pageno;
  65. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  66. var sqlwhere = "";
  67. if (self.search.HYZZDW != "") {
  68. sqlwhere += " and HYZZDW like'%" + self.search.HYZZDW + "%'"
  69. }
  70. if (self.search.HYMC != "") {
  71. sqlwhere += " and HYMC like'%" + self.search.HYMC + "%'"
  72. }
  73. if (self.search.HYRQ != "") {
  74. sqlwhere += " and HYRQ BETWEEN '" + self.search.HYRQ + " 00:00:00' AND '" + self.search.HYRQ + " 23:59:59'"
  75. }
  76. if (self.search.CHLD != "") {
  77. sqlwhere += " and CHLD like'%" + self.search.CHLD + "%'"
  78. }
  79. if (self.search.CHWLD != "") {
  80. sqlwhere += " and CHWLD like'%" + self.search.CHWLD + "%'"
  81. }
  82. var data = {
  83. tablename: "SX_PHD",
  84. colums: "*",
  85. order: "HYRQ desc",
  86. sqlwhere: sqlwhere,
  87. pageno: self.pageno,
  88. pagesize: self.itemsPerPage
  89. };
  90. console.log(data)
  91. $http.post(apiurljs.login + "g2app/dataabase/queryFormFlowWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  92. .success(function (obj) {
  93. var res = strToJson(s4.decryptData_CBC(obj.data));
  94. console.log(res.data)
  95. self.loading = false;
  96. if (res.data == null || res.data == undefined || res.data == "") {
  97. self.noDataTip = 0;
  98. } else {
  99. self.noDataTip = 1;
  100. self.list = res.data;
  101. self.total_count = res.totalCount;
  102. self.list.forEach(function (item) {
  103. item.WEEK = weeks[new Date(item.HYRQ).getDay()]
  104. item.HYRQ = sp.datefmt("yyyy-MM-dd HH:mm", item.HYRQ)
  105. self.JJQK.forEach(function (item1) {
  106. if (item.JJCD) {
  107. if (item.JJCD == item1.CODE)
  108. item.JJCD = item1.CNAME
  109. }
  110. })
  111. })
  112. }
  113. })
  114. }
  115. self.load = function () {
  116. if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
  117. self.getData(self.pageno);
  118. } else {
  119. $timeout(function () {
  120. self.getData(self.get_lastReturnPageno);
  121. }, 1)
  122. }
  123. }
  124. self.openLayer = function () {
  125. self.search = {
  126. HYZZDW: "",
  127. HYMC: "",
  128. HYRQ: "",//sp.format(sp.getLocalDate())
  129. CHLD: "",
  130. CHWLD: ""
  131. }
  132. sp.layer("#Search")
  133. }
  134. self.doSearch = function () {
  135. self.getData(self.pageno)
  136. sp.layerhide()
  137. }
  138. self.cancal = function () {
  139. self.search = {
  140. HYZZDW: "",
  141. HYMC: "",
  142. HYRQ: "",//sp.format(sp.getLocalDate())
  143. CHLD: "",
  144. CHWLD: ""
  145. }
  146. self.getData(1)
  147. sp.layerhide()
  148. }
  149. self.refresh = function () {
  150. self.getData(self.pageno);
  151. }
  152. self.goUrl = function (item) {
  153. if (self.deviceType == "pad") {
  154. window.location.href = "detail.html?routeinfoid=" + item.ROUTEINFOID
  155. } else {
  156. sp.openNewWindow("detail.html?routeinfoid=" + item.ROUTEINFOID, item.HYMC)
  157. }
  158. }
  159. self.editBZ = function (item) {
  160. self.edit = {
  161. ID: item.ID,
  162. HYMC: item.HYMC,
  163. BZ: item.BZ
  164. }
  165. sp.layer("#editBZ")
  166. }
  167. self.btnSave = function () {
  168. var data = {
  169. tablename: "SX_PHD",
  170. id: self.edit.ID,
  171. data: JSON.stringify({
  172. BZ: self.edit.BZ
  173. })
  174. }
  175. $http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  176. .success(function (obj) {
  177. var res = strToJson(s4.decryptData_CBC(obj.data));
  178. sp.layerhide()
  179. if (res.success) {
  180. self.getData(self.pageno)
  181. } else {
  182. sp.dialog(res.message)
  183. }
  184. })
  185. }
  186. $interval(function () {
  187. if (localStorage.getItem("GlWorkPlatform-PH1-refresh") == 1) {
  188. localStorage.removeItem("GlWorkPlatform-PH1-refresh")
  189. self.refresh()
  190. }
  191. }, 1000)
  192. //头部下滚冻结
  193. $(function () {
  194. //页面高度撑满
  195. setTimeout(function () {
  196. if ($(".ibox-content").height() < $(window).height() - 31) {
  197. $(".ibox-content").css("height", $(window).height() - 31)
  198. }
  199. }, 1)
  200. })
  201. }])