| | |
| | | class EditTable extends Component { |
| | | static propTpyes = { |
| | | actions: PropTypes.any, // 操作项 |
| | | searchKey: PropTypes.any, // 搜索条件 |
| | | data: PropTypes.any, // 数据列表 |
| | | columns: PropTypes.array, // 显示列 |
| | | onChange: PropTypes.func // 数据变化 |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { actions, indexShow } = this.props |
| | | const { actions, indexShow, searchKey } = this.props |
| | | const { editLineId } = this.state |
| | | |
| | | let components = { |
| | |
| | | } |
| | | |
| | | let moveprops = {} |
| | | if (actions.includes('move')) { |
| | | if (actions.includes('move') && !searchKey) { |
| | | components.body.row = DragableBodyRow |
| | | moveprops.moveAble = !this.state.editingKey |
| | | moveprops.moveRow = this.moveRow |
| | |
| | | return item |
| | | }) |
| | | |
| | | let reg = searchKey ? new RegExp(searchKey, 'ig') : null |
| | | |
| | | return ( |
| | | <EditableContext.Provider value={this.props.form}> |
| | | <div className="modal-edit-table"> |
| | |
| | | components={components} |
| | | dataSource={data} |
| | | columns={columns} |
| | | rowClassName={record => !editLineId || editLineId !== record.uuid ? 'editable-row' : 'editable-row active'} |
| | | rowClassName={record => { |
| | | let className = 'editable-row' |
| | | if (editLineId && editLineId === record.uuid) { |
| | | className += ' active' |
| | | } |
| | | if (searchKey) { |
| | | if (!reg.test(record.field) && !reg.test(record.label)) { |
| | | className += ' hidden' |
| | | } |
| | | } |
| | | return className |
| | | }} |
| | | pagination={false} |
| | | onRow={(record, index) => ({ |
| | | index, |