import React, { Component } from "react"; import { host, uploadBizInvoice, applyEinvoice } from '../../../services/api'; import { phone as phoneReg } from '../../../utils/regs'; // import $loading from '../../../utils/loading'; import { Button, Drawer, Form, Input, Upload, Icon, notification } from "antd"; const formItemLayout = { labelCol: { xs: { span: 5 }, sm: { span: 5 }, }, wrapperCol: { xs: { span: 18 }, sm: { span: 18 }, }, }; @Form.create() export default class Messages extends Component { constructor(props, context) { super(props, context); this.state = { invoiceInfo: null, fileList: [], invoiceUrl: '', }; } componentDidMount() { } render() { const { getFieldDecorator } = this.props.form; const { invoiceInfo } = this.props; const uploadProps = { name: 'xfile', action: `${host}/public/common/file/upload-file`, headers: { authorization: 'authorization-text', }, fileList: this.state.fileList, multiple: false, beforeUpload: file => { const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png' || file.type == 'application/pdf'; if (!isJpgOrPng) { this.setState({ fileList: [] }); notification.error({ message: '格式支持 jpg/png/pdf' }); } const isLt10M = file.size / 1024 / 1024 < 10; if (!isLt10M) { notification.error({ message: '上传文件不大于10M' }); } return isJpgOrPng && isLt10M; }, onChange: async info => { if (info.file.status === 'uploading') { this.setState({ fileList: [info.file] }); } if (info.file.status === 'removed') { this.setState({ fileList: [] }); } if (info.file.status === 'done') { const res = info.file.response; if (res.retType == 0) { this.setState({ invoiceUrl: res.data }); } else { notification.error({ message: res.msg }); } } else if (info.file.status === 'error') { this.setState({ fileList: [] }); notification.error({ message: `${info.file.name} 上传失败` }); } }, }; return ( { invoiceInfo &&
{getFieldDecorator('bizInvoiceMakeType', { initialValue: invoiceInfo.bizInvoiceMakeTypeStr, rules: [ { required: true, message: '请输入' }, { validator: this._inputValidator } ] })()} {getFieldDecorator('title', { initialValue: invoiceInfo.title, rules: [ { required: true, message: '请输入' }, { validator: this._inputValidator } ] })()} {getFieldDecorator('taxRegCerNo', { initialValue: invoiceInfo.taxRegCerNo, rules: [ { required: true, message: '请输入' }, { validator: this._inputValidator } ] })()} {getFieldDecorator('bank', { initialValue: invoiceInfo.bank, rules: [ { required: true, message: '请输入' }, { validator: this._inputValidator } ] })()} {getFieldDecorator('bankAccount', { initialValue: invoiceInfo.bankAccount, rules: [ { required: true, message: '请输入' }, { validator: this._inputValidator } ] })()} {getFieldDecorator('regPhone', { initialValue: invoiceInfo.regPhone, rules: [ { required: true, message: '请输入' }, { validator: this._inputValidator } ] })()} {getFieldDecorator('regAddress', { initialValue: invoiceInfo.regAddress, rules: [ { required: true, message: '请输入' }, { validator: this._inputValidator } ] })()} {getFieldDecorator('receiver', { initialValue: invoiceInfo.receiver, rules: [ { required: true, message: '请输入' }, { validator: this._inputValidator } ] })()} {getFieldDecorator('receiverPhone', { initialValue: invoiceInfo.receiverPhone, rules: [ { required: true, message: '请输入' }, { validator: (rule, value, callback) => { if (value && !phoneReg.test(value)) { callback('请输入正确的手机号'); } else { callback(); } } } ] })()} {getFieldDecorator('receiverAddress', { initialValue: invoiceInfo.receiverAddress, rules: [ { required: true, message: '请输入' }, { validator: this._inputValidator } ] })()} { invoiceInfo.invoiceUrl ? 点击查看 : '开票方暂未上传' } { invoiceInfo && invoiceInfo.isDrawer == 1 && invoiceInfo.makeStatus == 0 && invoiceInfo.invoiceUrl == '' && 仅支持支持 jpg/png/pdf格式 } { // 开票方 未开票 电子发票 invoiceInfo && invoiceInfo.isDrawer == 1 && invoiceInfo.makeStatus == 0 && invoiceInfo.bizInvoiceMakeType == 3 && }
} { // this.props.confirmStatus? '': // this.props.bizInvoiceType == 1 && invoiceInfo && invoiceInfo.isDrawer == 1 && invoiceInfo.makeStatus == 0 && invoiceInfo.invoiceUrl == '' && // invoiceInfo && invoiceInfo.isDrawer == 1 && invoiceInfo.makeStatus == 0 &&
}
); } }