123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- $(document).ready(function() {
- $(".onlogin .headnavbtn li").eq(0).addClass("navcurrent");
- $(".workmenu>ul>li.staffIcon").addClass("nowLi");
- var orgId = $.cookie('orgId');
- if(orgId == "" || orgId == null || orgId == "null"){
- location.href = "cmp-settled-log.html";
- }
- var pageSize = 10;
-
- resMgr(orgId);
- companyAuthStatus();
- getDefaultUser();
- authorizedUser(1,1,true);
- authorizedUser(1,0,true);
-
- function companyAuthStatus() {
- $.ajax({
- url: "/ajax/org/authStatus",
- type: "GET",
- timeout: 10000,
- dataType: "json",
- data: {
- "id": orgId
- },
- success: function(data) {
- if(data.success) {
- if(data.data !== '3') {
- var str = '<div class="default-text"><div>您的企业账户还未进行认证,还不能认证企业员工</div>'+
- '<a href="cmp-setAuth.html?auth=1">点击这里认证企业信息</a></div>';
- $("#staffContent").html(str);
- }
- }
- }
- })
- }
-
- function authorizedUser(pageNo,orgAuth,isbind) {
- var strId='',strPage='';
- if(orgAuth === 1){
- strId = "#authorizedUserList",
- strPage = "#authtcdPageCode"
- }else{
- strId = "#UnauthorizedUserList",
- strPage = "#UnauthtcdPageCode"
- }
- $.ajax({
- url: "/ajax/professor/pqOrgAuth",
- type: "GET",
- dataType: "json",
- data: {
- "orgId": orgId,
- "orgAuth": orgAuth,
- "pageSize":pageSize,
- "pageNo":pageNo
- },
- success: function(data) {
- if(data.success && data.data.data != "") {
- console.log(data);
- var $data = data.data.data;
- $(strPage).show();
- $(strId).html('');
- $(strId).parents('.list-wrapper').show();
- $("#authStaffs").html(data.data.total)
- for(var i = 0; i < $data.length; i++) {
- $.ajax({
- url: "/ajax/professor/baseInfo/" + $data[i].id,
- type: "GET",
- dataType: "json",
- success: function(res) {
- if(res.success) {
- authorizedUserHtml(orgAuth, res.data, strId);
- }
- }
- })
- }
-
- if(isbind) {
- $(strPage).createPage({
- pageCount: Math.ceil(data.data.total / pageSize),
- current: data.data.pageNo,
- backFn: function(p) {
- $(strId).html("");
- authorizedUser(p,orgAuth,false);
- }
- });
- }
- }else{
- if(orgAuth === 1){
- var str = '<div class="default-text default-text-2"><div>您还没有认证员工</div>'+
- '<a class="goYaoqing" href="javascript:void(0)">点击邀请您的员工</a></div>';
- $(strId).html(str);
- $(strPage).hide();
- }else{
- $(strId).parents('.list-wrapper').hide();
- }
-
- }
- }
- })
- }
-
- function getDefaultUser() {
- var strId = "#defaultUserList"
- $.ajax({
- url: "/ajax/org/linkman/queryAll",
- type: "GET",
- dataType: "json",
- data: {
- "oid": orgId
- },
- success: function(data) {
- if(data.success && data.data != "") {
- $(strId).html('');
- var $data = data.data
- for(var i = 0; i < $data.length; i++){
- $.ajax({
- url: "/ajax/professor/baseInfo/" + $data[i].pid,
- type: "GET",
- dataType: "json",
- success: function(res) {
- if(res.success) {
- authorizedUserHtml(2, res.data, strId);
- }
- }
- })
- }
-
- }else{
- var str = '<div class="default-text default-text-3">您还没有设置默认联系人<br>用户可以通过他与您的企业取得联系</div>';
- $(strId).html(str);
- }
- }
- })
- }
-
- function authorizedUserHtml(flag, $res, toHtm) {
- var img, tiof, deor, offt;
- if($res.hasHeadImage) {
- img = "/images/head/" + $res.id + "_l.jpg";
- } else {
- img = "../images/default-photo.jpg"
- }
- var userType = autho($res.authType, $res.orgAuth, $res.authStatus);
- if($res.title) {
- tiof = $res.title
- } else {
- if($res.office) {
- tiof = $res.office;
- } else {
- tiof = "";
- }
- }
- if($res.department) {
- if($res.orgName) {
- deor = $res.department + " ," + $res.orgName;
- } else {
- deor = $res.department;
- }
- } else {
- if($res.orgName) {
- deor = $res.orgName;
- } else {
- deor = "";
- }
- }
- if(tiof == ''){
- if(deor == ''){
- offt=''
- }else{
- offt = deor
- }
- }else{
- if(deor == ''){
- offt = tiof
- }else{
- offt = tiof + ',' + deor
- }
- }
- var btnStr='';
- if(flag===1){
- btnStr='<div class="block-btn" data-id="'+ $res.id +'">'+
- '<span class="block-btn-1 setDefault">设为默认联系人</span>'+
- '<span class="cancelAuth">取消认证</span>'+
- '</div>'
- }else if(flag===0){
- btnStr='<div class="block-btn block-btnT" data-id="'+ $res.id +'">'+
- '<span class="block-btn-1 setAuth">认证</span>'+
- '</div>'
- }
- var oString = '<div class="block-item">'+
- '<a class="block-item-child" href="../userInforShow.html?professorId='+ $res.id +'">'+
- '<div class="show-head" style="background-image:url('+img+')"></div>'+
- '<div class="show-info">'+
- '<div class="info-tit ellipsisSty">' + $res.name + '<em class="authicon '+ userType.sty +'" title="'+userType.title+'"></em></div>'+
- '<div class="info-tag ellipsisSty">' + offt + '</div>'+
- '</div>'+
- '</a>'+ btnStr +
- '</div>'
- $(toHtm).append(oString);
- }
-
- $("#authorizedUserList").on("click", ".setDefault", function() {
- var oDataId = $(this).parent().attr("data-id");
- var oDa = $(this);
- $.ajax({
- url: '/ajax/org/linkman/save',
- type: "POST",
- dataType: "json",
- data: {
- "oid": orgId,
- "pid": '1,'+oDataId
- },
- success: function(data) {
- if(data.success) {
- getDefaultUser()
- }
- }
- })
- })
-
- $("#UnauthorizedUserList").on("click", ".setAuth", function() {
- var oDataId = $(this).parent().attr("data-id");
- $.ajax({
- url: '/ajax/professor/passOrgAuth',
- type: "POST",
- dataType: "json",
- data: {
- "id": oDataId
- },
- success: function(data) {
- if(data.success) {
- authorizedUser(1,1,true);
- authorizedUser(1,0,true);
- }
- }
- })
- })
-
- $("#authorizedUserList").on("click", ".cancelAuth", function() {
- var oDataId = $(this).parent().attr("data-id");
- $.MsgBox.Confirm ('提示', '确认取消该员工的认证?<br><span style="color:#999;line-height:28px;font-size:13px;">确认后会同时取消该员工的所有联系人身份</span>', function(){
- $.ajax({
- url: "/ajax/professor/removeOrgAuth",
- type: "POST",
- dataType: "json",
- data: {
- "id": oDataId
- },
- success: function(data) {
- if(data.success) {
- authorizedUser(1,1,true);
- authorizedUser(1,0,true);
- getDefaultUser();
- }
- }
- })
- })
- })
-
- $('#staffContent').on("click", ".goSpan,.goYaoqing", function() {
- $("#mailVal").val('');
- $('.mb_success').html('');
- $(".blackcover2").fadeIn();
- $(".modelContain").show();
- $("body").addClass("modelOpen");
- })
- $(".mb_close").click(function() {
- $(".modelContain").hide();
- $(".blackcover2").fadeOut();
- $("body").removeClass("modelOpen");
- })
-
- $("#mailVal").on({
- keyup: function() {
- if($(this).val().length > 50) {
- $(this).val($(this).val().substr(0, 50));
- }
- }
- })
- $("#mailPub").on("click", function() {
- var oMail = $("#mailVal").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/sendMailWithInviteOrg",
- type: "POST",
- dataType: "json",
- data: {
- "oid": orgId,
- "mail": oMail
- },
- success: function(data) {
- if(data.success) {
- $('.mb_success').html('已发送邀请邮件!');
- $("#mailVal").val("");
- $(".blackcover2").fadeOut();
- $(".modelContain").hide();
- } else {
- $.MsgBox.Alert('提示', data.msg);
- }
- }
- })
- }
- })
- })
|