| | |
| | | } |
| | | |
| | | onChange = (val) => { |
| | | const { col } = this.props |
| | | const { col, record } = this.props |
| | | |
| | | let err = null |
| | | |
| | | if (col.type === 'number') { |
| | | if (col.noValue === 'hide' && val === null) { |
| | | val = 0 |
| | | } else { |
| | | val = +val |
| | | if (isNaN(val)) { |
| | | val = 0 |
| | |
| | | } else if (typeof(col.min) === 'number' && val < col.min) { |
| | | err = col.label + '最小为' + col.min |
| | | } |
| | | } |
| | | } else if (col.required === 'true' && !val) { |
| | | err = '请填写' + col.label |
| | | } |
| | | |
| | | this.setState({value: val, err}) |
| | | |
| | | if (col.clearField && record[col.clearField]) { |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, [col.clearField]: ''}, 'clear') |
| | | } |
| | | } |
| | | |
| | | onSwitchChange = (val, label) => { |
| | |
| | | class BodyAllCell extends React.Component { |
| | | state = { |
| | | err: null, |
| | | value: '' |
| | | value: '', |
| | | resting: false |
| | | } |
| | | |
| | | componentDidMount() { |
| | | const { col } = this.props |
| | | |
| | | if (col && col.type === 'number' && col.clearField) { |
| | | MKEmitter.addListener('resetCol', this.resetCol) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('resetCol', this.resetCol) |
| | | } |
| | | |
| | | enterPress = () => { |
| | |
| | | }, 50) |
| | | } |
| | | |
| | | resetCol = (tableId, clearField, id) => { |
| | | const { col, record } = this.props |
| | | |
| | | if (col.tableId === tableId && clearField === col.field && record.$$uuid === id) { |
| | | this.setState({resting: true}, () => { |
| | | this.setState({resting: false}) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | onChange = (val) => { |
| | | const { col } = this.props |
| | | const { col, record } = this.props |
| | | |
| | | if (col.noValue === 'hide' && val === null) { |
| | | this.setState({value: 0}) |
| | | } else { |
| | | this.setState({value: val}) |
| | | } |
| | | |
| | | if (col.clearField && record[col.clearField]) { |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, [col.clearField]: ''}, 'clear') |
| | | MKEmitter.emit('resetCol', col.tableId, col.clearField, record.$$uuid) |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | render() { |
| | | let { col, config, record, style, className, ...resProps } = this.props |
| | | const { err } = this.state |
| | | const { err, resting } = this.state |
| | | |
| | | if (!col) return (<td {...resProps} className={className} style={style}/>) |
| | | if (resting) return null |
| | | |
| | | let disabled = false |
| | | let editable = false |
| | |
| | | } |
| | | } |
| | | |
| | | changeRecord = (id, record) => { |
| | | changeRecord = (id, record, type) => { |
| | | const { setting } = this.props |
| | | const { tableId, signForms } = this.state |
| | | |
| | |
| | | if (setting.tableType && setting.hasAction && this.state.selectedRowKeys.includes(record.$$uuid)) { |
| | | this.selectdata(this.state.selectedRowKeys) |
| | | } |
| | | if (setting.commit === 'blur') { |
| | | if (setting.commit === 'blur' && type !== 'clear') { |
| | | this.submit(record) |
| | | } |
| | | }) |