2025-07-10 18:01:45 +08:00
|
|
|
import { MyColumns, MyProTableProps } from '@/common';
|
|
|
|
|
import { Apis } from '@/gen/Apis';
|
|
|
|
|
import {
|
|
|
|
|
HouseOccupantsHouseRelationEnum,
|
|
|
|
|
HouseOccupantsRelationWithOwnerEnum,
|
|
|
|
|
HouseOccupantsStatusEnum,
|
|
|
|
|
} from '@/gen/Enums';
|
|
|
|
|
import { ProTable } from '@ant-design/pro-components';
|
2025-08-18 11:36:25 +08:00
|
|
|
import { Popconfirm, Space, Tag } from 'antd';
|
2025-07-10 18:01:45 +08:00
|
|
|
import { useEffect, useRef } from 'react';
|
2025-08-27 11:24:29 +08:00
|
|
|
import Delivery from '../modals/Delivery';
|
2025-08-08 18:35:02 +08:00
|
|
|
import AddOccupant from './modals/AddOccupant';
|
2025-09-09 19:02:49 +08:00
|
|
|
import ChangePhone from './modals/ChangePhone';
|
2025-08-08 18:35:02 +08:00
|
|
|
import MoveIn from './modals/MoveIn';
|
|
|
|
|
import MoveOut from './modals/MoveOut';
|
|
|
|
|
import OccupantShow from './modals/OccupantShow';
|
|
|
|
|
import OccupantsUpdate from './modals/OccupantsUpdate';
|
2025-09-09 19:02:49 +08:00
|
|
|
import OwnerUpdate from './modals/OwnerUpdate';
|
2025-08-08 18:35:02 +08:00
|
|
|
import RemoveOwner from './modals/RemoveOwner';
|
|
|
|
|
import Transfer from './modals/Transfer';
|
2025-07-10 18:01:45 +08:00
|
|
|
|
|
|
|
|
export default function Index({ ...rest }) {
|
|
|
|
|
const actionLooks = useRef<any>();
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
actionLooks?.current.reloadAndRest();
|
|
|
|
|
}, [rest.loadmore]);
|
|
|
|
|
|
2025-08-18 11:36:25 +08:00
|
|
|
const handleReload = () => {
|
|
|
|
|
actionLooks?.current.reload();
|
|
|
|
|
rest.reload?.(); // 调用父组件的reload函数更新Pending计数
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-10 18:01:45 +08:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<ProTable<Record<any, any>>
|
|
|
|
|
{...MyProTableProps.props}
|
|
|
|
|
actionRef={actionLooks}
|
|
|
|
|
request={async (params, sort) =>
|
|
|
|
|
MyProTableProps.request(
|
|
|
|
|
{
|
|
|
|
|
...params,
|
2025-07-16 10:18:01 +08:00
|
|
|
asset_houses_id: rest.item?.asset_houses_id,
|
2025-07-10 18:01:45 +08:00
|
|
|
status: 'Normal',
|
|
|
|
|
},
|
|
|
|
|
sort,
|
|
|
|
|
Apis.Archive.HouseOccupants.List,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
toolBarRender={(action) => [
|
2025-08-27 11:24:29 +08:00
|
|
|
<Delivery
|
|
|
|
|
key="Delivery"
|
|
|
|
|
item={{ ...rest.item, size: 'middle' }}
|
2025-07-16 10:18:01 +08:00
|
|
|
reload={action?.reload}
|
2025-08-27 11:24:29 +08:00
|
|
|
title="添加产权人"
|
2025-07-10 18:01:45 +08:00
|
|
|
/>,
|
2025-08-27 11:24:29 +08:00
|
|
|
!rest.item?.house_occupants?.length ? (
|
|
|
|
|
''
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
<AddOccupant
|
|
|
|
|
key="AddOccupant"
|
|
|
|
|
item={rest.item}
|
|
|
|
|
reload={action?.reload}
|
|
|
|
|
title="添加客户"
|
|
|
|
|
/>
|
|
|
|
|
<Transfer
|
|
|
|
|
key="Transfer"
|
|
|
|
|
item={rest.item}
|
|
|
|
|
reload={action?.reload}
|
|
|
|
|
title=" 过户登记"
|
|
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
),
|
2025-07-10 18:01:45 +08:00
|
|
|
]}
|
|
|
|
|
search={false}
|
|
|
|
|
columns={[
|
|
|
|
|
MyColumns.EnumTag({
|
|
|
|
|
title: '房客关系',
|
|
|
|
|
dataIndex: 'house_relation',
|
|
|
|
|
valueEnum: HouseOccupantsHouseRelationEnum,
|
|
|
|
|
search: false,
|
|
|
|
|
}),
|
|
|
|
|
MyColumns.EnumTag({
|
2025-08-29 13:56:53 +08:00
|
|
|
title:
|
|
|
|
|
rest?.item?.status === 'Rented' ? '与主租人关系' : '与产权人关系',
|
|
|
|
|
// title: '关系说明',
|
2025-07-10 18:01:45 +08:00
|
|
|
dataIndex: 'relation_with_owner',
|
|
|
|
|
valueEnum: HouseOccupantsRelationWithOwnerEnum,
|
|
|
|
|
search: false,
|
|
|
|
|
}),
|
|
|
|
|
{
|
|
|
|
|
title: '姓名',
|
|
|
|
|
dataIndex: 'name',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '电话',
|
|
|
|
|
dataIndex: 'phone',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '入住日期',
|
|
|
|
|
dataIndex: 'is_live_in',
|
|
|
|
|
render(_, record) {
|
2025-08-08 18:35:02 +08:00
|
|
|
return `${record?.move_in_date || '未入住'}`;
|
2025-07-10 18:01:45 +08:00
|
|
|
},
|
|
|
|
|
},
|
2025-08-18 11:36:25 +08:00
|
|
|
{
|
|
|
|
|
title: '常用联系人',
|
|
|
|
|
render: (_, item, index, action) =>
|
|
|
|
|
item?.is_contact ? (
|
|
|
|
|
<Popconfirm
|
|
|
|
|
title="设置常用联系人"
|
|
|
|
|
description="您确认设置常用联系人吗?"
|
|
|
|
|
onConfirm={() => {
|
|
|
|
|
Apis.Archive.HouseOccupants.ChangeIsContact({
|
|
|
|
|
id: item.id,
|
|
|
|
|
is_contact: false,
|
|
|
|
|
}).then(() => action?.reload());
|
|
|
|
|
}}
|
|
|
|
|
okText="是"
|
|
|
|
|
cancelText="否"
|
|
|
|
|
>
|
|
|
|
|
<Tag color="green" style={{ cursor: 'pointer' }}>
|
|
|
|
|
是
|
|
|
|
|
</Tag>
|
|
|
|
|
</Popconfirm>
|
|
|
|
|
) : (
|
|
|
|
|
<Popconfirm
|
|
|
|
|
title="取消"
|
|
|
|
|
description="您确认取消常用联系人吗?"
|
|
|
|
|
onConfirm={() => {
|
|
|
|
|
Apis.Archive.HouseOccupants.ChangeIsContact({
|
|
|
|
|
id: item.id,
|
|
|
|
|
is_contact: true,
|
|
|
|
|
}).then(() => action?.reload());
|
|
|
|
|
}}
|
|
|
|
|
okText="是"
|
|
|
|
|
cancelText="否"
|
|
|
|
|
>
|
|
|
|
|
<Tag color="gray" style={{ cursor: 'pointer' }}>
|
|
|
|
|
否
|
|
|
|
|
</Tag>
|
|
|
|
|
</Popconfirm>
|
|
|
|
|
),
|
|
|
|
|
search: false,
|
|
|
|
|
},
|
2025-07-10 18:01:45 +08:00
|
|
|
MyColumns.EnumTag({
|
|
|
|
|
title: '状态',
|
|
|
|
|
dataIndex: 'status',
|
|
|
|
|
valueEnum: HouseOccupantsStatusEnum,
|
|
|
|
|
search: false,
|
|
|
|
|
}),
|
|
|
|
|
// MyColumns.UpdatedAt(),
|
|
|
|
|
MyColumns.Option({
|
|
|
|
|
render: (_, item: any, index, action) => (
|
|
|
|
|
<Space key={index}>
|
2025-07-25 16:42:54 +08:00
|
|
|
<OccupantShow item={item} reload={action?.reload} />
|
2025-09-09 19:02:49 +08:00
|
|
|
{item?.house_relation !==
|
|
|
|
|
HouseOccupantsHouseRelationEnum.NonOwner.value && (
|
|
|
|
|
<OwnerUpdate item={item} reload={action?.reload} />
|
|
|
|
|
)}
|
|
|
|
|
{item?.house_relation ===
|
|
|
|
|
HouseOccupantsHouseRelationEnum.NonOwner.value && (
|
|
|
|
|
<OccupantsUpdate item={item} reload={action?.reload} />
|
|
|
|
|
)}
|
|
|
|
|
<ChangePhone item={item} reload={action?.reload} />
|
|
|
|
|
{!item?.move_in_date && (
|
2025-07-16 10:18:01 +08:00
|
|
|
<MoveIn item={item} reload={action?.reload} title="入住" />
|
|
|
|
|
)}
|
|
|
|
|
{item?.move_in_date && (
|
2025-07-10 18:01:45 +08:00
|
|
|
<MoveOut item={item} reload={action?.reload} title="搬离" />
|
|
|
|
|
)}
|
2025-08-18 11:36:25 +08:00
|
|
|
<RemoveOwner item={item} reload={handleReload} title="移除" />
|
2025-07-10 18:01:45 +08:00
|
|
|
</Space>
|
|
|
|
|
),
|
|
|
|
|
}),
|
|
|
|
|
]}
|
|
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|