'use strict'; var app = angular.module('app', [ 'angularUtils.directives.dirPagination', ]); app.controller("indexCtrl", ["$scope", "$http", "$interval", "$timeout", function ($scope, $http, $interval, $timeout) { var self = this; self.userId = $.cookie("GlWorkPlatform-userid"); self.userName = $.cookie("GlWorkPlatform-username"); self.userChineseName = $.cookie("GlWorkPlatform-chineseName") self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken"); var postCfg = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken, } }; self.flows = []; self.test = []; self.getFlow = function () { var data = { userid: self.userId, ntops: 0//6 } $http.post(apiurljs.login + "g2work/routeinfo/queryDataToDoFlowRouteCountDesktopByUserid", data, postCfg) .success(function (obj) { // var res = strToJson(s4.decryptData_CBC(obj.data)); var res = obj; res.data.forEach(function (item) { if (item.FLOWID != "无") { self.flows.push(item.FLOWID) self.test.push({ FLOWID: item.FLOWID, FLOWCODE: item.FLOWCODE, CNAME: item.CNAME, FILEN: item.FILEN }) } }) //self.getToTal(0)//国务院来文等数量 }) } self.active = { str: "", size: 0 } self.getToTal = function (n) { var data = { userid: self.userId, ntops: 0 }; $http.post(apiurljs.login + "g2work/routeinfo/queryDataToDoFlowRouteRecordDesktopByUserid", data, postCfg) .success(function (obj) { //var res = strToJson(s4.decryptData_CBC(obj.data)); var res = obj; self.totalObj = res.data; if (n == 0) { self.totalObj.NEWCOUNT > 0 ? self.getdbList(self.totalObj.NEWCOUNT, self.totalObj.NEWROUTEIDVARLIST) : self.totalObj.LW01COUNT > 0 ? self.getdbList(self.totalObj.LW01COUNT, self.totalObj.LW01ROUTEIDVARLIST) : self.totalObj.LW02COUNT > 0 ? self.getdbList(self.totalObj.LW02COUNT, self.totalObj.LW02ROUTEIDVARLIST) : self.totalObj.LW03COUNT > 0 ? self.getdbList(self.totalObj.LW03COUNT, self.totalObj.LW03ROUTEIDVARLIST) : self.totalObj.LW04COUNT > 0 ? self.getdbList(self.totalObj.LW04COUNT, self.totalObj.LW04ROUTEIDVARLIST) : self.totalObj.LB01COUNT > 0 ? self.getdbList(self.totalObj.LB01COUNT, self.totalObj.LB01ROUTEIDVARLIST) : self.totalObj.LB02COUNT > 0 ? self.getdbList(self.totalObj.LB02COUNT, self.totalObj.LB02ROUTEIDVARLIST) : self.totalObj.LB03COUNT > 0 ? self.getdbList(self.totalObj.LB03COUNT, self.totalObj.LB03ROUTEIDVARLIST) : self.totalObj.BLACKCOUNT > 0 ? self.getdbList(self.totalObj.BLACKCOUNT, self.totalObj.BLACKROUTEIDVARLIST) : self.totalObj.REDCOUNT > 0 ? self.getdbList(self.totalObj.REDCOUNT, self.totalObj.REDROUTEIDVARLIST) : self.totalObj.YELLOWCOUNT > 0 ? self.getdbList(self.totalObj.YELLOWCOUNT, self.totalObj.YELLOWROUTEIDVARLIST) : self.totalObj.GREENCOUNT > 0 ? self.getdbList(self.totalObj.GREENCOUNT, self.totalObj.GREENROUTEIDVARLIST) : self.getdbList(self.totalObj.OTHERCOUNT, self.totalObj.OTHERROUTEIDVARLIST) } else { self.getdbList() } }) } self.getFlow() $interval(function () { //self.getToTal(1) }, 5000) self.getdbList = function (size, str) { if (str) { self.active = { str: str, size: size } } var querycondition = []; querycondition.push({ "CKIND": "VARLIST", "TABLEID": "SYS_ROUTE", "COLID": "ROUTEID", "VALUEA": self.active.str, "VALUEB": "" }) var data = { flowid: self.flows.join("|"), userid: self.userId, pageno: 1, pagesize: self.active.size, querycondition: JSON.stringify(querycondition) } $http.post(apiurljs.login + "g2work/routeinfo/queryDataTodoWithPage", data, postCfg) .success(function (obj) { //var res = strToJson(s4.decryptData_CBC(obj.data)); var res = obj; self.dbList = res.data; self.dbItemList = { "width": ($(".dbItem1").width() / 3) * self.dbList.length, "height": "140px", "transition": "margin-left 1s ease 0s" } $.each(self.dbList, function (index, item) { item.DATE = sp.datefmt("MM-dd HH:mm", item.RECEIVEDATE); item.MIJI = item[item.CODETABLE + ".MJ"] || item[item.CODETABLE + ".MIJI"]; item.JINJI = item[item.CODETABLE + ".JJCD"] || item[item.CODETABLE + ".JJLB"] || item[item.CODETABLE + ".JJQK"]; item.DP1 = "来自:" + item.DP; item.USERNAMEFROM1 = "转自:" + item.USERNAMEFROM; item.width = { "width": $(".dbItem1").width() / 3 - 11, "height": "140px" }; item.FILEN = item.FILEN + "&dotype=1"; }) }) } self.getDay = function (str) { var a = getDate(new Date()); var b = getDate(new Date(str)); var c = parseInt((a - b) / 86400000); return c < 0 || c > 2 ? 3 : c; } self.dbItemNo = 0;//待办事项向左平移n个按钮 self.dbpageWidth = 0;//待办事项向左平移距离 self.dbpageLeft = function () { if (self.dbItemNo > 0 && self.dbList.length > 3) { self.dbItemNo = self.dbItemNo - 3; self.dbpageWidth = $(".dbItem1").outerWidth(true) * (self.dbItemNo / 3); $(".dbItem1").children().first().css("margin-left", self.dbpageWidth * -1); } else { return; } } self.dbpageRight = function () { if (self.dbItemNo < $(".dbItem").length - 3 && self.dbList.length > 3) { self.dbItemNo = self.dbItemNo + 3; self.dbpageWidth = $(".dbItem1").outerWidth(true) * (self.dbItemNo / 3); $(".dbItem1").children().first().css("margin-left", self.dbpageWidth * -1); } else { return; } } self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType"); self.openSwen = function (obj) { self.test.forEach(function (item) { if (item.FLOWID.indexOf(obj.FLOWID) > -1) { obj.FLOWCODE = item.FLOWCODE; obj.CNAME = item.CNAME; if (obj.FILEN.indexOf("tpl") == -1) { obj.FILEN = item.FILEN.replace(item.FILEN.split("/")[2], obj.FILEN) } } }) if (self.deviceType == "pad") { window.top.jumpPageParent(obj.FLOWCODE, obj.CNAME, obj.FILEN); } else { //window.top.sp.addTabNav(obj.FLOWCODE, obj.CNAME, obj.FILEN); sp.openNewWindow("../../" + obj.FILEN + "&flowid=" + obj.FLOWID, obj.TITLE) } self.getToTal(1) event.stopPropagation() } self.goParams1 = function (params) { if (self.deviceType == "pad") { window.top.jumpPageParent("FZB01", "收文办理", "tpl/shouwenbg/list.html?params=" + params); } else { window.top.sp.addTabNav("FZB01", "收文办理", "tpl/shouwenbg/list.html?params=" + params); } } self.appList = [] var colors = ["#d5e7f5", "#d2f4e0", "#feedcf", "#fcdce1", "#e0f2f2", "#eae9f7"] self.getTop6 = function () { var data = { userid: self.userId } $http.post(apiurljs.login + "g2work/routeinfo/queryDataToDoFlowRouteCountDesktopByUseridGroup", data, postCfg) .success(function (obj) { //var res = strToJson(s4.decryptData_CBC(obj.data)); var res = obj; self.ywblList = res.data; $.each(self.ywblList, function (index, item) { item.background = { "background-color": "" + colors[index % 6] + "" }; item.news = { "background": "url(img/triangle" + (index % 6 + 1) + ".png) no-repeat center" } item.base = { "background": "url('img/base" + (index % 6 + 1) + ".png') no-repeat center center", "background-size": "110% 115%" }; item.circel = { "background": "url('img/icon" + (index % 6 + 1) + ".png') no-repeat center center rgba(74,156,247,0.6)" }; if (item.DESKTOP) { for (let i = 0; i < item.DESKTOP.length; i++) { let iitem = item.DESKTOP[i] if (iitem.FILEN) { iitem.show = true || iitem.FILEN.indexOf("shouwenbg") > -1 || iitem.FILEN.indexOf("shixiangdb") > -1 || iitem.FILEN.indexOf("xinfangbg") > -1 } } } }) self.ywblCss = { "width": "100%", "height": "150px", "overflow": "hidden" } }) } self.activeBottomObj = 1; self.secondAfter = 0;//记录左移右移次数 self.appDbCount = 0 self.getTop6() $interval(function () { self.getTop6() }, 20000) self.ywblMove = function (n) { var marginLeft = parseInt($(".List").css("margin-left").slice(0, $(".List").css("margin-left").indexOf("px"))) + n * $(".Item").outerWidth(); if (marginLeft > 0) { $(".List").css("margin-left", 0) } else if (marginLeft < ($(".List").outerWidth() - $(".Item").outerWidth() * 7) * -1) { $(".List").css("margin-left", ($(".List").outerWidth() - $(".Item").outerWidth() * 7) * -1) } else { self.secondAfter = self.secondAfter + n; $(".List").css("margin-left", marginLeft) self.activeBottomObj = self.activeBottomObj + n * -1; if (self.activeBottomObj < 1) { self.activeBottomObj = 1 } else if (self.activeBottomObj > self.ywblList.length) { self.activeBottomObj = self.ywblList.length; } } } self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType"); self.addTabNav = function (obj, n) { self.activeBottomObj = n + 1 $(".bottomObj").removeClass($(".bottomObj").attr("class").split(" ")[2]) if (self.secondAfter != 0) { $(".bottomObj").addClass("bottomObj" + (n + 1 + self.secondAfter)) } else { $(".bottomObj").addClass("bottomObj" + (n + 1)) } } self.goParams = function (obj, params) { if (params != "") { if (self.deviceType == "pad") { window.top.jumpPageParent(obj.FLOWCODE, obj.CNAME, obj.FILEN); } else { window.top.sp.addTabNav(obj.FLOWCODE, obj.CNAME, obj.FILEN); } } event.stopPropagation() } self.goHref = function (obj) { if (self.deviceType == "pad") { window.top.jumpPageParent(obj.FLOWCODE, obj.CNAME, obj.FILEN + (obj.FILEN.indexOf("?") > -1 ? "&flowids=" + obj.FLOWID : "?flowids=" + obj.FLOWID)); } else { window.top.sp.addTabNav(obj.FLOWCODE, obj.CNAME, obj.FILEN + (obj.FILEN.indexOf("?") > -1 ? "&flowids=" + obj.FLOWID : "?flowids=" + obj.FLOWID)); } } self.goHref1=function(obj){ window.open(obj.FILEN) } self.goApp = function (obj) { if (obj.url.indexOf("?") == -1) { window.open(obj.url + '?token=' + localStorage.getItem("main-token"), "") } else { window.open(obj.url + '&token=' + localStorage.getItem("main-token"), "") } } self.sysappListOuter = function () { let postCfg_ = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } }; var data = { token: localStorage.getItem("main-token"), userid: self.userId, type: 'oa', portalShow: 1, } $http.post(apiurljs.login + "g2app/pluginkinds/sysappListOuter",data, postCfg_) .success(function (obj) { //var res = strToJson(s4.decryptData_CBC(obj.data)); var res = obj; let appList = [] for (let i = 0; i < res.result.length; i++) { let item = res.result[i] for (let j = 0; j < item.appList.length; j++) { let appItem = item.appList[j] appList.push({ name: appItem.appName, url: appItem.indexUrl, appCode: appItem.appCode }) } } self.appList = appList self.appDbCount = 0 for (let i = 0; i < self.appList.length; i++) { let data_ = { token: localStorage.getItem("main-token"), userid: self.userId, appCode: self.appList[i].appCode, portalShow: 1, } $http.post(apiurljs.login + "g2app/pluginkinds/behalf", data_, postCfg_) .success(function (objj) { //var ress = strToJson(s4.decryptData_CBC(objj.data)); var res = obj; if (isNaN(parseFloat(ress.result)) == true) { self.appDbCount = 0; return } if (ress.result == '-1') { self.appList[i].dbCount = 0 } else { self.appList[i].dbCount = +ress.result } self.appDbCount += self.appList[i].dbCount }) } }) } self.sysappListOuter() }]) app.directive("repeatFinish", function () { return { link: function (scope) { if (scope.$parent.ctl.deviceType == "pad") { $(".Item").eq(scope.$index).css("width", $(window).width() / 7) if (scope.$last == true) { $(".List").css("width", scope.$parent.ctl.ywblList.length * $(window).width() / 7) } } else { $(".Item").eq(scope.$index).css("width", $(window).width() / 7) if (scope.$last == true) { $(".List").css("width", scope.$parent.ctl.ywblList.length * $(window).width() / 7) } } } }; }); function formate(num) { return num > 9 ? num : "0" + num; } function getWeek(date) { switch (new Date(date).getDay()) { case 0: return "星期日"; break; case 1: return "星期一"; break; case 2: return "星期二"; break; case 3: return "星期三"; break; case 4: return "星期四"; break; case 5: return "星期五"; break; case 6: return "星期六"; break; } } function getDate(str) { var year = str.getFullYear(); var month = str.getMonth(); var day = str.getDate(); return new Date(year, month, day).getTime() }