Authored by chenchao

load default value

... ... @@ -51,20 +51,44 @@ var fixDateTime=function(){
}
//修复日期格式,只修改一次即可
fixDateTime();
var str2Json=function(){
if(PromotionInfo.promotionParams){
if(PromotionInfo.promotionParams && PromotionInfo.promotionParams.actionParam){
PromotionInfo.promotionParams.actionParam=JSON.parse(PromotionInfo.promotionParams.actionParam);
}
if(PromotionInfo.promotionParams.conditionParam){
PromotionInfo.promotionParams.conditionParam=JSON.parse(PromotionInfo.promotionParams.conditionParam);
}
if(PromotionInfo.promotionParams.rejectParam){
PromotionInfo.promotionParams.rejectParam=JSON.parse(PromotionInfo.promotionParams.rejectParam);
}
}
}
str2Json();
//加载显示tab页内容
var loadTabHtml=function(columnname){
var default_html="<a href='#'>bad error</a>";
if (columnname === ENUM.tabName[0].en) {//baseinfo
var html_baseinfo=common.util.__template2($("#fm_baseInfo").html(), PromotionInfo);
$("#tab_body").html(html_baseinfo);
baseInfoEdit.load({promotionId:PromotionInfo.id});
baseInfoEdit.load({promotionId : PromotionInfo.id});
}else if(columnname === ENUM.tabName[1].en) {//condition
var html_condition = $("#fm_condition").html()||default_html;
$("#tab_body").html(html_condition);
} else if(columnname === ENUM.tabName[2].en) {//operation
var html_operation = $("#fm_operation").html()||default_html;
$("#tab_body").html(html_operation);
operationEdit.load();
var operationData={
promotionType : PromotionInfo.promotionParams.promotionType,
actionParam : PromotionInfo.promotionParams.actionParam,
promotionId : PromotionInfo.id
};
operationEdit.load(operationData);
}else if(columnname === ENUM.tabName[3].en) {//limit
var html_limit = $("#fm_limit").html()||default_html;
$("#tab_body").html(html_limit);
... ...
... ... @@ -139,15 +139,21 @@ var operationEdit={
}
},
promotionId:null,
promotionType:null,
actionParam:null,
edit:null,
actionUrl:"/promotionInfo/setOperation",
load:function(config){
var _e= new edit("#tab_body",{});
this.edit=_e;
if(config){
this.promotionId=config.promotionId
this.promotionType=config.promotionType;
this.actionParam=config.actionParam;
this.promotionId=config.promotionId;
}
$("#promotionType").val(this.promotionType);
_e.init();
selectOneOption(this.promotionType);
this.bindEvent();
},
template:function(_htmlObj,_data){
... ... @@ -161,11 +167,20 @@ var operationEdit={
switch(_param.type){
case "text":
_input=$("<input type=\"text\" class=\"form-control\" />");
if(this.actionParam&&this.actionParam[_param.name]){
_input.val(this.actionParam[_param.name]);
}else{
_input.val(_param.default_value);
}
break;
case "textarea":
_input=$("<textarea style=\"width: 400px; height: 90px;\"></textarea>");
if(this.actionParam&&this.actionParam[_param.name]){
_input.text(this.actionParam[_param.name]);
}else{
_input.text(_param.default_value);
}
break;
}
_input.attr("id",_param.name);
... ... @@ -176,11 +191,10 @@ var operationEdit={
}
}
},
selectOneOption:function(_sel){
selectOneOption:function(selectKey){
var firstGroup=$("#tab_body>.row").find(".form-group:eq(0)");
//移除兄弟节点
firstGroup.nextAll().remove();
var selectKey=$(_sel).children('option:selected').val();
var _html;
var _selectObj;
switch(selectKey){
... ... @@ -220,7 +234,10 @@ var operationEdit={
bindEvent:function(){
var _g=this;
$(document).on('click','#save',function(){return this.save()});
$("#promotionType").change(function(){return _g.selectOneOption(this)});
$("#promotionType").change(function(){
var selectKey=$(this).children('option:selected').val();
return _g.selectOneOption(selectKey);
});
},
save:function(){
var e=this.edit;
... ...