98 lines
2.7 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';
import { ProTable } from '@ant-design/pro-components';
2025-06-30 14:24:39 +08:00
import { useNavigate } from '@umijs/max';
2025-06-29 18:42:50 +08:00
import { Space } from 'antd';
2025-08-27 11:24:29 +08:00
import ComponentsInfo from './components/ComponentsInfo';
import CompanyCreate from './modals/CompanyCreate';
2025-08-27 11:24:29 +08:00
import CompanyUpdate from './modals/CompanyUpdate';
2025-06-29 18:42:50 +08:00
export default function Index({ title = '机构列表' }) {
2025-06-30 14:24:39 +08:00
const navigate = useNavigate();
2025-07-25 16:42:54 +08:00
// 注册当前页面为标签页
usePageTabs({
tabKey: 'company-companies',
tabLabel: title,
});
2025-06-29 18:42:50 +08:00
return (
<MyPageContainer
2025-07-25 16:42:54 +08:00
title={title}
enableTabs={true}
tabKey="company-companies"
tabLabel={title}
>
2025-06-29 18:42:50 +08:00
<ProTable
{...MyProTableProps.props}
request={async (params, sort) =>
MyProTableProps.request(params, sort, Apis.Company.Companies.List)
}
toolBarRender={(action) => [
<CompanyCreate key="Create" reload={action?.reload} title={title} />,
2025-06-29 18:42:50 +08:00
]}
columns={[
MyColumns.ID(),
{
title: '机构简称',
2025-06-29 18:42:50 +08:00
dataIndex: 'short_name',
search: false,
2025-06-29 18:42:50 +08:00
},
{
title: '企业名称',
dataIndex: 'name',
2025-06-29 18:42:50 +08:00
},
// MyColumns.EnumTag({
// title: '类型',
// dataIndex: 'merchant_type',
// valueEnum: CompaniesMerchantTypeEnum,
// search: false,
// }),
MyColumns.SoftDelete({
onRestore: Apis.Company.Companies.Restore,
onSoftDelete: Apis.Company.Companies.SoftDelete,
search: false,
}),
MyColumns.CreatedAt(),
2025-06-29 18:42:50 +08:00
MyColumns.Option({
render: (_, item: any, index, action) => (
<Space key={index}>
2025-08-27 11:24:29 +08:00
<ComponentsInfo
item={item}
title="查看"
reload={action?.reload}
/>
<CompanyUpdate
item={{ ...item, type: 'link' }}
title="机构"
reload={action?.reload}
/>
2025-06-30 14:24:39 +08:00
<MyButtons.View
2025-08-27 11:24:29 +08:00
title="配置"
2025-09-02 16:22:57 +08:00
data-tooltip-position="top"
2025-06-30 14:24:39 +08:00
onClick={() => {
navigate(`/company/${item.id}`);
2025-06-30 14:24:39 +08:00
}}
/>
2025-06-29 18:42:50 +08:00
<MyButtons.Delete
onConfirm={() =>
Apis.Company.Companies.Delete({ id: item.id }).then(() =>
2025-06-29 18:42:50 +08:00
action?.reload(),
)
}
/>
</Space>
),
}),
]}
/>
</MyPageContainer>
);
}