1. trim value of string
2. count empty
Showing
2 changed files
with
17 additions
and
4 deletions
@@ -263,14 +263,22 @@ var operationEdit={ | @@ -263,14 +263,22 @@ var operationEdit={ | ||
263 | var alwaysExistsKeys=["promotionType","promotionId"]; | 263 | var alwaysExistsKeys=["promotionType","promotionId"]; |
264 | var dynaKey_index; | 264 | var dynaKey_index; |
265 | var _temp={}; | 265 | var _temp={}; |
266 | + var emptyValCnt=0; | ||
266 | for(var key in reqData){ | 267 | for(var key in reqData){ |
267 | dynaKey_index=$.inArray(key,alwaysExistsKeys); | 268 | dynaKey_index=$.inArray(key,alwaysExistsKeys); |
268 | - if(dynaKey_index===-1){ | 269 | + if(dynaKey_index===-1){ |
270 | + if(!reqData[key]){ | ||
271 | + emptyValCnt++; | ||
272 | + } | ||
269 | _temp[key]=reqData[key]; | 273 | _temp[key]=reqData[key]; |
270 | delete reqData[key]; | 274 | delete reqData[key]; |
271 | continue; | 275 | continue; |
272 | } | 276 | } |
273 | } | 277 | } |
278 | + if(emptyValCnt>0){ | ||
279 | + common.util.__tip("没有填写数据!", "warning"); | ||
280 | + return false; | ||
281 | + } | ||
274 | 282 | ||
275 | if($.isEmptyObject(_temp)){ | 283 | if($.isEmptyObject(_temp)){ |
276 | common.util.__tip("没有填写数据!", "warning"); | 284 | common.util.__tip("没有填写数据!", "warning"); |
1 | 1 | ||
2 | +var $ = require('jquery'); | ||
2 | var jsonUtils={ | 3 | var jsonUtils={ |
3 | formSerializeArrayKey:{ | 4 | formSerializeArrayKey:{ |
4 | name:"name", | 5 | name:"name", |
@@ -8,12 +9,16 @@ var jsonUtils={ | @@ -8,12 +9,16 @@ var jsonUtils={ | ||
8 | var _g=this; | 9 | var _g=this; |
9 | var result={}; | 10 | var result={}; |
10 | var one_form_data= _params.data; | 11 | var one_form_data= _params.data; |
11 | - | 12 | + var _value; |
12 | for(var key in one_form_data){ | 13 | for(var key in one_form_data){ |
13 | - result[one_form_data[key][_g.formSerializeArrayKey.name]]=one_form_data[key][_g.formSerializeArrayKey.value]; | 14 | + _value=one_form_data[key][_g.formSerializeArrayKey.value]; |
15 | + if(typeof(_value)==="string"){ | ||
16 | + _value=$.trim(_value); | ||
17 | + } | ||
18 | + result[one_form_data[key][_g.formSerializeArrayKey.name]]=_value; | ||
14 | } | 19 | } |
15 | return result; | 20 | return result; |
16 | }, | 21 | }, |
17 | -} | 22 | +}; |
18 | 23 | ||
19 | module.exports = jsonUtils; | 24 | module.exports = jsonUtils; |
-
Please register or login to post a comment