215 lines
6.0 KiB
TypeScript
Raw Normal View History

2025-07-04 17:26:52 +08:00
import {
MyBetaModalFormProps,
MyButtons,
MyFormItems,
MyModalFormProps,
rulesHelper,
} from '@/common';
import { Selects } from '@/components/Select';
import { Apis } from '@/gen/Apis';
import { HouseBillsTypeEnum } from '@/gen/Enums';
import { BetaSchemaForm } from '@ant-design/pro-components';
import { Form, message } from 'antd';
export default function Create(props: MyBetaModalFormProps) {
const [form] = Form.useForm();
return (
<BetaSchemaForm<ApiTypes.Bill.HouseBills.Store>
{...MyModalFormProps.props}
title={`添加${props.title}`}
wrapperCol={{ span: 24 }}
width="600px"
trigger={<MyButtons.Create title={`添加${props.title}`} />}
onOpenChange={(open: any) => {
if (open) {
form.resetFields(); // 清空表单数据
}
}}
onFinish={async (values) =>
Apis.Bill.HouseBills.Store(values)
.then(() => {
props.reload?.();
message.success(props.title + '成功');
return true;
})
.catch(() => false)
}
columns={[
Selects?.AssetProjects({
title: '选择项目',
key: 'asset_projects_id',
2025-07-10 18:01:45 +08:00
colProps: { span: 24 },
2025-07-04 17:26:52 +08:00
formItemProps: { ...rulesHelper.text },
}),
{
valueType: 'dependency',
2025-07-10 18:01:45 +08:00
name: ['asset_projects_id', 'asset_buildings_id', 'asset_units_id'],
columns: ({
asset_projects_id,
asset_buildings_id,
asset_units_id,
}) => {
return [
{
valueType: 'group',
columns: [
Selects?.AssetBuildings({
key: 'asset_buildings_id',
title: '选择楼栋',
params: {
asset_projects_id: asset_projects_id,
},
colProps: { span: 8 },
formItemProps: { ...rulesHelper.number },
fieldProps: {
showSearch: true,
onChange: () => {
form.setFieldsValue({
asset_units_id: undefined,
asset_floors_id: undefined,
});
},
},
}),
Selects?.AssetUnits({
key: 'asset_units_id',
title: '选择单元',
params: {
asset_projects_id: asset_projects_id,
asset_buildings_id: asset_buildings_id,
},
colProps: { span: 8 },
formItemProps: { ...rulesHelper.number },
}),
Selects?.AssetHouses({
title: '选择房屋',
key: 'asset_houses_id',
params: {
asset_projects_id: asset_projects_id,
asset_buildings_id: asset_buildings_id,
asset_units_id: asset_units_id,
},
formItemProps: { ...rulesHelper.text },
colProps: { span: 8 },
}),
],
},
];
},
2025-07-04 17:26:52 +08:00
},
{
key: 'amount',
2025-07-10 18:01:45 +08:00
title: '账单金额',
2025-07-04 17:26:52 +08:00
valueType: 'digit',
colProps: { span: 8 },
fieldProps: {
2025-07-10 18:01:45 +08:00
addonAfter: '元',
2025-07-04 17:26:52 +08:00
style: {
width: '100%',
},
},
formItemProps: { ...rulesHelper.number },
},
{
key: 'discount_amount',
title: '优惠金额',
valueType: 'digit',
fieldProps: {
2025-07-10 18:01:45 +08:00
addonAfter: '元',
2025-07-04 17:26:52 +08:00
style: {
width: '100%',
},
},
colProps: { span: 8 },
},
{
key: 'late_fee',
title: '滞纳金',
valueType: 'digit',
fieldProps: {
2025-07-10 18:01:45 +08:00
addonAfter: '元',
2025-07-04 17:26:52 +08:00
style: {
width: '100%',
},
},
colProps: { span: 8 },
},
MyFormItems.EnumRadio({
key: 'type',
2025-07-10 18:01:45 +08:00
title: '收费项目',
2025-07-04 17:26:52 +08:00
colProps: { span: 24 },
valueEnum: HouseBillsTypeEnum,
required: true,
}),
2025-07-10 18:01:45 +08:00
{
key: 'month',
title: '账单月份',
valueType: 'date',
colProps: { span: 8 },
fieldProps: {
picker: 'month',
format: 'YYYY-MM',
valueFormat: 'YYYY-MM',
style: {
width: '100%',
},
},
formItemProps: { ...rulesHelper.text },
},
2025-07-04 17:26:52 +08:00
{
key: 'start_date',
title: '计费开始日期',
valueType: 'date',
colProps: { span: 8 },
fieldProps: {
style: {
width: '100%',
},
},
formItemProps: { ...rulesHelper.text },
},
{
key: 'end_date',
title: '计费结束日期',
valueType: 'date',
colProps: { span: 8 },
fieldProps: {
style: {
width: '100%',
},
},
},
{
key: 'late_start_date',
title: '滞纳金起算日期',
valueType: 'date',
fieldProps: {
style: {
width: '100%',
},
},
colProps: { span: 8 },
},
{
key: 'collected_late_fee_days',
title: '已收滞纳金天数',
valueType: 'digit',
fieldProps: {
addonAfter: '天',
style: {
width: '100%',
},
},
colProps: { span: 8 },
},
{
title: '备注',
key: 'remark',
valueType: 'textarea',
colProps: { span: 24 },
},
]}
/>
);
}