94 lines
2.6 KiB
TypeScript
Raw Normal View History

2025-09-18 19:40:30 +08:00
import {
MyButtons,
MyColumns,
MyPageContainer,
MyProTableProps,
usePageTabs,
} from '@/common';
2025-06-30 18:42:21 +08:00
import { Apis } from '@/gen/Apis';
import { ProTable } from '@ant-design/pro-components';
2025-09-18 19:40:30 +08:00
import { useNavigate } from '@umijs/max';
2025-06-30 18:42:21 +08:00
import { Space } from 'antd';
import GridCreate from './modals/GridCreate';
import GridMannger from './modals/GridMannger';
import GridShow from './modals/GridShow';
2025-09-18 19:40:30 +08:00
import GridUpdate from './modals/GridUpdate';
2025-06-30 18:42:21 +08:00
2025-09-18 19:40:30 +08:00
export default function Index({ title = '楼栋范围' }) {
const navigate = useNavigate();
// 注册当前页面为标签页
usePageTabs({
tabKey: 'grids',
tabLabel: title,
});
2025-06-30 18:42:21 +08:00
return (
2025-09-18 19:40:30 +08:00
<MyPageContainer
title={title}
enableTabs={true}
tabKey="grids"
tabLabel={title}
>
<ProTable
2025-06-30 18:42:21 +08:00
{...MyProTableProps.props}
request={async (params, sort) =>
2025-09-18 19:40:30 +08:00
MyProTableProps.request(params, sort, Apis.Grid.Grids.List)
2025-06-30 18:42:21 +08:00
}
toolBarRender={(action) => [
2025-09-18 19:40:30 +08:00
<GridCreate key="Select" reload={action?.reload} title="楼栋划分" />,
2025-06-30 18:42:21 +08:00
]}
columns={[
2025-09-18 19:40:30 +08:00
{
title: '关联项目',
dataIndex: ['asset_project', 'name'],
search: {
transform: (value) => {
return { project_name: value };
},
},
},
2025-06-30 18:42:21 +08:00
{
title: 'ID',
2025-06-30 18:42:21 +08:00
dataIndex: 'id',
},
{
title: '板块名称',
2025-06-30 18:42:21 +08:00
dataIndex: 'name',
},
{
2025-09-18 19:40:30 +08:00
title: '标识',
2025-06-30 18:42:21 +08:00
dataIndex: 'grid_mark',
},
2025-07-16 10:18:01 +08:00
{
2025-09-18 19:40:30 +08:00
title: '楼栋管家',
2025-07-16 10:18:01 +08:00
dataIndex: ['company_employee', 'name'],
render: (_, item: any) =>
`${item?.company_employee?.name || ''}-${
item?.company_employee?.phone || ''
}`,
},
// MyColumns.CreatedAt(),
2025-06-30 18:42:21 +08:00
MyColumns.UpdatedAt(),
MyColumns.Option({
render: (_, item: any, index, action) => (
<Space key={index}>
<GridShow item={item} reload={action?.reload} />
2025-09-18 19:40:30 +08:00
<GridUpdate item={item} reload={action?.reload} />
2025-07-16 10:18:01 +08:00
<GridMannger item={item} reload={action?.reload} />
2025-06-30 18:42:21 +08:00
<MyButtons.Delete
onConfirm={() =>
2025-07-17 13:58:54 +08:00
Apis.Grid.Grids.Delete({ id: item.id }).then(() =>
2025-06-30 18:42:21 +08:00
action?.reload(),
)
}
/>
</Space>
),
}),
]}
/>
2025-09-18 19:40:30 +08:00
</MyPageContainer>
2025-06-30 18:42:21 +08:00
);
}