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 {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 {useAtom, useAtomValue} from 'jotai' |
||||
import React, {useEffect, useMemo, useState} from 'react' |
import React, {useEffect, useMemo, useState} from 'react' |
||||
import {BetaSchemaForm, ProColumns, ProFormColumnsType,} from '@ant-design/pro-components' |
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 {msgListAtom, msgSearchAtom, saveMsgAtom} from "@/store/message/my.ts"; |
||||
import {templateAllListAtom} from "@/store/message/template.ts"; |
import {templateAllListAtom} from "@/store/message/template.ts"; |
||||
import {coverType, IMsgTemplate} from "@/types/message/template.ts"; |
import {coverType, IMsgTemplate} from "@/types/message/template.ts"; |
||||
|
import dayjs from "dayjs"; |
||||
|
|
||||
const i18nPrefix = 'msgMy.list' |
const i18nPrefix = 'msgMy.list' |
||||
|
|
||||
@ -83,7 +84,7 @@ const MdwMessage = () => { |
|||||
} |
} |
||||
}, |
}, |
||||
{ |
{ |
||||
title: t(`${i18nPrefix}.columns.type`, '消息类型'), |
|
||||
|
title: t(`${i18nPrefix}.columns.type`, '通道类型'), |
||||
dataIndex: 'type', |
dataIndex: 'type', |
||||
valueType: 'select', |
valueType: 'select', |
||||
fieldProps: { |
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', |
dataIndex: 'token', |
||||
valueType: 'text', |
valueType: 'text', |
||||
|
fieldProps: { |
||||
|
placeholder: "请输入 @BotFather 获取到的BOT的API Token" |
||||
|
}, |
||||
formItemProps: { |
formItemProps: { |
||||
hidden: templateType != 'TG', |
hidden: templateType != 'TG', |
||||
rules: [ |
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', |
dataIndex: 'dest', |
||||
valueType: 'textarea', |
valueType: 'textarea', |
||||
fieldProps: { |
fieldProps: { |
||||
maxLength: 1000, |
maxLength: 1000, |
||||
showCount: true, |
showCount: true, |
||||
rows: 5, |
rows: 5, |
||||
placeholder: '[email protected],[email protected]', |
|
||||
|
placeholder: '[email protected],[email protected],-1001953214222,-1001953214333', |
||||
}, |
}, |
||||
formItemProps: { |
formItemProps: { |
||||
rules: [ |
rules: [ |
||||
@ -225,7 +229,19 @@ const MdwMessage = () => { |
|||||
dataIndex: 'content', |
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', |
dataIndex: 'dest', |
||||
}, |
}, |
||||
{ |
{ |
||||
@ -240,28 +256,13 @@ const MdwMessage = () => { |
|||||
{ |
{ |
||||
title: t(`${i18nPrefix}.columns.send_at`, '发送时间'), |
title: t(`${i18nPrefix}.columns.send_at`, '发送时间'), |
||||
dataIndex: '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(() => { |
useEffect(() => { |
||||
|
|
||||
@ -354,6 +355,9 @@ const MdwMessage = () => { |
|||||
}) |
}) |
||||
}, |
}, |
||||
}} |
}} |
||||
|
expandable={{ |
||||
|
expandedRowRender, |
||||
|
}} |
||||
/> |
/> |
||||
<BetaSchemaForm |
<BetaSchemaForm |
||||
grid={true} |
grid={true} |
||||
@ -376,7 +380,7 @@ const MdwMessage = () => { |
|||||
|
|
||||
}} |
}} |
||||
onFinish={async (values) => { |
onFinish={async (values) => { |
||||
saveOrUpdate({...values, "template_id": currentTemplate?.id}) |
|
||||
|
saveOrUpdate({...values, "alias": currentTemplate?.alias}) |
||||
}} |
}} |
||||
columns={drawerColumns as ProFormColumnsType[]}/> |
columns={drawerColumns as ProFormColumnsType[]}/> |
||||
<BetaSchemaForm |
<BetaSchemaForm |
||||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue