Skip to content

Commit b90528a

Browse files
author
xiechun
committed
增加外部修改json事件
1 parent 0d0c582 commit b90528a

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ var form = new seeditForm({
9494
+ onSuccess: `function` 提交资料失败回调
9595
+ onClose: `function` 返回按钮的回调事件
9696
+ onSubmit: `function` 提交按钮的回调事件
97+
+ editJson: `function` 外部修改提交的json
9798

9899
## 初始化参数的`list`下的`name`值介绍
99100
+ `realname` 真实姓名

examples/index.md

+6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ form = new seeditForm({
6767
},
6868
onSuccess: function(data){
6969

70+
},
71+
editJson:function(json){
72+
json.add = "222";
7073
}
7174
});
7275
document.querySelector('#btn').addEventListener('click', function(){
@@ -133,6 +136,9 @@ form = new seeditForm({
133136
},
134137
formatValue: function(json){
135138
console.log(json);return json;
139+
},
140+
editJson:function(json){
141+
json.add = "222";
136142
}
137143
});
138144
document.querySelector('#btn').addEventListener('click', function(){

index.js

+6
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ seeditForm.prototype.format = function(options){
121121
this.btn.close = options.onClose || function(){
122122
_this.close();
123123
};
124+
//外部修改提交数据
125+
this.editJson = options.editJson || function(){
126+
127+
}
124128
// 程序异常回调
125129
this.onEventError = options.onEventError || function(){
126130

@@ -556,6 +560,8 @@ seeditForm.prototype.submit = function(num){
556560
} else json[ this.params.list[i].name ] = document.querySelector('#' + this.params.id + ' input[name="' + this.params.list[i].name + '"]').value;
557561
}
558562
}
563+
// 外部修改json
564+
this.editJson(json);
559565
// 格式化数据
560566
json = this.params.formatValue(json);
561567
if( !!this.params.unionid ) json.unionid = this.params.unionid;

src/css/style.css

+4-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ span{
6363
}
6464
.personal-info-list{
6565
background: #fff;
66-
border-top:1px solid #D4D4D4;
66+
margin-top: 0.625em;
6767
}
6868
.personal-info-list li {
6969
padding: 0 5%;
@@ -72,6 +72,9 @@ span{
7272
border-bottom:1px solid #D4D4D4;
7373
font-size: 1em;
7474
}
75+
.personal-info-list li:first-child{
76+
border-top:1px solid #D4D4D4;
77+
}
7578
.personal-info-list li span {
7679
float: left;
7780
width: 4.625em;
@@ -165,7 +168,6 @@ span{
165168
}
166169
.user-info{
167170
background: #fff;
168-
margin-bottom: 0.625em;
169171
padding: 0.2em 5%;
170172
font-size: 1em;
171173
line-height: 2em;

0 commit comments

Comments
 (0)