202 lines
6.4 KiB
TypeScript
Raw Normal View History

2025-07-02 16:43:04 +08:00
import {
MyBetaModalFormProps,
MyButtons,
MyFormItems,
MyModalFormProps,
rulesHelper,
} from '@/common';
import { Apis } from '@/gen/Apis';
import {
HouseOccupantsCardTypeEnum,
2025-07-25 16:42:54 +08:00
HouseOccupantsHouseRelationEnum,
2025-07-02 16:43:04 +08:00
HouseRegistersCustomerTypeEnum,
} from '@/gen/Enums';
import { BetaSchemaForm, ProCard } from '@ant-design/pro-components';
import { Form, message } from 'antd';
export default function Create(props: MyBetaModalFormProps) {
const [form] = Form.useForm();
return (
<BetaSchemaForm<ApiTypes.Archive.HouseRegisters.Store>
{...MyModalFormProps.props}
title={`${props.title}`}
2025-07-02 16:43:04 +08:00
wrapperCol={{ span: 24 }}
width="900px"
trigger={
<MyButtons.Default title={props.title} size="middle" type="primary" />
2025-07-02 16:43:04 +08:00
}
key={new Date().getTime()}
form={form}
2025-07-02 16:43:04 +08:00
onOpenChange={(open: any) => {
if (open) {
form.resetFields(); // 清空表单数据
}
}}
onFinish={async (values) =>
2025-07-02 16:43:04 +08:00
Apis.Archive.HouseRegisters.Store({
...values,
asset_houses_id: props?.item?.id,
type: 'Transfer',
2025-07-02 16:43:04 +08:00
})
.then(() => {
props.reload?.();
message.success(props.title + '成功');
return true;
})
.catch(() => false)
}
columns={[
// MyFormItems.EnumRadio({
// key: 'house_status',
// title: '房屋状态',
// colProps: { span: 12 },
// valueEnum: HouseRegistersHouseStatusEnum,
// formItemProps: { ...rulesHelper.text },
// }),
// MyFormItems.EnumRadio({
// key: 'house_status',
// title: '使用计划',
// colProps: { span: 8 },
// valueEnum: HouseRegistersUsagePlanEnum,
// formItemProps: { ...rulesHelper.text },
// }),
MyFormItems.EnumSelect({
2025-07-10 18:01:45 +08:00
key: 'customer_type',
title: '产权归属',
colProps: { span: 6 },
2025-07-10 18:01:45 +08:00
valueEnum: HouseRegistersCustomerTypeEnum,
}),
MyFormItems.UploadImages({
key: 'ownership_info',
title: '产权文件',
tooltip: '上限3张',
uploadType: 'file',
max: 3,
colProps: { span: 18 },
formItemProps: { ...rulesHelper.array },
2025-07-10 18:01:45 +08:00
}),
2025-07-02 16:43:04 +08:00
{
valueType: 'formList',
dataIndex: 'customer_info',
colProps: { span: 24 },
fieldProps: {
copyIconProps: false,
creatorButtonProps: {
creatorButtonText: '添加产权人',
2025-07-02 16:43:04 +08:00
},
itemRender: (
{ listDom, action }: any,
{ index }: { index: number },
) => {
return (
<ProCard
bordered
style={{ marginBlockEnd: 0 }}
title={`产权人 ${index + 1}`}
2025-07-02 16:43:04 +08:00
extra={action}
bodyStyle={{ paddingBlockEnd: 0 }}
>
{listDom}
</ProCard>
);
},
},
columns: [
{
valueType: 'group',
columns: [
{
title: '名称',
2025-07-02 16:43:04 +08:00
dataIndex: 'name',
2025-07-25 16:42:54 +08:00
colProps: { span: 5 },
2025-07-02 16:43:04 +08:00
formItemProps: { ...rulesHelper.text },
},
{
title: '手机号',
dataIndex: 'phone',
2025-07-25 16:42:54 +08:00
colProps: { span: 5 },
2025-07-02 16:43:04 +08:00
fieldProps: {
2025-07-10 18:01:45 +08:00
maxLength: 11,
2025-07-02 16:43:04 +08:00
},
2025-07-25 16:42:54 +08:00
formItemProps: { ...rulesHelper.phone },
2025-07-02 16:43:04 +08:00
},
MyFormItems.EnumSelect({
key: 'card_type',
title: '证件类型',
2025-07-25 16:42:54 +08:00
colProps: { span: 6 },
2025-07-02 16:43:04 +08:00
valueEnum: HouseOccupantsCardTypeEnum,
required: true,
}),
{
title: '证件号码',
dataIndex: 'id_card',
2025-07-25 16:42:54 +08:00
colProps: { span: 8 },
2025-07-02 16:43:04 +08:00
fieldProps: {
maxLength: 18,
},
formItemProps: { ...rulesHelper.text },
},
2025-07-25 16:42:54 +08:00
MyFormItems.EnumRadio({
key: 'house_relation',
title: '住户类型',
colProps: { span: 6 },
valueEnum: HouseOccupantsHouseRelationEnum,
fieldProps: {
defaultValue: 'Owner',
},
hideInForm: true,
}),
2025-07-02 16:43:04 +08:00
{
valueType: 'group',
columns: [
MyFormItems.UploadImages({
key: 'card_front_image',
2025-07-10 18:01:45 +08:00
title: '证件正面',
uploadType: 'file',
2025-07-02 16:43:04 +08:00
max: 1,
colProps: { span: 6 },
2025-07-02 16:43:04 +08:00
}),
MyFormItems.UploadImages({
key: 'card_back_image',
2025-07-10 18:01:45 +08:00
title: '证件反面',
uploadType: 'file',
2025-07-02 16:43:04 +08:00
max: 1,
colProps: { span: 6 },
2025-07-02 16:43:04 +08:00
}),
2025-07-25 16:42:54 +08:00
{
title: '是否办理入住',
2025-07-25 16:42:54 +08:00
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-02 16:43:04 +08:00
],
},
],
},
],
},
]}
/>
);
}