import React, { PureComponent } from 'react'; import { Modal, Form, Select, InputNumber } from 'antd'; import { chargeUnit } from '../../../utils/config'; const Option = Select.Option; @Form.create() export default class NewPriceModal extends PureComponent { handleModalOnOk = () => { const { form: { validateFields, getFieldsValue, }, data, onSubmit, } = this.props; validateFields((errors) => { if (errors) return; const formData = getFieldsValue(); const newData = { ...formData }; newData.duration = chargeUnit[formData.chargeUnit]; data.id ? newData.id = data.id : null; onSubmit(newData); }); } handleTest = (value) => { console.log(value); } render() { const { form, data, onSubmit, ...modalProps } = this.props; const { getFieldDecorator } = form; const formItemLayout = { labelCol: { span: 9 }, wrapperCol: { span: 10 }, }; return (
{getFieldDecorator('chargeUnit', { rules: [{ required: true, type: 'string', message: '请选择一种计价单位!' }], initialValue: data.chargeUnit, })( )} {getFieldDecorator('cpPrice', { initialValue: data.cpPrice, })( `¥ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')} parser={value => value.replace(/\¥\s?|(,*)/g, '')} /> )} {getFieldDecorator('merchantPrice', { initialValue: data.merchantPrice, })( `¥ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')} parser={value => value.replace(/\¥\s?|(,*)/g, '')} /> )} {getFieldDecorator('terminalPrice', { initialValue: data.terminalPrice, })( `¥ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')} parser={value => value.replace(/\¥\s?|(,*)/g, '')} /> )}
); } }