king
2020-11-10 5df578ff69f6b02e821d59a8883bc75d78695a62
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Form, Col, Icon } from 'antd'
 
import zhCN from '@/locales/zh-CN/mob.js'
import enUS from '@/locales/en-US/mob.js'
import StyleInput from '../stylecontroller/styleInput'
import './index.scss'
 
class MobController extends Component {
  static propTpyes = {
    config: PropTypes.any,
    updateConfig: PropTypes.func,
  }
 
  state = {
    dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    paddingTop: '',
    paddingBottom: '',
    paddingLeft: '',
    paddingRight: ''
  }
 
  UNSAFE_componentWillMount () {
 
  }
 
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.state), fromJS(nextState))
  }
 
  /**
   * @description 修改背景颜色 ,颜色控件
   */
  changePadding = (val, type) => {
    let config = fromJS(this.props.config).toJS()
 
    config.style[type] = val
    this.props.updateConfig(config)
  }
 
  render () {
    const { config } = this.props
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 4 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 20 }
      }
    }
 
    return (
      <div className="menu-padding-controller">
        <Form {...formItemLayout}>
          <Col span={24}>
            <Form.Item
              colon={false}
              label={<Icon title="上边距" type="arrow-up"/>}
            >
              <StyleInput defaultValue={config.style.paddingTop || '0px'} options={['px', 'vh', 'vw']} onChange={(val) => this.changePadding(val, 'paddingTop')}/>
            </Form.Item>
          </Col>
          <Col span={24}>
            <Form.Item
              colon={false}
              label={<Icon title="下边距" type="arrow-down"/>}
            >
              <StyleInput defaultValue={config.style.paddingBottom || '0px'} options={['px', 'vh', 'vw']} onChange={(val) => this.changePadding(val, 'paddingBottom')}/>
            </Form.Item>
          </Col>
          <Col span={24}>
            <Form.Item
              colon={false}
              label={<Icon title="左边距" type="arrow-left"/>}
            >
              <StyleInput defaultValue={config.style.paddingLeft || '0px'} options={['px', 'vh', 'vw']} onChange={(val) => this.changePadding(val, 'paddingLeft')}/>
            </Form.Item>
          </Col>
          <Col span={24}>
            <Form.Item
              colon={false}
              label={<Icon title="右边距" type="arrow-right"/>}
            >
              <StyleInput defaultValue={config.style.paddingRight || '0px'} options={['px', 'vh', 'vw']} onChange={(val) => this.changePadding(val, 'paddingRight')}/>
            </Form.Item>
          </Col>
        </Form>
      </div>
    )
  }
}
 
export default MobController