2024-04-07 17:37:09 +08:00
|
|
|
import {Button, Flex, Modal, Popconfirm, Space, Table, TableProps} from "antd";
|
2024-04-03 18:33:37 +08:00
|
|
|
import {DeleteOutlined, EditOutlined, PlusOutlined} from "@ant-design/icons";
|
|
|
|
import useMessage from "antd/es/message/useMessage";
|
2024-04-07 17:37:09 +08:00
|
|
|
import {useEffect, useRef, useState} from "react";
|
|
|
|
import {del, get} from "../../../util/AjaxUtils.ts";
|
2024-04-03 18:33:37 +08:00
|
|
|
import {IListPage} from "../../../interfaces/listpage/IListPage.ts";
|
|
|
|
import InvoiceInfoSave from "./InvoiceInfoSave.tsx";
|
2024-04-07 17:37:09 +08:00
|
|
|
import InvoiceInfoEdit from "./InvoiceInfoEdit.tsx";
|
2024-04-03 18:33:37 +08:00
|
|
|
|
|
|
|
type DataType = {
|
|
|
|
invoiceTitle: string;
|
|
|
|
invoicePhone: string;
|
|
|
|
invoiceNo: string;
|
|
|
|
invoiceInfoId: string;
|
|
|
|
invoiceBank: string;
|
|
|
|
invoiceAddress: string;
|
|
|
|
invoiceAccount: string;
|
|
|
|
gmtCreate: number;
|
|
|
|
creator: string;
|
|
|
|
}
|
|
|
|
|
2024-04-07 17:37:09 +08:00
|
|
|
interface ListProps {
|
|
|
|
handleOk: (selectedInvoice: DataType) => void;
|
|
|
|
handleCancel: () => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function InvoiceInfoList(props: ListProps) {
|
2024-04-03 18:33:37 +08:00
|
|
|
const [messageApi, messageContext] = useMessage();
|
2024-04-07 17:37:09 +08:00
|
|
|
const [isInvoiceInfoSaveOpen, setIsInvoiceInfoSaveOpen] = useState(false);
|
|
|
|
const [isInvoiceInfoEditOpen, setIsInvoiceInfoEditOpen] = useState(false);
|
2024-04-03 18:33:37 +08:00
|
|
|
const [page, setPage] = useState(1);
|
|
|
|
const [total, setTotal] = useState(0);
|
|
|
|
const [dataArray, setDataArray] = useState<DataType[]>([]);
|
2024-04-07 17:37:09 +08:00
|
|
|
const editInvoiceInfoId = useRef('');
|
|
|
|
const selectedInvoice = useRef<DataType | null>(null);
|
2024-04-03 18:33:37 +08:00
|
|
|
|
|
|
|
const columns: TableProps<DataType>['columns'] = [
|
|
|
|
{
|
|
|
|
title: '公司名称',
|
|
|
|
dataIndex: 'invoiceTitle',
|
|
|
|
align: 'center',
|
|
|
|
width: 180,
|
|
|
|
fixed: 'left'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '纳税人识别号',
|
|
|
|
dataIndex: 'invoiceNo',
|
|
|
|
align: 'center',
|
|
|
|
width: 180
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '公司地址',
|
|
|
|
dataIndex: 'invoiceAddress',
|
|
|
|
align: 'center',
|
|
|
|
width: 180
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '联系电话',
|
|
|
|
dataIndex: 'invoicePhone',
|
|
|
|
align: 'center',
|
|
|
|
width: 180
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '开户行',
|
|
|
|
dataIndex: 'invoiceBank',
|
|
|
|
align: 'center',
|
|
|
|
width: 180
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '开户行账号',
|
|
|
|
dataIndex: 'invoiceAccount',
|
|
|
|
align: 'center',
|
|
|
|
width: 180
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '操作',
|
|
|
|
dataIndex: 'option',
|
|
|
|
align: 'center',
|
|
|
|
width: 100,
|
|
|
|
fixed: 'right',
|
2024-04-07 17:37:09 +08:00
|
|
|
render: (_value, record) => {
|
2024-04-03 18:33:37 +08:00
|
|
|
return (
|
|
|
|
<Space size={5}>
|
2024-04-07 17:37:09 +08:00
|
|
|
<Button type="primary" size="small" onClick={() => {
|
|
|
|
editInvoiceInfoId.current = record.invoiceInfoId;
|
|
|
|
setIsInvoiceInfoEditOpen(true);
|
|
|
|
}}><EditOutlined/></Button>
|
|
|
|
<Popconfirm
|
|
|
|
placement="right"
|
|
|
|
title={false}
|
|
|
|
description="确定删除吗?"
|
|
|
|
okText="确定"
|
|
|
|
cancelText="取消"
|
|
|
|
onConfirm={() => {
|
|
|
|
del<any>({
|
|
|
|
messageApi,
|
|
|
|
url: `/api/invoice-info/remove/${record.invoiceInfoId}`,
|
|
|
|
onSuccess() {
|
|
|
|
messageApi.success('删除成功');
|
|
|
|
getData();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Button type="primary" size="small" danger><DeleteOutlined/></Button>
|
|
|
|
</Popconfirm>
|
2024-04-03 18:33:37 +08:00
|
|
|
</Space>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2024-04-07 17:37:09 +08:00
|
|
|
const getData = () => {
|
2024-04-03 18:33:37 +08:00
|
|
|
get<IListPage<DataType>>({
|
|
|
|
messageApi,
|
|
|
|
url: '/api/invoice-info/listpage/self',
|
|
|
|
config: {
|
|
|
|
params: {
|
|
|
|
page: page,
|
|
|
|
rows: 20
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onSuccess({data}) {
|
|
|
|
setPage(data.page);
|
|
|
|
setTotal(data.total);
|
|
|
|
setDataArray(data.rows);
|
|
|
|
}
|
|
|
|
})
|
2024-04-07 17:37:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
getData();
|
2024-04-03 18:33:37 +08:00
|
|
|
}, [page]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className="invoice-list-container">
|
|
|
|
<div className="mod-list">
|
|
|
|
<div className="table-btn-group" style={{marginBottom: '15px'}}>
|
|
|
|
<Button value="small" onClick={() => {
|
2024-04-07 17:37:09 +08:00
|
|
|
setIsInvoiceInfoSaveOpen(true);
|
2024-04-03 18:33:37 +08:00
|
|
|
}}><PlusOutlined/> 新增</Button>
|
|
|
|
</div>
|
|
|
|
<Table rowSelection={
|
|
|
|
{
|
|
|
|
type: 'radio',
|
2024-04-07 17:37:09 +08:00
|
|
|
onChange: (_selectedRowKeys, selectedRows) => {
|
|
|
|
selectedInvoice.current = selectedRows[0];
|
2024-04-03 18:33:37 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
} columns={columns} dataSource={dataArray} pagination={
|
|
|
|
{
|
|
|
|
pageSize: 20,
|
|
|
|
total: total,
|
|
|
|
onChange: (currentPage) => {
|
|
|
|
setPage(currentPage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} scroll={{y: 500}} bordered key="dataTable" rowKey="invoiceInfoId"/>
|
|
|
|
</div>
|
2024-04-07 17:37:09 +08:00
|
|
|
<Flex justify="center">
|
|
|
|
<Space size={5}>
|
|
|
|
<Button type="primary"
|
|
|
|
style={{backgroundColor: 'var(--color-primary)'}}
|
|
|
|
onClick={() => {
|
|
|
|
if (!selectedInvoice.current) {
|
|
|
|
messageApi.error('请选择开票信息');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
props.handleOk(selectedInvoice.current);
|
|
|
|
}}
|
|
|
|
>确定</Button>
|
|
|
|
<Button type="default" onClick={() => {
|
|
|
|
props.handleCancel();
|
|
|
|
}}>关闭</Button>
|
|
|
|
</Space>
|
|
|
|
</Flex>
|
2024-04-03 18:33:37 +08:00
|
|
|
</div>
|
2024-04-07 17:37:09 +08:00
|
|
|
<Modal open={isInvoiceInfoSaveOpen}
|
2024-04-03 18:33:37 +08:00
|
|
|
title="新增"
|
|
|
|
footer={false}
|
2024-04-07 17:37:09 +08:00
|
|
|
onCancel={() => {
|
|
|
|
setIsInvoiceInfoSaveOpen(false)
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<InvoiceInfoSave
|
|
|
|
handleOk={() => {
|
|
|
|
getData();
|
|
|
|
setIsInvoiceInfoSaveOpen(false);
|
|
|
|
}}
|
|
|
|
handleCancel={() => {
|
|
|
|
setIsInvoiceInfoSaveOpen(false);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Modal>
|
|
|
|
<Modal open={isInvoiceInfoEditOpen}
|
|
|
|
title="编辑"
|
|
|
|
footer={false}
|
|
|
|
onCancel={() => {
|
|
|
|
setIsInvoiceInfoEditOpen(false)
|
|
|
|
}}
|
2024-04-03 18:33:37 +08:00
|
|
|
>
|
2024-04-07 17:37:09 +08:00
|
|
|
<InvoiceInfoEdit
|
|
|
|
invoiceInfoId={editInvoiceInfoId.current}
|
|
|
|
handleOk={() => {
|
|
|
|
getData();
|
|
|
|
setIsInvoiceInfoEditOpen(false);
|
|
|
|
}}
|
|
|
|
handleCancel={() => {
|
|
|
|
setIsInvoiceInfoEditOpen(false);
|
|
|
|
}}
|
|
|
|
/>
|
2024-04-03 18:33:37 +08:00
|
|
|
</Modal>
|
|
|
|
{messageContext}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|