'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; //self.getdbList(self.totalObj.OTHERCOUNT, self.totalObj.OTHERROUTEIDVARLIST) 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.goParams = 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); } } }]) 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() }