123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- 'use strict';
- var app = angular.module('app', [
- 'angularUtils.directives.dirPagination'
- ]);
- app.controller("listCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) {
- var self = this;
- var s4 = new SM4Util();
- self.userId = $.cookie("GlWorkPlatform-userid");
- self.userName = $.cookie("GlWorkPlatform-chineseName");
- self.userType = $.cookie("GlWorkPlatform-userType");
- self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
- self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- }
- self.search = {
- TITLE: "",
- LOGTYPE: ""
- }
- self.CrossPage = window.parent.CrossPage;
- self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
- self.list = [];
- self.pageno = 1;
- self.total_count = 0;
- self.itemsPerPage = 10;
- self.pageOptions = [10, 20, 30, 40];
- //安全管理员看系统管理员的日志,系统管理员看普通用户的日志,审计看安全管理员和系统管理员的日志
- self.getData = function (pageno) {
- self.pageno = pageno;
- $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
- self.list = [];
- var data = {
- tablename: "SYS_CLICKLOG",
- sqlwhere: {},
- sqlorwhere: {},
- sqlinwhere: {},
- sqllikewhere: {
- TITLE: self.search.TITLE
- },
- colums: "ID,TITLE,REQUESTURL,LOGTYPE,USERTYPE,CLIENTIP,PCNAME,BROWSERNAME,TO_CHAR(CTIME,'YYYY-mm-dd hh24:mi:ss.ff3') AS CTIME1,TO_CHAR(RESPONSETIME,'YYYY-mm-dd hh24:mi:ss.ff3') AS RESPONSETIME1",
- order: "ID",
- pagesize: self.itemsPerPage,
- pageno: self.pageno
- }
- if (self.search.LOGTYPE != "") {
- data.sqlwhere.LOGTYPE = self.search.LOGTYPE
- }
- if (self.userType == "安全管理员") {
- data.sqlwhere.USERTYPE = "系统管理员"
- }
- if (self.userType == "系统管理员") {
- data.sqlwhere.USERTYPE = "普通用户"
- }
- if (self.userType == "审计管理员") {
- data.sqlinwhere.USERTYPE = "'安全管理员','系统管理员'"
- }
- $http.post(apiurljs.login + "g2app/DangJian/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.data == null || res.data == undefined || res.data == "") {
- self.noDataTip = 0;
- } else {
- self.noDataTip = 1;
- self.list = res.data;
- self.total_count = res.totalCount;
- self.list.forEach(function (item) {
- item.CTIME2 = item.CTIME1.split(".")[0];
- item.RESPONSETIME2 = minS(new Date(item.RESPONSETIME1).getTime() - new Date(item.CTIME1).getTime());
- if (item.REQUESTURL == "") {
- item.REQUESTURL = "/g2workweb/index.html/#menu-list"
- }
- })
- }
- if (self.CrossPage.type == 0) {
- self.journalRecord(self.CrossPage.ctime, sp.getLocalDate1(), "", "接入日志", window.location.pathname)
- }
- })
- }
- self.load = function () {
- if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
- self.getData(self.pageno);
- } else {
- self.getData(self.get_lastReturnPageno);
- }
- }
- self.load();
- self.refresh = function () {
- self.CrossPage.type = null;
- self.getData(self.pageno);
- }
- self.openSearchLayer = function () {
- var time1 = sp.getLocalDate1();
- self.journalRecord(time1, sp.getLocalDate1(), "查询", "查询日志", "/g2app/DangJian/queryDataByColWithPage")
- self.CrossPage.type = 1;
- sp.layer("#layer_search");
- }
- self.doSearch = function () {
- sp.closeCenter('.sp-layer');
- self.getData(1);
- }
- self.closeSeach = function () {
- self.search = {
- TITLE: "",
- LOGTYPE: ""
- }
- sp.layerhide();
- self.getData(1);
- };
- //记录日志
- self.journalRecord = function (time1, time2, title, func, url) {
- if (!self.CrossPage.cname) { return; }
- var data = {
- tablename: "SYS_CLICKLOG",
- data: {
- CTIME: time1 == null ? sp.getLocalDate1() : time1,
- TITLE: (title != "" ? self.CrossPage.cname + "/" + title : self.CrossPage.cname),
- REQUESTURL: url,
- REQUESTHEADERURL: window.location.origin,
- LOGTYPE: func,
- USERTYPE: $.cookie("GlWorkPlatform-userType"),
- ADMIN: $.cookie("GlWorkPlatform-userTypeEng"),
- CLIENTIP: sp.myIP(),
- PCNAME: sp.detectOS(),
- BROWSERNAME: sp.browser(),
- RESPONSETIME: time2 == null ? sp.getLocalDate1() : time2,
- USERID: self.userId,
- USERNAME: self.userName
- }
- }
- $http.post(apiurljs.login + "g2app/DangJian/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (res) {
- self.CrossPage.type = 1;
- })
- }
- }])
- function minS(str) {
- var time = "";
- if (str < 1000) {
- time = str + "毫秒";
- }
- if (str >= 1000 && str < 60000) {
- time = str / 1000 + "秒";
- }
- if (str >= 60000 && str < 3600000) {
- time = Math.floor(str / 60000) + "分" + (str - 60000 * Math.floor(str / 60000)) / 1000 + "秒";
- }
- if (str >= 3600000) {
- time = Math.floor(str / 3600000) + "小时" + Math.floor((str - 3600000 * Math.floor(str / 3600000)) / 60000) + "分" + (str - 60000 * Math.floor(str / 60000)) / 1000 + "秒";
- }
- return time;
- }
|