157 lines
4.4 KiB
TypeScript
Raw Normal View History

2026-01-08 16:35:06 +08:00
import {
MyButtons,
MyColumns,
MyPageContainer,
MyProTableProps,
MyTableActions,
MyToolBarActions,
2026-01-08 16:35:06 +08:00
} from '@/common';
2026-01-18 18:48:42 +08:00
import { MyExport } from '@/components/MyExport';
2026-01-08 16:35:06 +08:00
import { Selects } from '@/components/Select';
import { Apis } from '@/gen/Apis';
import {
AssetCarPortsPropertyTypeEnum,
AssetCarPortsStatusEnum,
AssetCarPortsTypeEnum,
} from '@/gen/Enums';
import { ProTable } from '@ant-design/pro-components';
import { Space } from 'antd';
2026-01-18 18:48:42 +08:00
import { useState } from 'react';
import AreaUpdate from './modals/AreaUpdate';
2026-01-18 18:48:42 +08:00
import SpaceShow from './modals/SpaceShow';
2026-01-08 16:35:06 +08:00
import SpaceUpdate from './modals/SpaceUpdate';
export default function Index({ title = '车位列表' }) {
2026-01-18 18:48:42 +08:00
const [getParams, setParams] = useState({ page: 1 });
2026-01-08 16:35:06 +08:00
return (
<MyPageContainer
title={title}
enableTabs={true}
tabKey="asset_parking_places"
tabLabel={title}
>
<ProTable
{...MyProTableProps.props}
headerTitle="车位列表"
tooltip="车位列表的信息管理,请在【项目列表】中进行操作"
2026-01-08 16:35:06 +08:00
request={async (params, sort) =>
2026-01-18 18:48:42 +08:00
MyProTableProps.request(
params,
sort,
Apis.Asset.AssetCarPorts.List,
setParams,
)
2026-01-08 16:35:06 +08:00
}
2026-01-18 18:48:42 +08:00
toolBarRender={(action) => [
<MyToolBarActions
key="toolbar"
actions={{
export: (
<MyExport
key="export"
item={{ current: getParams?.page || 1, ...getParams }}
reload={action?.reload}
download={Apis.Asset.AssetCarPorts}
/>
),
}}
2026-01-18 18:48:42 +08:00
/>,
]}
2026-01-08 16:35:06 +08:00
columns={[
MyColumns.ID({ search: false }),
Selects?.AssetProjects({
title: '选择项目',
key: 'asset_projects_id',
hidden: true,
}),
{
title: '项目名称',
dataIndex: ['asset_project', 'name'],
2026-01-18 18:48:42 +08:00
search: false,
2026-01-08 16:35:06 +08:00
},
{
title: '车位全称',
dataIndex: 'full_name',
},
2026-01-08 16:35:06 +08:00
{
title: '车场名称',
dataIndex: ['asset_parking_place', 'name'],
search: {
transform: (value) => {
return { parking_place_name: value };
},
},
render: (_, item: any) => (
<AreaUpdate
item={{
...item,
type: 'link',
titl: `${item?.asset_parking_place?.name}`,
}}
title={item?.asset_parking_place?.name}
/>
),
2026-01-08 16:35:06 +08:00
},
{
title: '车位号',
dataIndex: 'name',
search: false,
},
2026-01-08 16:35:06 +08:00
MyColumns.EnumTag({
title: '类型',
dataIndex: 'type',
valueEnum: AssetCarPortsTypeEnum,
}),
MyColumns.EnumTag({
title: '产权类型',
dataIndex: 'property_type',
valueEnum: AssetCarPortsPropertyTypeEnum,
}),
MyColumns.EnumTag({
title: '状态',
dataIndex: 'status',
valueEnum: AssetCarPortsStatusEnum,
}),
{
title: '建筑面积',
dataIndex: 'built_area',
search: false,
},
// MyColumns.CreatedAt(),
MyColumns.UpdatedAt(),
2026-01-08 16:35:06 +08:00
MyColumns.Option({
render: (_, item: any, index, action) => (
2026-01-18 18:48:42 +08:00
<Space key={index}>
<SpaceShow item={item} reload={action?.reload} title={title} />
<MyTableActions
actions={{
update: (
<SpaceUpdate
item={item}
reload={action?.reload}
title={title}
/>
),
delete: (
<MyButtons.Delete
onConfirm={() =>
Apis.Asset.AssetCarPorts.Delete({
id: item.id,
}).then(() => action?.reload())
}
/>
),
}}
/>
2026-01-18 18:48:42 +08:00
</Space>
2026-01-08 16:35:06 +08:00
),
}),
]}
/>
</MyPageContainer>
);
}