| | |
| | | }) |
| | | } |
| | | |
| | | handleAdd = (e) => { |
| | | e.stopPropagation() |
| | | const { dataSource, selectedRowKeys } = this.state |
| | | const item = { |
| | | uuid: Utils.getuuid(), |
| | | key: '', |
| | | value: '', |
| | | description: '', |
| | | selected: true |
| | | } |
| | | |
| | | let _data = [...dataSource, item] |
| | | |
| | | this.setState({ |
| | | dataSource: _data, |
| | | selectedRowKeys: [...selectedRowKeys, item.uuid] |
| | | }, () => { |
| | | this.props.onChange(_data) |
| | | }) |
| | | } |
| | | |
| | | handleSave = row => { |
| | | const newData = this.state.dataSource.map(item => { |
| | | let newData = this.state.dataSource.map(item => { |
| | | if (row.uuid === item.uuid) return row |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ dataSource: newData }, () => { |
| | | let selectedRowKeys = this.state.selectedRowKeys |
| | | |
| | | let last = newData[newData.length - 1] |
| | | if (last.key || last.value || last.description) { |
| | | const item = { |
| | | uuid: Utils.getuuid(), |
| | | key: '', |
| | | value: '', |
| | | description: '', |
| | | selected: true |
| | | } |
| | | |
| | | newData = [...newData, item] |
| | | selectedRowKeys = [...selectedRowKeys, item.uuid] |
| | | } |
| | | |
| | | this.setState({ dataSource: newData, selectedRowKeys }, () => { |
| | | this.props.onChange(newData) |
| | | }) |
| | | } |
| | |
| | | }) |
| | | return ( |
| | | <div className="params-edit-table"> |
| | | <Icon className="add-row" type="plus" onClick={this.handleAdd} /> |
| | | <Table |
| | | rowKey="uuid" |
| | | components={components} |
| | |
| | | .request-interface { |
| | | background: #ffffff; |
| | | margin-bottom: 10px; |
| | | |
| | | .ant-input-group.ant-input-group-compact > *:not(:last-child) { |
| | | border-right-width: 0px; |
| | | } |
| | | .ant-select-selection { |
| | | height: 40px; |
| | | width: 90px; |
| | |
| | | line-height: 40px; |
| | | padding-left: 15px; |
| | | border-top: 1px solid #e8e8e8; |
| | | .ant-radio-wrapper { |
| | | margin-right: 20px; |
| | | } |
| | | } |
| | | .body-content { |
| | | display: none; |
| | | .no-body { |
| | | color: rgba(0, 0, 0, 0.45); |
| | | border-top: 1px solid #e8e8e8; |
| | | border-bottom: 1px solid #e8e8e8; |
| | | text-align: center; |
| | | height: 40px; |
| | | line-height: 40px; |
| | | } |
| | | .CodeMirror { |
| | | height: 200px; |
| | | line-height: 1.5; |
| | | } |
| | | } |
| | | .body-content.show { |
| | | display: block; |