king
2020-06-30 e62bed4f742dd29820499cfe745eb381d9f39f87
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
import React, {Component} from 'react'
import PropTypes from 'prop-types'
// import { is, fromJS } from 'immutable'
import { Form, Icon, Popover, Input } from 'antd'
 
import zhCN from '@/locales/zh-CN/mob.js'
import enUS from '@/locales/en-US/mob.js'
import './index.scss'
 
class ContentUpdate extends Component {
  static propTpyes = {
    element: PropTypes.object,
    updateContent: PropTypes.func
  }
 
  state = {
    dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
  }
 
  UNSAFE_componentWillMount () {
 
  }
 
  // shouldComponentUpdate (nextProps, nextState) {
  //   return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
  // }
 
  onVisibleChange = (visible) => {
    let val = this.props.form.getFieldValue('content')
    console.log(visible)
    console.log(val)
  }
 
  render () {
    const { element } = this.props
    const { getFieldDecorator } = this.props.form
 
    return (
      <div className="mob-content-update">
        <Popover content={
          <div>
            {getFieldDecorator('content', {
              initialValue: element.content
            })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />)}
          </div>
        } overlayClassName="mob-content-update-popover" placement="bottomRight" title="" trigger="click" onVisibleChange={this.onVisibleChange}>
          <Icon type="edit" />
        </Popover>
      </div>
    )
  }
}
 
export default Form.create()(ContentUpdate)