173 lines
5.3 KiB
TypeScript
Raw Normal View History

2026-01-08 16:35:06 +08:00
import {
MyButtons,
MyColumns,
MyPageContainer,
MyProTableProps,
} from '@/common';
import { Apis } from '@/gen/Apis';
2026-01-18 20:05:19 +08:00
import { HouseBillsBillStatusEnum, HouseBillsTypeEnum } from '@/gen/Enums';
2026-01-08 16:35:06 +08:00
import { ProTable } from '@ant-design/pro-components';
import { useNavigate } from '@umijs/max';
import { Space } from 'antd';
import BillCreate from './modals/BillCreate';
import BIllInfo from './modals/BIllInfo';
import BillRefund from './modals/BillRefund';
import BillUpdate from './modals/BillUpdate';
export default function Index({ title = '账单明细' }) {
const navigate = useNavigate();
return (
<MyPageContainer
title={title}
enableTabs={true}
tabKey="house_bills"
tabLabel={title}
>
<ProTable
{...MyProTableProps.props}
headerTitle={title}
request={async (params, sort) =>
MyProTableProps.request(params, sort, Apis.Bill.HouseBills.List)
}
toolBarRender={(action) => [
2026-01-18 19:18:51 +08:00
// <MyImportModal
// key="ImportHouse"
// title="账单导入"
// type="default"
// size="middle"
// templateApi={Apis.Bill.HouseBills.DownloadTemplate}
// importApi={Apis.Bill.HouseBills.Import}
// reload={action?.reload}
// />,
2026-01-08 16:35:06 +08:00
<BillCreate key="Create" reload={action?.reload} title={title} />,
]}
columns={[
MyColumns.ID({ search: false }),
{
title: '房屋',
dataIndex: ['asset_house', 'full_name'],
search: {
transform: (value) => {
return { full_name: value };
},
},
render: (_, record) => {
2026-01-18 20:05:19 +08:00
return record.asset_houses_id ? (
2026-01-08 16:35:06 +08:00
<MyButtons.View
2026-01-18 19:18:51 +08:00
title={record?.asset_house?.full_name || '-'}
2026-01-08 16:35:06 +08:00
type="link"
onClick={() => {
2026-01-18 20:05:19 +08:00
record.asset_houses_id
? navigate(
`/bills/summary/show/${record.asset_houses_id}`,
)
: '';
2026-01-08 16:35:06 +08:00
}}
/>
2026-01-18 20:05:19 +08:00
) : (
'车位| ' + record.asset_car_port.full_name
2026-01-08 16:35:06 +08:00
);
},
},
{
title: '账单月份',
render: (_, record) => {
return `${record.year}-${String(record.month).padStart(2, '0')}`;
},
search: false,
},
MyColumns.EnumTag({
title: '类型',
dataIndex: 'type',
valueEnum: HouseBillsTypeEnum,
search: false,
}),
MyColumns.EnumTag({
title: '状态',
dataIndex: 'bill_status',
valueEnum: HouseBillsBillStatusEnum,
search: {
transform: (value) => {
return { bill_status: [value] };
},
},
}),
{
title: '账单金额',
dataIndex: 'amount',
search: false,
},
{
title: '优惠金额',
dataIndex: 'discount_amount',
search: false,
},
{
title: '滞纳金',
dataIndex: 'late_fee',
search: false,
},
{
title: '应收金额',
dataIndex: 'total_payable_amount',
search: false,
},
{
title: '已收金额',
dataIndex: 'total_paid_amount',
search: false,
},
{
title: '计费周期',
dataIndex: 'start_date',
render: (_, record) => {
return `${record.start_date}${record.end_date}`;
},
search: false,
},
MyColumns.CreatedAt(),
MyColumns.Option({
render: (_, item: any, index, action) => (
<Space key={index}>
<BIllInfo
item={{ ...item, type: 'primary' }}
reload={action?.reload}
title="查看"
/>
<BillUpdate item={item} reload={action?.reload} title={title} />
{item.bill_status ===
HouseBillsBillStatusEnum.PartiallyPaid.value ||
(item.bill_status === HouseBillsBillStatusEnum.Paid.value && (
<BillRefund
item={{
...item,
// 跟据发起的页面传递的type来判断退款类型
2026-01-18 20:05:19 +08:00
// type: RefundsTypeEnum.HouseOrder.value,
2026-01-08 16:35:06 +08:00
// 审批模板的类型
2026-01-18 20:05:19 +08:00
// approval_type: ApprovalTemplatesTypeEnum.Refund.value,
2026-01-08 16:35:06 +08:00
total_paid_amount: item.total_paid_amount,
}}
reload={action?.reload}
title={title}
/>
))}
<MyButtons.Delete
onConfirm={() =>
Apis.Bill.HouseBills.Delete({ id: item.id }).then(() =>
action?.reload(),
)
}
/>
</Space>
),
}),
]}
/>
</MyPageContainer>
);
}