首页 > 代码库 > 记录前台js判断,如果为空,給议空的占位
记录前台js判断,如果为空,給议空的占位
这个主要是根据所有的值,按顺序输出,如果没有值,就给予空的占位,
//页面加载的时候获取左边和右边的所有游客id
var array_left_start = new Array();
var array_right_start = new Array();
var tourist_left_start=new Array();
var tourist_right_start=new Array();
$(function(){
$(".left_table").find("input[name=‘tourist_id‘]").each(function(i,item){
array_left_start.push($(this).val());
});
$(".right_table").find("input[name=‘tourist_id‘]").each(function(i,item){
array_right_start.push($(this).val());
});
$(".left_table").find("input[name=‘tourist_name‘]").each(function(i,item){
tourist_left_start.push($(this).val());
});
$(".right_table").find("input[name=‘tourist_name‘]").each(function(i,item){
tourist_right_start.push($(this).val());
});
})
function moveteamsave(){
debugger;
var islock=true;
//调整后左边的id
var array_left_end = new Array();
//调整后右边的id
var array_right_end = new Array();
//调整后左边的游客名称
var tourist_left_end=new Array();
//调整右边的游客名称
var tourist_right_end=new Array();
//调整后最终的游客的id
var final_left_right=new Array();
var tourst_left_right=new Array();
$(".left_table").find("input[name=‘tourist_id‘]").each(function(i,item){
array_left_end.push($(this).val());
});
//右边最新游客id
$(".right_table").find("input[name=‘tourist_id‘]").each(function(i,item){
array_right_end.push($(this).val());
});
$(".left_table").find("input[name=‘tourist_name‘]").each(function(i,item){
tourist_left_end.push($(this).val());
});
$(".right_table").find("input[name=‘tourist_name‘]").each(function(i,item){
tourist_right_end.push($(this).val());
});
$.each(array_left_end,function(key,value){
//如果不包含的话就加入最终的数组
if($.inArray(value,array_left_start)==-1){
final_left_right.push(value);
}
});
$.each(array_right_end,function(key,value){
//如果不包含的话就加入最终的数组
if($.inArray(value,array_right_start)==-1){
final_left_right.push(value);
}
});
$.each(tourist_left_end,function(key,value){
if($.inArray(value,tourist_left_start)==-1){
tourst_left_right.push(value);
}
});
$.each(tourist_right_end,function(key,value){
if($.inArray(value,tourist_right_start)==-1){
tourst_left_right.push(value);
}
});
var teamidarray=new Array();
var teamnumarry=new Array();
//左边最新游客id
var left_team_id=$("#left_team_id").val();
var right_team_id=$("#right_team_id").val();
var left_team_num=$("#left_team_num").val();
var right_team_num=$("#right_team_num").val();
if(left_team_id!=null && ""!=left_team_id){
teamidarray.push(left_team_id);
}
if(right_team_id!=null && ""!=right_team_id){
teamidarray.push(right_team_id);
}
if(left_team_num!=null && ""!=left_team_num){
teamnumarry.push(left_team_num);
}
if(right_team_num!=null && ""!=right_team_num){
teamnumarry.push(right_team_num);
}
//所有的锁团内容的数组
var teamcontent=new Array();
if(teamidarray.length>0){
$.each(teamidarray,function(k,v ){
var title=movelock(v);
if(""!=title){
teamcontent.push(title);
}else{
teamnumarry.remove(k);
}
});
}
//所有的游客锁内容的数组
var tourstcon=new Array();
if(final_left_right.length>0){
$.each(final_left_right,function(k,v){
var title=touristlock(v);
if(""!=title){
tourstcon.push(title);
}else{
tourstcon.push("");
}
});
}
//比较团锁数据
var teamis_lock=true;
if(teamcontent.length>0){
var firstteam=teamcontent[0];
$.each(teamcontent,function(k,v){
if(firstteam!=v){
teamis_lock=false;
return;
}
});
}
//比较游客数据
var tourstis_lock=true;
if(tourstcon.length>0){
var firsttour=tourstcon[0];
$.each(tourstcon,function(k,v){
if(firsttour!=v){
tourstis_lock=false;
return;
}
});
}
var team_lock_content="";
if(teamcontent.length>0){
if(teamis_lock){
var team_num="";
$.each(teamnumarry,function(k,v){
team_num+=v+",";
});
if(""!=team_num){
team_num=team_num.substring(0,team_num.length-1);
team_lock_content="团期"+"【"+team_num+"】"+"已被"+teamcontent[0];
}
}else{
$.each(teamnumarry,function(k,v){
team_lock_content+="团期"+"【"+v+"】"+"已被"+teamcontent[k]+"\n";
});
}
}
var tourist_lock_content="";
if(tourstcon.length>0){
if(tourstis_lock){
var tous_name="";
$.each(tourst_left_right,function(k,v){
tous_name+=v+",";
});
if(""!=tous_name){
tous_name=tous_name.substring(0,tous_name.length-1);
tourist_lock_content="游客"+"【"+tous_name+"】"+"已被"+tourstcon[0]+"不能挪团";
}
}else{
$.each(tourst_left_right,function(k,v){
if(tourstcon[k] !=""){
tourist_lock_content+="游客"+"【"+v+"】"+"已被"+tourstcon[k]+"\n";
}
});
tourist_lock_content+="不能挪团";
}
}
var team_tourst_content="";
if(""!=team_lock_content){
team_tourst_content+=team_lock_content;
}
if(""!=tourist_lock_content){
team_tourst_content+=tourist_lock_content;
}
if(""!=team_tourst_content){
alert(team_tourst_content);
islock=false;
}
//获取团团id
return islock;
}
function movelock(teamId){
var str_content="ERP系统自动锁定,不能挪团,解锁可联系该团期负责人";
var prom_cw_content="";
$.ajax({
type:"post",
url:contextPath + "/common/queryFinanceLockForAjax.html",
async:false,
dataType:"json",
data:{teamId:teamId},
success:function(data){
var fin_lock_status = data.fin_lock_status;//财务锁
var fin_locker = data.fin_locker;//财务锁,以及系统锁admin
var lock_status = data.lock_status;//计调锁
var locker = data.locker;//计调锁,以及系统锁admin
var op = data.op;
var isJp = data.isJP;
//财务团锁
var caiwu_lock_dep = data.caiwu_lock_dep;//财务部门
var caiwu_lock_name = data.caiwu_lock_name;//财务名字
var caiwu_lock_tell = data.caiwu_lock_tell;//财务电话
var emp_name = data.emp_name;
var tell = data.tell;
//计调团锁
var jidiao_lock_dep = data.jidiao_lock_dep;//计调部门
var jidiao_lock_name = data.jidiao_lock_name;//计调名字
var jidiao_lock_tell = data.jidiao_lock_tell;//计调电话
var op_name = data.op_name;
var op_phone = data.op_phone;
//票务团锁
var piaowu_ticket_lock_status = data.piaowu_ticket_lock_status;
var piaowu_dep_name = data.piaowu_dep_name;
var piaowu_emp_name = data.piaowu_emp_name;
var piaowu_tell = data.piaowu_tell;
//签证团锁
var team_visa_lock_status = data.team_visa_lock_status;
var qianzheng_team_lock_dep = data.qianzheng_team_lock_dep;
var qianzheng_team_lock_name = data.qianzheng_team_lock_name;
var qianzheng_team_lock_tell = data.qianzheng_team_lock_tell;
var accountant_id = data.accountant_id;
var isPiaoWu = data.isPiaoWu;
var JDList=data.JDList;
//财务团锁
if(fin_lock_status==‘1‘){
result_status=false;
if(fin_locker=="admin"){
$.ajax({
type:"post",
url:contextPath + "/teamSupply/queryDepNameByOpForAjax.html",
dataType:"json",
async:false,
data:{od_user:op},
success:function(data){
var list = data.resultList;
var text = "线路会计-";
$.each(list,function(i){
var name=list[i].emp_name;
var mobile=list[i].tell;
text +=name + "(" + mobile +")、";
});
if(text.indexOf("、") > -1) {
text = text.substring(0,text.length - 1);
}
prom_cw_content = str_content+text;
}
});
}else{
prom_cw_content += "【财务部: "+caiwu_lock_name+" 锁定,手机:"+caiwu_lock_tell+"】";
}
}else{
//票务团锁
if(piaowu_ticket_lock_status=="1"){
result_status = false;
prom_cw_content += "【票务部: "+piaowu_emp_name+" 锁定,手机:"+piaowu_tell+"】";
}
//签证团锁
if(team_visa_lock_status=="1"){
result_status = false;
prom_cw_content +="【签证部: "+qianzheng_team_lock_name+" 锁定,手机:"+qianzheng_team_lock_tell+"】";
}
}
}
});
return prom_cw_content;
}
function touristlock(tourist_id){
var title = "";
// 计调游客锁,提示信息
$.ajax({
type : "post",
url : contextPath + "/common/queryTouristLockForAjax.html",
async : false,
dataType : "json",
data : {tourist_id : tourist_id},
success : function(data) {
// 计调游客锁
var lock_status = data[0].lock_status;
var locker_name = data[0].locker_name;
var locker_phone = data[0].locker_phone;
// 财务游客锁
var youke_cw_lock_status = data[0].fin_lock_status;
var youke_cw_lock_name = data[0].fin_locker_name;
var youke_cw_lock_phone = data[0].fin_locker_phone;
// 票务游客锁
var youke_pw_lock_status = data[0].ticketlock_status;
var youke_pw_lock_name = data[0].ticket_locker_name;
var youke_pw_lock_phone = data[0].ticket_locker_phone;
// 签证游客锁
var visa_lock_status = data[0].visa_lock_status;
var visa_locker_name = data[0].visa_locker_name;
var visa_locker_phone = data[0].visa_locker_phone;
if (youke_cw_lock_status == "1") {
if (youke_cw_lock_name != null && youke_cw_lock_name != "") {
title += "【"+"财务部 " + youke_cw_lock_name+"锁定,"+"(" + youke_cw_lock_phone + ")"+"】";
} else {
title += "【财务部】,";
}
}
if (youke_pw_lock_status == "1") {
if (youke_pw_lock_name != null && youke_pw_lock_name != "") {
title += "【"+"票务部 " + youke_pw_lock_name+"锁定,"+"(" + youke_pw_lock_phone + ")"+"】";
} else {
title += "【票务部】,";
}
}
if (visa_lock_status == "1") {
if (visa_locker_name != null && visa_locker_name != "") {
title += "【"+"签证部 " + visa_locker_name+"锁定,"+"(" + visa_locker_phone + ")"+"】";
} else {
title += "【签证部】,";
}
}
/**if (lock_status == "1") {
if (locker_name != null && locker_name != "") {
title += "【"+"计调部 " + locker_name+"锁定,"+ "(" + locker_phone + ")"+"】";
} else {
title += "【计调部】,";
}
}*/
}
});
if (title.length > 1) {
title = title.substr(0, title.length - 1);
}
return title;
}
Array.prototype.remove=function(dx){
if(isNaN(dx)||dx>this.length){
return false;
}
for(var i=0,n=0;i<this.length;i++){
if(this[i]!=this[dx]){
this[n++]=this[i]
}
}
this.length-=1
}
记录前台js判断,如果为空,給议空的占位