gzt.js 15 KB

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