137 lines
4.1 KiB
TypeScript
Raw Normal View History

2025-06-29 18:42:50 +08:00
import {
MyButtons,
MyColumns,
MyPageContainer,
MyProTableProps,
2025-07-25 16:42:54 +08:00
usePageTabs,
2025-06-29 18:42:50 +08:00
} from '@/common';
import { Apis } from '@/gen/Apis';
2025-07-17 13:58:54 +08:00
import { AssetProjectsPropertyTypeEnum } from '@/gen/Enums';
2025-06-29 18:42:50 +08:00
import { ProTable } from '@ant-design/pro-components';
import { Space } from 'antd';
import { useNavigate } from 'react-router-dom';
import AssetInfo from './components/AssetInfo';
2025-08-27 11:24:29 +08:00
import AssetCreate from './modals/AssetCreate';
import AssetUpdate from './modals/AssetUpdate';
2025-06-29 18:42:50 +08:00
export default function Index({ title = '项目列表' }) {
2025-06-29 18:42:50 +08:00
const navigate = useNavigate();
2025-07-25 16:42:54 +08:00
// 注册当前页面为标签页
usePageTabs({
tabKey: 'asset-projects',
tabLabel: title,
});
2025-06-29 18:42:50 +08:00
return (
<MyPageContainer title={title}>
<ProTable
{...MyProTableProps.props}
2025-06-30 14:20:46 +08:00
// search={false}
2025-06-29 18:42:50 +08:00
request={async (params, sort) =>
MyProTableProps.request(params, sort, Apis.Asset.AssetProjects.List)
}
2025-07-25 16:42:54 +08:00
// headerTitle="项目列表"
2025-06-29 18:42:50 +08:00
toolBarRender={(action) => [
2025-08-27 11:24:29 +08:00
<AssetCreate key="Create" reload={action?.reload} title={'项目'} />,
2025-06-29 18:42:50 +08:00
]}
columns={[
MyColumns.ID(),
2025-06-30 14:20:46 +08:00
MyColumns.EnumTag({
title: '类型',
2025-06-30 14:20:46 +08:00
dataIndex: 'property_type',
valueEnum: AssetProjectsPropertyTypeEnum,
2025-06-30 18:42:21 +08:00
search: false,
2025-06-30 14:20:46 +08:00
}),
2025-06-29 18:42:50 +08:00
{
title: '项目名称',
dataIndex: 'name',
},
2025-06-30 14:20:46 +08:00
// {
2025-07-17 13:58:54 +08:00
// title: '项目别名',
// dataIndex: 'alias_name',
2025-06-30 14:20:46 +08:00
// },
2025-06-29 18:42:50 +08:00
{
2025-06-30 14:20:46 +08:00
title: '地址',
render: (_, i: any) => {
return `${i?.province || ''}${i?.city || ''}${i?.district || ''}${
i?.address || ''
}`;
},
2025-06-30 18:42:21 +08:00
search: false,
2025-06-29 18:42:50 +08:00
},
2025-07-17 13:58:54 +08:00
// MyColumns.EnumTag({
// title: '项目状态',
// dataIndex: 'status',
// valueEnum: AssetProjectsStatusEnum,
// search: false,
// }),
// MyColumns.EnumTag({
// title: '委托类型',
// dataIndex: 'entrust_type',
// valueEnum: AssetProjectsEntrustTypeEnum,
// search: false,
// }),
// MyColumns.EnumTag({
// title: '收费方式',
// dataIndex: 'charge',
// valueEnum: AssetProjectsChargeEnum,
// search: false,
// }),
2025-06-30 14:20:46 +08:00
MyColumns.SoftDelete({
title: '启/禁用',
onRestore: Apis.Asset.AssetProjects.Restore,
onSoftDelete: Apis.Asset.AssetProjects.SoftDelete,
search: false,
2025-06-29 18:42:50 +08:00
}),
2025-09-08 17:22:58 +08:00
{
title: '物业品牌',
dataIndex: ['company_property_brand', 'name'],
search: false,
},
{
2025-09-18 19:40:30 +08:00
title: '关联机构',
dataIndex: ['company', 'name'],
search: {
transform: (value) => {
return { company_name: value };
},
},
},
2025-06-30 14:20:46 +08:00
// {
// title: '接管日期',
// dataIndex: 'takeover_date',
// search:false,
// },
// {
// title: '封园日期',
// dataIndex: 'closure_date',
// search:false,
// },
2025-06-29 18:42:50 +08:00
MyColumns.CreatedAt(),
MyColumns.Option({
render: (_, item: any, index, action) => (
<Space key={index}>
<AssetInfo item={item} title="查看" reload={action?.reload} />
<AssetUpdate item={item} title="项目" reload={action?.reload} />
2025-06-29 18:42:50 +08:00
<MyButtons.View
2025-09-03 09:25:23 +08:00
title="配置"
2025-06-29 18:42:50 +08:00
onClick={() => {
2025-09-18 19:40:30 +08:00
navigate(`/asset/list/show/${item.id}`);
2025-06-29 18:42:50 +08:00
}}
/>
<MyButtons.Delete
onConfirm={() =>
Apis.Common.Admins.Delete({ id: item.id }).then(() =>
action?.reload(),
)
}
/>
</Space>
),
}),
]}
/>
</MyPageContainer>
);
}