feat:增加房屋登记
This commit is contained in:
parent
aa49d82c16
commit
4494bc0119
@ -250,4 +250,38 @@ export const Selects = {
|
||||
},
|
||||
};
|
||||
},
|
||||
//房屋
|
||||
AssetHouses(props?: PropsType): ReturnType {
|
||||
const {
|
||||
title = '选择房屋',
|
||||
key = 'asset_houses_id',
|
||||
required = false,
|
||||
hideInTable = true,
|
||||
...rest
|
||||
} = props ?? {};
|
||||
|
||||
return {
|
||||
title: title,
|
||||
key: key,
|
||||
valueType: 'select',
|
||||
hideInTable: hideInTable,
|
||||
formItemProps: { ...(required ? rulesHelper.number : {}) },
|
||||
request: async (params) =>
|
||||
(
|
||||
await Apis.Asset.AssetHouses.Select({
|
||||
keywords: params?.KeyWords,
|
||||
...params,
|
||||
})
|
||||
).data,
|
||||
...rest,
|
||||
fieldProps: {
|
||||
showSearch: true,
|
||||
fieldNames: {
|
||||
label: 'label',
|
||||
value: 'value',
|
||||
},
|
||||
...rest?.fieldProps,
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
6
src/gen/ApiTypes.d.ts
vendored
6
src/gen/ApiTypes.d.ts
vendored
@ -134,6 +134,12 @@ declare namespace ApiTypes {
|
||||
type Delete = {
|
||||
"id": number; // id
|
||||
};
|
||||
type Select = {
|
||||
"asset_projects_id"?: number; // 所属项目id,[ref:asset_projects]
|
||||
"asset_buildings_id"?: number; // 所属楼栋id,[ref:asset_buildings]
|
||||
"asset_units_id"?: number; // 所属单元id,[ref:asset_units]
|
||||
"keywords"?: string; // 关键词
|
||||
};
|
||||
}
|
||||
namespace AssetProjects {
|
||||
type List = {
|
||||
|
||||
@ -75,6 +75,9 @@ export const Apis = {
|
||||
Delete(data: ApiTypes.Asset.AssetHouses.Delete): Promise<MyResponseType> {
|
||||
return request('admin/asset/asset_houses/delete', { data });
|
||||
},
|
||||
Select(data?: ApiTypes.Asset.AssetHouses.Select): Promise<MyResponseType> {
|
||||
return request('admin/asset/asset_houses/select', { data });
|
||||
},
|
||||
},
|
||||
AssetProjects: {
|
||||
List(data?: ApiTypes.Asset.AssetProjects.List): Promise<MyResponseType> {
|
||||
|
||||
89
src/pages/archive/house_registers/index.tsx
Normal file
89
src/pages/archive/house_registers/index.tsx
Normal file
@ -0,0 +1,89 @@
|
||||
import {
|
||||
MyButtons,
|
||||
MyColumns,
|
||||
MyPageContainer,
|
||||
MyProTableProps,
|
||||
} from '@/common';
|
||||
import { Apis } from '@/gen/Apis';
|
||||
import {
|
||||
HouseRegistersCustomerTypeEnum,
|
||||
HouseRegistersHouseStatusEnum,
|
||||
HouseRegistersStatusEnum,
|
||||
HouseRegistersTypeEnum,
|
||||
HouseRegistersUsagePlanEnum,
|
||||
} from '@/gen/Enums';
|
||||
import { ProTable } from '@ant-design/pro-components';
|
||||
import { Space } from 'antd';
|
||||
import Create from './modals/Create';
|
||||
import Update from './modals/Update';
|
||||
|
||||
export default function Index({ title = '房屋登记' }) {
|
||||
return (
|
||||
<MyPageContainer title={title}>
|
||||
<ProTable
|
||||
{...MyProTableProps.props}
|
||||
// search={false}
|
||||
request={async (params, sort) =>
|
||||
MyProTableProps.request(
|
||||
params,
|
||||
sort,
|
||||
Apis.Archive.HouseRegisters.List,
|
||||
)
|
||||
}
|
||||
toolBarRender={(action) => [
|
||||
<Create key="Create" reload={action?.reload} title={title} />,
|
||||
]}
|
||||
columns={[
|
||||
MyColumns.ID(),
|
||||
{
|
||||
title: '房屋',
|
||||
dataIndex: ['asset_house', 'full_name'],
|
||||
},
|
||||
MyColumns.EnumTag({
|
||||
title: '类型',
|
||||
dataIndex: 'type',
|
||||
valueEnum: HouseRegistersTypeEnum,
|
||||
}),
|
||||
MyColumns.EnumTag({
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
valueEnum: HouseRegistersStatusEnum,
|
||||
}),
|
||||
MyColumns.EnumTag({
|
||||
title: '房屋状态',
|
||||
dataIndex: 'house_status',
|
||||
valueEnum: HouseRegistersHouseStatusEnum,
|
||||
search: false,
|
||||
}),
|
||||
MyColumns.EnumTag({
|
||||
title: '使用计划',
|
||||
dataIndex: 'usage_plan',
|
||||
valueEnum: HouseRegistersUsagePlanEnum,
|
||||
search: false,
|
||||
}),
|
||||
MyColumns.EnumTag({
|
||||
title: '客户类型',
|
||||
dataIndex: 'customer_type',
|
||||
valueEnum: HouseRegistersCustomerTypeEnum,
|
||||
search: false,
|
||||
}),
|
||||
MyColumns.CreatedAt(),
|
||||
MyColumns.Option({
|
||||
render: (_, item: any, index, action) => (
|
||||
<Space key={index}>
|
||||
<Update item={item} reload={action?.reload} title={title} />
|
||||
<MyButtons.Delete
|
||||
onConfirm={() =>
|
||||
Apis.Archive.HouseRegisters.Delete({ id: item.id }).then(
|
||||
() => action?.reload(),
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Space>
|
||||
),
|
||||
}),
|
||||
]}
|
||||
/>
|
||||
</MyPageContainer>
|
||||
);
|
||||
}
|
||||
78
src/pages/archive/house_registers/modals/Create.tsx
Normal file
78
src/pages/archive/house_registers/modals/Create.tsx
Normal file
@ -0,0 +1,78 @@
|
||||
import {
|
||||
MyBetaModalFormProps,
|
||||
MyButtons,
|
||||
MyFormItems,
|
||||
MyModalFormProps,
|
||||
rulesHelper,
|
||||
} from '@/common';
|
||||
import { Selects } from '@/components/Select';
|
||||
import { Apis } from '@/gen/Apis';
|
||||
import {
|
||||
HouseRegistersCustomerTypeEnum,
|
||||
HouseRegistersHouseStatusEnum,
|
||||
HouseRegistersStatusEnum,
|
||||
HouseRegistersTypeEnum,
|
||||
HouseRegistersUsagePlanEnum,
|
||||
} from '@/gen/Enums';
|
||||
import { BetaSchemaForm } from '@ant-design/pro-components';
|
||||
import { message } from 'antd';
|
||||
|
||||
export default function Create(props: MyBetaModalFormProps) {
|
||||
return (
|
||||
<BetaSchemaForm<ApiTypes.Archive.HouseRegisters.Store>
|
||||
{...MyModalFormProps.props}
|
||||
title={`添加${props.title}`}
|
||||
wrapperCol={{ span: 24 }}
|
||||
width="800px"
|
||||
trigger={<MyButtons.Create title={`添加${props.title}`} />}
|
||||
onFinish={async (values) =>
|
||||
Apis.Archive.HouseRegisters.Store(values)
|
||||
.then(() => {
|
||||
props.reload?.();
|
||||
message.success(props.title + '成功');
|
||||
return true;
|
||||
})
|
||||
.catch(() => false)
|
||||
}
|
||||
columns={[
|
||||
Selects?.AssetHouses({
|
||||
title: '选择房屋',
|
||||
key: 'asset_houses_id',
|
||||
formItemProps: { ...rulesHelper.text },
|
||||
colProps: { span: 12 },
|
||||
}),
|
||||
MyFormItems.EnumRadio({
|
||||
key: 'type',
|
||||
title: '类型',
|
||||
colProps: { span: 12 },
|
||||
valueEnum: HouseRegistersTypeEnum,
|
||||
required: true,
|
||||
}),
|
||||
MyFormItems.EnumRadio({
|
||||
key: 'customer_type',
|
||||
title: '客户类型',
|
||||
colProps: { span: 12 },
|
||||
valueEnum: HouseRegistersCustomerTypeEnum,
|
||||
}),
|
||||
MyFormItems.EnumRadio({
|
||||
key: 'usage_plan',
|
||||
title: '使用计划',
|
||||
colProps: { span: 12 },
|
||||
valueEnum: HouseRegistersUsagePlanEnum,
|
||||
}),
|
||||
MyFormItems.EnumRadio({
|
||||
key: 'status',
|
||||
title: '状态',
|
||||
colProps: { span: 12 },
|
||||
valueEnum: HouseRegistersStatusEnum,
|
||||
}),
|
||||
MyFormItems.EnumRadio({
|
||||
key: 'house_status',
|
||||
title: '房屋状态',
|
||||
colProps: { span: 12 },
|
||||
valueEnum: HouseRegistersHouseStatusEnum,
|
||||
}),
|
||||
]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
91
src/pages/archive/house_registers/modals/Update.tsx
Normal file
91
src/pages/archive/house_registers/modals/Update.tsx
Normal file
@ -0,0 +1,91 @@
|
||||
import {
|
||||
MyBetaModalFormProps,
|
||||
MyButtons,
|
||||
MyFormItems,
|
||||
MyModalFormProps,
|
||||
rulesHelper,
|
||||
} from '@/common';
|
||||
|
||||
import { Selects } from '@/components/Select';
|
||||
import { Apis } from '@/gen/Apis';
|
||||
import {
|
||||
HouseRegistersCustomerTypeEnum,
|
||||
HouseRegistersHouseStatusEnum,
|
||||
HouseRegistersStatusEnum,
|
||||
HouseRegistersTypeEnum,
|
||||
HouseRegistersUsagePlanEnum,
|
||||
} from '@/gen/Enums';
|
||||
import { BetaSchemaForm } from '@ant-design/pro-components';
|
||||
import { Form, message } from 'antd';
|
||||
export default function Update(props: MyBetaModalFormProps) {
|
||||
const [form] = Form.useForm();
|
||||
return (
|
||||
<BetaSchemaForm<ApiTypes.Archive.HouseRegisters.Update>
|
||||
{...MyModalFormProps.props}
|
||||
title={`编辑员工`}
|
||||
trigger={<MyButtons.Edit />}
|
||||
wrapperCol={{ span: 24 }}
|
||||
width="800px"
|
||||
form={form}
|
||||
onOpenChange={(open: any) => {
|
||||
if (open && props.item) {
|
||||
form.setFieldsValue({
|
||||
...props.item,
|
||||
roles_id: props.item?.roles?.map((item: any) => item.value),
|
||||
});
|
||||
}
|
||||
}}
|
||||
onFinish={async (values) =>
|
||||
Apis.Archive.HouseRegisters.Update({
|
||||
...values,
|
||||
id: props.item?.id ?? 0,
|
||||
})
|
||||
.then(() => {
|
||||
props.reload?.();
|
||||
message.success(props.title + '成功');
|
||||
return true;
|
||||
})
|
||||
.catch(() => false)
|
||||
}
|
||||
columns={[
|
||||
Selects?.AssetHouses({
|
||||
title: '选择房屋',
|
||||
key: 'asset_houses_id',
|
||||
formItemProps: { ...rulesHelper.text },
|
||||
colProps: { span: 8 },
|
||||
}),
|
||||
MyFormItems.EnumRadio({
|
||||
key: 'type',
|
||||
title: '类型',
|
||||
colProps: { span: 12 },
|
||||
valueEnum: HouseRegistersTypeEnum,
|
||||
required: true,
|
||||
}),
|
||||
MyFormItems.EnumRadio({
|
||||
key: 'customer_type',
|
||||
title: '客户类型',
|
||||
colProps: { span: 12 },
|
||||
valueEnum: HouseRegistersCustomerTypeEnum,
|
||||
}),
|
||||
MyFormItems.EnumRadio({
|
||||
key: 'usage_plan',
|
||||
title: '使用计划',
|
||||
colProps: { span: 12 },
|
||||
valueEnum: HouseRegistersUsagePlanEnum,
|
||||
}),
|
||||
MyFormItems.EnumRadio({
|
||||
key: 'status',
|
||||
title: '状态',
|
||||
colProps: { span: 12 },
|
||||
valueEnum: HouseRegistersStatusEnum,
|
||||
}),
|
||||
MyFormItems.EnumRadio({
|
||||
key: 'house_status',
|
||||
title: '房屋状态',
|
||||
colProps: { span: 12 },
|
||||
valueEnum: HouseRegistersHouseStatusEnum,
|
||||
}),
|
||||
]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user