import React from 'react'; import { Button, DatePicker, Form, Input, message, InputNumber } from 'kts-xui'; import { Col, Row } from "kts-components-antd-x4"; import agent from '../../../Server'; import { getSwjg, adm, alxd } from './VerifyInvoice'; const FormItem = Form.Item; interface IProps { url: any; fnForceUpdate: () => void; } export default class Component extends React.Component { constructor(props: IProps) { super(props); this.state = { value: '', loading: false, showCheck: false, tip: '开具金额(不含税)', url: this.props.url && this.props.url.key4 }; } handleSubmit =async values => { const url = this.state.url; let data = { ...values, invoiceDate: values['invoiceDate'] && values['invoiceDate'].format('YYYY-MM-DD'), }; const res: any = await agent.post('', data, this); if(!res.err){ this.success(); }else{ const err2 = res.err; message.error(err2.status.description); return null; } this.setState({ loading: true }); } resetForm = () => { } success = () => { message.success('录入成功'); this.props.fnForceUpdate(); } error = () => { message.error('录入失败'); } onCodeChange = (rule, value, callback) => { //检测是否为全数字 if (rule.pattern.test(value)) { if (value.length === 10 || value.length === 12) { let swjginfo = getSwjg(value, 0); if (swjginfo.length === 0) { callback('发票代码有误!'); } else { if (!adm(value) || swjginfo.length === 0) { callback('发票代码有误!'); } else { let fplx = alxd(value);//fplx 发票类型 if ((fplx === '01' || fplx === '02' || fplx === '03')) { this.setState({ showCheck: false }); if (fplx === '02') { this.setState({ tip: '合计金额' }); } else if (fplx === '03') { this.setState({ tip: '不含税价' }); } else { this.setState({ tip: '开具金额(不含税)' }); } } else if (fplx === '04' || fplx === '10' || fplx === '11' || fplx === '14') { this.setState({ showCheck: true }); } callback(); } } } else { callback('请输入10位或12位合法的发票代码'); } } else { callback('发票代码只支持数字'); } } render() { let formItemLayout = { labelCol: { span: 8 }, wrapperCol: { span: 16 } }; return (
{!this.state.showCheck && ( )} {this.state.showCheck && ( )}
); } }