| | |
| | | class TransferForm extends Component { |
| | | static propTypes = { |
| | | columns: PropTypes.array, |
| | | selected: PropTypes.array, |
| | | dict: PropTypes.object, // 字典项 |
| | | selected: PropTypes.array |
| | | } |
| | | |
| | | state = { |
| | |
| | | key: item.uuid, |
| | | title: item.label, |
| | | field: item.field, |
| | | description: '' |
| | | description: item.label + '(' + item.field + ')' |
| | | } |
| | | }), |
| | | targetKeys: selecteds |
| | |
| | | } |
| | | |
| | | getItem = (item) => { |
| | | let content = item.title + '(' + item.field + ')' |
| | | return <span title={content}> |
| | | {content} |
| | | <Icon type="arrow-up" onClick={(e) => {this.changeorder(e, item, 'up')}} /> |
| | | <Icon type="arrow-down" onClick={(e) => {this.changeorder(e, item, 'down')}} /> |
| | | </span> |
| | | const { targetKeys } = this.state |
| | | |
| | | if (targetKeys.includes(item.key)) { |
| | | return <span title={item.description}> |
| | | {item.description} |
| | | <Icon type="arrow-up" onClick={(e) => {this.changeorder(e, item, 'up')}} /> |
| | | <Icon type="arrow-down" onClick={(e) => {this.changeorder(e, item, 'down')}} /> |
| | | </span> |
| | | } else { |
| | | return item.description |
| | | } |
| | | } |
| | | |
| | | filterdata = (inputValue, option) => { |
| | | if (!inputValue) return true |
| | | |
| | | return option.description.toLowerCase().indexOf(inputValue.toLowerCase()) > -1 |
| | | } |
| | | |
| | | render() { |
| | |
| | | <div className="common-table-columns-transfer"> |
| | | <Transfer |
| | | dataSource={this.state.data} |
| | | titles={[this.props.dict['header.form.column.source'], this.props.dict['header.form.column.target']]} |
| | | showSearch={this.state.data.length > 10} |
| | | filterOption={this.filterdata} |
| | | targetKeys={targetKeys} |
| | | locale={{itemUnit: this.props.dict['header.form.column.itemUnit'], itemsUnit: this.props.dict['header.form.column.itemsUnit']}} |
| | | selectedKeys={selectedKeys} |
| | | onChange={this.handleChange} |
| | | onSelectChange={this.handleSelectChange} |