gzt.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination',
  4. ]);
  5. app.controller("indexCtrl", ["$scope", "$http", "$interval", "$timeout", function ($scope, $http, $interval, $timeout) {
  6. var self = this;
  7. self.userId = $.cookie("GlWorkPlatform-userid");
  8. self.userName = $.cookie("GlWorkPlatform-username");
  9. self.userChineseName = $.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.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
  18. self.appList = []
  19. //var colors = ["#d5e7f5", "#d2f4e0", "#feedcf", "#fcdce1", "#e0f2f2", "#eae9f7"]
  20. if (self.deviceType == "pad") {
  21. var colors = ["#d5e7f5", "#d5e7f5", "#d5e7f5", "#feedcf", "#eae9f7", "#eae9f7", "#eae9f7", "#eae9f7"]//浅色
  22. } else {
  23. var colors = ["#d5e7f5", "#d5e7f5", "#d5e7f5", "#feedcf", "#eae9f7", "#eae9f7", "#eae9f7", "#eae9f7"]//浅色
  24. //colors = ["#2073b3", "#2073b3", "#2073b3", "#faaf2a", "#7369f4", "#7369f4", "#7369f4", "#7369f4"]//深色
  25. //colors = ["#904644", "#8e651d", "#403a8c", "#1d638f", "#403a8c", "#468c63", "#2e8919", "#468c63"]//红蓝绿
  26. }
  27. self.getTop6 = function () {
  28. var data = {
  29. userid: self.userId
  30. }
  31. $http.post(apiurljs.login + "g2work/routeinfo/queryDataToDoFlowRouteCountDesktopByUseridGroup", data, postCfg)
  32. .success(function (obj) {
  33. //var res = strToJson(s4.decryptData_CBC(obj.data));
  34. var res = obj;
  35. self.ywblList = res.data;
  36. $.each(self.ywblList, function (index, item) {
  37. item.background = { "background-color": "" + colors[index % 8] + "" };
  38. item.news = { "background": "url(img/triangle" + (index % 8 + 1) + ".png) no-repeat center" }
  39. item.base = { "background": "url('img/base" + (index % 8 + 1) + ".png') no-repeat center center", "background-size": "110% 115%" };
  40. item.circel = { "background": "url('img/icon" + (index % 8 + 1) + ".png') no-repeat center center rgba(74,156,247,0.6)" };
  41. if (item.DESKTOP) {
  42. for (let i = 0; i < item.DESKTOP.length; i++) {
  43. let iitem = item.DESKTOP[i]
  44. if (iitem.FILEN) {
  45. iitem.show = true || iitem.FILEN.indexOf("shouwenbg") > -1 || iitem.FILEN.indexOf("shixiangdb") > -1 || iitem.FILEN.indexOf("xinfangbg") > -1
  46. }
  47. }
  48. }
  49. if (item.CNAME == "督查督办") {
  50. var data = {
  51. userid: self.userId
  52. };
  53. $http.post(apiurljs.login + "g2work/datazu/queryDataUserAuth", data, postCfg)
  54. .success(function (res) {
  55. res.data[0].auths.forEach(function (n) {
  56. if (n.ZID == "AA84" && n.AUTH == "1") {
  57. for (var x = 0; x < item.DESKTOP.length; x++) {
  58. if (item.DESKTOP[x].FLOWCODE == "FZG09" && self.deviceType == "pad") {
  59. item.DESKTOP.splice(x + 1, 0, { CNAME: "一张图", FLOWID: "POPUP", GROUPITEMSHOW: 1, FILEN: apiurljs.onePic + "digitalHousingUrbanRuralCommissionSzpd?token=" + localStorage.getItem("main-token") + "&name=&type=&id=" })
  60. break
  61. }
  62. }
  63. }
  64. })
  65. });
  66. }
  67. })
  68. self.ywblCss = {
  69. "width": "100%",
  70. "height": self.deviceType == "pad" ? "120px" : "150px",
  71. "overflow": "hidden"
  72. }
  73. })
  74. }
  75. self.activeBottomObj = 1;
  76. self.secondAfter = 0;//记录左移右移次数
  77. self.appDbCount = 0
  78. self.getTop6()
  79. $interval(function () {
  80. self.getTop6()
  81. }, 20000)
  82. self.ywblMove = function (n) {
  83. var marginLeft = parseInt($(".List").css("margin-left").slice(0, $(".List").css("margin-left").indexOf("px"))) + n * $(".Item").outerWidth();
  84. if (marginLeft > 0) {
  85. $(".List").css("margin-left", 0)
  86. } else if (marginLeft < ($(".List").outerWidth() - $(".Item").outerWidth() * 7) * -1) {
  87. $(".List").css("margin-left", ($(".List").outerWidth() - $(".Item").outerWidth() * 7) * -1)
  88. } else {
  89. self.secondAfter = self.secondAfter + n;
  90. $(".List").css("margin-left", marginLeft)
  91. self.activeBottomObj = self.activeBottomObj + n * -1;
  92. if (self.activeBottomObj < 1) {
  93. self.activeBottomObj = 1
  94. } else if (self.activeBottomObj > self.ywblList.length) {
  95. self.activeBottomObj = self.ywblList.length;
  96. }
  97. }
  98. }
  99. self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
  100. self.addTabNav = function (obj, n) {
  101. self.activeBottomObj = n + 1
  102. $(".bottomObj").removeClass($(".bottomObj").attr("class").split(" ")[2])
  103. if (self.secondAfter != 0) {
  104. $(".bottomObj").addClass("bottomObj" + (n + 1 + self.secondAfter))
  105. } else {
  106. $(".bottomObj").addClass("bottomObj" + (n + 1))
  107. }
  108. }
  109. self.goParams = function (obj, params) {
  110. if (params != "" && params != undefined && params != null) {
  111. if (self.deviceType == "pad") {
  112. window.top.jumpPageParent(obj.FLOWCODE, obj.CNAME, obj.FILEN);
  113. } else {
  114. window.top.sp.addTabNav(obj.FLOWCODE, obj.CNAME, obj.FILEN);
  115. }
  116. } else {
  117. if (self.deviceType == "pad") {
  118. window.top.jumpPageParent(obj.FLOWCODE, obj.CNAME, obj.FILEN);
  119. } else {
  120. window.top.sp.addTabNav(obj.FLOWCODE, obj.CNAME, obj.FILEN);
  121. }
  122. }
  123. event.stopPropagation()
  124. }
  125. self.goHref = function (obj) {
  126. if (obj.FLOWID.indexOf("POPUP") > -1) {
  127. window.open(obj.FILEN + (obj.FLOWID.indexOf("TOKEN") > -1 ? "?token=" + localStorage.getItem("main-token") : ""), "")
  128. return
  129. }
  130. if (self.deviceType == "pad") {
  131. window.top.jumpPageParent(obj.FLOWCODE, obj.CNAME, obj.FILEN);
  132. } else {
  133. window.top.sp.addTabNav(obj.FLOWCODE, obj.CNAME, obj.FILEN);
  134. }
  135. }
  136. self.goHref1=function(obj){
  137. window.open(obj.FILEN)
  138. }
  139. self.goApp = function (obj) {
  140. if (obj.url.indexOf("@token") > -1) {
  141. window.top.sp.addTabNav(obj.appCode, obj.name, obj.url.replace("@token", localStorage
  142. .getItem("main-token")));
  143. } else {
  144. window.top.sp.addTabNav(obj.appCode, obj.name, obj.url);
  145. }
  146. }
  147. self.sysappListOuter = function () {
  148. let postCfg_ = {
  149. headers: {
  150. 'Content-Type': 'application/json',
  151. 'Authorization': "Bearer " + self.get_AccessToken
  152. }
  153. };
  154. var data = {
  155. token: localStorage.getItem("main-token"),
  156. userid: self.userId,
  157. type: 'oa',
  158. portalShow: 1,
  159. }
  160. $http.post(apiurljs.login + "g2app/pluginkinds/sysappListOuter",data, postCfg_)
  161. .success(function (obj) {
  162. //var res = strToJson(s4.decryptData_CBC(obj.data));
  163. var res = obj;
  164. let appList = []
  165. for (let i = 0; i < res.result.length; i++) {
  166. let item = res.result[i]
  167. for (let j = 0; j < item.appList.length; j++) {
  168. let appItem = item.appList[j]
  169. appList.push({
  170. name: appItem.appName,
  171. url: appItem.indexUrl,
  172. appCode: appItem.appCode
  173. })
  174. }
  175. }
  176. self.appList = appList
  177. self.appDbCount = 0
  178. for (let i = 0; i < self.appList.length; i++) {
  179. let data_ = {
  180. token: localStorage.getItem("main-token"),
  181. userid: self.userId,
  182. appCode: self.appList[i].appCode,
  183. portalShow: 1,
  184. }
  185. $http.post(apiurljs.login + "g2app/pluginkinds/behalf", data_, postCfg_)
  186. .success(function (objj) {
  187. //var ress = strToJson(s4.decryptData_CBC(objj.data));
  188. var res = obj;
  189. if (isNaN(parseFloat(ress.result)) == true) {
  190. self.appDbCount = 0;
  191. return
  192. }
  193. if (ress.result == '-1') {
  194. self.appList[i].dbCount = 0
  195. } else {
  196. self.appList[i].dbCount = +ress.result
  197. }
  198. self.appDbCount += self.appList[i].dbCount
  199. })
  200. }
  201. })
  202. }
  203. self.sysappListOuter()
  204. }])
  205. app.directive("repeatFinish", function () {
  206. return {
  207. link: function (scope) {
  208. if (scope.$parent.ctl.deviceType == "pad") {
  209. $(".Item").eq(scope.$index).css("width", $(window).width() / 7)
  210. if (scope.$last == true) {
  211. $(".List").css("width", scope.$parent.ctl.ywblList.length * $(window).width() / 7)
  212. }
  213. } else {
  214. $(".Item").eq(scope.$index).css("width", $(window).width() / 7)
  215. if (scope.$last == true) {
  216. $(".List").css("width", scope.$parent.ctl.ywblList.length * $(window).width() / 7)
  217. }
  218. }
  219. }
  220. };
  221. });
  222. function formate(num) {
  223. return num > 9 ? num : "0" + num;
  224. }
  225. function getWeek(date) {
  226. switch (new Date(date).getDay()) {
  227. case 0: return "星期日"; break;
  228. case 1: return "星期一"; break;
  229. case 2: return "星期二"; break;
  230. case 3: return "星期三"; break;
  231. case 4: return "星期四"; break;
  232. case 5: return "星期五"; break;
  233. case 6: return "星期六"; break;
  234. }
  235. }
  236. function getDate(str) {
  237. var year = str.getFullYear();
  238. var month = str.getMonth();
  239. var day = str.getDate();
  240. return new Date(year, month, day).getTime()
  241. }