Skip to content

Commit

Permalink
Merge pull request #1498 from tangcent/fix#1489
Browse files Browse the repository at this point in the history
fix: handle null value in  handleBulk
  • Loading branch information
hellosean1025 committed Nov 19, 2019
2 parents 7442b0e + cb40e9f commit af3bbd1
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ class InterfaceEditForm extends Component {

// 处理批量导入参数
handleBulkOk = () => {
let curValue = this.props.form.getFieldValue(this.state.bulkName);
let curValue = this.props.form.getFieldValue(this.state.bulkName)||[];
// { name: '', required: '1', desc: '', example: '' }
let newValue = [];

Expand All @@ -553,6 +553,7 @@ class InterfaceEditForm extends Component {
newValue.push(valueItem);
});

this.props.form.setFieldsValue({[this.state.bulkName]: newValue});
this.setState({
visible: false,
bulkValue: null,
Expand All @@ -574,9 +575,11 @@ class InterfaceEditForm extends Component {
let value = this.props.form.getFieldValue(name);

let bulkValue = ``;
value.forEach(item => {
return (bulkValue += item.name ? `${item.name}:${item.example || ''}\n` : '');
});
if(value) {
value.forEach(item => {
return (bulkValue += item.name ? `${item.name}:${item.example || ''}\n` : '');
});
}

this.setState({
visible: true,
Expand Down

0 comments on commit af3bbd1

Please sign in to comment.