153 lines
4.4 KiB
TypeScript
Raw Normal View History

2025-09-26 21:02:38 +08:00
import {
MyButtons,
MyColumns,
MyPageContainer,
MyProTableProps,
usePageTabs,
} from '@/common';
import { Apis } from '@/gen/Apis';
2025-09-30 14:30:47 +08:00
import {
CustomerMomentsChannelEnum,
CustomerMomentsContentTypeEnum,
2025-10-10 00:28:59 +08:00
CustomerMomentsPushStatusEnum,
2025-09-30 14:30:47 +08:00
CustomerMomentsPushTypeEnum,
CustomerMomentsTaskEndTypeEnum,
} from '@/gen/Enums';
2025-09-26 21:02:38 +08:00
import { ProTable } from '@ant-design/pro-components';
2025-09-30 14:30:47 +08:00
import { Card, Space } from 'antd';
2025-09-26 21:02:38 +08:00
import Create from './modals/Create';
2025-10-09 23:24:10 +08:00
export default function Index({ title = '创建内容' }) {
2025-09-26 21:02:38 +08:00
// 注册当前页面为标签页
usePageTabs({
tabKey: 'moments-list',
tabLabel: title,
});
return (
<MyPageContainer
title={title}
enableTabs={true}
tabKey="moments-list"
tabLabel={title}
>
<ProTable
{...MyProTableProps.props}
expandable={{
defaultExpandAllRows: true,
}}
request={async (params, sort) =>
MyProTableProps.request(
params,
sort,
Apis.Customer.CustomerMoments.List,
)
}
toolBarRender={(action) => [
<Create key="Create" reload={action?.reload} title={title} />,
]}
columns={[
MyColumns.ID(),
2025-10-10 00:28:59 +08:00
MyColumns.EnumTag({
title: '任务推送',
dataIndex: 'push_status',
valueEnum: CustomerMomentsPushStatusEnum,
search: false,
}),
2025-09-26 21:02:38 +08:00
{
2025-10-10 00:28:59 +08:00
title: '标题',
2025-09-30 14:30:47 +08:00
dataIndex: 'title',
render: (_, i: any) => {
return (
<Card size="small">
<Space align="start">
<div>{i?.title}</div>
2025-10-10 00:28:59 +08:00
<img
src={
i?.cover_image?.length > 0
? i?.cover_image[0]?.url
: i?.attachments[0]?.url
}
width={45}
height={45}
/>
2025-09-30 14:30:47 +08:00
</Space>
</Card>
);
},
},
MyColumns.EnumTag({
title: '发送渠道',
dataIndex: 'channel',
valueEnum: CustomerMomentsChannelEnum,
}),
MyColumns.EnumTag({
title: '内容类型',
dataIndex: 'content_type',
valueEnum: CustomerMomentsContentTypeEnum,
}),
MyColumns.EnumTag({
title: '推送类型',
dataIndex: 'push_type',
valueEnum: CustomerMomentsPushTypeEnum,
}),
{
2025-10-10 00:28:59 +08:00
title: '推送时间',
2025-09-30 14:30:47 +08:00
dataIndex: 'scheduled_time',
search: false,
},
MyColumns.EnumTag({
title: '任务结束类型',
dataIndex: 'task_end_type',
valueEnum: CustomerMomentsTaskEndTypeEnum,
search: false,
}),
{
2025-10-10 00:28:59 +08:00
title: '任务结束时间',
2025-09-30 14:30:47 +08:00
dataIndex: 'task_days',
search: false,
2025-10-10 00:28:59 +08:00
render: (_, record: any) => {
return record?.task_end_type === 'AfterNDays'
? `任务发送后:${record?.task_days}`
: '${record?.task_end_time}';
},
2025-09-30 14:30:47 +08:00
},
2025-10-10 00:28:59 +08:00
2025-09-26 21:02:38 +08:00
MyColumns.UpdatedAt(),
MyColumns.CreatedAt(),
MyColumns.Option({
render: (_, item: any, index, action) => (
<Space key={index}>
2025-09-30 14:30:47 +08:00
{/* <Update item={item} reload={action?.reload} title={title} /> */}
<MyButtons.Default
isConfirm
title="发送"
type="primary"
disabled={
item?.push_type === 'ScheduledPush' ||
item?.push_status === 'Pushed'
}
description="确定发送?"
onConfirm={() => {
Apis.Customer.CustomerMoments.Send({
id: item.id,
}).then(() => action?.reload());
}}
/>
{/* <MyButtons.Delete
2025-09-26 21:02:38 +08:00
onConfirm={() =>
2025-09-30 14:30:47 +08:00
Apis.Customer.CustomerMoments.Delete({
2025-09-26 21:02:38 +08:00
id: item.id,
}).then(() => action?.reload())
}
2025-09-30 14:30:47 +08:00
/> */}
2025-09-26 21:02:38 +08:00
</Space>
),
}),
]}
/>
</MyPageContainer>
);
}