fix: 接口导入 onChange

This commit is contained in:
zwjamnsss 2017-09-29 14:45:48 +08:00
parent 07900bc947
commit 243cd83c68
2 changed files with 13 additions and 10 deletions

View File

@ -46,19 +46,20 @@ export default class ImportInterface extends Component {
}) : []
}
});
const self = this;
const rowSelection = {
onChange: (selectedRowKeys) => {
// onChange: (selectedRowKeys) => {
// console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
// if (selectedRows.isCategory) {
// const selectedRowKeys = selectedRows.children.map(item => item._id)
// this.setState({ selectedRowKeys })
// }
this.props.onChange(selectedRowKeys.filter(id => id.indexOf('category') === -1));
},
// this.props.onChange(selectedRowKeys.filter(id => ('' + id).indexOf('category') === -1));
// },
onSelect: (record, selected) => {
// console.log(record, selected, selectedRows);
const oldSelecteds = this.state.selectedRowKeys;
const categoryCount = this.state.categoryCount;
const oldSelecteds = self.state.selectedRowKeys;
const categoryCount = self.state.categoryCount;
const categoryKey = record.categoryKey;
const categoryLength = record.categoryLength;
let selectedRowKeys = [];
@ -90,12 +91,13 @@ export default class ImportInterface extends Component {
selectedRowKeys = selectedRowKeys.filter(id => id !== categoryKey)
}
}
this.setState({ selectedRowKeys, categoryCount })
self.setState({ selectedRowKeys, categoryCount })
self.props.onChange(selectedRowKeys.filter(id => ('' + id).indexOf('category') === -1));
},
onSelectAll: (selected) => {
// console.log(selected, selectedRows, changeRows);
let selectedRowKeys = [];
let categoryCount = this.state.categoryCount;
let categoryCount = self.state.categoryCount;
if (selected) {
data.forEach(item => {
if(item.children) {
@ -108,9 +110,10 @@ export default class ImportInterface extends Component {
categoryCount = {};
selectedRowKeys = [];
}
this.setState({ selectedRowKeys, categoryCount })
self.setState({ selectedRowKeys, categoryCount })
self.props.onChange(selectedRowKeys.filter(id => ('' + id).indexOf('category') === -1));
},
selectedRowKeys: this.state.selectedRowKeys
selectedRowKeys: self.state.selectedRowKeys
};
const columns = [{

View File

@ -335,7 +335,7 @@ export default class InterfaceColMenu extends Component {
onCancel={this.handleImportCancel}
width={800}
>
<ImportInterface onSelect={this.selectInterface} list={this.props.list} />
<ImportInterface onChange={this.selectInterface} list={this.props.list} />
</Modal>
</div>
)