import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { Form, Row, Col, Radio, Tooltip, Select, Input } 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}
|
<Col span={8}>
|
<Form.Item label="前缀">
|
{getFieldDecorator('prefix', {
|
initialValue: line.prefix || ''
|
})(
|
<Input autoComplete="off" onChange={(e) => this.onChange('prefix', e.target.value)} onPressEnter={this.props.submit}/>
|
)}
|
</Form.Item>
|
</Col>
|
<Col span={8}>
|
<Form.Item label="后缀">
|
{getFieldDecorator('postfix', {
|
initialValue: line.postfix || ''
|
})(
|
<Input autoComplete="off" onChange={(e) => this.onChange('postfix', e.target.value)} onPressEnter={this.props.submit}/>
|
)}
|
</Form.Item>
|
</Col>
|
</Row>
|
</Form>
|
)
|
}
|
}
|
|
export default Form.create()(ExcelOutOtherColumn)
|