蹦蹦炸弹

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

View File

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