gzt.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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.flows = [];
  18. self.test = [];
  19. self.getFlow = function () {
  20. var data = {
  21. userid: self.userId,
  22. ntops: 0//6
  23. }
  24. $http.post(apiurljs.login + "g2work/routeinfo/queryDataToDoFlowRouteCountDesktopByUserid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  25. .success(function (obj) {
  26. var res = strToJson(s4.decryptData_CBC(obj.data));
  27. res.data.forEach(function (item) {
  28. if (item.FLOWID != "无") {
  29. self.flows.push(item.FLOWID)
  30. self.test.push({ FLOWID: item.FLOWID, FLOWCODE: item.FLOWCODE, CNAME: item.CNAME, FILEN: item.FILEN })
  31. }
  32. })
  33. //self.getToTal(0)//国务院来文等数量
  34. })
  35. }
  36. self.active = {
  37. str: "",
  38. size: 0
  39. }
  40. self.getToTal = function (n) {
  41. var data = {
  42. userid: self.userId,
  43. ntops: 0
  44. };
  45. $http.post(apiurljs.login + "g2work/routeinfo/queryDataToDoFlowRouteRecordDesktopByUserid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  46. .success(function (obj) {
  47. var res = strToJson(s4.decryptData_CBC(obj.data));
  48. self.totalObj = res.data;
  49. if (n == 0) {
  50. self.totalObj.NEWCOUNT > 0 ?
  51. self.getdbList(self.totalObj.NEWCOUNT, self.totalObj.NEWROUTEIDVARLIST) :
  52. self.totalObj.LW01COUNT > 0 ?
  53. self.getdbList(self.totalObj.LW01COUNT, self.totalObj.LW01ROUTEIDVARLIST) :
  54. self.totalObj.LW02COUNT > 0 ?
  55. self.getdbList(self.totalObj.LW02COUNT, self.totalObj.LW02ROUTEIDVARLIST) :
  56. self.totalObj.LW03COUNT > 0 ?
  57. self.getdbList(self.totalObj.LW03COUNT, self.totalObj.LW03ROUTEIDVARLIST) :
  58. self.totalObj.LW04COUNT > 0 ?
  59. self.getdbList(self.totalObj.LW04COUNT, self.totalObj.LW04ROUTEIDVARLIST) :
  60. self.totalObj.LB01COUNT > 0 ?
  61. self.getdbList(self.totalObj.LB01COUNT, self.totalObj.LB01ROUTEIDVARLIST) :
  62. self.totalObj.LB02COUNT > 0 ?
  63. self.getdbList(self.totalObj.LB02COUNT, self.totalObj.LB02ROUTEIDVARLIST) :
  64. self.totalObj.LB03COUNT > 0 ?
  65. self.getdbList(self.totalObj.LB03COUNT, self.totalObj.LB03ROUTEIDVARLIST) :
  66. self.totalObj.BLACKCOUNT > 0 ?
  67. self.getdbList(self.totalObj.BLACKCOUNT, self.totalObj.BLACKROUTEIDVARLIST) :
  68. self.totalObj.REDCOUNT > 0 ?
  69. self.getdbList(self.totalObj.REDCOUNT, self.totalObj.REDROUTEIDVARLIST) :
  70. self.totalObj.YELLOWCOUNT > 0 ?
  71. self.getdbList(self.totalObj.YELLOWCOUNT, self.totalObj.YELLOWROUTEIDVARLIST) :
  72. self.totalObj.GREENCOUNT > 0 ?
  73. self.getdbList(self.totalObj.GREENCOUNT, self.totalObj.GREENROUTEIDVARLIST) :
  74. self.getdbList(self.totalObj.OTHERCOUNT, self.totalObj.OTHERROUTEIDVARLIST)
  75. } else {
  76. self.getdbList()
  77. }
  78. })
  79. }
  80. self.getFlow()
  81. $interval(function () {
  82. //self.getToTal(1)
  83. }, 5000)
  84. self.getdbList = function (size, str) {
  85. if (str) {
  86. self.active = {
  87. str: str,
  88. size: size
  89. }
  90. }
  91. var querycondition = [];
  92. querycondition.push({ "CKIND": "VARLIST", "TABLEID": "SYS_ROUTE", "COLID": "ROUTEID", "VALUEA": self.active.str, "VALUEB": "" })
  93. var data = {
  94. flowid: self.flows.join("|"),
  95. userid: self.userId,
  96. pageno: 1,
  97. pagesize: self.active.size,
  98. querycondition: JSON.stringify(querycondition)
  99. }
  100. $http.post(apiurljs.login + "g2work/routeinfo/queryDataTodoWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  101. .success(function (obj) {
  102. var res = strToJson(s4.decryptData_CBC(obj.data));
  103. self.dbList = res.data;
  104. self.dbItemList = {
  105. "width": ($(".dbItem1").width() / 3) * self.dbList.length,
  106. "height": "140px",
  107. "transition": "margin-left 1s ease 0s"
  108. }
  109. $.each(self.dbList, function (index, item) {
  110. item.DATE = sp.datefmt("MM-dd HH:mm", item.RECEIVEDATE);
  111. item.MIJI = item[item.CODETABLE + ".MJ"] || item[item.CODETABLE + ".MIJI"];
  112. item.JINJI = item[item.CODETABLE + ".JJCD"] || item[item.CODETABLE + ".JJLB"] || item[item.CODETABLE + ".JJQK"];
  113. item.DP1 = "来自:" + item.DP;
  114. item.USERNAMEFROM1 = "转自:" + item.USERNAMEFROM;
  115. item.width = { "width": $(".dbItem1").width() / 3 - 11, "height": "140px" };
  116. item.FILEN = item.FILEN + "&dotype=1";
  117. })
  118. })
  119. }
  120. self.getDay = function (str) {
  121. var a = getDate(new Date());
  122. var b = getDate(new Date(str));
  123. var c = parseInt((a - b) / 86400000);
  124. return c < 0 || c > 2 ? 3 : c;
  125. }
  126. self.dbItemNo = 0;//待办事项向左平移n个按钮
  127. self.dbpageWidth = 0;//待办事项向左平移距离
  128. self.dbpageLeft = function () {
  129. if (self.dbItemNo > 0 && self.dbList.length > 3) {
  130. self.dbItemNo = self.dbItemNo - 3;
  131. self.dbpageWidth = $(".dbItem1").outerWidth(true) * (self.dbItemNo / 3);
  132. $(".dbItem1").children().first().css("margin-left", self.dbpageWidth * -1);
  133. } else {
  134. return;
  135. }
  136. }
  137. self.dbpageRight = function () {
  138. if (self.dbItemNo < $(".dbItem").length - 3 && self.dbList.length > 3) {
  139. self.dbItemNo = self.dbItemNo + 3;
  140. self.dbpageWidth = $(".dbItem1").outerWidth(true) * (self.dbItemNo / 3);
  141. $(".dbItem1").children().first().css("margin-left", self.dbpageWidth * -1);
  142. } else {
  143. return;
  144. }
  145. }
  146. self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
  147. self.openSwen = function (obj) {
  148. self.test.forEach(function (item) {
  149. if (item.FLOWID.indexOf(obj.FLOWID) > -1) {
  150. obj.FLOWCODE = item.FLOWCODE;
  151. obj.CNAME = item.CNAME;
  152. if (obj.FILEN.indexOf("tpl") == -1) {
  153. obj.FILEN = item.FILEN.replace(item.FILEN.split("/")[2], obj.FILEN)
  154. }
  155. }
  156. })
  157. if (self.deviceType == "pad") {
  158. window.top.jumpPageParent(obj.FLOWCODE, obj.CNAME, obj.FILEN);
  159. } else {
  160. //window.top.sp.addTabNav(obj.FLOWCODE, obj.CNAME, obj.FILEN);
  161. sp.openNewWindow("../../" + obj.FILEN + "&flowid=" + obj.FLOWID, obj.TITLE)
  162. }
  163. self.getToTal(1)
  164. event.stopPropagation()
  165. }
  166. self.goParams1 = function (params) {
  167. if (self.deviceType == "pad") {
  168. window.top.jumpPageParent("FZB01", "收文办理", "tpl/shouwenbg/list.html?params=" + params);
  169. } else {
  170. window.top.sp.addTabNav("FZB01", "收文办理", "tpl/shouwenbg/list.html?params=" + params);
  171. }
  172. }
  173. self.appList = []
  174. var colors = ["#d5e7f5", "#d2f4e0", "#feedcf", "#fcdce1", "#e0f2f2", "#eae9f7"]
  175. self.getTop6 = function () {
  176. var data = {
  177. userid: self.userId
  178. }
  179. $http.post(apiurljs.login + "g2work/routeinfo/queryDataToDoFlowRouteCountDesktopByUseridGroup", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  180. .success(function (obj) {
  181. var res = strToJson(s4.decryptData_CBC(obj.data));
  182. self.ywblList = res.data;
  183. $.each(self.ywblList, function (index, item) {
  184. item.background = { "background-color": "" + colors[index % 6] + "" };
  185. item.news = { "background": "url(img/triangle" + (index % 6 + 1) + ".png) no-repeat center" }
  186. item.base = { "background": "url('img/base" + (index % 6 + 1) + ".png') no-repeat center center", "background-size": "110% 115%" };
  187. item.circel = { "background": "url('img/icon" + (index % 6 + 1) + ".png') no-repeat center center rgba(74,156,247,0.6)" };
  188. if (item.DESKTOP) {
  189. for (let i = 0; i < item.DESKTOP.length; i++) {
  190. let iitem = item.DESKTOP[i]
  191. if (iitem.FILEN) {
  192. iitem.show = true || iitem.FILEN.indexOf("shouwenbg") > -1 || iitem.FILEN.indexOf("shixiangdb") > -1 || iitem.FILEN.indexOf("xinfangbg") > -1
  193. }
  194. }
  195. }
  196. })
  197. self.ywblCss = {
  198. "width": "100%",
  199. "height": "150px",
  200. "overflow": "hidden"
  201. }
  202. })
  203. }
  204. self.activeBottomObj = 1;
  205. self.secondAfter = 0;//记录左移右移次数
  206. self.appDbCount = 0
  207. self.getTop6()
  208. $interval(function () {
  209. //self.getTop6()
  210. }, 20000)
  211. self.ywblMove = function (n) {
  212. var marginLeft = parseInt($(".List").css("margin-left").slice(0, $(".List").css("margin-left").indexOf("px"))) + n * $(".Item").outerWidth();
  213. if (marginLeft > 0) {
  214. $(".List").css("margin-left", 0)
  215. } else if (marginLeft < ($(".List").outerWidth() - $(".Item").outerWidth() * 7) * -1) {
  216. $(".List").css("margin-left", ($(".List").outerWidth() - $(".Item").outerWidth() * 7) * -1)
  217. } else {
  218. self.secondAfter = self.secondAfter + n;
  219. $(".List").css("margin-left", marginLeft)
  220. self.activeBottomObj = self.activeBottomObj + n * -1;
  221. if (self.activeBottomObj < 1) {
  222. self.activeBottomObj = 1
  223. } else if (self.activeBottomObj > self.ywblList.length) {
  224. self.activeBottomObj = self.ywblList.length;
  225. }
  226. }
  227. }
  228. self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
  229. self.addTabNav = function (obj, n) {
  230. self.activeBottomObj = n + 1
  231. $(".bottomObj").removeClass($(".bottomObj").attr("class").split(" ")[2])
  232. if (self.secondAfter != 0) {
  233. $(".bottomObj").addClass("bottomObj" + (n + 1 + self.secondAfter))
  234. } else {
  235. $(".bottomObj").addClass("bottomObj" + (n + 1))
  236. }
  237. }
  238. self.goParams = function (obj, params) {
  239. if (params != "") {
  240. if (self.deviceType == "pad") {
  241. window.top.jumpPageParent(obj.FLOWCODE, obj.CNAME, obj.FILEN)// + (obj.FILEN.indexOf("?") == -1 ? "?params=" + params : "&params=" + params));
  242. } else {
  243. window.top.sp.addTabNav(obj.FLOWCODE, obj.CNAME, obj.FILEN);
  244. }
  245. }
  246. event.stopPropagation()
  247. }
  248. self.goHref = function (obj) {
  249. if (self.deviceType == "pad") {
  250. window.top.jumpPageParent(obj.FLOWCODE, obj.CNAME, obj.FILEN + (obj.FILEN.indexOf("?") == -1 ? "?params=" + params : "&params=" + params));
  251. } else {
  252. window.top.sp.addTabNav(obj.FLOWCODE, obj.CNAME, obj.FILEN);
  253. }
  254. }
  255. self.goHref1=function(obj){
  256. window.open(obj.FILEN)
  257. }
  258. self.goApp = function (obj) {
  259. if (obj.url.indexOf("?") == -1) {
  260. window.open(obj.url + '?token=' + localStorage.getItem("main-token"), "")
  261. } else {
  262. window.open(obj.url + '&token=' + localStorage.getItem("main-token"), "")
  263. }
  264. }
  265. self.sysappListOuter = function () {
  266. let postCfg_ = {
  267. headers: {
  268. 'Content-Type': 'application/json',
  269. 'Authorization': "Bearer " + self.get_AccessToken
  270. }
  271. };
  272. var data = {
  273. token: localStorage.getItem("main-token"),
  274. userid: self.userId,
  275. type: 'oa',
  276. portalShow: 1,
  277. }
  278. $http.post(apiurljs.login + "g2app/pluginkinds/sysappListOuter", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg_)
  279. .success(function (obj) {
  280. var res = strToJson(s4.decryptData_CBC(obj.data));
  281. let appList = []
  282. for (let i = 0; i < res.result.length; i++) {
  283. let item = res.result[i]
  284. for (let j = 0; j < item.appList.length; j++) {
  285. let appItem = item.appList[j]
  286. appList.push({
  287. name: appItem.appName,
  288. url: appItem.indexUrl,
  289. appCode: appItem.appCode
  290. })
  291. }
  292. }
  293. self.appList = appList
  294. self.appDbCount = 0
  295. for (let i = 0; i < self.appList.length; i++) {
  296. let data_ = {
  297. token: localStorage.getItem("main-token"),
  298. userid: self.userId,
  299. appCode: self.appList[i].appCode,
  300. portalShow: 1,
  301. }
  302. $http.post(apiurljs.login + "g2app/pluginkinds/behalf", { data: s4.encryptData_CBC(JSON.stringify(data_)) }, postCfg_)
  303. .success(function (objj) {
  304. var ress = strToJson(s4.decryptData_CBC(objj.data));
  305. if (isNaN(parseFloat(ress.result)) == true) {
  306. self.appDbCount = 0;
  307. return
  308. }
  309. if (ress.result == '-1') {
  310. self.appList[i].dbCount = 0
  311. } else {
  312. self.appList[i].dbCount = +ress.result
  313. }
  314. self.appDbCount += self.appList[i].dbCount
  315. })
  316. }
  317. })
  318. }
  319. self.sysappListOuter()
  320. }])
  321. app.directive("repeatFinish", function () {
  322. return {
  323. link: function (scope) {
  324. if (scope.$parent.ctl.deviceType == "pad") {
  325. $(".Item").eq(scope.$index).css("width", $(window).width() / 7)
  326. if (scope.$last == true) {
  327. $(".List").css("width", scope.$parent.ctl.ywblList.length * $(window).width() / 7)
  328. }
  329. } else {
  330. $(".Item").eq(scope.$index).css("width", $(window).width() / 7)
  331. if (scope.$last == true) {
  332. $(".List").css("width", scope.$parent.ctl.ywblList.length * $(window).width() / 7)
  333. }
  334. }
  335. }
  336. };
  337. });
  338. function formate(num) {
  339. return num > 9 ? num : "0" + num;
  340. }
  341. function getWeek(date) {
  342. switch (new Date(date).getDay()) {
  343. case 0: return "星期日"; break;
  344. case 1: return "星期一"; break;
  345. case 2: return "星期二"; break;
  346. case 3: return "星期三"; break;
  347. case 4: return "星期四"; break;
  348. case 5: return "星期五"; break;
  349. case 6: return "星期六"; break;
  350. }
  351. }
  352. function getDate(str) {
  353. var year = str.getFullYear();
  354. var month = str.getMonth();
  355. var day = str.getDate();
  356. return new Date(year, month, day).getTime()
  357. }