king
2024-03-26 380b4b3234084862a30faae34a7d3ed70d119f34
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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