import React, {Component} from 'react'
|
import { Button, Modal, Input, notification } from 'antd'
|
|
// import './index.scss'
|
|
const { TextArea } = Input
|
|
class ResetRemark extends Component {
|
state = {
|
visible: false,
|
remark: ''
|
}
|
|
submit = () => {
|
const { ID } = this.props
|
|
let node = document.getElementById(ID)
|
let val = node.value
|
|
if (val && val.length > 512) {
|
notification.warning({
|
top: 92,
|
message: '当前内容超长,备注最多512个字符。',
|
duration: 5
|
})
|
return
|
}
|
|
this.setState({remark: '', visible: false})
|
this.props.onChange(val)
|
}
|
|
trigger = () => {
|
const { remark } = this.props
|
|
this.setState({visible: true, remark: remark})
|
}
|
|
render() {
|
const { ID, disabled } = this.props
|
const { visible, remark } = this.state
|
|
return (
|
<>
|
<Button type="link" onClick={this.trigger}>备注</Button>
|
<Modal
|
title="备注"
|
visible={visible}
|
width={700}
|
maskClosable={false}
|
onOk={this.submit}
|
onCancel={() => { this.setState({ visible: false })}}
|
destroyOnClose
|
>
|
<TextArea id={ID} disabled={disabled} defaultValue={remark} rows={6}/>
|
</Modal>
|
</>
|
)
|
}
|
}
|
|
export default ResetRemark
|