Authored by chenchao

load default value

@@ -51,20 +51,44 @@ var fixDateTime=function(){ @@ -51,20 +51,44 @@ var fixDateTime=function(){
51 } 51 }
52 //修复日期格式,只修改一次即可 52 //修复日期格式,只修改一次即可
53 fixDateTime(); 53 fixDateTime();
  54 +
  55 +var str2Json=function(){
  56 + if(PromotionInfo.promotionParams){
  57 + if(PromotionInfo.promotionParams && PromotionInfo.promotionParams.actionParam){
  58 + PromotionInfo.promotionParams.actionParam=JSON.parse(PromotionInfo.promotionParams.actionParam);
  59 + }
  60 +
  61 + if(PromotionInfo.promotionParams.conditionParam){
  62 + PromotionInfo.promotionParams.conditionParam=JSON.parse(PromotionInfo.promotionParams.conditionParam);
  63 + }
  64 +
  65 + if(PromotionInfo.promotionParams.rejectParam){
  66 + PromotionInfo.promotionParams.rejectParam=JSON.parse(PromotionInfo.promotionParams.rejectParam);
  67 + }
  68 +
  69 + }
  70 +
  71 +}
  72 +str2Json();
54 //加载显示tab页内容 73 //加载显示tab页内容
55 var loadTabHtml=function(columnname){ 74 var loadTabHtml=function(columnname){
56 var default_html="<a href='#'>bad error</a>"; 75 var default_html="<a href='#'>bad error</a>";
57 if (columnname === ENUM.tabName[0].en) {//baseinfo 76 if (columnname === ENUM.tabName[0].en) {//baseinfo
58 var html_baseinfo=common.util.__template2($("#fm_baseInfo").html(), PromotionInfo); 77 var html_baseinfo=common.util.__template2($("#fm_baseInfo").html(), PromotionInfo);
59 $("#tab_body").html(html_baseinfo); 78 $("#tab_body").html(html_baseinfo);
60 - baseInfoEdit.load({promotionId:PromotionInfo.id}); 79 + baseInfoEdit.load({promotionId : PromotionInfo.id});
61 }else if(columnname === ENUM.tabName[1].en) {//condition 80 }else if(columnname === ENUM.tabName[1].en) {//condition
62 var html_condition = $("#fm_condition").html()||default_html; 81 var html_condition = $("#fm_condition").html()||default_html;
63 $("#tab_body").html(html_condition); 82 $("#tab_body").html(html_condition);
64 } else if(columnname === ENUM.tabName[2].en) {//operation 83 } else if(columnname === ENUM.tabName[2].en) {//operation
65 var html_operation = $("#fm_operation").html()||default_html; 84 var html_operation = $("#fm_operation").html()||default_html;
66 $("#tab_body").html(html_operation); 85 $("#tab_body").html(html_operation);
67 - operationEdit.load(); 86 + var operationData={
  87 + promotionType : PromotionInfo.promotionParams.promotionType,
  88 + actionParam : PromotionInfo.promotionParams.actionParam,
  89 + promotionId : PromotionInfo.id
  90 + };
  91 + operationEdit.load(operationData);
68 }else if(columnname === ENUM.tabName[3].en) {//limit 92 }else if(columnname === ENUM.tabName[3].en) {//limit
69 var html_limit = $("#fm_limit").html()||default_html; 93 var html_limit = $("#fm_limit").html()||default_html;
70 $("#tab_body").html(html_limit); 94 $("#tab_body").html(html_limit);
@@ -139,15 +139,21 @@ var operationEdit={ @@ -139,15 +139,21 @@ var operationEdit={
139 } 139 }
140 }, 140 },
141 promotionId:null, 141 promotionId:null,
  142 + promotionType:null,
  143 + actionParam:null,
142 edit:null, 144 edit:null,
143 actionUrl:"/promotionInfo/setOperation", 145 actionUrl:"/promotionInfo/setOperation",
144 load:function(config){ 146 load:function(config){
145 var _e= new edit("#tab_body",{}); 147 var _e= new edit("#tab_body",{});
146 this.edit=_e; 148 this.edit=_e;
147 - if(config){  
148 - this.promotionId=config.promotionId 149 + if(config){
  150 + this.promotionType=config.promotionType;
  151 + this.actionParam=config.actionParam;
  152 + this.promotionId=config.promotionId;
149 } 153 }
  154 + $("#promotionType").val(this.promotionType);
150 _e.init(); 155 _e.init();
  156 + selectOneOption(this.promotionType);
151 this.bindEvent(); 157 this.bindEvent();
152 }, 158 },
153 template:function(_htmlObj,_data){ 159 template:function(_htmlObj,_data){
@@ -161,11 +167,20 @@ var operationEdit={ @@ -161,11 +167,20 @@ var operationEdit={
161 switch(_param.type){ 167 switch(_param.type){
162 case "text": 168 case "text":
163 _input=$("<input type=\"text\" class=\"form-control\" />"); 169 _input=$("<input type=\"text\" class=\"form-control\" />");
164 - _input.val(_param.default_value); 170 + if(this.actionParam&&this.actionParam[_param.name]){
  171 + _input.val(this.actionParam[_param.name]);
  172 + }else{
  173 + _input.val(_param.default_value);
  174 + }
165 break; 175 break;
166 case "textarea": 176 case "textarea":
167 _input=$("<textarea style=\"width: 400px; height: 90px;\"></textarea>"); 177 _input=$("<textarea style=\"width: 400px; height: 90px;\"></textarea>");
168 - _input.text(_param.default_value); 178 + if(this.actionParam&&this.actionParam[_param.name]){
  179 + _input.text(this.actionParam[_param.name]);
  180 + }else{
  181 + _input.text(_param.default_value);
  182 + }
  183 +
169 break; 184 break;
170 } 185 }
171 _input.attr("id",_param.name); 186 _input.attr("id",_param.name);
@@ -176,11 +191,10 @@ var operationEdit={ @@ -176,11 +191,10 @@ var operationEdit={
176 } 191 }
177 } 192 }
178 }, 193 },
179 - selectOneOption:function(_sel){ 194 + selectOneOption:function(selectKey){
180 var firstGroup=$("#tab_body>.row").find(".form-group:eq(0)"); 195 var firstGroup=$("#tab_body>.row").find(".form-group:eq(0)");
181 //移除兄弟节点 196 //移除兄弟节点
182 - firstGroup.nextAll().remove();  
183 - var selectKey=$(_sel).children('option:selected').val(); 197 + firstGroup.nextAll().remove();
184 var _html; 198 var _html;
185 var _selectObj; 199 var _selectObj;
186 switch(selectKey){ 200 switch(selectKey){
@@ -220,7 +234,10 @@ var operationEdit={ @@ -220,7 +234,10 @@ var operationEdit={
220 bindEvent:function(){ 234 bindEvent:function(){
221 var _g=this; 235 var _g=this;
222 $(document).on('click','#save',function(){return this.save()}); 236 $(document).on('click','#save',function(){return this.save()});
223 - $("#promotionType").change(function(){return _g.selectOneOption(this)}); 237 + $("#promotionType").change(function(){
  238 + var selectKey=$(this).children('option:selected').val();
  239 + return _g.selectOneOption(selectKey);
  240 + });
224 }, 241 },
225 save:function(){ 242 save:function(){
226 var e=this.edit; 243 var e=this.edit;