|
|
@ -45,7 +45,6 @@ export default class Transfer extends React.Component {
|
|
|
|
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
this.state = {
|
|
|
|
leftFilter: '',
|
|
|
|
leftFilter: '',
|
|
|
|
rightFilter: '',
|
|
|
|
rightFilter: '',
|
|
|
@ -53,9 +52,16 @@ export default class Transfer extends React.Component {
|
|
|
|
rightCheckedKeys: [],
|
|
|
|
rightCheckedKeys: [],
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillReceiveProps(nextProps) {
|
|
|
|
splitDataSource() {
|
|
|
|
const { leftCheckedKeys, rightCheckedKeys } = this.state;
|
|
|
|
const { targetKeys, dataSource } = this.props;
|
|
|
|
const { leftDataSource, rightDataSource } = this.splitDataSource(nextProps);
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
|
|
leftCheckedKeys: leftCheckedKeys.filter(data => leftDataSource.filter(leftData => leftData.key === data).length),
|
|
|
|
|
|
|
|
rightCheckedKeys: rightCheckedKeys.filter(data => rightDataSource.filter(rightData => rightData.key === data).length),
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
splitDataSource(props) {
|
|
|
|
|
|
|
|
const { targetKeys, dataSource } = props;
|
|
|
|
|
|
|
|
|
|
|
|
let leftDataSource = [...dataSource];
|
|
|
|
let leftDataSource = [...dataSource];
|
|
|
|
let rightDataSource = [];
|
|
|
|
let rightDataSource = [];
|
|
|
@ -99,7 +105,7 @@ export default class Transfer extends React.Component {
|
|
|
|
moveToRight = () => this.moveTo('right')
|
|
|
|
moveToRight = () => this.moveTo('right')
|
|
|
|
|
|
|
|
|
|
|
|
getGlobalCheckStatus(direction) {
|
|
|
|
getGlobalCheckStatus(direction) {
|
|
|
|
const { leftDataSource, rightDataSource } = this.splitDataSource();
|
|
|
|
const { leftDataSource, rightDataSource } = this.splitDataSource(this.props);
|
|
|
|
const { leftFilter, rightFilter, leftCheckedKeys, rightCheckedKeys } = this.state;
|
|
|
|
const { leftFilter, rightFilter, leftCheckedKeys, rightCheckedKeys } = this.state;
|
|
|
|
|
|
|
|
|
|
|
|
const dataSource = direction === 'left' ? leftDataSource : rightDataSource;
|
|
|
|
const dataSource = direction === 'left' ? leftDataSource : rightDataSource;
|
|
|
@ -134,7 +140,7 @@ export default class Transfer extends React.Component {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
handleSelectAll = (direction) => {
|
|
|
|
handleSelectAll = (direction) => {
|
|
|
|
const { leftDataSource, rightDataSource } = this.splitDataSource();
|
|
|
|
const { leftDataSource, rightDataSource } = this.splitDataSource(this.props);
|
|
|
|
const { leftFilter, rightFilter } = this.state;
|
|
|
|
const { leftFilter, rightFilter } = this.state;
|
|
|
|
const dataSource = direction === 'left' ? leftDataSource : rightDataSource;
|
|
|
|
const dataSource = direction === 'left' ? leftDataSource : rightDataSource;
|
|
|
|
const filter = direction === 'left' ? leftFilter : rightFilter;
|
|
|
|
const filter = direction === 'left' ? leftFilter : rightFilter;
|
|
|
@ -201,7 +207,7 @@ export default class Transfer extends React.Component {
|
|
|
|
} = this.props;
|
|
|
|
} = this.props;
|
|
|
|
const { leftFilter, rightFilter, leftCheckedKeys, rightCheckedKeys } = this.state;
|
|
|
|
const { leftFilter, rightFilter, leftCheckedKeys, rightCheckedKeys } = this.state;
|
|
|
|
|
|
|
|
|
|
|
|
const { leftDataSource, rightDataSource } = this.splitDataSource();
|
|
|
|
const { leftDataSource, rightDataSource } = this.splitDataSource(this.props);
|
|
|
|
const leftActive = rightCheckedKeys.length > 0;
|
|
|
|
const leftActive = rightCheckedKeys.length > 0;
|
|
|
|
const rightActive = leftCheckedKeys.length > 0;
|
|
|
|
const rightActive = leftCheckedKeys.length > 0;
|
|
|
|
|
|
|
|
|
|
|
|