'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 } }; var colors = ["#d5e7f5", "#d2f4e0", "#feedcf", "#fcdce1", "#e0f2f2", "#eae9f7"] self.getTop6 = 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; 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)" }; item.show = item.FILEN.indexOf("shouwenbg") > -1 || item.FILEN.indexOf("shixiangdb") > -1 || item.FILEN.indexOf("xinfangbg") > -1 //self.getData(item, index + 1) }) self.ywblCss = { "width": self.ywblList.length > 6 ? self.deviceType == "pad" ? "calc(100% - 60px)" : "calc(100% - 100px)" : "100%", "height": "150px", "overflow": "hidden" } }) } self.getTop6() $interval(function () { //self.getTop6() }, 5000) self.ywblMove = function (n) { var marginLeft = parseInt($(".sp-page").css("margin-left").slice(0, $(".sp-page").css("margin-left").indexOf("px"))) + n * $(".Item").outerWidth(); if (marginLeft > 0) { marginLeft = 0 } else if (marginLeft < ($(".sp-page").outerWidth() - $(".Item").outerWidth() * 6) * -1) { marginLeft = ($(".sp-page").outerWidth() - $(".Item").outerWidth() * 6) * -1 } $(".sp-page").css("margin-left", marginLeft) } self.getData = function (obj, n) { $timeout(function () { var chart = new Highcharts.Chart({ chart: { spacing: [40, 0, 40, 0], renderTo: "chart" + n, backgroundColor: 'rgba(0,0,0,0)', type: 'pie', style: { position: 'relative', left: '-8px' } }, title: { floating: true, text: '', //图表的标题 useHTML: true, formatter: function () { return '' } }, tooltip: { enabled: false, }, colors: ['#FFFF00', '#32CD32', '#FF0000'], legend: { enabled: false, }, plotOptions: { pie: { cursor: 'pointer', size: 75, dataLabels: { enabled: false, } } }, series: [{ data: [{ name: "紫灯", y: 1, num: obj.BLACKCOUNT }, { name: "红灯", y: 1, num: obj.REDCOUNT }, { name: "黄灯", y: 1, num: obj.YELLOWCOUNT }, { name: "绿灯", y: 1, num: obj.GREENCOUNT }] }], credits: { enabled: false//隐藏右下角网址 }, exporting: { enabled: false//隐藏右上角打印 } }) chart.setSize(100, 98) },0) } self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType"); self.addTabNav = function (obj) { 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.goParams = function (obj, params) { if (params != "") { if (self.deviceType == "pad") { window.top.jumpPageParent(obj.FLOWCODE, obj.CNAME, obj.FILEN + (obj.FILEN.indexOf("?") == -1 ? "?params=" + params : "¶ms=" + params)); } else { window.top.sp.addTabNav(obj.FLOWCODE, obj.CNAME, obj.FILEN + (obj.FILEN.indexOf("?") == -1 ? "?params=" + params : "¶ms=" + params)); } } event.stopPropagation() } self.updateTest = function () { var data1 = { tablename: "SW_LDPSCBD", id: "1241076374974132224", data: { DBSX: "2024-07-15 00:00:00" } } $http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(data1)) }, postCfg) .success(function (obj1) { var res1 = strToJson(s4.decryptData_CBC(obj1.data)); //if (res1.success) { // var data2 = { // routeinfoid: "1254744583690924032", // userid: "", // edate: "2024-07-15 00:00:00", // linkrouteinfoid: "1241076374982520832" // } // $http.post(apiurljs.login + // "g2work/routeinfo/addRouteinfoTimelimitDelayedate", { // data: s4.encryptData_CBC(JSON.stringify(data2)) // }, postCfg) // .success(function (obj2) { // self.getDataTest() // }) //} }) } //self.updateTest() self.getDataTest = function () { var data = { tablename: "SW_LDPSCBD", colums: "*", order: "ID", sqlwhere: { ID: "1241076374974132224" }, sqlinwhere: "", sqllikewhere: "" } $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); console.log(res) }) } //self.getDataTest() }]) app.directive("repeatFinish", function () { return { link: function (scope) { if (scope.$parent.ctl.ywblList.length > 6) { if (scope.$parent.ctl.deviceType == "pad") { $(".Item").eq(scope.$index).css("width", ($(window).width() - 60) / 6) if (scope.$last == true) { $(".sp-page").css("width", scope.$parent.ctl.ywblList.length * ($(window).width() - 60) / 6) } } else { $(".Item").eq(scope.$index).css("width", ($(window).width() - 100) / 6) if (scope.$last == true) { $(".sp-page").css("width", scope.$parent.ctl.ywblList.length * ($(window).width() - 100) / 6) } } } else { $(".Item").eq(scope.$index).css("width", $(window).width() / 6) if (scope.$last == true) { $(".sp-page").css("width", scope.$parent.ctl.ywblList.length * $(window).width() / 6) } } } }; });