Skip to content

Commit

Permalink
fix: handle null value in handleBulk
Browse files Browse the repository at this point in the history
  • Loading branch information
tangcent committed Nov 16, 2019
1 parent 7442b0e commit cb40e9f
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 cb40e9f

Please sign in to comment.