修复了extraInfo,待实现提交返回逻辑

main
白封羽 2022-12-28 11:07:49 +08:00
parent 6f089a08d8
commit e005d48d56
2 changed files with 34 additions and 11 deletions

View File

@ -95,8 +95,7 @@ export class InvoiceCommit {
invoiceCheckCode:string
invoiceRegionCode: Nullable<string>
invoiceSellerTaxCode:Nullable<string>
invoiceExtraInfo: []
invoiceExtraInfo:Nullable<string>|[]
constructor() {
this.invoiceFileName = ""
this.invoiceNo = ""
@ -108,7 +107,7 @@ export class InvoiceCommit {
this.invoiceCheckCode = "000000"
this.invoiceRegionCode = null
this.invoiceSellerTaxCode = null
this.invoiceExtraInfo = []
this.invoiceExtraInfo = null
}
setValue(props: FormData) {
console.log("1111"+props.toString())

View File

@ -90,7 +90,7 @@ class InvoiceUploadView extends React.Component<any, any>{
let data= new FormData();
data.append('invoiceFile',tempFile)
axiosInstance({
url: '/invoice/identify',//123131',//FIXME
url: 'common/invoice/identify',
method: 'POST',
data: data
}).then(response => {
@ -103,7 +103,10 @@ class InvoiceUploadView extends React.Component<any, any>{
result.invoiceCheckCode = response.data.invoiceCheckCode
result.invoiceKind = response.data.invoiceKind
result.invoiceFileName = response.data.invoiceFileName
result.invoiceExtraInfo = response.data.invoiceExtraInfo.toString()
result.invoiceExtraInfo = ""
for(let i=0;i<response.data.invoiceExtraInfo.length;i++){
result.invoiceExtraInfo+=(response.data.invoiceExtraInfo[i].name+": "+response.data.invoiceExtraInfo[i].value+"\n")
}
this.setState({invoiceCommit:result})
this.formRef.current!.setFieldsValue(result);
}).catch(function (error) {
@ -128,6 +131,27 @@ class InvoiceUploadView extends React.Component<any, any>{
this.setOpen(false);
};
submit=()=>{
let result=this.formRef.current!.getFieldsValue()
result.invoiceDate=result.invoiceDate.format("YYYY-MM-DD")
let extraInfo=[]
let line = result.invoiceExtraInfo.split('\n')
for(let i=0;i<line.length;i++){
let tmp = line[i].split(": ")
if(tmp.length===2){
extraInfo.push({name:tmp[0],value:tmp[1]})
}
}
result.invoiceExtraInfo=extraInfo
axiosInstance({
url: 'common/invoice/submit',
method: 'POST',
data: result
}).then(response => {
//TODO
console.log(response.data)
}).catch(function (error) {
console.log(error)
})
}
render() {
@ -200,12 +224,12 @@ class InvoiceUploadView extends React.Component<any, any>{
>
<Input />
</Form.Item>
<Form.Item
name={`invoiceAmountWithoutTax`}
label={`非税金额`}
>
<Input/>
</Form.Item>
{/*<Form.Item*/}
{/* name={`invoiceAmountWithoutTax`}*/}
{/* label={`非税金额`}*/}
{/*>*/}
{/* <Input/>*/}
{/*</Form.Item>*/}
<Form.Item
name={`invoiceDate`}
label={`开票日期`}