2025-07-16 10:18:01 +08:00
|
|
|
import {
|
|
|
|
|
MyBetaModalFormProps,
|
|
|
|
|
MyButtons,
|
|
|
|
|
MyFormItems,
|
|
|
|
|
MyModalFormProps,
|
|
|
|
|
rulesHelper,
|
|
|
|
|
} from '@/common';
|
|
|
|
|
import { Apis } from '@/gen/Apis';
|
|
|
|
|
import {
|
|
|
|
|
HouseOccupantsCardTypeEnum,
|
2025-07-17 13:58:54 +08:00
|
|
|
HouseOccupantsHouseRelationEnum,
|
2025-08-08 18:35:02 +08:00
|
|
|
HouseOccupantsRelationWithOwnerEnum,
|
2025-08-27 11:24:29 +08:00
|
|
|
HouseOccupantsResidentialRelationEnum,
|
|
|
|
|
HouseRegistersTypeEnum,
|
2025-07-16 10:18:01 +08:00
|
|
|
} from '@/gen/Enums';
|
|
|
|
|
import { BetaSchemaForm, ProCard } from '@ant-design/pro-components';
|
|
|
|
|
import { Form, message } from 'antd';
|
|
|
|
|
|
2025-08-27 11:24:29 +08:00
|
|
|
export default function AddOccupant(props: MyBetaModalFormProps) {
|
2025-07-16 10:18:01 +08:00
|
|
|
const [form] = Form.useForm();
|
|
|
|
|
return (
|
|
|
|
|
<BetaSchemaForm<ApiTypes.Archive.HouseRegisters.Store>
|
|
|
|
|
{...MyModalFormProps.props}
|
2025-07-25 16:42:54 +08:00
|
|
|
title={`${props.title}`}
|
2025-07-16 10:18:01 +08:00
|
|
|
wrapperCol={{ span: 24 }}
|
2025-08-08 18:35:02 +08:00
|
|
|
width="800px"
|
2025-07-16 10:18:01 +08:00
|
|
|
trigger={
|
2025-08-08 18:35:02 +08:00
|
|
|
<MyButtons.Default title={props.title} size="middle" type="primary" />
|
2025-07-16 10:18:01 +08:00
|
|
|
}
|
2025-08-08 18:35:02 +08:00
|
|
|
key={new Date().getTime()}
|
|
|
|
|
form={form}
|
2025-07-16 10:18:01 +08:00
|
|
|
onOpenChange={(open: any) => {
|
|
|
|
|
if (open) {
|
|
|
|
|
form.resetFields(); // 清空表单数据
|
|
|
|
|
}
|
|
|
|
|
}}
|
2025-08-08 18:35:02 +08:00
|
|
|
onFinish={async (values) =>
|
2025-07-16 10:18:01 +08:00
|
|
|
Apis.Archive.HouseRegisters.Store({
|
|
|
|
|
...values,
|
2025-08-08 18:35:02 +08:00
|
|
|
asset_houses_id: props?.item?.id,
|
2025-08-27 11:24:29 +08:00
|
|
|
type: HouseRegistersTypeEnum.AddOccupant.value,
|
|
|
|
|
customer_info: values.customer_info?.map((res: any) => {
|
|
|
|
|
return {
|
|
|
|
|
...res,
|
|
|
|
|
house_relation: HouseOccupantsHouseRelationEnum.NonOwner.value,
|
|
|
|
|
};
|
|
|
|
|
}),
|
2025-07-16 10:18:01 +08:00
|
|
|
})
|
|
|
|
|
.then(() => {
|
|
|
|
|
props.reload?.();
|
|
|
|
|
message.success(props.title + '成功');
|
|
|
|
|
return true;
|
|
|
|
|
})
|
|
|
|
|
.catch(() => false)
|
|
|
|
|
}
|
|
|
|
|
columns={[
|
|
|
|
|
{
|
|
|
|
|
valueType: 'formList',
|
|
|
|
|
dataIndex: 'customer_info',
|
|
|
|
|
colProps: { span: 24 },
|
2025-08-27 11:24:29 +08:00
|
|
|
initialValue: [''],
|
|
|
|
|
|
2025-07-16 10:18:01 +08:00
|
|
|
fieldProps: {
|
|
|
|
|
copyIconProps: false,
|
|
|
|
|
creatorButtonProps: {
|
2025-08-27 11:24:29 +08:00
|
|
|
creatorButtonText: '添加客户',
|
2025-07-16 10:18:01 +08:00
|
|
|
},
|
|
|
|
|
itemRender: (
|
|
|
|
|
{ listDom, action }: any,
|
|
|
|
|
{ index }: { index: number },
|
|
|
|
|
) => {
|
|
|
|
|
return (
|
|
|
|
|
<ProCard
|
|
|
|
|
bordered
|
2025-08-08 18:35:02 +08:00
|
|
|
style={{ marginBlockEnd: 0 }}
|
2025-08-27 11:24:29 +08:00
|
|
|
title={`客户${index + 1}`}
|
2025-07-16 10:18:01 +08:00
|
|
|
extra={action}
|
|
|
|
|
bodyStyle={{ paddingBlockEnd: 0 }}
|
|
|
|
|
>
|
|
|
|
|
{listDom}
|
|
|
|
|
</ProCard>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
columns: [
|
|
|
|
|
{
|
|
|
|
|
valueType: 'group',
|
|
|
|
|
columns: [
|
2025-08-08 18:35:02 +08:00
|
|
|
MyFormItems.EnumRadio({
|
2025-08-27 11:24:29 +08:00
|
|
|
key: 'residential_relation',
|
|
|
|
|
title: '居住关系',
|
|
|
|
|
colProps: { span: 12 },
|
|
|
|
|
valueEnum: HouseOccupantsResidentialRelationEnum,
|
|
|
|
|
// valueEnum: () => {
|
|
|
|
|
// let obj: any = JSON.parse(
|
|
|
|
|
// JSON.stringify(HouseOccupantsResidentialRelationEnum),
|
|
|
|
|
// );
|
|
|
|
|
// delete obj.Tenant;
|
|
|
|
|
// return obj;
|
|
|
|
|
// },
|
2025-08-08 18:35:02 +08:00
|
|
|
required: true,
|
|
|
|
|
}),
|
|
|
|
|
MyFormItems.EnumRadio({
|
|
|
|
|
key: 'relation_with_owner',
|
|
|
|
|
title: '关系标记',
|
|
|
|
|
valueEnum: HouseOccupantsRelationWithOwnerEnum,
|
|
|
|
|
colProps: { span: 18 },
|
|
|
|
|
required: true,
|
|
|
|
|
}),
|
2025-07-16 10:18:01 +08:00
|
|
|
{
|
|
|
|
|
title: '姓名',
|
|
|
|
|
dataIndex: 'name',
|
2025-08-08 18:35:02 +08:00
|
|
|
colProps: { span: 6 },
|
2025-07-16 10:18:01 +08:00
|
|
|
formItemProps: { ...rulesHelper.text },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '手机号',
|
|
|
|
|
dataIndex: 'phone',
|
2025-08-08 18:35:02 +08:00
|
|
|
colProps: { span: 6 },
|
2025-07-16 10:18:01 +08:00
|
|
|
fieldProps: {
|
|
|
|
|
maxLength: 11,
|
|
|
|
|
},
|
2025-07-25 16:42:54 +08:00
|
|
|
formItemProps: { ...rulesHelper.phone },
|
2025-07-16 10:18:01 +08:00
|
|
|
},
|
|
|
|
|
MyFormItems.EnumSelect({
|
|
|
|
|
key: 'card_type',
|
|
|
|
|
title: '证件类型',
|
2025-07-25 16:42:54 +08:00
|
|
|
colProps: { span: 6 },
|
2025-07-16 10:18:01 +08:00
|
|
|
valueEnum: HouseOccupantsCardTypeEnum,
|
|
|
|
|
required: true,
|
|
|
|
|
}),
|
|
|
|
|
{
|
|
|
|
|
title: '证件号码',
|
|
|
|
|
dataIndex: 'id_card',
|
2025-08-08 18:35:02 +08:00
|
|
|
colProps: { span: 6 },
|
2025-07-16 10:18:01 +08:00
|
|
|
fieldProps: {
|
|
|
|
|
maxLength: 18,
|
|
|
|
|
},
|
|
|
|
|
formItemProps: { ...rulesHelper.text },
|
|
|
|
|
},
|
2025-08-08 18:35:02 +08:00
|
|
|
|
2025-07-16 10:18:01 +08:00
|
|
|
{
|
|
|
|
|
valueType: 'group',
|
|
|
|
|
columns: [
|
|
|
|
|
MyFormItems.UploadImages({
|
|
|
|
|
key: 'card_front_image',
|
|
|
|
|
title: '证件正面',
|
2025-08-08 18:35:02 +08:00
|
|
|
uploadType: 'file',
|
2025-07-16 10:18:01 +08:00
|
|
|
max: 1,
|
2025-08-08 18:35:02 +08:00
|
|
|
colProps: { span: 6 },
|
2025-07-16 10:18:01 +08:00
|
|
|
formItemProps: { ...rulesHelper.text },
|
|
|
|
|
}),
|
|
|
|
|
MyFormItems.UploadImages({
|
|
|
|
|
key: 'card_back_image',
|
|
|
|
|
title: '证件反面',
|
2025-08-08 18:35:02 +08:00
|
|
|
uploadType: 'file',
|
2025-07-16 10:18:01 +08:00
|
|
|
max: 1,
|
2025-08-08 18:35:02 +08:00
|
|
|
colProps: { span: 6 },
|
2025-07-16 10:18:01 +08:00
|
|
|
formItemProps: { ...rulesHelper.text },
|
|
|
|
|
}),
|
2025-07-25 16:42:54 +08:00
|
|
|
{
|
|
|
|
|
title: '是否入住',
|
|
|
|
|
dataIndex: 'is_live_in',
|
|
|
|
|
colProps: { span: 6 },
|
|
|
|
|
valueType: 'switch',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: ['is_live_in'],
|
|
|
|
|
valueType: 'dependency',
|
|
|
|
|
columns: ({ is_live_in }: any) => {
|
|
|
|
|
return is_live_in
|
|
|
|
|
? [
|
|
|
|
|
{
|
|
|
|
|
title: '入住日期',
|
|
|
|
|
dataIndex: 'move_in_date',
|
|
|
|
|
valueType: 'date',
|
|
|
|
|
colProps: { span: 6 },
|
|
|
|
|
fieldProps: {
|
|
|
|
|
style: { width: '100%' },
|
|
|
|
|
},
|
|
|
|
|
formItemProps: { ...rulesHelper.text },
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
: [];
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-07-16 10:18:01 +08:00
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|