合并代码
This commit is contained in:
@ -18,29 +18,33 @@ interface InvoiceInfo {
|
||||
certificateUrl: string;
|
||||
}
|
||||
|
||||
interface InvoiceTabProps {
|
||||
viewType?: boolean;
|
||||
}
|
||||
|
||||
const InvoiceTab: React.FC = () => {
|
||||
const InvoiceTab: React.FC<InvoiceTabProps> = (props) => {
|
||||
const { viewType = false } = props;
|
||||
//语言切换
|
||||
const intl = useIntl();
|
||||
//列表渲染数据
|
||||
const [data, setData] = useState<InvoiceInfo[]>([]);
|
||||
//列表加载
|
||||
const [loading, setLoading] = useState(false);
|
||||
//列表分页
|
||||
//列表分页
|
||||
const [pagination, setPagination] = useState<TablePaginationConfig>({ current: 1, pageSize: 10, total: 0 });
|
||||
|
||||
|
||||
//列表方法
|
||||
const getList = async (pageNo = 1, pageSize = 10) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const { code, data } = await invoiceGetPage({pageNo, pageSize});
|
||||
if (code === 200) {
|
||||
setData(data.records);
|
||||
setPagination({ current: pageNo, pageSize, total:data.total });
|
||||
}
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
setLoading(true);
|
||||
try {
|
||||
const { code, data } = await invoiceGetPage({ pageNo, pageSize });
|
||||
if (code === 200) {
|
||||
setData(data.records);
|
||||
setPagination({ current: pageNo, pageSize, total: data.total });
|
||||
}
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
//增改查
|
||||
@ -71,7 +75,7 @@ const InvoiceTab: React.FC = () => {
|
||||
|
||||
//初始化
|
||||
useEffect(() => {
|
||||
getList();
|
||||
getList();
|
||||
}, []);
|
||||
|
||||
const columns: ColumnsType<InvoiceInfo> = [
|
||||
@ -86,33 +90,37 @@ const InvoiceTab: React.FC = () => {
|
||||
{ title: 'page.workbench.invoice.updateTime', dataIndex: 'updateTime', ellipsis: true },
|
||||
{
|
||||
title: 'page.workbench.invoice.qualificationCertificate',
|
||||
width:'180px',
|
||||
width: '180px',
|
||||
dataIndex: 'qualificationCertificate',
|
||||
render: (val: string) => (val ? <a href={val} target="_blank" rel="noreferrer">查看附件</a> : '-'),
|
||||
},
|
||||
{
|
||||
title: 'page.workbench.attachments.action',
|
||||
dataIndex: 'option',
|
||||
width: 120,
|
||||
render: (_: any, record: InvoiceInfo) => (
|
||||
<>
|
||||
<a style={{ marginRight: 8 }} onClick={() => handleView(record)}>查看</a>
|
||||
<a onClick={() => handleEdit(record)}>修改</a>
|
||||
</>
|
||||
),
|
||||
},
|
||||
...(viewType ? [] : [
|
||||
{
|
||||
title: 'page.workbench.attachments.action',
|
||||
dataIndex: 'option',
|
||||
width: 120,
|
||||
render: (_: any, record: InvoiceInfo) => (
|
||||
<>
|
||||
<a style={{ marginRight: 8 }} onClick={() => handleView(record)}>查看</a>
|
||||
<a onClick={() => handleEdit(record)}>修改</a>
|
||||
</>
|
||||
),
|
||||
},
|
||||
]),
|
||||
];
|
||||
return (
|
||||
<div style={{ padding: '0 30px 0 0' }}>
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<Button type="primary" onClick={handleAdd}>新增</Button>
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
{!viewType && (
|
||||
<Button type="primary" onClick={handleAdd}>新增</Button>
|
||||
)}
|
||||
</div>
|
||||
<Table
|
||||
className="custom-table"
|
||||
rowKey="id"
|
||||
columns={columns.map(column => ({
|
||||
...column,
|
||||
title: intl.formatMessage({ id: column.title as string })
|
||||
title: intl.formatMessage({ id: column.title as string })
|
||||
}))}
|
||||
dataSource={data}
|
||||
pagination={pagination}
|
||||
|
Reference in New Issue
Block a user