'use strict'; var app = angular.module('app', [ 'angularUtils.directives.dirPagination', ]); app.controller("indexCtrl", ["$scope", "$http", "$timeout", "$interval", function ($scope, $http, $timeout, $interval) { 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.flowids = []; self.flows = []; self.getFlow = function () { var data = { userid: self.userId, ntops: 0 } $http.post(apiurljs.login + "g2work/routeinfo/queryDataToDoFlowRouteCountDesktopByUserid", data, postCfg) .success(function (obj) { var res = obj; res.data.forEach(function (item) { if (item.FLOWID.indexOf("AA") > -1) { self.flowids.push(item.FLOWID) self.flows.push({ FLOWID: item.FLOWID, FLOWCODE: item.FLOWCODE, CNAME: item.CNAME, FILEN: item.FILEN }) } }) self.getDBFL() }) } self.getDBFL = function () { var data = { ckey: "CODE_DBFL", routeinfoid: "" } $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.DBFL = res.data.CODE_DBFL.reverse(); self.getData(1) }) } self.getFlow() self.thWidth = { width: $(".sp-table").outerWidth() - 405 }; self.noDataTip = 1;//没有数据时赋变量为0,先默认为1 self.pageno = 1; self.total_count = 0; self.itemsPerPage = 5; self.type = 0; self.getData = function (pageno) { self.list = []; self.pageno = pageno; $scope.__default__currentPage = self.pageno; //设置页面样式在第几页 var querycondition = []; var ordercondition = [{ COLID: "RECEIVEDATE", SORTTYPE: "desc" }] var data = { flowid: self.type == 0 ? self.flowids.join("|") : self.DBFL[self.DBFL.length - self.type].CODE.replace(/,/g,"|"), userid: self.userId, pageno: self.pageno, pagesize: self.itemsPerPage, columnscondition:"", querycondition: JSON.stringify(querycondition), ordercondition: JSON.stringify(ordercondition) } $http.post(apiurljs.login + "g2work/routeinfo/queryDataTodoWithPage", data, postCfg) .success(function (res) { if (res.data == null || res.data == undefined || res.data == "") { self.noDataTip = 0; if (self.params != "") { self.params = ""; self.getData(1) } } else { self.noDataTip = 1; self.list = res.data; self.total_count = res.totalCount; $.each(self.list, function (index, item) { item.TITLE1 = item.TITLE.length > 20 ? item.TITLE.slice(0, 20) + "..." : item.TITLE; if (self.type == "finish") { item.RECEIVEDATE = item.FINISHEDDATE; } }) } }) } self.refresh = function () { self.getData(self.pageno); } self.goUrl = function (obj) { self.flows.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 { sp.openNewWindow("../../" + obj.FILEN + "&dotype=1&flowid=" + obj.FLOWID, obj.TITLE) } self.getToTal(1) event.stopPropagation() } self.dbCount = 0; self.getDB = function () { var data = { userid: self.userId, msgkind: "督办台账" } $http.post(apiurljs.login + "icenter/notice/queryDataMessageCount", data, postCfg) .success(function (res) { self.dbCount = res.data.MSGCOUNT; }) } self.goDBMORE = function () { window.top.sp.addTabNav("DBTX", "督办提醒", "tpl/shixiangdb/dbmore.html") } self.getDB() $interval(function () { self.refresh() }, 60000) $interval(function () { self.getDB() }, 5000) }])