king
2024-04-08 37e28da53f6d4d7d8abe7626ba28ba7dbe16e7bb
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Radio, Tooltip, Select } from 'antd'
import { QuestionCircleOutlined } from '@ant-design/icons'
// import './index.scss'
 
class ExcelOutOtherColumn extends Component {
  static propTpyes = {
    onChange: PropTypes.func
  }
 
  onChange = (key, val) => {
    const { line } = this.props
 
    this.props.onChange({...line, [key]: val})
  }
 
  render() {
    const { getFieldDecorator } = this.props.form
    const { line } = this.props
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 8 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      }
    }
 
    return (
      <Form {...formItemLayout} style={{minHeight: '100px', paddingTop: '10px'}}>
        <Row gutter={24}>
          {line.type === 'number' ? <Col span={8}>
            <Form.Item label="取绝对值">
              {getFieldDecorator('abs', {
                initialValue: line.abs || 'false'
              })(
                <Radio.Group style={{whiteSpace: 'nowrap'}} onChange={(e) => {this.onChange('abs', e.target.value)}}>
                  <Radio value="true">是</Radio>
                  <Radio value="false">否</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col> : null}
          {line.type === 'text' ? <Col span={8}>
            <Form.Item label="自动换行">
              {getFieldDecorator('wrapText', {
                initialValue: line.wrapText || 'false'
              })(
                <Radio.Group style={{whiteSpace: 'nowrap'}} onChange={(e) => {this.onChange('wrapText', e.target.value)}}>
                  <Radio value="true">是</Radio>
                  <Radio value="false">否</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col> : null}
          <Col span={8}>
            <Form.Item label={line.type === 'number' ? '0值' : 
              <Tooltip placement="topLeft" title="时间小于 1949-10-02 时。">
                <QuestionCircleOutlined className="mk-form-tip" />
                空值
              </Tooltip>
            }>
              {getFieldDecorator('noValue', {
                initialValue: line.noValue || 'true'
              })(
                <Radio.Group style={{whiteSpace: 'nowrap'}} onChange={(e) => {this.onChange('noValue', e.target.value)}}>
                  <Radio value="true">导出</Radio>
                  <Radio value="false">不导出</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col>
          {line.type === 'number' ? <Col span={8}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="使用格式化时,需设置小数位。">
                <QuestionCircleOutlined className="mk-form-tip" />
                格式化
              </Tooltip>
            }>
              {getFieldDecorator('format', {
                initialValue: line.format || ''
              })(
                <Select onChange={(val) => this.onChange('format', val)}>
                  <Select.Option value=""> 无 </Select.Option>
                  <Select.Option value="thdSeparator"> 千分位 </Select.Option>
                  <Select.Option value="thdSepPm"> 千分位(负值红色) </Select.Option>
                  <Select.Option value="percent"> 百分比 </Select.Option>
                </Select>
              )}
            </Form.Item>
          </Col> : null}
          {line.type === 'text' ? <Col span={8}>
            <Form.Item label="格式化">
              {getFieldDecorator('textFormat', {
                initialValue: line.textFormat || ''
              })(
                <Select onChange={(val) => this.onChange('textFormat', val)}>
                  <Select.Option value=""> 无 </Select.Option>
                  <Select.Option value="YYYY-MM-DD"> YYYY-MM-DD </Select.Option>
                  <Select.Option value="YYYY-MM-DD HH:mm:ss"> YYYY-MM-DD HH:mm:ss </Select.Option>
                </Select>
              )}
            </Form.Item>
          </Col> : null}
        </Row>
      </Form>
    )
  }
}
 
export default Form.create()(ExcelOutOtherColumn)