From 9b37b62529952b137c1c8f5a0053ffc4d1c52642 Mon Sep 17 00:00:00 2001 From: "yang.yongquan" <3395816735@qq.com> Date: Tue, 27 Dec 2022 22:41:02 +0800 Subject: [PATCH] =?UTF-8?q?Karlis=20=E8=BF=9B=E8=A1=8C=E7=9A=84=E5=8F=98?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/Staff.ts | 7 +- src/pages/Invoice/mine/InvoiceUploadView.tsx | 101 +++++++++++-------- 2 files changed, 61 insertions(+), 47 deletions(-) diff --git a/src/models/Staff.ts b/src/models/Staff.ts index 1da9f86..013073c 100644 --- a/src/models/Staff.ts +++ b/src/models/Staff.ts @@ -1,3 +1,4 @@ +import dayjs from "dayjs"; export interface Token { accessToken: string; @@ -86,7 +87,7 @@ export class InvoiceCommit { invoiceNo: string invoiceCode:string invoiceKind:string - invoiceDate:Date + invoiceDate:dayjs.Dayjs invoiceAmount:number invoiceAmountWithoutTax: number invoiceCheckCode:string @@ -99,7 +100,7 @@ export class InvoiceCommit { this.invoiceNo = "" this.invoiceCode = "" this.invoiceKind = "" - this.invoiceDate = new Date() + this.invoiceDate = dayjs() this.invoiceAmount = 0 this.invoiceAmountWithoutTax = 0 this.invoiceCheckCode = "000000" @@ -113,7 +114,7 @@ export class InvoiceCommit { 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.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() diff --git a/src/pages/Invoice/mine/InvoiceUploadView.tsx b/src/pages/Invoice/mine/InvoiceUploadView.tsx index ca33cf4..06c8df4 100644 --- a/src/pages/Invoice/mine/InvoiceUploadView.tsx +++ b/src/pages/Invoice/mine/InvoiceUploadView.tsx @@ -1,12 +1,15 @@ import React, {useState} from 'react'; -import {Button, Modal, UploadProps, message, Upload, UploadFile, Form, Input,DatePicker} from 'antd'; +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"; +import type { FormInstance } from 'antd/es/form'; +import {useAppDispatch} from "../../../models/hooks"; const { Dragger } = Upload; + let tempFile :File const props: UploadProps = { name: 'file', @@ -51,6 +54,7 @@ class FileUploadView extends React.Component{ class InvoiceUploadView extends React.Component{ + formRef = React.createRef(); constructor(props: {}) { super(props); this.state = { @@ -60,6 +64,7 @@ class InvoiceUploadView extends React.Component{ uploadStep: 0, invoiceCommit: new InvoiceCommit(), } + this.state.invoiceCommit.invoiceNo="init" } setUploadOpen(value: Boolean) { this.setState({uploadOpen: value}) @@ -80,8 +85,8 @@ class InvoiceUploadView extends React.Component{ handleOk = () => { this.setLoading(true); - //this.setLoading(false); - this.setOpen(false); + //this.setLoading(false); + this.setOpen(false); let data= new FormData(); data.append('invoiceFile',tempFile) axiosInstance({ @@ -92,20 +97,23 @@ class InvoiceUploadView extends React.Component{ console.log(response.data) let result = new InvoiceCommit() result.invoiceNo = response.data.invoiceNo - result.invoiceDate = response.data.invoiceDate + result.invoiceDate = dayjs(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 + result.invoiceExtraInfo = response.data.invoiceExtraInfo.toString() this.setState({invoiceCommit:result}) + this.formRef.current!.setFieldsValue(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" @@ -115,6 +123,7 @@ class InvoiceUploadView extends React.Component{ }; + handleCancel = () => { this.setOpen(false); }; @@ -126,29 +135,32 @@ class InvoiceUploadView extends React.Component{ console.log(this.state.uploadStep) - return ( - <> - - - 取消 - , - - ]} - > - - + // @ts-ignore + // @ts-ignore + return ( + <> + + + 取消 + , + + ]} + > + + { , - ]} > -
+ + - + - + - + - + - + - + - + -