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] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=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 ( + <> + + + 取消 + , + + ]} + > + + + + 取消 + , + + ]} + > +
+ + + + + + + + + + + + + + + + + + + + + + +