| | |
| | | |
| | | class MkSwitch extends Component { |
| | | static propTpyes = { |
| | | autoFocus: PropTypes.bool, |
| | | defaultValue: PropTypes.any, |
| | | config: PropTypes.object, |
| | | onChange: PropTypes.func |
| | |
| | | if (config.$ctrl) { |
| | | MKEmitter.emit('colBlur' + config.tableId, lineId, config.uuid) |
| | | } |
| | | |
| | | this.props.onBlur && this.props.onBlur() |
| | | } |
| | | |
| | | render() { |
| | | const { config, autoFocus } = this.props |
| | | const { config } = this.props |
| | | const { status } = this.state |
| | | |
| | | return ( |
| | |
| | | ref={ref => this.node = ref} |
| | | checkedChildren={config.openText} |
| | | checked={status} |
| | | autoFocus={autoFocus} |
| | | onFocus={this.onFocus} |
| | | onBlur={this.onBlur} |
| | | unCheckedChildren={config.closeText} |
| | |
| | | } |
| | | |
| | | if (col.editable === 'true' && !disabled) { |
| | | if (editing) { |
| | | if (col.editType === 'switch') { |
| | | let _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> |
| | | <MkSwitch config={col} lineId={record.$$uuid} defaultValue={_value} onChange={this.onColChange}/> |
| | | </td>) |
| | | } else if (editing) { |
| | | let _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | |
| | | if (!col.editType || col.editType === 'text') { |
| | | return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> |
| | | <MkInput config={col} lineId={record.$$uuid} defaultValue={_value} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/> |
| | | </td>) |
| | | } else if (col.editType === 'switch') { |
| | | return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> |
| | | <MkSwitch config={col} lineId={record.$$uuid} defaultValue={_value} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/> |
| | | </td>) |
| | | } else if (col.editType === 'date') { |
| | | return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> |
| | |
| | | ) |
| | | } else if (col.editType === 'switch') { |
| | | children = ( |
| | | <MkSwitch config={col} lineId={record.$$uuid} defaultValue={_value} autoFocus={false} onChange={this.onColChange}/> |
| | | <MkSwitch config={col} lineId={record.$$uuid} defaultValue={_value} onChange={this.onColChange}/> |
| | | ) |
| | | } else if (col.editType === 'date') { |
| | | children = ( |
| | |
| | | delete result.message |
| | | delete result.status |
| | | |
| | | this.props.columns.forEach(item => { |
| | | if (item.arr_field && result[item.arr_field]) { |
| | | result[item.uuid] = result[item.arr_field] |
| | | } |
| | | }) |
| | | |
| | | this.resetFormList(result) |
| | | }) |
| | | } |