|
@@ -1,14 +1,15 @@
|
|
|
-import { Modal } from 'antd';
|
|
|
|
|
import {
|
|
import {
|
|
|
ArrayTable,
|
|
ArrayTable,
|
|
|
Editable,
|
|
Editable,
|
|
|
Form,
|
|
Form,
|
|
|
|
|
+ FormButtonGroup,
|
|
|
FormItem,
|
|
FormItem,
|
|
|
Input,
|
|
Input,
|
|
|
PreviewText,
|
|
PreviewText,
|
|
|
Radio,
|
|
Radio,
|
|
|
Select,
|
|
Select,
|
|
|
Space,
|
|
Space,
|
|
|
|
|
+ Submit,
|
|
|
Switch,
|
|
Switch,
|
|
|
} from '@formily/antd';
|
|
} from '@formily/antd';
|
|
|
import type { Field } from '@formily/core';
|
|
import type { Field } from '@formily/core';
|
|
@@ -16,19 +17,25 @@ import { createForm, onFieldValueChange } from '@formily/core';
|
|
|
import { createSchemaField } from '@formily/react';
|
|
import { createSchemaField } from '@formily/react';
|
|
|
import type { ISchema } from '@formily/json-schema';
|
|
import type { ISchema } from '@formily/json-schema';
|
|
|
import styles from './index.less';
|
|
import styles from './index.less';
|
|
|
-import { useMemo } from 'react';
|
|
|
|
|
|
|
+import { useMemo, useState } from 'react';
|
|
|
import FUpload from '@/components/Upload';
|
|
import FUpload from '@/components/Upload';
|
|
|
|
|
+import { useParams } from 'umi';
|
|
|
|
|
+import { PageContainer } from '@ant-design/pro-layout';
|
|
|
|
|
+import { Card, Col, Row } from 'antd';
|
|
|
|
|
|
|
|
-interface Props {
|
|
|
|
|
- type: 'weixin' | 'dingTalk' | 'voice' | 'sms' | 'email';
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-const Detail = (props: Props) => {
|
|
|
|
|
- const { type = 'dingTalk' } = props;
|
|
|
|
|
|
|
+const createImageLabel = (image: string, text: string) => {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <>
|
|
|
|
|
+ <img alt="" height="100px" src={image} />
|
|
|
|
|
+ <div style={{ textAlign: 'center' }}>{text}</div>
|
|
|
|
|
+ </>
|
|
|
|
|
+ );
|
|
|
|
|
+};
|
|
|
|
|
+const Detail = () => {
|
|
|
|
|
+ const { id } = useParams<{ id: string }>();
|
|
|
|
|
|
|
|
// 正则提取${}里面的值
|
|
// 正则提取${}里面的值
|
|
|
const pattern = /(?<=\$\{).*?(?=\})/g;
|
|
const pattern = /(?<=\$\{).*?(?=\})/g;
|
|
|
- // console.log(pattern.test(str));
|
|
|
|
|
const form = useMemo(
|
|
const form = useMemo(
|
|
|
() =>
|
|
() =>
|
|
|
createForm({
|
|
createForm({
|
|
@@ -44,7 +51,7 @@ const Detail = (props: Props) => {
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
}),
|
|
}),
|
|
|
- [type],
|
|
|
|
|
|
|
+ [id],
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
const SchemaField = createSchemaField({
|
|
const SchemaField = createSchemaField({
|
|
@@ -62,89 +69,59 @@ const Detail = (props: Props) => {
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ const [result, setResult] = useState<any>({});
|
|
|
|
|
+ const handleSave = async () => {
|
|
|
|
|
+ const data = await form.submit();
|
|
|
|
|
+ setResult(data);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
const typeList = {
|
|
const typeList = {
|
|
|
weixin: [
|
|
weixin: [
|
|
|
{
|
|
{
|
|
|
- label: (
|
|
|
|
|
- <>
|
|
|
|
|
- <img
|
|
|
|
|
- alt=""
|
|
|
|
|
- height="100px"
|
|
|
|
|
- src="https://lf1-cdn-tos.bytegoofy.com/goofy/lark/passport/staticfiles/passport/OKR.png"
|
|
|
|
|
- />
|
|
|
|
|
- <div style={{ textAlign: 'center' }}>企业消息</div>
|
|
|
|
|
- </>
|
|
|
|
|
|
|
+ label: createImageLabel(
|
|
|
|
|
+ 'https://lf1-cdn-tos.bytegoofy.com/goofy/lark/passport/staticfiles/passport/OKR.png',
|
|
|
|
|
+ '企业消息',
|
|
|
),
|
|
),
|
|
|
value: 'corpMessage',
|
|
value: 'corpMessage',
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- label: (
|
|
|
|
|
- <>
|
|
|
|
|
- <img
|
|
|
|
|
- alt=""
|
|
|
|
|
- height="100px"
|
|
|
|
|
- src="https://lf1-cdn-tos.bytegoofy.com/goofy/lark/passport/staticfiles/passport/Hire.png"
|
|
|
|
|
- />
|
|
|
|
|
- <div style={{ textAlign: 'center' }}>服务号消息</div>
|
|
|
|
|
- </>
|
|
|
|
|
|
|
+ label: createImageLabel(
|
|
|
|
|
+ 'https://lf1-cdn-tos.bytegoofy.com/goofy/lark/passport/staticfiles/passport/Hire.png',
|
|
|
|
|
+ '服务号消息',
|
|
|
),
|
|
),
|
|
|
value: 'officialMessage',
|
|
value: 'officialMessage',
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
dingTalk: [
|
|
dingTalk: [
|
|
|
{
|
|
{
|
|
|
- label: (
|
|
|
|
|
- <>
|
|
|
|
|
- <img
|
|
|
|
|
- alt=""
|
|
|
|
|
- height="100px"
|
|
|
|
|
- src="https://lf1-cdn-tos.bytegoofy.com/goofy/lark/passport/staticfiles/passport/OKR.png"
|
|
|
|
|
- />
|
|
|
|
|
- <div style={{ textAlign: 'center' }}>钉钉消息</div>
|
|
|
|
|
- </>
|
|
|
|
|
|
|
+ label: createImageLabel(
|
|
|
|
|
+ 'https://lf1-cdn-tos.bytegoofy.com/goofy/lark/passport/staticfiles/passport/OKR.png',
|
|
|
|
|
+ '钉钉消息',
|
|
|
),
|
|
),
|
|
|
value: 'dingTalkMessage',
|
|
value: 'dingTalkMessage',
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- label: (
|
|
|
|
|
- <>
|
|
|
|
|
- <img
|
|
|
|
|
- alt=""
|
|
|
|
|
- height="100px"
|
|
|
|
|
- src="https://lf1-cdn-tos.bytegoofy.com/goofy/lark/passport/staticfiles/passport/Hire.png"
|
|
|
|
|
- />
|
|
|
|
|
- <div style={{ textAlign: 'center' }}>群机器人消息</div>
|
|
|
|
|
- </>
|
|
|
|
|
|
|
+ label: createImageLabel(
|
|
|
|
|
+ 'https://lf1-cdn-tos.bytegoofy.com/goofy/lark/passport/staticfiles/passport/Hire.png',
|
|
|
|
|
+ '群机器人消息',
|
|
|
),
|
|
),
|
|
|
value: 'dingTalkRobotWebHook',
|
|
value: 'dingTalkRobotWebHook',
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
voice: [
|
|
voice: [
|
|
|
{
|
|
{
|
|
|
- label: (
|
|
|
|
|
- <>
|
|
|
|
|
- <img
|
|
|
|
|
- alt=""
|
|
|
|
|
- height="100px"
|
|
|
|
|
- src="https://lf1-cdn-tos.bytegoofy.com/goofy/lark/passport/staticfiles/passport/OKR.png"
|
|
|
|
|
- />
|
|
|
|
|
- <div style={{ textAlign: 'center' }}>阿里云语音</div>
|
|
|
|
|
- </>
|
|
|
|
|
|
|
+ label: createImageLabel(
|
|
|
|
|
+ 'https://lf1-cdn-tos.bytegoofy.com/goofy/lark/passport/staticfiles/passport/OKR.png',
|
|
|
|
|
+ '阿里云语音',
|
|
|
),
|
|
),
|
|
|
value: 'aliyun',
|
|
value: 'aliyun',
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
sms: [
|
|
sms: [
|
|
|
{
|
|
{
|
|
|
- label: (
|
|
|
|
|
- <>
|
|
|
|
|
- <img
|
|
|
|
|
- alt=""
|
|
|
|
|
- height="100px"
|
|
|
|
|
- src="https://lf1-cdn-tos.bytegoofy.com/goofy/lark/passport/staticfiles/passport/OKR.png"
|
|
|
|
|
- />
|
|
|
|
|
- <div style={{ textAlign: 'center' }}>阿里云短信</div>
|
|
|
|
|
- </>
|
|
|
|
|
|
|
+ label: createImageLabel(
|
|
|
|
|
+ 'https://lf1-cdn-tos.bytegoofy.com/goofy/lark/passport/staticfiles/passport/OKR.png',
|
|
|
|
|
+ '阿里云短信',
|
|
|
),
|
|
),
|
|
|
value: 'aliyunSms',
|
|
value: 'aliyunSms',
|
|
|
},
|
|
},
|
|
@@ -185,20 +162,27 @@ const Detail = (props: Props) => {
|
|
|
'x-component-props': {
|
|
'x-component-props': {
|
|
|
optionType: 'button',
|
|
optionType: 'button',
|
|
|
},
|
|
},
|
|
|
- enum: typeList[type] || [],
|
|
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ 'x-visible': typeList[id]?.length > 0,
|
|
|
|
|
+ enum: typeList[id] || [],
|
|
|
},
|
|
},
|
|
|
configId: {
|
|
configId: {
|
|
|
title: '绑定配置',
|
|
title: '绑定配置',
|
|
|
type: 'string',
|
|
type: 'string',
|
|
|
'x-decorator': 'FormItem',
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Select',
|
|
'x-component': 'Select',
|
|
|
|
|
+ enum: [
|
|
|
|
|
+ { label: '测试配置1', value: 'test1' },
|
|
|
|
|
+ { label: '测试配置2', value: 'test2' },
|
|
|
|
|
+ { label: '测试配置3', value: 'test3' },
|
|
|
|
|
+ ],
|
|
|
},
|
|
},
|
|
|
template: {
|
|
template: {
|
|
|
type: 'object',
|
|
type: 'object',
|
|
|
properties: {
|
|
properties: {
|
|
|
weixin: {
|
|
weixin: {
|
|
|
type: 'void',
|
|
type: 'void',
|
|
|
- 'x-visible': type === 'weixin',
|
|
|
|
|
|
|
+ 'x-visible': id === 'weixin',
|
|
|
properties: {
|
|
properties: {
|
|
|
agentID: {
|
|
agentID: {
|
|
|
title: 'AgentId',
|
|
title: 'AgentId',
|
|
@@ -248,7 +232,7 @@ const Detail = (props: Props) => {
|
|
|
},
|
|
},
|
|
|
dingTalk: {
|
|
dingTalk: {
|
|
|
type: 'void',
|
|
type: 'void',
|
|
|
- 'x-visible': type === 'dingTalk',
|
|
|
|
|
|
|
+ 'x-visible': id === 'dingTalk',
|
|
|
properties: {
|
|
properties: {
|
|
|
dingTalkMessage: {
|
|
dingTalkMessage: {
|
|
|
type: 'void',
|
|
type: 'void',
|
|
@@ -388,6 +372,7 @@ const Detail = (props: Props) => {
|
|
|
type: 'void',
|
|
type: 'void',
|
|
|
properties: {
|
|
properties: {
|
|
|
voice: {
|
|
voice: {
|
|
|
|
|
+ 'x-visible': id === 'voice',
|
|
|
type: 'object',
|
|
type: 'object',
|
|
|
properties: {
|
|
properties: {
|
|
|
// ttsCode String 语音-模版ID
|
|
// ttsCode String 语音-模版ID
|
|
@@ -409,6 +394,7 @@ const Detail = (props: Props) => {
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
sms: {
|
|
sms: {
|
|
|
|
|
+ 'x-visible': id === 'sms',
|
|
|
type: 'object',
|
|
type: 'object',
|
|
|
properties: {
|
|
properties: {
|
|
|
code: {
|
|
code: {
|
|
@@ -433,6 +419,7 @@ const Detail = (props: Props) => {
|
|
|
},
|
|
},
|
|
|
email: {
|
|
email: {
|
|
|
type: 'object',
|
|
type: 'object',
|
|
|
|
|
+ 'x-visible': id === 'email',
|
|
|
properties: {
|
|
properties: {
|
|
|
// subject String 邮件-模板ID
|
|
// subject String 邮件-模板ID
|
|
|
// sendTo Array 邮件-收件人
|
|
// sendTo Array 邮件-收件人
|
|
@@ -441,6 +428,8 @@ const Detail = (props: Props) => {
|
|
|
|
|
|
|
|
subject: {
|
|
subject: {
|
|
|
title: '模版ID',
|
|
title: '模版ID',
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-component': 'Input',
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -549,11 +538,25 @@ const Detail = (props: Props) => {
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
return (
|
|
return (
|
|
|
- <Modal width={'40vw'} visible={true} title="通知模版详情">
|
|
|
|
|
- <Form className={styles.form} form={form} layout={'vertical'}>
|
|
|
|
|
- <SchemaField schema={schema} />
|
|
|
|
|
- </Form>
|
|
|
|
|
- </Modal>
|
|
|
|
|
|
|
+ <PageContainer>
|
|
|
|
|
+ <Card>
|
|
|
|
|
+ <Row>
|
|
|
|
|
+ <Col span={10}>
|
|
|
|
|
+ <Form className={styles.form} form={form} layout={'vertical'}>
|
|
|
|
|
+ <SchemaField schema={schema} />
|
|
|
|
|
+ <FormButtonGroup.Sticky>
|
|
|
|
|
+ <FormButtonGroup.FormItem>
|
|
|
|
|
+ <Submit onSubmit={handleSave}>保存</Submit>
|
|
|
|
|
+ </FormButtonGroup.FormItem>
|
|
|
|
|
+ </FormButtonGroup.Sticky>
|
|
|
|
|
+ </Form>
|
|
|
|
|
+ </Col>
|
|
|
|
|
+ <Col span={12} push={2}>
|
|
|
|
|
+ {JSON.stringify(result, null, 2)}
|
|
|
|
|
+ </Col>
|
|
|
|
|
+ </Row>
|
|
|
|
|
+ </Card>
|
|
|
|
|
+ </PageContainer>
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
export default Detail;
|
|
export default Detail;
|