蹦蹦炸弹

main
白封羽 2023-01-03 21:26:54 +08:00
parent ca60ee536b
commit fcba9e958b
2 changed files with 50 additions and 20 deletions

View File

@ -16,7 +16,7 @@ import TextArea from "antd/es/input/TextArea";
import {ApprovalProcess, Invoice, ReimbursementDetailModal} from "../../../models/ReimbursementDetailModal"; import {ApprovalProcess, Invoice, ReimbursementDetailModal} from "../../../models/ReimbursementDetailModal";
import dayjs, {Dayjs} from "dayjs"; import dayjs, {Dayjs} from "dayjs";
import {ExclamationCircleOutlined} from "@ant-design/icons"; import {ExclamationCircleOutlined} from "@ant-design/icons";
import displayInvoicesList from "./component/tempComponent"; import DisplayInvoicesList from "./component/ReimbursementDetailFiles";
import { import {
CheckCircleOutlined, CheckCircleOutlined,
ClockCircleOutlined, ClockCircleOutlined,
@ -91,8 +91,9 @@ function displayRawInfo(reimbursement: ReimbursementDetailModal | undefined | nu
{reimbursement.reimbursementNote} {reimbursement.reimbursementNote}
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item span={2} label="附件列表"> <Descriptions.Item span={2} label="附件列表">
{displayInvoicesList(reimbursement.reimbursementDepartureInvoice, <DisplayInvoicesList departureInvoice={reimbursement.reimbursementDepartureInvoice}
reimbursement.reimbursementDestinationInvoice, reimbursement.invoices)} destinationInvoice={reimbursement.reimbursementDestinationInvoice}
otherInvoices={reimbursement.invoices}/>
</Descriptions.Item> </Descriptions.Item>
</Descriptions> </Descriptions>
</>) </>)

View File

@ -6,6 +6,7 @@ import {Tree} from 'antd';
import type {DataNode, DirectoryTreeProps} from 'antd/es/tree'; import type {DataNode, DirectoryTreeProps} from 'antd/es/tree';
import {SwapRightOutlined, SwapLeftOutlined} from '@ant-design/icons' import {SwapRightOutlined, SwapLeftOutlined} from '@ant-design/icons'
import InvoiceDetailModal from "../../../Invoice/InvoiceDetailModal"; import InvoiceDetailModal from "../../../Invoice/InvoiceDetailModal";
import axiosInstance from "../../../../utils/axiosInstance";
const {DirectoryTree} = Tree; const {DirectoryTree} = Tree;
@ -29,35 +30,60 @@ function toInvoiceDetail(invoice: Invoice) {
invoiceCode: invoice.invoiceCode ? invoice.invoiceCode : "Undefined", invoiceCode: invoice.invoiceCode ? invoice.invoiceCode : "Undefined",
invoiceDate: invoice.invoiceDate, invoiceDate: invoice.invoiceDate,
invoiceDeparture: invoice.invoiceDeparture ? invoice.invoiceDeparture : "", invoiceDeparture: invoice.invoiceDeparture ? invoice.invoiceDeparture : "",
invoiceDestination: invoice.invoiceDestination ? invoice.invoiceDestination: "", invoiceDestination: invoice.invoiceDestination ? invoice.invoiceDestination : "",
invoiceFileUri: invoice.invoiceFileUri ? invoice.invoiceFileUri : "", invoiceFileUri: invoice.invoiceFileUri ? invoice.invoiceFileUri : "",
invoiceThumbnailUri: invoice.invoiceThumbnailUri ? invoice.invoiceThumbnailUri: "", invoiceThumbnailUri: invoice.invoiceThumbnailUri ? invoice.invoiceThumbnailUri : "",
invoiceId: invoice.invoiceId, invoiceId: invoice.invoiceId,
invoiceKind: invoice.invoiceKind ? invoice.invoiceKind : 0 invoiceKind: invoice.invoiceKind ? invoice.invoiceKind : 0
}; };
return resInvoiceDetail; return resInvoiceDetail;
} }
function displayInvoicesList(departureInvoice: Invoice, destinationInvoice: Invoice | null, otherInvoices: Invoice[]) {
function DisplayInvoicesList(props:{departureInvoice: Invoice, destinationInvoice: Invoice | null, otherInvoices: Invoice[]}) {
let departureInvoice = props.departureInvoice;
let destinationInvoice = props.destinationInvoice;
let otherInvoices = props.otherInvoices;
const [invoiceDetail, setInvoiceDetail] = useState(departureInvoice)
const [detailModalOpen, setDetailModalOpen] = useState(false)
function getTreeData() { function getTreeData() {
let treeData: DataNode[] = []; let treeData: DataNode[] = [];
let mainData: DataNode = { let mainData = {
title: '往返票据', title: '往返票据',
key: '0-0', key: '0-0',
children: [ children: [
{title: '出发票据', key: '0-0-0', isLeaf: true, icon: <SwapRightOutlined/>}, {
title: '出发票据',
key: departureInvoice.invoiceId.toString(),
isLeaf: true,
icon: <SwapRightOutlined/>
},
] ]
}; };
if (destinationInvoice != null) { if (destinationInvoice != null) {
mainData.children?.push({title: '返程票据', key: '0-0-1', isLeaf: true, icon: <SwapLeftOutlined/>}); mainData.children.push({
title: '返程票据',
key: destinationInvoice.invoiceId.toString(),
isLeaf: true,
icon: <SwapLeftOutlined/>
});
} }
let othersData: DataNode = { let othersData: DataNode = {
title: '其他票据', title: '其他票据',
key: '0-1', key: '0-1',
children: [] children: []
}; };
for(let i=0; i<otherInvoices.length; i++) { let cnt = 0
othersData.children?.push({title: `附加票据-${i}`, key: `0-1-${i}`, isLeaf: true}); for (let i = 0; i < otherInvoices.length; i++) {
if (otherInvoices[i].invoiceId != departureInvoice.invoiceId && otherInvoices[i].invoiceId != destinationInvoice?.invoiceId) {
othersData.children?.push({
title: `附加票据-${cnt + 1}`,
key: otherInvoices[i].invoiceId.toString(),
isLeaf: true
});
cnt++;
}
} }
treeData.push(mainData) treeData.push(mainData)
treeData.push(othersData) treeData.push(othersData)
@ -65,24 +91,27 @@ function displayInvoicesList(departureInvoice: Invoice, destinationInvoice: Invo
} }
const onSelect: DirectoryTreeProps['onSelect'] = (keys, info) => { const onSelect: DirectoryTreeProps['onSelect'] = (keys, info) => {
if(keys[0] == '0-0-0') { if (keys[0] == '0-0' || keys[0] == '0-1') {
return;
} }
if(keys[0] == '0-0-1') { let invoiceId = Number(keys[0]);
axiosInstance.get("common/invoice/" + invoiceId).then((res) => {
} setInvoiceDetail(res.data);
let keyList = keys[0].toString().split('-') setDetailModalOpen(true);
let index = parseInt(keyList[keyList.length-1]) })
}; };
return (<> return (<>
<DirectoryTree <DirectoryTree
defaultExpandAll defaultExpandAll
selectedKeys={[]}
onSelect={onSelect} onSelect={onSelect}
treeData={getTreeData()} treeData={getTreeData()}
/> />
<InvoiceDetailModal invoiceDetail={invoiceDetail} open={detailModalOpen} onClose={() => {
setDetailModalOpen(false)
}}/>
</>) </>)
} }
export default displayInvoicesList export default DisplayInvoicesList