cs
2 months ago
6 changed files with 92 additions and 35 deletions
-
1package.json
-
60src/pages/message/my/index.tsx
-
55src/pages/message/template/index.tsx
-
2src/store/message/my.ts
-
8src/types/message/my.ts
-
1src/types/message/template.ts
@ -1,5 +1,5 @@ |
|||
import {useTranslation} from '@/i18n.ts' |
|||
import {Badge, Button, Divider, Form, Input, Select, Space, Tooltip} from 'antd' |
|||
import {Badge, Button, Divider, Form, Input, Select, Space, Table, TableColumnsType, Tooltip} from 'antd' |
|||
import {useAtom, useAtomValue} from 'jotai' |
|||
import React, {useEffect, useMemo, useState} from 'react' |
|||
import {BetaSchemaForm, ProColumns, ProFormColumnsType,} from '@ant-design/pro-components' |
|||
@ -11,6 +11,7 @@ import {Table as ProTable} from '@/components/table' |
|||
import {msgListAtom, msgSearchAtom, saveMsgAtom} from "@/store/message/my.ts"; |
|||
import {templateAllListAtom} from "@/store/message/template.ts"; |
|||
import {coverType, IMsgTemplate} from "@/types/message/template.ts"; |
|||
import dayjs from "dayjs"; |
|||
|
|||
const i18nPrefix = 'msgMy.list' |
|||
|
|||
@ -83,7 +84,7 @@ const MdwMessage = () => { |
|||
} |
|||
}, |
|||
{ |
|||
title: t(`${i18nPrefix}.columns.type`, '消息类型'), |
|||
title: t(`${i18nPrefix}.columns.type`, '通道类型'), |
|||
dataIndex: 'type', |
|||
valueType: 'select', |
|||
fieldProps: { |
|||
@ -104,9 +105,12 @@ const MdwMessage = () => { |
|||
} |
|||
}, |
|||
{ |
|||
title: t(`${i18nPrefix}.columns.token`, 'Telegram Token'), |
|||
title: t(`${i18nPrefix}.columns.token`, 'Telegram BOT API Token'), |
|||
dataIndex: 'token', |
|||
valueType: 'text', |
|||
fieldProps: { |
|||
placeholder: "请输入 @BotFather 获取到的BOT的API Token" |
|||
}, |
|||
formItemProps: { |
|||
hidden: templateType != 'TG', |
|||
rules: [ |
|||
@ -179,14 +183,14 @@ const MdwMessage = () => { |
|||
}, |
|||
}, |
|||
{ |
|||
title: t(`${i18nPrefix}.columns.dest`, '收件人(多个收件人用英文逗号隔开,如果类型是TG,则填token)'), |
|||
title: t(`${i18nPrefix}.columns.dest`, '收件人(多个收件人用英文逗号隔开;如果类型是Telegram,请填写User ID或Chat ID)'), |
|||
dataIndex: 'dest', |
|||
valueType: 'textarea', |
|||
fieldProps: { |
|||
maxLength: 1000, |
|||
showCount: true, |
|||
rows: 5, |
|||
placeholder: '[email protected],[email protected]', |
|||
placeholder: '[email protected],[email protected],-1001953214222,-1001953214333', |
|||
}, |
|||
formItemProps: { |
|||
rules: [ |
|||
@ -225,7 +229,19 @@ const MdwMessage = () => { |
|||
dataIndex: 'content', |
|||
}, |
|||
{ |
|||
title: t(`${i18nPrefix}.columns.dest`, '收件人'), |
|||
title: t(`${i18nPrefix}.columns.send_at`, '预计发送时间'), |
|||
dataIndex: 'send_at', |
|||
render: (_, record) => { |
|||
return <div>{record.send_at == 0 ? "立即" : dayjs(record.send_at).format('YYYY-MM-DD HH:mm:ss')}</div> |
|||
} |
|||
}, |
|||
] as ProColumns[] |
|||
}, [search, currentTemplate]) |
|||
|
|||
const expandedRowRender = (record) => { |
|||
const expandedColumns: TableColumnsType = [ |
|||
{ |
|||
title: "收件人", |
|||
dataIndex: 'dest', |
|||
}, |
|||
{ |
|||
@ -240,28 +256,13 @@ const MdwMessage = () => { |
|||
{ |
|||
title: t(`${i18nPrefix}.columns.send_at`, '发送时间'), |
|||
dataIndex: 'send_at', |
|||
render: (_, record) => { |
|||
return <div>{record.send_at == 0 ? 0 : dayjs(record.send_at*1000).format('YYYY-MM-DD HH:mm:ss')}</div> |
|||
} |
|||
}, |
|||
// {
|
|||
// title: t(`${i18nPrefix}.columns.option`, '操作'),
|
|||
// key: 'option',
|
|||
// valueType: 'option',
|
|||
// fixed: 'right',
|
|||
// render: (_, record) => [
|
|||
// <Popconfirm
|
|||
// key={'del_confirm'}
|
|||
// disabled={isDeleting}
|
|||
// onConfirm={() => {
|
|||
// deleteAppPackage(record.id)
|
|||
// }}
|
|||
// title={t('message.deleteConfirm')}>
|
|||
// <a key="del">
|
|||
// {t('actions.delete', '删除')}
|
|||
// </a>
|
|||
// </Popconfirm>,
|
|||
// ]
|
|||
// }
|
|||
] as ProColumns[] |
|||
}, [search, currentTemplate]) |
|||
]; |
|||
return <Table columns={expandedColumns} dataSource={record.dest} pagination={false}/>; |
|||
} |
|||
|
|||
useEffect(() => { |
|||
|
|||
@ -354,6 +355,9 @@ const MdwMessage = () => { |
|||
}) |
|||
}, |
|||
}} |
|||
expandable={{ |
|||
expandedRowRender, |
|||
}} |
|||
/> |
|||
<BetaSchemaForm |
|||
grid={true} |
|||
@ -376,7 +380,7 @@ const MdwMessage = () => { |
|||
|
|||
}} |
|||
onFinish={async (values) => { |
|||
saveOrUpdate({...values, "template_id": currentTemplate?.id}) |
|||
saveOrUpdate({...values, "alias": currentTemplate?.alias}) |
|||
}} |
|||
columns={drawerColumns as ProFormColumnsType[]}/> |
|||
<BetaSchemaForm |
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue