diff --git a/src/index.tsx b/src/index.tsx index 9951af1..adbaaf1 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -9,6 +9,7 @@ import {RouterProvider} from "react-router-dom"; import CustomRouter from "./router/router"; import {PersistGate} from 'redux-persist/integration/react' import {ConfigProvider} from "antd"; +import zhCN from 'antd/locale/zh_CN'; const root = ReactDOM.createRoot( document.getElementById('root') as HTMLElement @@ -17,7 +18,7 @@ root.render( - = T | undefined | null; -export class InvoiceSearchOption{ + +export class InvoiceSearchOption { invoiceNo: Nullable invoiceCode: Nullable invoiceUploadTimeStart: Nullable - invoiceUploadTimeEnd:Nullable - invoiceState:Nullable - invoiceKind:Nullable - invoiceDateStart:Nullable - invoiceDateEnd:Nullable - invoiceNote:Nullable - invoiceUploader:Nullable - pageNum:number - pageSize:number - constructor(){ - this.pageNum=0 - this.pageSize=20 + invoiceUploadTimeEnd: Nullable + invoiceState: Nullable + invoiceKind: Nullable + invoiceDateStart: Nullable + invoiceDateEnd: Nullable + invoiceNote: Nullable + invoiceUploader: Nullable + pageNum: number + pageSize: number + + constructor() { + this.pageNum = 0 + this.pageSize = 20 this.clear() } - clear(){ - this.invoiceNo=null - this.invoiceCode=null - this.invoiceUploadTimeStart=null - this.invoiceUploadTimeEnd=null - this.invoiceState=null - this.invoiceKind=null - this.invoiceDateStart=null - this.invoiceDateEnd=null - this.invoiceNote=null - this.invoiceUploader=null - this.pageNum=0 - this.pageSize=20 + + clear() { + this.invoiceNo = null + this.invoiceCode = null + this.invoiceUploadTimeStart = null + this.invoiceUploadTimeEnd = null + this.invoiceState = null + this.invoiceKind = null + this.invoiceDateStart = null + this.invoiceDateEnd = null + this.invoiceNote = null + this.invoiceUploader = null + this.pageNum = 0 + this.pageSize = 20 } // toString(){ @@ -114,17 +74,18 @@ export class InvoiceSearchOption{ } export class InvoiceCommit { - invoiceFileName: string + invoiceFileName: string invoiceNo: string - invoiceCode:string - invoiceKind:string - invoiceDate:dayjs.Dayjs - invoiceAmount:number + invoiceCode: string + invoiceKind: string + invoiceDate: dayjs.Dayjs + invoiceAmount: number invoiceAmountWithoutTax: number - invoiceCheckCode:string + invoiceCheckCode: string invoiceRegionCode: Nullable - invoiceSellerTaxCode:Nullable - invoiceExtraInfo:Nullable|[]|Map + invoiceSellerTaxCode: Nullable + invoiceExtraInfo: Nullable | [] | Map + constructor() { this.invoiceFileName = "" this.invoiceNo = "" @@ -138,10 +99,11 @@ export class InvoiceCommit { this.invoiceSellerTaxCode = null this.invoiceExtraInfo = null } + setValue(props: FormData) { - console.log("1111"+props.toString()) + console.log("1111" + props.toString()) this.invoiceFileName = props.get("invoiceFileName")!.toString() - this.invoiceNo = props.get("invoiceNo")!.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()) @@ -153,21 +115,22 @@ export class InvoiceCommit { //this.invoiceExtraInfo = props.get("invoiceExtraInfo")!. } } + export interface Reimbursement { /** * 差旅补助金额 */ - reimbursementAdditionalAmount: number; - reimbursementDepartureInvoiceId: number; - reimbursementDepartureName: string; + reimbursementAdditionalAmount: number; + reimbursementDepartureInvoiceId: number; + reimbursementDepartureName: string; reimbursementDestinationInvoiceId?: number; - reimbursementDestinationName: string; - reimbursementId: number; + reimbursementDestinationName: string; + reimbursementId: number; /** * 发票金额 */ reimbursementInvoiceAmount: number; - reimbursementNote?: string; + reimbursementNote?: string; /** * 0: success * 1: 待主管审批 @@ -176,10 +139,10 @@ export interface Reimbursement { * 4: 待总经理审批 * 5: 未通过 */ - reimbursementStatus: number; + reimbursementStatus: number; reimbursementSubmitDepartmentId: number; - reimbursementSubmitStaffId: string; - reimbursementSubmitTime: string; + reimbursementSubmitStaffId: string; + reimbursementSubmitTime: string; /** * 单位为天 */ diff --git a/src/models/store.ts b/src/models/store.ts index 98b65f6..ce15132 100644 --- a/src/models/store.ts +++ b/src/models/store.ts @@ -38,6 +38,7 @@ const staffSlice = createSlice({ state.staffName = action.payload.staffName state.managingDepartment = action.payload.managingDepartment state.staffDepartments = action.payload.staffDepartments + }, }, }); diff --git a/src/pages/HomeView.tsx b/src/pages/HomeView.tsx index a6acce7..e1735ce 100644 --- a/src/pages/HomeView.tsx +++ b/src/pages/HomeView.tsx @@ -71,7 +71,7 @@ function HeaderBar(props: any) { const departmentToString = (staff: Staff) => { let result = staff.managingDepartment === null ? '' : staff.managingDepartment.departmentName + '主管' for (const department of staff.staffDepartments) { - result += ' ' + department.departmentName + result += '\xa0\xa0' + department.departmentName } return result } @@ -85,7 +85,7 @@ function HeaderBar(props: any) { flexDirection: 'row-reverse', alignItems: 'center' }}> - + diff --git a/src/pages/Invoice/mine/InvoiceListView.tsx b/src/pages/Invoice/mine/InvoiceListView.tsx index 9519895..248aa0c 100644 --- a/src/pages/Invoice/mine/InvoiceListView.tsx +++ b/src/pages/Invoice/mine/InvoiceListView.tsx @@ -18,7 +18,7 @@ import { import type {MenuProps, PaginationProps} from 'antd'; import {DownOutlined, UploadOutlined} from '@ant-design/icons'; import React, {ReactElement, JSXElementConstructor, ReactFragment, ReactPortal, useState} from "react"; -import {Invoice, InvoiceCommit, InvoiceSearchOption} from "../../../models/Staff" +import {InvoiceCommit, InvoiceSearchOption} from "../../../models/Staff" import {Space, Typography} from 'antd'; import {SizeType} from "antd/es/config-provider/SizeContext"; import axios from "axios"; @@ -28,6 +28,7 @@ import change = Simulate.change; import {useNavigate} from "react-router-dom"; import {useAppDispatch} from "../../../models/hooks"; import InvoiceUploadView from "./InvoiceUploadView"; +import {Invoice, invoiceTypeNameMap} from "../../../models/Invoice"; const {Meta} = Card; const {Search} = Input; @@ -238,7 +239,7 @@ class InvoiceItem extends React.Component { >
  • ¥{(this.state.invoiceAmount / 100.0).toFixed(2)}
  • -
  • {this.state.invoiceKind}
  • +
  • {invoiceTypeNameMap.get(this.state.invoiceKind)}
  • {this.state.invoiceNo}
  • {this.state.invoiceDate}
  • @@ -262,6 +263,9 @@ class InvoiceListView extends React.Component { totalNum: 2, PaginationKey: -2 } + } + + componentDidMount(){ this.searchInvoiceContent() } diff --git a/src/pages/Invoice/mine/InvoiceUploadView.tsx b/src/pages/Invoice/mine/InvoiceUploadView.tsx index b442b34..d5ac694 100644 --- a/src/pages/Invoice/mine/InvoiceUploadView.tsx +++ b/src/pages/Invoice/mine/InvoiceUploadView.tsx @@ -1,13 +1,19 @@ import React, {useEffect, useRef, 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, Select, InputNumber} from 'antd'; import {InboxOutlined, UploadOutlined} from '@ant-design/icons'; import axiosInstance from "../../../utils/axiosInstance"; -import {InvoiceCommit, InvoiceIdentifyResponse} from "../../../models/Staff"; -import dayjs from 'dayjs'; +import {InvoiceCommit} from "../../../models/Staff"; +import dayjs, {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"; +import { + InvoiceIdentifyResponse, + invoiceItemsMap, + invoiceTypeItemsMap, + invoiceTypeNameMap, +} from "../../../models/Invoice"; const {Dragger} = Upload; @@ -22,17 +28,6 @@ const props: UploadProps = { 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); }, @@ -86,7 +81,7 @@ function UpLoadModal(props: any) { return ( { setOpen(props.open) + console.log(props.invoiceIdentifyResponse) + let i = {...props.invoiceIdentifyResponse} + setInvoice(i) + form.setFieldsValue(i) }, [props]); const handleCancel = () => { setOpen(false); }; const submit = () => { - let result = form!.getFieldsValue() - result.invoiceDate = result.invoiceDate.format("YYYY-MM-DD") - result.invoiceExtraInfo = new Map(result.invoiceExtraInfo.split("\n").map((entry: string) => entry.split(": "))) - console.log(result.invoiceExtraInfo.split("\n").map((entry: string) => entry.split(": "))) - // let extraInfo=[] - // let line = result.invoiceExtraInfo.split('\n') - // for(let i=0;i { - //TODO console.log(response.data) + setLoading(false) + setOpen(false) }).catch(function (error) { console.log(error) + setLoading(false) }) } + + const inputComponent = (item: string) => { + if (item === 'invoiceDate') + return + else if(item === 'invoiceAmount') + return `¥ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')} + /> + else + return + } + let formItems = invoiceTypeItemsMap.get(props.invoiceIdentifyResponse?.invoiceKind)?.map((item, index) => { + return ( + + {inputComponent(item)} + + ) + }) + + const getInvoiceKindOptions = () => { + let options: { value: number; label: string; }[] = [] + invoiceTypeNameMap.forEach(function (value, key, map) { + options.push({ + value: key, + label: value, + }) + }) + return options + } + return ( 取消 , - ]} > -
    - - - - - - - + - + - - - - - - - - - - -