sp.setCssSkin(); //皮肤换色GlWorkPlatform-username
var get_userid = $.cookie("GlWorkPlatform-userid"); //获取userid
var get_username = $.cookie("GlWorkPlatform-username"); //获取英文名
var get_chineseName = decodeURI($.cookie("GlWorkPlatform-chineseName")); //获取中文名
var UserRole = "";
document.addEventListener("visibilitychange", function () {
if (document.visibilityState == "visible") {
if ($("#spanAdminUserId").val() != $.cookie("GlWorkPlatform-userid")) {
var dialogHead = "温馨提示";
var dialogBody = "
有新用户登入,当前用户为" + decodeURI($.cookie("GlWorkPlatform-chineseName")) + "!
";
var dialogFoot = "";
$('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
sp.openDLTX(".sp-dialog");
$("#delDataTrue").click(function () {
window.location.reload()
});
}
}
})
if (get_userid == null || get_userid == "" || get_userid == "undefined") {
window.location.href = "login.html";
}
//判断从哪里进来,只有从登录页进来才可以
var get_sessionStorage = sessionStorage.getItem("GlWorkPlatform-LoginFrom");
if (get_sessionStorage == null || get_sessionStorage == "" || get_sessionStorage == "undefined") {
window.location.href = "login.html";
} else {
$("#spanAdminUserId").val(get_userid);
$("#spanAdminUserName").text(get_chineseName);
}
//退出
function btnLoginOut() {
window.location.href = "login.html";
//window.location.href = "http://10.233.22.218/sy/#/sso?token=" + localStorage.getItem("main-token");
$.cookie("GlWorkPlatform-userid", null, { path: '/', expires: -1 });
$.cookie("GlWorkPlatform-username", null, { path: '/', expires: -1 });
$.cookie("GlWorkPlatform-chineseName", null, { path: '/', expires: -1 });
$.cookie("GlWorkPlatform-photo", null, { path: '/', expires: -1 });
sessionStorage.removeItem("GlWorkPlatform-LoginFrom");
localStorage.removeItem("GlWorkPlatform-openfileArray"); ////清空保存菜单文件的变量
localStorage.removeItem("GlWorkPlatform-setLeftBarClickID");
localStorage.removeItem("GlWorkPlatform-userInfoJsonStr");
};
//判断是否是第一次进入这个系统,即是否为空库
function checkIsEmptyDatabase() {
$.ajax({
type: "get",
url: apiurljs.login + "connect/isemptydatabase",
//data: { action: "fadetail", userid: userid, routeinfoid: routeinfoid },
dataType: "json",
ContentType: 'application/x-www-form-urlencoded',
success: function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
//console.log(JSON.stringify(res.data));
document.getElementsByTagName("title")[0].innerText = res.data.SYSNAME;
//$(".sp-wrapper-head-title span").html(res.data.SYSNAME);
$.cookie("GlWorkPlatform-SYSNAME", res.data.SECTION, { path: '/', expires: 1 });
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
console.log(errorThrown);
}
});
};
//为保证页面显示效果,判断浏览器版本是否过低
function checkIEVersion() {
var getjson = sp.getExplorerInfo();
if (getjson.type == "IE") {
if (getjson.version == "8.0" || getjson.version == "7.0" || getjson.version == "6.0") {
$("#checkIEVersionDiv").text("您当前使用的是" + getjson.type + "浏览器 版本:" + getjson.version + ",版本过低,请更新IE浏览器或使用其他浏览器");
$("#checkIEVersionDiv").show();
//然后跳到需要连接的下载网站
//window.location.href="http://jiaoxueyun.com/download.jsp";
}
}
}
checkIsEmptyDatabase();
checkIEVersion();
//被邀请加入共享沟通
var userMsg = { userid: get_userid, username: get_chineseName };
if (apiurljs.meetingFlag == true) {
var socket = io.connect(apiurljs.wsio, { path: apiurljs.wspath })
window.socket = socket;
var meetingData = new Object;
socket.emit('userReg', userMsg);
socket.on('error', function (data) {
console.log(JSON.stringify(data) + ' - error');
});
socket.on('disconnect', function (data) {
//失去连接的事件
console.log(JSON.stringify(data) + ' - disconnect');
});
socket.on('reconnect', function (data) {
//重新连接的事件
console.log(JSON.stringify(data) + ' - reconnect');
socket.emit('userReg', userMsg);
});
socket.on('invitemeeting', function (data) {
meetingData = data;
$("#meetingMsg").html("【" + meetingData.title + "】的沟通会议邀请");
$("#meetingMsg").show();
var dialogHead = "系统提示×";
var dialogBody = "您有一个【" + meetingData.title + "】的沟通会议邀请,确认后跳转到沟通会议室。
如暂时不进入会议室,可以稍后在个人消息列表中选择进入。
";
var dialogFoot = "";
$('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
sp.openCenter(".sp-dialog");
$(".closeDialog").click(function (event) {
sp.closeCenter(".sp-dialog");
event.preventDefault();
event.stopPropagation();
});
$("#joinInMeet").click(function () {
sp.dialoghide();
joinMeeting();
});
});
}
function joinMeeting() {
$("#meetingMsg").hide();
var data = meetingData;
var time = new Date().valueOf();
$.cookie("wb_data" + time, JSON.stringify({
meetingid: data.meetingid,
masterid: data.masterid,
mastername: data.mastername,
userid: data.touserid,
username: data.tousername,
title: data.title,
pdf: data.pdf,
wsio: apiurljs.wsio,
wspath: apiurljs.wspath,
uploadUrl: data.uploadUrl,
AccessToken: data.AccessToken,
routeinfoid: data.routeinfoid
}), { path: '/', expires: 1 });
window.sp.addTabNav("GXGT", "共享沟通", "meeting/chat.html?wb_ts=" + time);
setTimeout(function () {
$.cookie("wb_data" + time, null, { path: '/', expires: -1 });
//document.getElementById('wrapper_tabs_box_col_GXGT').childNodes[0].contentWindow.postMessage({
// masterid: data.masterid,
// touserid: data.touserid,
// tousername: data.tousername,
// title: data.title,
// pdf: data.pdf,
// meetingid: data.meetingid,
// uploadUrl: data.uploadUrl,
// AccessToken: data.AccessToken,
// routeinfoid: data.routeinfoid
//}, "*")
}, 5000)
}
window.onmessage = function (event) {
if (event.data == "close") {
$("#wrapper_tabs_menu_li_GXGT").prev("li").addClass("sp-wrapper-tabs-current").show();
$("#wrapper_tabs_box_col_GXGT").prev(".sp-wrapper-tabs-box-col").addClass("sp-wrapper-tabs-box-current").show();
$("#wrapper_tabs_menu_li_GXGT").remove();
$("#wrapper_tabs_box_col_GXGT").remove();
}
}
var app = angular.module('app', []);
app.controller("leftPartCtrl", ["$scope", "$http", "$interval", "$timeout", function ($scope, $http, $interval, $timeout) {
var self = this;
var s4 = new SM4Util();
self.userId = $.cookie("GlWorkPlatform-userid");
self.engName = $.cookie("GlWorkPlatform-username");
self.userName = $.cookie("GlWorkPlatform-chineseName");
self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
self.ctime = $.cookie("CrossPage-ctime");
self.outToken = localStorage.getItem("main-token");
///增加设备标识
localStorage.setItem("tjJxtGoldenlinkWork-deviceType", "pc");
var postCfg = {
headers: {
'Content-Type': 'application/json',
'Authorization': "Bearer " + self.get_AccessToken
}
};
self.set_imgurl = "";
self.get_userInfoJsonStr = {};
self.getReloadUserData = function () {
var postData = {};
//console.log(postData);
//console.log(postData); s4.encryptData_CBC(JSON.stringify(postData))
$http.post(apiurljs.login + "api/User/UserInfo", JSON.stringify(postData), postCfg)
.success(function (obj) {
var res1 = strToJson(s4.decryptData_CBC(obj.data));
localStorage.setItem("GlWorkPlatform-userInfoJsonStr", s4.encryptData_CBC(JSON.stringify(res1.data)));
self.get_userInfoJsonStr = res1.data;
////加载背景图片*******************************************************************************************
if (apiurljs.login.indexOf("http://139.129.27.3:85") != -1) {
self.set_imgurl = "http://139.129.27.3:8511/web/UploadAttach";
} else {
self.set_imgurl = apiurljs.login.split("glwork")[0] + "glworkweb/UploadAttach";
}
$(".sp-wrapper-tabs .sp-wrapper-tabs-head").css("background-image", "url(" + self.set_imgurl + self.get_userInfoJsonStr.bkimageurl + ")");
self.getData_bkimage();///背景图片
self.getHomePage();
})
.error(function (XMLHttpRequest, textStatus, errorThrown) {
if (textStatus != 200) {
self.loading = false;
}
})
}
self.getReloadUserData();
/////点击桌面设置,打开并跨域发送消息打开设置弹出层--zyg--20230426
self.btnSetDesktop = function () {
var id = 'FZ0';
var setID = "wrapper_tabs_box_col_" + id;
$("#spWrapperTabsPart .sp-wrapper-tabs-box .sp-wrapper-tabs-box-col").removeClass("sp-wrapper-tabs-box-current");
$("#" + setID).addClass("sp-wrapper-tabs-box-current").show();
$timeout(function () {
var ifr = document.getElementById('iframe_wrapper_tabs_box_col_FZ0');
var json = {};
var func = { name: "openLayerSetting", arg: json };//传输name名称以及json串
ifr.contentWindow.postMessage(func, '*');
}, 200);
};
self.imgColActive_code_bkimage = "";
self.bkimageArray = [];
self.bkimageArray_active = {};
self.ifHasDefault_bkimage = 0;
self.getData_bkimage = function () {
var postData = { "userid": self.userId };
//console.log(postData);
//console.log(postData); s4.encryptData_CBC(JSON.stringify(postData))
$http.post(apiurljs.login + "g2work/bkimage/queryDataUserByUserid", JSON.stringify(postData), postCfg)
.success(function (obj) {
//var res = strToJson(s4.decryptData_CBC(obj.data));
var res = obj;
//console.log(JSON.stringify(res));
if (res.success) {
self.bkimageArray = res.data;
angular.forEach(self.bkimageArray, function (item) {
item.URL_set = self.set_imgurl + item.URL;
});
} else {
self.loading = false;
self.bkimageArray = [];
self.bkimageArray_active = {};
}
})
.error(function (XMLHttpRequest, textStatus, errorThrown) {
if (textStatus != 200) {
self.loading = false;
}
})
};
$timeout(function () {
//选择底图
if ($("body").find(".sp-desk-img").length > 0) {
$(".sp-desk-img").each(function () {
$(this).click(function () {
var get_url = $(this).attr('data-url');
var get_code = $(this).attr('data-code');
$(this).addClass("sp-desk-current").siblings().removeClass("sp-desk-current");
$("#wrapper_tabs_box_col_FZ0").find("iframe").contents().find("body").css("background-image", "url(" + get_url + ")")
$("#wrapper_tabs_box_col_FZ0").find("iframe").contents().find("body").css("background-repeat", "no-repeat")
$("#wrapper_tabs_box_col_FZ0").find("iframe").contents().find("body").css("background-size", "cover")
$("#wrapper_tabs_box_col_FZ0").find("iframe").contents().find("body").css("background-position", "0 -30px")
$(".sp-wrapper-tabs .sp-wrapper-tabs-head").css("background-image", "url(" + get_url + ")");
var postData_2 = {
"userid": self.userId,
"code": get_code
};
$http.post(apiurljs.login + "g2work/bkimage/updateDataUserDefault", JSON.stringify(postData_2), postCfg)
.success(function (obj_2) {
//var res = strToJson(s4.decryptData_CBC(obj.data));
var res_2 = obj_2;
//console.log(JSON.stringify(res));
if (res_2.success) {
console.log("背景图片修改成功");
} else {
sp.dialog(res_2.message);
}
})
.error(function (XMLHttpRequest, textStatus, errorThrown) {
if (textStatus != 200) {
self.loading = false;
}
})
});
});
}
}, 1000);
////加载背景图片*******************************************************************************************
//声明一个左侧的功能列表
self.userFuncList = [];
//首选获取当前用户的个人桌面
self.getHomePage = function () {
self.userFuncList = [];
var postData = {
userid: self.userId
}
$http.post(apiurljs.login + "g2work/desktop/queryDesktopMarkT", { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
//console.log(JSON.stringify(res));
var homePageObj = {
CNAME: "工作桌面",
C_H_I_L_D: [],
COPYCHILD: [],
///FILEN: res.data.tenantcode,
FILEN: self.get_userInfoJsonStr.desktopurl,
FUNCSCOPE: "ADMINISTATOR|ADMIN",
LEAF: 0,
LEVELS: 1,
OPENTYPE: "0",
PARENTID: "0",
PKID: "FZ0",
SORTID: 1,
SRCIMG: "",
SRCIMG32: "",
WINDOWS: "",
IMGBox: "box0",
}
$.cookie("GlWorkPlatform-userTypeEng", res.data.data, { path: '/', expires: 1 });
if (res.data.data == "USER") {
$.cookie("GlWorkPlatform-userType", "普通用户", { path: '/', expires: 1 })
} else if (res.data.data == "SYSADMIN") {
$.cookie("GlWorkPlatform-userType", "系统管理员", { path: '/', expires: 1 })
} else if (res.data.data == "SECADMIN") {
$.cookie("GlWorkPlatform-userType", "安全管理员", { path: '/', expires: 1 })
} else if (res.data.data == "AUDITADMIN") {
$.cookie("GlWorkPlatform-userType", "审计管理员", { path: '/', expires: 1 })
} else if (res.data.data == "ADMIN") {
$.cookie("GlWorkPlatform-userType", "总管理员", { path: '/', expires: 1 })
}
self.userFuncList.push(homePageObj);
//获取用户的功能列表
self.getUserFunc();
////20230423--zyg-修改,变更成加载图片base64编码,判断是否为base64图片,是直接加载,否设置图片路径;
if (res.data.imgsrc.indexOf("data:image") != -1) {
///base64图片格式直接加载
$("#spanAdminPhoto").attr("src", res.data.imgsrc);
} else {
///路径图片,赋值
$("#spanAdminPhoto").attr("src", "AFrontEnd/css/icons/photo/" + res.data.imgsrc);
}
var data = {
tablename: "SYS_CLICKLOG",
data: {
CTIME: self.ctime,
TITLE: "系统登录",
REQUESTURL: window.location.pathname,
REQUESTHEADERURL: window.location.origin,
LOGTYPE: "登录登出",
USERTYPE: $.cookie("GlWorkPlatform-userType"),
ADMIN: $.cookie("GlWorkPlatform-userTypeEng"),
CLIENTIP: sp.myIP(),
PCNAME: sp.detectOS(),
BROWSERNAME: sp.browser(),
RESPONSETIME: sp.getLocalDate1(),
USERID: self.userId,
USERNAME: self.userName
}
}
$http.post(apiurljs.login + "g2app/dataabase/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (res) {
$.cookie("CrossPage-ctime", null, { path: '/', expires: -1 });
})
})
}
self.iframefileurl = "";
//获取用户的功能列表
self.getUserFunc = function () {
$http.post(apiurljs.login + "UserPower/Permissions", { data: s4.encryptData_CBC("") }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
res.data.rows.forEach(function (item) {
item.showRightMenu = false;
if (item.C_H_I_L_D.length == 0) {
item.IMGBox = "box0";
} else if (item.C_H_I_L_D.length > 0 && item.C_H_I_L_D.length <= 4) {
item.IMGBox = "box4";
} else if (item.C_H_I_L_D.length > 4) {
item.IMGBox = "box9";
}
let array = angular.copy(item.C_H_I_L_D);
if (array.length >= 12) {
item.COPYCHILD = array.slice(0, 12);
item.hideFunc = true;
item.showFunc = false;
} else {
item.COPYCHILD = array;
item.hideFunc = false;
item.showFunc = false;
}
self.userFuncList.push(item);
})
//console.log(JSON.stringify(self.userFuncList));
//默认打开工作桌面
var title = self.userFuncList[0].CNAME;
var id = self.userFuncList[0].PKID;
var src = self.userFuncList[0].FILEN;
CrossPage = {
cname: "",
ctime: sp.getLocalDate(),
type: 0
}
//self.iframefileurl = self.userFuncList[0].FILEN;
//$("#indexhd_iframe_fileurl").attr("src", self.userFuncList[0].FILEN); ////然后让里面的iframe重新加载点击后的页面
//$(".sp-wrapper-tabs-box-col").show();
sp.addTabNav(id, title, src);
//CrossPage = {
// cname: "",
// ctime: sp.getLocalDate(),
// type: 0
//}
// if (getParameter("openPage") == "") {
// //sp.loadmenufiles();//加载记录菜单文件
// }
// if (getParameter("openPage") != "") {
// self.secondMenu = "全部/";
// self.func.normalList.forEach(function (item) {
// if (item.PKID == getParameter("PKID")) {
// self.CrossPage(item)
// }
// })
// sp.addTabNav(getParameter("PKID"), decodeURI(getParameter("CNAME")), getParameter("openPage"))
// }
})
}
////点击菜单事件
self.btnNavPage = function (itemdata) {
//console.log(str);
//self.iframefileurl = str;
///$("#indexhd_iframe_fileurl").attr("src", str)
if (itemdata.OPENTYPE == "1") {
window.open(itemdata.FILEN);
} else {
sp.addTabNav(itemdata.PKID, itemdata.CNAME, itemdata.FILEN);
}
};
//sp.fitHeight("iframe", $(".sp-wrapper-head").outerHeight() + $(".sp-wrapper-tabs-head").outerHeight()); //设置iframe的高度
//获取上传附件文件格式限制----20230517
uploadformat = [];
function getUploadFormat() {
var data = { tablename: "CODE_UPLOADFORMAT" }
$http.post(apiurljs.login + "g2app/DangAn/queryCodeData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
uploadformat = res.data;
})
};
getUploadFormat()
////头部关键字搜索---20230905
self.headBtnSearchKeyword = "";
self.headSearchResult = [];
self.headSearchResult_view = false;
self.headBtnSearch = function () {
if (sp.isval(self.headBtnSearchKeyword)) {
self.headSearchResult = [];
var data = {
"url": "/basic/api/StatSelect/selectCodeList",
"data": { "keyWord": self.headBtnSearchKeyword }
}
//console.log(JSON.stringify(data));
$http.post(apiurljs.login + "g2app/yizhangtu/selectCodeList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
//console.log(JSON.stringify(res.data));
self.headSearchResult = res.data.build;
if (sp.isval(self.headSearchResult)) {
self.headSearchResult_view = true;
} else {
self.headSearchResult_view = false;
}
})
} else {
self.headSearchResult_view = false;
}
};
self.headKeywordPage = function (itemdata) {
var get_token = localStorage.getItem("main-token");
var set_url = apiurljs.onePic + "wholeProcessPage?token=" + get_token + "&name=" + itemdata.name + "&type=" + itemdata.type + "&id=" + itemdata.id + "";
sp.addTabNav(itemdata.id, '一张图', set_url);
self.headSearchResult_view = false;
};
//跨页面记录日志参数
self.CrossPage = function (obj) {
CrossPage = {
cname: obj.CNAME,
ctime: sp.getLocalDate1(),
type: 0
}
}
self.addTabNav = function () {
sp.addTabNav("DTSS", "地图搜索", apiurljs.onePic + "wholeProcessPage?token=" + self.outToken)
}
}]);
var CrossPage = new Object();