king
2020-09-16 c34bcb0a3054bdab29fbaff17e587c19d7b5de28
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
import React, {Component} from 'react'
import PropTypes from 'prop-types'
// import { is, fromJS } from 'immutable'
import { Icon, Modal } from 'antd'
 
import zhCN from '@/locales/zh-CN/mob.js'
import enUS from '@/locales/en-US/mob.js'
import './index.scss'
 
const { confirm } = Modal
 
class ContentDelete extends Component {
  static propTpyes = {
    element: PropTypes.object,
    list: PropTypes.array,
    updateContent: PropTypes.func
  }
 
  state = {
    dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    images: [],
    visible: false
  }
 
  UNSAFE_componentWillMount () {
 
  }
 
  // shouldComponentUpdate (nextProps, nextState) {
  //   return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
  // }
 
  deleteElement = () => {
    const { list, element } = this.props
    const _this = this
 
    confirm({
      title: '确定删除元素吗?',
      onOk() {
        _this.props.updateContent({...list, subItems: list.subItems.filter(item => item.uuid !== element.uuid)})
      },
      onCancel() {}
    })
  }
 
  
 
  render () {
    return (
      <div className="mob-content-list-delete">
        <Icon type="close" onClick={this.deleteElement} />
      </div>
    )
  }
}
 
export default ContentDelete