116 lines
3.1 KiB
TypeScript
116 lines
3.1 KiB
TypeScript
import {
|
|
MyButtons,
|
|
MyColumns,
|
|
MyPageContainer,
|
|
MyProTableProps,
|
|
usePageTabs,
|
|
} from '@/common';
|
|
import { Apis } from '@/gen/Apis';
|
|
import { ConvenienceServicesTypeEnum } from '@/gen/Enums';
|
|
import { ProTable } from '@ant-design/pro-components';
|
|
import { useNavigate } from '@umijs/max';
|
|
import { Space } from 'antd';
|
|
import BannerCreate from './modals/ServiceCreate';
|
|
import ServiceUpdate from './modals/ServiceUpdate';
|
|
|
|
export default function Index({ title = '便民服务' }) {
|
|
const navigate = useNavigate();
|
|
|
|
// 注册当前页面为标签页
|
|
usePageTabs({
|
|
tabKey: 'convenience_services',
|
|
tabLabel: title,
|
|
});
|
|
|
|
return (
|
|
<MyPageContainer
|
|
title={title}
|
|
enableTabs={true}
|
|
tabKey="banners"
|
|
tabLabel={title}
|
|
>
|
|
<ProTable
|
|
{...MyProTableProps.props}
|
|
request={async (params, sort) =>
|
|
MyProTableProps.request(
|
|
params,
|
|
sort,
|
|
Apis.Common.ConvenienceServices.List,
|
|
)
|
|
}
|
|
toolBarRender={(action) => [
|
|
<BannerCreate key="Create" reload={action?.reload} title={title} />,
|
|
]}
|
|
columns={[
|
|
MyColumns.ID(),
|
|
{
|
|
title: '关联项目',
|
|
dataIndex: ['asset_project', 'name'],
|
|
search: {
|
|
transform: (value) => {
|
|
return { project_name: value };
|
|
},
|
|
},
|
|
},
|
|
MyColumns.EnumTag({
|
|
title: '类型',
|
|
dataIndex: 'type',
|
|
valueEnum: ConvenienceServicesTypeEnum,
|
|
search: false,
|
|
}),
|
|
{
|
|
title: '服务名称',
|
|
dataIndex: 'name',
|
|
},
|
|
|
|
{
|
|
title: '联系方式',
|
|
render(_, record) {
|
|
const content = record?.content || [];
|
|
|
|
// 过滤有效数据
|
|
const validItems = content.filter(
|
|
(item: any) => item?.name && item?.phone,
|
|
);
|
|
|
|
return (
|
|
<div style={{ lineHeight: '1.6' }}>
|
|
{validItems.length > 0 ? (
|
|
validItems.map((item: any, index: number) => (
|
|
// 每个客户信息单独一行
|
|
<div key={index}>
|
|
{item.name}: {item.phone}
|
|
</div>
|
|
))
|
|
) : (
|
|
<span>暂无客户信息</span>
|
|
)}
|
|
</div>
|
|
);
|
|
},
|
|
search: false,
|
|
},
|
|
MyColumns.Option({
|
|
render: (_, item: any, index, action) => (
|
|
<Space key={index}>
|
|
<ServiceUpdate
|
|
item={item}
|
|
reload={action?.reload}
|
|
title={title}
|
|
/>
|
|
<MyButtons.Delete
|
|
onConfirm={() =>
|
|
Apis.Common.ConvenienceServices.Delete({
|
|
id: item.id,
|
|
}).then(() => action?.reload())
|
|
}
|
|
/>
|
|
</Space>
|
|
),
|
|
}),
|
|
]}
|
|
/>
|
|
</MyPageContainer>
|
|
);
|
|
}
|