$(document).ready(function() {
$(".onlogin .headnavbtn li").eq(0).addClass("navcurrent");
var id = $.cookie('orgId');
if(id == "" || id == null || id == "null"){
location.href = "cmp-settled-log.html";
}
/*判断企业是否认证*/
function companyAuthStatus() {
$.ajax({
url: "/ajax/org/authStatus",
type: "GET",
timeout: 10000,
dataType: "json",
data: {
"id": id
},
success: function(data, textState) {
if(data.success) {
if(data.data == 3) {
$("#staff").show();
} else {
$("#identityState").show();
$("#costf").html("员工管理");
}
}
},
error: function(XMLHttpRequest, textStats, errorThrown) {
$.MsgBox.Alert('提示', '服务器请求失败')
}
})
}
companyAuthStatus();
/*获取企业认证的用户*/
function UnauthorizedUser() {
$.ajax({
url: "/ajax/professor/qaOrgAuth",
type: "GET",
timeout: 10000,
dataType: "json",
data: {
"orgId": id,
"orgAuth": 1
},
success: function(data, textState) {
if(data.success) {
console.log(data);
var $data = data.data;
UnauthorizedUserHtml($data, "#authorizedUserList", 0);
}
},
error: function(XMLHttpRequest, textStats, errorThrown) {
$.MsgBox.Alert('提示', '服务器请求失败')
}
})
}
UnauthorizedUser()
/*企业认证用户html*/
function UnauthorizedUserHtml() {
var arr = new Array();
for(var i = 0; i < arguments[0].length; i++) {
var img, tiof, deor, otex;
if(arguments[0][i].hasHeadImage) {
img = "/images/head/" + arguments[0][i].id + "_l.jpg";
} else {
img = "../images/default-photo.jpg"
}
if(arguments[0][i].title) {
if(arguments[0][i].office) {
tiof = arguments[0][i].title + " ," + arguments[0][i].office;
} else {
tiof = arguments[0][i].title;
}
} else {
if(arguments[0][i].office) {
tiof = arguments[0][i].office;
} else {
tiof = "";
}
}
if(arguments[0][i].department) {
if(arguments[0][i].orgName) {
deor = arguments[0][i].department + " ," + arguments[0][i].orgName;
} else {
deor = arguments[0][i].department;
}
} else {
if(arguments[0][i].orgName) {
deor = arguments[0][i].orgName;
} else {
deor = "";
}
}
if(arguments[2] == 1) {
otex = "待认证";
} else {
otex = "移除";
}
var oString = "
"
oString += ""
oString += "
"
oString += "
"
oString += ""
oString += "
" + arguments[0][i].name + "
"
oString += "
" + tiof + "
"
oString += "
" + deor + "
"
oString += "
"
oString += ""
oString += ""
$(arguments[1]).append(oString);
}
}
/*移除企业员工*/
$("#authorizedUserList").on("click", "button", function() {
var oDataId = $(this).attr("data-id");
var oDa = $(this);
$.ajax({
url: "/ajax/professor/removeOrgAuth",
type: "POST",
timeout: 10000,
dataType: "json",
data: {
"id": oDataId,
},
success: function(data, textState) {
if(data.success) {
oDa.parents("li").remove();
}
},
error: function(XMLHttpRequest, textStats, errorThrown) {
$.MsgBox.Alert('提示', '服务器请求失败')
}
})
})
/*检验邮箱*/
$("#mail").on("blur", function() {
var oMail = $(this).val();
var gunf = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
if(oMail.trim().length == 0) {
$.MsgBox.Alert('提示', '请输入您企业员工的邮箱地址');
return;
}
if(!gunf.test(oMail.trim())) {
$.MsgBox.Alert('提示', '请输入正确的邮箱地址');
}
})
$("button:contains('邀请')").on("click", function() {
var oMail = $("#mail").val();
var gunf = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
if(oMail.trim().length == 0) {
$.MsgBox.Alert('提示', '请输入您企业员工的邮箱地址');
return;
}
if(!gunf.test(oMail.trim())) {
$.MsgBox.Alert('提示', '请输入正确的邮箱地址');
return;
} else {
/*验证邮箱是否注册*/
$.ajax({
url: "/ajax/isReg",
type: "GET",
timeout: 10000,
dataType: "json",
data: {
"key": oMail
},
success: function(data, textState) {
if(data.success) {
if(data.data) {
$.ajax({
url: "/ajax/inviteStaffMail",
type: "GET",
timeout: 10000,
dataType: "json",
data: {
"orgId": id,
"mail": oMail
},
success: function(data, textState) {
if(data.success) {
if(data.data) {
$.MsgBox.Alert('提示', '已发送邀请邮件');
$("#mb_msgicon").css({
"background-image": "url(images/sign_icon_chenggong_nor.png)",
"background-size": "cover"
});
$("#mail").val("");
}
} else {
$.MsgBox.Alert('提示', data.msg);
}
},
error: function(XMLHttpRequest, textStats, errorThrown) {
$.MsgBox.Alert('提示', '服务器请求失败')
}
})
} else {
$.MsgBox.Alert('提示', "该邮箱已注册账户");
}
} else {
$.MsgBox.Alert('提示', data.msg);
}
},
error: function(XMLHttpRequest, textStats, errorThrown) {
$.MsgBox.Alert('提示', '服务器请求失败')
}
})
}
})
})