From 03d747d12390134d75d87ad922ad101d2fa52dfe Mon Sep 17 00:00:00 2001 From: "yang.yongquan" <3395816735@qq.com> Date: Tue, 27 Dec 2022 19:01:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E4=B8=AD=E8=AF=86=E5=88=AB=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/Staff.ts | 42 ++++++++++++++++++++++++++++++++++++++ src/utils/axiosInstance.ts | 4 ++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/models/Staff.ts b/src/models/Staff.ts index c9b8fb4..1da9f86 100644 --- a/src/models/Staff.ts +++ b/src/models/Staff.ts @@ -79,4 +79,46 @@ export class InvoiceSearchOption{ // res+=(this.invoiceUploader===undefined||this.invoiceUploader===null?"":("&invoiceUploader="+this.invoiceUploader)); // return res; // } +} + +export class InvoiceCommit { + invoiceFileName: string + invoiceNo: string + invoiceCode:string + invoiceKind:string + invoiceDate:Date + invoiceAmount:number + invoiceAmountWithoutTax: number + invoiceCheckCode:string + invoiceRegionCode: Nullable + invoiceSellerTaxCode:Nullable + + invoiceExtraInfo: [] + constructor() { + this.invoiceFileName = "" + this.invoiceNo = "" + this.invoiceCode = "" + this.invoiceKind = "" + this.invoiceDate = new Date() + this.invoiceAmount = 0 + this.invoiceAmountWithoutTax = 0 + this.invoiceCheckCode = "000000" + this.invoiceRegionCode = null + this.invoiceSellerTaxCode = null + this.invoiceExtraInfo = [] + } + setValue(props: FormData) { + console.log("1111"+props.toString()) + this.invoiceFileName = props.get("invoiceFileName")!.toString() + this.invoiceNo = props.get("invoiceNo")!.toString() + this.invoiceCode = props.get("invoiceCode")!.toString() + this.invoiceKind = props.get("invoiceKind")!.toString() + this.invoiceDate = new Date(props.get("invoiceDate")!.toString()) + //this.invoiceAmount = props.get("invoiceAmount")!.toString() + //this.invoiceAmountWithoutTax = props.get("invoiceAmountWithoutTax")!.toString() + this.invoiceCheckCode = props.get("invoiceCheckCode")!.toString() + this.invoiceRegionCode = props.get("invoiceRegionCode")!.toString() + this.invoiceSellerTaxCode = props.get("invoiceSellerTaxCode")!.toString() + //this.invoiceExtraInfo = props.get("invoiceExtraInfo")!. + } } \ No newline at end of file diff --git a/src/utils/axiosInstance.ts b/src/utils/axiosInstance.ts index a15c920..ae9a1b1 100644 --- a/src/utils/axiosInstance.ts +++ b/src/utils/axiosInstance.ts @@ -1,8 +1,8 @@ import axios, {AxiosRequestConfig, AxiosResponse} from "axios"; import {store} from "../models/store"; -export const baseUrl = "http://101.34.228.45:8080/" -//export const baseUrl = "https://mock.apifox.cn/m1/2116708-0-default/" +// export const baseUrl = "http://101.34.228.45:8080/" +export const baseUrl = "https://mock.apifox.cn/m1/2116708-0-ae5ae4e4/" const axiosInstance = axios.create({ baseURL: baseUrl, From 6ba1e4fe6ef58e63ac0757e0146b16f997380ac8 Mon Sep 17 00:00:00 2001 From: "yang.yongquan" <3395816735@qq.com> Date: Tue, 27 Dec 2022 19:01:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E4=B8=AD=E8=AF=86=E5=88=AB=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Invoice/mine/InvoiceUploadView.tsx | 222 +++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 src/pages/Invoice/mine/InvoiceUploadView.tsx diff --git a/src/pages/Invoice/mine/InvoiceUploadView.tsx b/src/pages/Invoice/mine/InvoiceUploadView.tsx new file mode 100644 index 0000000..ca33cf4 --- /dev/null +++ b/src/pages/Invoice/mine/InvoiceUploadView.tsx @@ -0,0 +1,222 @@ +import React, {useState} from 'react'; +import {Button, Modal, UploadProps, message, Upload, UploadFile, Form, Input,DatePicker} from 'antd'; +import { InboxOutlined } from '@ant-design/icons'; +import axiosInstance from "../../../utils/axiosInstance"; +import {InvoiceCommit} from "../../../models/Staff"; +import dayjs from 'dayjs'; +import TextArea from "antd/es/input/TextArea"; +import {constants} from "http2"; +const { Dragger } = Upload; +let tempFile :File +const props: UploadProps = { + name: 'file', + multiple: false, + maxCount: 1, + accept: "image/png, image/jpeg, image/jpg", + beforeUpload: (file,fileList)=>{ + tempFile=file + console.log(file) + return false + }, + onChange(info) { + // const { status } = info.file; + // if (status !== 'uploading') { + // console.log('here---------'+info.file, info.fileList); + // } + // if (status === 'done') { + // message.success(`${info.file.name} file uploaded successfully.`); + // } else if (status === 'error') { + // message.error(`${info.file.name} file upload failed.`); + // } + }, + onDrop(e) { + console.log('Dropped files', e.dataTransfer.files); + }, +}; + +class FileUploadView extends React.Component{ + render() { + return ( +

+ +

+

点击或将文件拖拽到这里上传

+

+ 支持扩展名: .png, .jpg, .jpeg +

+
+ ) + } +} + + +class InvoiceUploadView extends React.Component{ + constructor(props: {}) { + super(props); + this.state = { + loading: false, + open: false, + uploadOpen: false, + uploadStep: 0, + invoiceCommit: new InvoiceCommit(), + } + } + setUploadOpen(value: Boolean) { + this.setState({uploadOpen: value}) + } + setOpen(value: Boolean) { + this.setState({open : value}) + } + setLoading(value: Boolean) { + this.setState({loading : value}) + } + setUploadStep(value: number) { + this.setState({uploadStep : value}) + } + + showUploadView = () => { + this.setOpen(true); + }; + + handleOk = () => { + this.setLoading(true); + //this.setLoading(false); + this.setOpen(false); + let data= new FormData(); + data.append('invoiceFile',tempFile) + axiosInstance({ + url: '/invoice/identify',//123131',//FIXME + method: 'POST', + data: data + }).then(response => { + console.log(response.data) + let result = new InvoiceCommit() + result.invoiceNo = response.data.invoiceNo + result.invoiceDate = response.data.invoiceDate + result.invoiceAmount = response.data.invoiceAmount + result.invoiceCode = response.data.invoiceCode + result.invoiceCheckCode = response.data.invoiceCheckCode + result.invoiceKind = response.data.invoiceKind + result.invoiceFileName = response.data.invoiceFileName + result.invoiceExtraInfo = response.data.invoiceExtraInfo + this.setState({invoiceCommit:result}) + }).catch(function (error) { + console.log(error) + }) + this.setState({uploadStep:1}) + this.setUploadOpen(true) + this.setLoading(false); + // let fakeData=new InvoiceCommit() + // fakeData.invoiceNo="No" + // fakeData.invoiceCode="Code" + // fakeData.invoiceDate=new Date() + // setInvoiceCommit(fakeData) + + + }; + + handleCancel = () => { + this.setOpen(false); + }; + submit=()=>{ + + } + render() { + console.log(this.state.invoiceCommit) + console.log(this.state.uploadStep) + + + return ( + <> + + + 取消 + , + + ]} + > + + + + 取消 + , + + ]} + > +
+ + + + + + + + + + + + + + + + + + + + + + +