129 lines
3.5 KiB
TypeScript
Raw Normal View History

2025-07-04 17:26:52 +08:00
import {
MyButtons,
MyColumns,
MyImportModal,
2025-07-04 17:26:52 +08:00
MyPageContainer,
MyProTableProps,
2025-07-25 16:42:54 +08:00
usePageTabs,
2025-07-04 17:26:52 +08:00
} from '@/common';
import { Apis } from '@/gen/Apis';
import { HouseBillsBillStatusEnum, HouseBillsTypeEnum } from '@/gen/Enums';
2025-07-04 17:26:52 +08:00
import { ProTable } from '@ant-design/pro-components';
import { Space } from 'antd';
import BillCreate from './modals/BillCreate';
import BillUpdate from './modals/BillUpdate';
2025-07-04 17:26:52 +08:00
2025-09-25 20:20:46 +08:00
export default function Index({ title = '账单明细' }) {
2025-07-25 16:42:54 +08:00
// 注册当前页面为标签页
usePageTabs({
2025-09-25 20:20:46 +08:00
tabKey: 'housebills',
2025-07-25 16:42:54 +08:00
tabLabel: title,
});
2025-07-04 17:26:52 +08:00
return (
<MyPageContainer
2025-07-25 16:42:54 +08:00
title={title}
enableTabs={true}
2025-09-25 20:20:46 +08:00
tabKey="housebills"
2025-07-25 16:42:54 +08:00
tabLabel={title}
>
2025-07-04 17:26:52 +08:00
<ProTable
{...MyProTableProps.props}
request={async (params, sort) =>
MyProTableProps.request(params, sort, Apis.Bill.HouseBills.List)
}
toolBarRender={(action) => [
<MyImportModal
key="ImportHouse"
title="批量导入"
type="danger"
size="middle"
templateApi={Apis.Bill.HouseBills.DownloadTemplate}
importApi={Apis.Bill.HouseBills.Import}
reload={action?.reload}
/>,
<BillCreate key="Create" reload={action?.reload} title={title} />,
2025-07-04 17:26:52 +08:00
]}
columns={[
MyColumns.ID(),
MyColumns.EnumTag({
title: '状态',
dataIndex: 'bill_status',
valueEnum: HouseBillsBillStatusEnum,
}),
2025-07-10 18:01:45 +08:00
MyColumns.EnumTag({
title: '类型',
dataIndex: 'type',
valueEnum: HouseBillsTypeEnum,
}),
{
title: '房屋',
dataIndex: ['asset_house', 'full_name'],
search: {
transform: (value) => {
return { full_name: value };
},
},
},
{
title: '账单月份',
render: (_, record) => {
return `${record.year}-${String(record.month).padStart(2, '0')}`;
},
2025-07-10 18:01:45 +08:00
},
2025-07-04 17:26:52 +08:00
{
2025-07-16 10:18:01 +08:00
title: '账单金额',
2025-07-04 17:26:52 +08:00
dataIndex: 'amount',
2025-07-10 18:01:45 +08:00
search: false,
2025-07-04 17:26:52 +08:00
},
{
title: '优惠金额',
dataIndex: 'discount_amount',
search: false,
},
{
title: '滞纳金',
dataIndex: 'late_fee',
search: false,
},
{
title: '应付金额',
dataIndex: 'total_payable_amount',
search: false,
},
{
title: '计费开始日期',
dataIndex: 'start_date',
search: false,
},
{
title: '计费结束日期',
dataIndex: 'end_date',
search: false,
},
2025-07-10 18:01:45 +08:00
// title: '备注',
// dataIndex: 'remark',
// search: false,
// },
MyColumns.CreatedAt(),
2025-07-04 17:26:52 +08:00
MyColumns.Option({
render: (_, item: any, index, action) => (
<Space key={index}>
<BillUpdate item={item} reload={action?.reload} title={title} />
2025-07-04 17:26:52 +08:00
<MyButtons.Delete
onConfirm={() =>
2025-10-09 23:24:10 +08:00
Apis.Bill.HouseBills.Delete({ id: item.id }).then(() =>
2025-07-04 17:26:52 +08:00
action?.reload(),
)
}
/>
</Space>
),
}),
]}
/>
</MyPageContainer>
);
}