diff --git a/components/transfer/demo/basic.md b/components/transfer/demo/basic.md index 75aaa31327..ace1b7085d 100644 --- a/components/transfer/demo/basic.md +++ b/components/transfer/demo/basic.md @@ -36,7 +36,8 @@ const App = React.createClass({ } this.setState({ mockData, targetKeys }); }, - handleChange(targetKeys) { + handleChange(targetKeys, direction, moveKeys) { + console.log(targetKeys, direction, moveKeys); this.setState({ targetKeys }); }, renderFooter() { diff --git a/components/transfer/index.jsx b/components/transfer/index.jsx index bfcd3fe1a6..245384b584 100644 --- a/components/transfer/index.jsx +++ b/components/transfer/index.jsx @@ -46,19 +46,18 @@ class Transfer extends Component { moveTo(direction) { const { targetKeys } = this.props; const { leftCheckedKeys, rightCheckedKeys } = this.state; + const moveKeys = direction === 'right' ? leftCheckedKeys : rightCheckedKeys; // move items to target box - const newTargetKeys = direction === 'right' ? - leftCheckedKeys.concat(targetKeys) : - targetKeys.filter((targetKey) => { - return !rightCheckedKeys.some((checkedKey) => targetKey === checkedKey); - }); + const newTargetKeys = direction === 'right' + ? moveKeys.concat(targetKeys) + : targetKeys.filter(targetKey => !moveKeys.some(checkedKey => targetKey === checkedKey)); // empty checked keys this.setState({ [direction === 'right' ? 'leftCheckedKeys' : 'rightCheckedKeys']: [], }); - this.props.onChange(newTargetKeys); + this.props.onChange(newTargetKeys, direction, moveKeys); } getGlobalCheckStatus(direction) { diff --git a/components/transfer/index.md b/components/transfer/index.md index 4e2fb29367..ece3889de3 100644 --- a/components/transfer/index.md +++ b/components/transfer/index.md @@ -21,7 +21,7 @@ | dataSource | 数据源 | Array | [] | | render | 每行数据渲染函数 | Function(record) | | | targetKeys | 显示在右侧框数据的key集合 | Array | [] | -| onChange | 变化时回调函数 | Function(newTargetKeys) | | +| onChange | 变化时回调函数 | Function(targetKeys, direction, moveKeys) | | | listStyle | 两个穿梭框的自定义样式 | Object | | | className | 自定义类 | String | | | titles | 标题集合,顺序从左至右 | Array | ['源列表', '目的列表'] |