修改逻辑,默认值也加入字段逻辑控制

This commit is contained in:
wangxin
2019-01-12 20:47:59 +08:00
parent 0018befabc
commit a38d337776
2 changed files with 112 additions and 107 deletions

View File

@@ -19,49 +19,54 @@ $(function(){
var processDoLog=function(doLog){
var doLogValue=$("[name$='doLog']:checked").val();
var dologObj=doLogOpt(doLog);
if(dologObj.isShown==0){
$(".doLog").addClass("hidden");
}else{
$(".doLog").removeClass("hidden");
}
var dologOptionValues=dologObj.options.split(",");
if(dologOptionValues.length==1){
$(".doLog").find("[name='doLog']").each(function(){
if($(this).val()==dologObj.options){
$(this).attr("checked",true);
$(this).parents(".radio-inline").removeClass("hidden");
}else{
$(this).removeAttr("checked");
$(this).parents(".radio-inline").addClass("hidden");
}
});
}else{
$(".doLog").find("[name$='doLog']").each(function(){
var has=false;
for(var j in dologOptionValues){
if($(this).val()==dologOptionValues[j]){
has=true;
break;
}
}
if(has){
$(this).parents(".radio-inline").removeClass("hidden");
}else{
$(this).parents(".radio-inline").addClass("hidden");
}
});
if($(".doLog").find("[name$='doLog'] [value='"+doLogValue+"']:visible")){
$(".doLog").find("[name$='doLog'] [value='"+doLogValue+"']:visible").attr("checked",true);
}else if($(".doLog").find("[name$='doLog'] [value='2']:visible")){//默认值为2
$(".doLog").find("[name$='doLog'] [value='2']:visible").attr("checked",true);
if(dologObj){
var defaults=dologObj.defaults;
if(dologObj.isShown==0){
$(".doLog").addClass("hidden");
}else{
$(".doLog").removeClass("hidden");
}
var dologOptionValues=dologObj.options.split(",");
if(dologOptionValues.length==1){
$(".doLog").find("[name='doLog']").each(function(){
if($(this).val()==dologObj.options){
$(this).attr("checked",true);
$(this).parents(".radio-inline").removeClass("hidden");
}else{
$(this).removeAttr("checked");
$(this).parents(".radio-inline").addClass("hidden");
}
});
}else{
$(".doLog").find("[name$='doLog']").each(function(){
var has=false;
for(var j in dologOptionValues){
if($(this).val()==dologOptionValues[j]){
has=true;
break;
}
}
if(has){
$(this).parents(".radio-inline").removeClass("hidden");
}else{
$(this).parents(".radio-inline").addClass("hidden");
}
});
if($(".doLog").find("[name$='doLog'] [value='"+doLogValue+"']:visible")){
$(".doLog").find("[name$='doLog'] [value='"+doLogValue+"']:visible").attr("checked",true);
}else if($(".doLog").find("[name$='doLog'] [value='"+defaults+"']:visible")){//默认值为2
$(".doLog").find("[name$='doLog'] [value='2']:visible").attr("checked",true);
}
}
}
}
var doLogOpt=function(doLog){
var doLogObj={};
var doArr=doLog.split(';');
doLogObj.isShown=doArr[0];
doLogObj.options=doArr[1];
doLogObj.defaults=doArr[2];
return doLogObj;
}