mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:39:05 +08:00
feat: action 支持发送邮件 (#1842)
* feat: action 支持发送邮件 * feat: action 支持发送邮件 Co-authored-by: yupeng12 <yupeng12@baidu.com>
This commit is contained in:
parent
01b432cfe2
commit
ea215312a1
@ -389,6 +389,49 @@ icon 也可以是 url 地址,比如
|
||||
| url | `string` | - | 按钮点击后,会打开指定页面。可用 `${xxx}` 取值。 |
|
||||
| blank | `boolean` | `false` | 如果为 `true` 将在新 tab 页面打开。 |
|
||||
|
||||
## 发送邮件
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"label": "发送邮件",
|
||||
"type": "button",
|
||||
"actionType": "email",
|
||||
"to": "amis@baidu.com",
|
||||
"cc": "baidu@baidu.com",
|
||||
"subject": "这是邮件主题",
|
||||
"body": "这是邮件正文"
|
||||
}
|
||||
```
|
||||
|
||||
### 异步获取数据
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "page",
|
||||
"initApi": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/mail/mailInfo",
|
||||
"body": {
|
||||
"label": "发送邮件",
|
||||
"type": "button",
|
||||
"actionType": "email",
|
||||
"to": "${to}",
|
||||
"cc": "${cc}",
|
||||
"subject": "${subject}",
|
||||
"body": "${body}"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**属性表**
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ---------- | -------- | ------- | -------------------------------- |
|
||||
| actionType | `string` | `email` | 点击后显示一个弹出框 |
|
||||
| to | `string` | - | 收件人邮箱,可用 ${xxx} 取值。 |
|
||||
| cc | `string` | - | 抄送邮箱,可用 ${xxx} 取值。 |
|
||||
| bcc | `string` | - | 匿名抄送邮箱,可用 ${xxx} 取值。 |
|
||||
| subject | `string` | - | 邮件主题,可用 ${xxx} 取值。 |
|
||||
| body | `string` | - | 邮件正文,可用 ${xxx} 取值。 |
|
||||
|
||||
## 弹框
|
||||
|
||||
```schema: scope="body"
|
||||
|
@ -8,6 +8,9 @@ import {IRootStore, RootStore} from './store/root';
|
||||
import {Action} from './types';
|
||||
import {bulkBindFunctions, guid, isVisible} from './utils/helper';
|
||||
import {filter} from './utils/tpl';
|
||||
import qs from 'qs';
|
||||
import pick from 'lodash/pick';
|
||||
import mapValues from 'lodash/mapValues';
|
||||
|
||||
export interface RootRendererProps extends RootProps {
|
||||
location?: any;
|
||||
@ -111,6 +114,14 @@ export class RootRenderer extends React.Component<RootRendererProps> {
|
||||
action,
|
||||
ctx
|
||||
);
|
||||
} else if (action.actionType === 'email') {
|
||||
const mailTo = filter(action.to, ctx);
|
||||
const mailInfo = mapValues(pick(action, 'to', 'cc', 'bcc', 'subject', 'body'), val => filter(val, ctx));
|
||||
const mailStr = qs.stringify(mailInfo);
|
||||
const mailto = `mailto:${mailTo}?${mailStr}`;
|
||||
|
||||
window.open(mailto);
|
||||
|
||||
} else if (action.actionType === 'dialog') {
|
||||
store.setCurrentAction(action);
|
||||
store.openDialog(ctx);
|
||||
|
@ -222,6 +222,38 @@ export interface ReloadActionSchema extends ButtonSchema {
|
||||
target?: SchemaReload;
|
||||
}
|
||||
|
||||
export interface EmailActionSchema extends ButtonSchema {
|
||||
/**
|
||||
* 指定为打开邮箱行为
|
||||
*/
|
||||
actionType: 'email';
|
||||
|
||||
/**
|
||||
* 收件人邮箱
|
||||
*/
|
||||
to: string;
|
||||
|
||||
/**
|
||||
* 抄送邮箱
|
||||
*/
|
||||
cc?: string;
|
||||
|
||||
/**
|
||||
* 匿名抄送邮箱
|
||||
*/
|
||||
bcc?: string;
|
||||
|
||||
/**
|
||||
* 邮件主题
|
||||
*/
|
||||
subject?: string;
|
||||
|
||||
/**
|
||||
* 邮件正文
|
||||
*/
|
||||
body?: string;
|
||||
}
|
||||
|
||||
export interface OtherActionSchema extends ButtonSchema {
|
||||
actionType:
|
||||
| 'prev'
|
||||
@ -252,6 +284,7 @@ export type ActionSchema =
|
||||
| DrawerActionSchema
|
||||
| CopyActionSchema
|
||||
| ReloadActionSchema
|
||||
| EmailActionSchema
|
||||
| OtherActionSchema
|
||||
| VanillaAction;
|
||||
|
||||
@ -274,6 +307,10 @@ const ActionProps = [
|
||||
'blank',
|
||||
'tooltipPlacement',
|
||||
'to',
|
||||
'cc',
|
||||
'bcc',
|
||||
'subject',
|
||||
'body',
|
||||
'content',
|
||||
'required',
|
||||
'type',
|
||||
@ -319,6 +356,7 @@ export interface ActionProps
|
||||
Omit<DrawerActionSchema, 'type' | 'className' | 'iconClassName'>,
|
||||
Omit<CopyActionSchema, 'type' | 'className' | 'iconClassName'>,
|
||||
Omit<ReloadActionSchema, 'type' | 'className' | 'iconClassName'>,
|
||||
Omit<EmailActionSchema, 'type' | 'className' | 'iconClassName'>,
|
||||
Omit<OtherActionSchema, 'type' | 'className' | 'iconClassName'> {
|
||||
actionType: any;
|
||||
onAction?: (
|
||||
|
@ -85,6 +85,7 @@ export interface Action extends Button {
|
||||
| 'jump'
|
||||
| 'link'
|
||||
| 'url'
|
||||
| 'email'
|
||||
| 'close'
|
||||
| 'confirm'
|
||||
| 'add'
|
||||
@ -106,6 +107,10 @@ export interface Action extends Button {
|
||||
target?: string;
|
||||
link?: string;
|
||||
url?: string;
|
||||
cc?: string;
|
||||
bcc?: string;
|
||||
subject?: string;
|
||||
body?: string;
|
||||
mergeData?: boolean;
|
||||
reload?: string;
|
||||
messages?: {
|
||||
|
Loading…
Reference in New Issue
Block a user