|
@@ -15,20 +15,20 @@ import {
|
|
|
Submit,
|
|
Submit,
|
|
|
Switch,
|
|
Switch,
|
|
|
} from '@formily/antd';
|
|
} from '@formily/antd';
|
|
|
-import type { Field } from '@formily/core';
|
|
|
|
|
-import { createForm, onFieldInit, onFieldValueChange } from '@formily/core';
|
|
|
|
|
-import { createSchemaField, observer } from '@formily/react';
|
|
|
|
|
-import type { ISchema } from '@formily/json-schema';
|
|
|
|
|
|
|
+import type {Field} from '@formily/core';
|
|
|
|
|
+import {createForm, onFieldInit, onFieldValueChange} from '@formily/core';
|
|
|
|
|
+import {createSchemaField, observer} from '@formily/react';
|
|
|
|
|
+import type {ISchema} from '@formily/json-schema';
|
|
|
import styles from './index.less';
|
|
import styles from './index.less';
|
|
|
-import { useEffect, useMemo, useState } from 'react';
|
|
|
|
|
|
|
+import {useEffect, 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, message, Row } from 'antd';
|
|
|
|
|
-import { typeList } from '@/pages/notice';
|
|
|
|
|
-import { configService, service, state } from '@/pages/notice/Template';
|
|
|
|
|
|
|
+import {useParams} from 'umi';
|
|
|
|
|
+import {PageContainer} from '@ant-design/pro-layout';
|
|
|
|
|
+import {Card, Col, message, Row} from 'antd';
|
|
|
|
|
+import {typeList} from '@/pages/notice';
|
|
|
|
|
+import {configService, service, state} from '@/pages/notice/Template';
|
|
|
import FBraftEditor from '@/components/FBraftEditor';
|
|
import FBraftEditor from '@/components/FBraftEditor';
|
|
|
-import { useAsyncDataSource } from '@/utils/util';
|
|
|
|
|
|
|
+import {useAsyncDataSource} from '@/utils/util';
|
|
|
import WeixinCorp from '@/pages/notice/Template/Detail/doc/WeixinCorp';
|
|
import WeixinCorp from '@/pages/notice/Template/Detail/doc/WeixinCorp';
|
|
|
import WeixinApp from '@/pages/notice/Template/Detail/doc/WeixinApp';
|
|
import WeixinApp from '@/pages/notice/Template/Detail/doc/WeixinApp';
|
|
|
import DingTalk from '@/pages/notice/Template/Detail/doc/DingTalk';
|
|
import DingTalk from '@/pages/notice/Template/Detail/doc/DingTalk';
|
|
@@ -39,31 +39,31 @@ import Email from '@/pages/notice/Template/Detail/doc/Email';
|
|
|
|
|
|
|
|
export const docMap = {
|
|
export const docMap = {
|
|
|
weixin: {
|
|
weixin: {
|
|
|
- corpMessage: <WeixinCorp />,
|
|
|
|
|
- officialMessage: <WeixinApp />,
|
|
|
|
|
|
|
+ corpMessage: <WeixinCorp/>,
|
|
|
|
|
+ officialMessage: <WeixinApp/>,
|
|
|
},
|
|
},
|
|
|
dingTalk: {
|
|
dingTalk: {
|
|
|
- dingTalkMessage: <DingTalk />,
|
|
|
|
|
- dingTalkRobotWebHook: <DingTalkRebot />,
|
|
|
|
|
|
|
+ dingTalkMessage: <DingTalk/>,
|
|
|
|
|
+ dingTalkRobotWebHook: <DingTalkRebot/>,
|
|
|
},
|
|
},
|
|
|
voice: {
|
|
voice: {
|
|
|
- aliyun: <AliyunVoice />,
|
|
|
|
|
|
|
+ aliyun: <AliyunVoice/>,
|
|
|
},
|
|
},
|
|
|
sms: {
|
|
sms: {
|
|
|
- aliyunSms: <AliyunSms />,
|
|
|
|
|
|
|
+ aliyunSms: <AliyunSms/>,
|
|
|
},
|
|
},
|
|
|
email: {
|
|
email: {
|
|
|
- embedded: <Email />,
|
|
|
|
|
|
|
+ embedded: <Email/>,
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const Detail = observer(() => {
|
|
const Detail = observer(() => {
|
|
|
- const { id } = useParams<{ id: string }>();
|
|
|
|
|
|
|
+ const {id} = useParams<{ id: string }>();
|
|
|
|
|
|
|
|
const getConfig = () =>
|
|
const getConfig = () =>
|
|
|
configService
|
|
configService
|
|
|
.queryNoPagingPost({
|
|
.queryNoPagingPost({
|
|
|
- terms: [{ column: 'type$IN', value: id }],
|
|
|
|
|
|
|
+ terms: [{column: 'type$IN', value: id}],
|
|
|
})
|
|
})
|
|
|
.then((resp: any) => {
|
|
.then((resp: any) => {
|
|
|
return resp.result?.map((item: any) => ({
|
|
return resp.result?.map((item: any) => ({
|
|
@@ -87,39 +87,29 @@ const Detail = observer(() => {
|
|
|
const [provider, setProvider] = useState<string>();
|
|
const [provider, setProvider] = useState<string>();
|
|
|
// 正则提取${}里面的值
|
|
// 正则提取${}里面的值
|
|
|
const pattern = /(?<=\$\{).*?(?=\})/g;
|
|
const pattern = /(?<=\$\{).*?(?=\})/g;
|
|
|
|
|
+
|
|
|
const form = useMemo(
|
|
const form = useMemo(
|
|
|
() =>
|
|
() =>
|
|
|
createForm({
|
|
createForm({
|
|
|
validateFirst: true,
|
|
validateFirst: true,
|
|
|
effects() {
|
|
effects() {
|
|
|
- onFieldInit('template.message', (field, form1) => {
|
|
|
|
|
|
|
+ onFieldInit('template.message', (field) => {
|
|
|
if (id === 'email') {
|
|
if (id === 'email') {
|
|
|
field.setComponent(FBraftEditor);
|
|
field.setComponent(FBraftEditor);
|
|
|
- // form1.setValuesIn('template.message', 'testtt')
|
|
|
|
|
}
|
|
}
|
|
|
- console.log(form1);
|
|
|
|
|
- ///给FBraftEditor 设置初始值
|
|
|
|
|
});
|
|
});
|
|
|
onFieldValueChange('provider', (field) => {
|
|
onFieldValueChange('provider', (field) => {
|
|
|
const value = field.value;
|
|
const value = field.value;
|
|
|
setProvider(value);
|
|
setProvider(value);
|
|
|
});
|
|
});
|
|
|
onFieldValueChange('template.message', (field, form1) => {
|
|
onFieldValueChange('template.message', (field, form1) => {
|
|
|
- let value = (field as Field).value;
|
|
|
|
|
- try {
|
|
|
|
|
- if (id === 'email' && form1.modified) {
|
|
|
|
|
- value = value?.toHTML();
|
|
|
|
|
- }
|
|
|
|
|
- console.log(value, 'value');
|
|
|
|
|
- const idList = value
|
|
|
|
|
- ?.match(pattern)
|
|
|
|
|
- ?.filter((i: string) => i)
|
|
|
|
|
- .map((item: string) => ({ id: item, type: 'string', format: '--' }));
|
|
|
|
|
- if (form1.modified) {
|
|
|
|
|
- form1.setValuesIn('variableDefinitions', idList);
|
|
|
|
|
- }
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- message.error('邮件数据反显开发中...');
|
|
|
|
|
|
|
+ const value = (field as Field).value;
|
|
|
|
|
+ const idList = (typeof value === 'string') && value
|
|
|
|
|
+ ?.match(pattern)
|
|
|
|
|
+ ?.filter((i: string) => i)
|
|
|
|
|
+ .map((item: string) => ({id: item, type: 'string', format: '--'}));
|
|
|
|
|
+ if (form1.modified) {
|
|
|
|
|
+ form1.setValuesIn('variableDefinitions', idList);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
onFieldValueChange('variableDefinitions.*.type', (field) => {
|
|
onFieldValueChange('variableDefinitions.*.type', (field) => {
|
|
@@ -129,11 +119,11 @@ const Detail = observer(() => {
|
|
|
case 'date':
|
|
case 'date':
|
|
|
format.setComponent(Select);
|
|
format.setComponent(Select);
|
|
|
format.setDataSource([
|
|
format.setDataSource([
|
|
|
- { label: 'String类型的UTC时间戳 (毫秒)', value: 'string' },
|
|
|
|
|
- { label: 'yyyy-MM-dd', value: 'yyyy-MM-dd' },
|
|
|
|
|
- { label: 'yyyy-MM-dd HH:mm:ss', value: 'yyyy-MM-dd HH:mm:ss' },
|
|
|
|
|
- { label: 'yyyy-MM-dd HH:mm:ss EE', value: 'yyyy-MM-dd HH:mm:ss EE' },
|
|
|
|
|
- { label: 'yyyy-MM-dd HH:mm:ss zzz', value: 'yyyy-MM-dd HH:mm:ss zzz' },
|
|
|
|
|
|
|
+ {label: 'String类型的UTC时间戳 (毫秒)', value: 'string'},
|
|
|
|
|
+ {label: 'yyyy-MM-dd', value: 'yyyy-MM-dd'},
|
|
|
|
|
+ {label: 'yyyy-MM-dd HH:mm:ss', value: 'yyyy-MM-dd HH:mm:ss'},
|
|
|
|
|
+ {label: 'yyyy-MM-dd HH:mm:ss EE', value: 'yyyy-MM-dd HH:mm:ss EE'},
|
|
|
|
|
+ {label: 'yyyy-MM-dd HH:mm:ss zzz', value: 'yyyy-MM-dd HH:mm:ss zzz'},
|
|
|
]);
|
|
]);
|
|
|
format.setValue('string');
|
|
format.setValue('string');
|
|
|
break;
|
|
break;
|
|
@@ -148,9 +138,9 @@ const Detail = observer(() => {
|
|
|
case 'file':
|
|
case 'file':
|
|
|
format.setComponent(Select);
|
|
format.setComponent(Select);
|
|
|
format.setDataSource([
|
|
format.setDataSource([
|
|
|
- { label: '视频', value: 'video' },
|
|
|
|
|
- { label: '图片', value: 'img' },
|
|
|
|
|
- { label: '全部', value: 'any' },
|
|
|
|
|
|
|
+ {label: '视频', value: 'video'},
|
|
|
|
|
+ {label: '图片', value: 'img'},
|
|
|
|
|
+ {label: '全部', value: 'any'},
|
|
|
]);
|
|
]);
|
|
|
format.setValue('any');
|
|
format.setValue('any');
|
|
|
break;
|
|
break;
|
|
@@ -219,7 +209,7 @@ const Detail = observer(() => {
|
|
|
}
|
|
}
|
|
|
if (id === 'email') {
|
|
if (id === 'email') {
|
|
|
data.provider = 'embedded';
|
|
data.provider = 'embedded';
|
|
|
- data.template.text = data.template.message.toHTML();
|
|
|
|
|
|
|
+ data.template.text = data.template.message;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
let response;
|
|
let response;
|
|
@@ -384,8 +374,8 @@ const Detail = observer(() => {
|
|
|
'x-component': 'Radio.Group',
|
|
'x-component': 'Radio.Group',
|
|
|
'x-decorator': 'FormItem',
|
|
'x-decorator': 'FormItem',
|
|
|
enum: [
|
|
enum: [
|
|
|
- { label: '是', value: true },
|
|
|
|
|
- { label: '否', value: false },
|
|
|
|
|
|
|
+ {label: '是', value: true},
|
|
|
|
|
+ {label: '否', value: false},
|
|
|
],
|
|
],
|
|
|
},
|
|
},
|
|
|
userIdList: {
|
|
userIdList: {
|
|
@@ -440,9 +430,9 @@ const Detail = observer(() => {
|
|
|
'x-component': 'Select',
|
|
'x-component': 'Select',
|
|
|
'x-decorator': 'FormItem',
|
|
'x-decorator': 'FormItem',
|
|
|
enum: [
|
|
enum: [
|
|
|
- { label: 'markdown', value: 'markdown' },
|
|
|
|
|
- { label: 'text', value: 'text' },
|
|
|
|
|
- { label: 'link', value: 'link' },
|
|
|
|
|
|
|
+ {label: 'markdown', value: 'markdown'},
|
|
|
|
|
+ {label: 'text', value: 'text'},
|
|
|
|
|
+ {label: 'link', value: 'link'},
|
|
|
],
|
|
],
|
|
|
},
|
|
},
|
|
|
markdown: {
|
|
markdown: {
|
|
@@ -640,14 +630,6 @@ const Detail = observer(() => {
|
|
|
tip: '请输入收件人邮箱,多个收件人用换行分隔',
|
|
tip: '请输入收件人邮箱,多个收件人用换行分隔',
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
- // message: {
|
|
|
|
|
- // "x-component": 'FBraftEditor',
|
|
|
|
|
- // "x-decorator": 'FormItem',
|
|
|
|
|
- // title: '模版内容',
|
|
|
|
|
- // "x-decorator-props": {
|
|
|
|
|
- // tip: '请输入收件人邮箱,多个收件人用换行分隔'
|
|
|
|
|
- // },
|
|
|
|
|
- // },
|
|
|
|
|
attachments: {
|
|
attachments: {
|
|
|
type: 'array',
|
|
type: 'array',
|
|
|
title: '附件信息',
|
|
title: '附件信息',
|
|
@@ -660,15 +642,13 @@ const Detail = observer(() => {
|
|
|
},
|
|
},
|
|
|
items: {
|
|
items: {
|
|
|
type: 'object',
|
|
type: 'object',
|
|
|
-
|
|
|
|
|
- 'x-component': 'FormGrid',
|
|
|
|
|
- 'x-component-props': {
|
|
|
|
|
|
|
+ 'x-decorator': 'FormGrid',
|
|
|
|
|
+ 'x-decorator-props': {
|
|
|
maxColumns: 24,
|
|
maxColumns: 24,
|
|
|
minColumns: 24,
|
|
minColumns: 24,
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
properties: {
|
|
properties: {
|
|
|
- file: {
|
|
|
|
|
|
|
+ '{url:location,name:name}': {
|
|
|
'x-component': 'FUpload',
|
|
'x-component': 'FUpload',
|
|
|
'x-decorator': 'FormItem',
|
|
'x-decorator': 'FormItem',
|
|
|
'x-decorator-props': {
|
|
'x-decorator-props': {
|
|
@@ -679,6 +659,7 @@ const Detail = observer(() => {
|
|
|
},
|
|
},
|
|
|
'x-component-props': {
|
|
'x-component-props': {
|
|
|
type: 'file',
|
|
type: 'file',
|
|
|
|
|
+ display: 'name',
|
|
|
placeholder: '请上传文件',
|
|
placeholder: '请上传文件',
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -722,8 +703,8 @@ const Detail = observer(() => {
|
|
|
'x-decorator': 'FormItem',
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'ArrayTable',
|
|
'x-component': 'ArrayTable',
|
|
|
'x-component-props': {
|
|
'x-component-props': {
|
|
|
- pagination: { pageSize: 9999 },
|
|
|
|
|
- scroll: { x: '100%' },
|
|
|
|
|
|
|
+ pagination: {pageSize: 9999},
|
|
|
|
|
+ scroll: {x: '100%'},
|
|
|
},
|
|
},
|
|
|
items: {
|
|
items: {
|
|
|
type: 'object',
|
|
type: 'object',
|
|
@@ -731,7 +712,7 @@ const Detail = observer(() => {
|
|
|
column1: {
|
|
column1: {
|
|
|
type: 'void',
|
|
type: 'void',
|
|
|
'x-component': 'ArrayTable.Column',
|
|
'x-component': 'ArrayTable.Column',
|
|
|
- 'x-component-props': { title: '变量', width: '120px' },
|
|
|
|
|
|
|
+ 'x-component-props': {title: '变量', width: '120px'},
|
|
|
properties: {
|
|
properties: {
|
|
|
id: {
|
|
id: {
|
|
|
type: 'string',
|
|
type: 'string',
|
|
@@ -744,7 +725,7 @@ const Detail = observer(() => {
|
|
|
column2: {
|
|
column2: {
|
|
|
type: 'void',
|
|
type: 'void',
|
|
|
'x-component': 'ArrayTable.Column',
|
|
'x-component': 'ArrayTable.Column',
|
|
|
- 'x-component-props': { title: '名称' },
|
|
|
|
|
|
|
+ 'x-component-props': {title: '名称'},
|
|
|
properties: {
|
|
properties: {
|
|
|
name: {
|
|
name: {
|
|
|
type: 'string',
|
|
type: 'string',
|
|
@@ -757,7 +738,7 @@ const Detail = observer(() => {
|
|
|
column3: {
|
|
column3: {
|
|
|
type: 'void',
|
|
type: 'void',
|
|
|
'x-component': 'ArrayTable.Column',
|
|
'x-component': 'ArrayTable.Column',
|
|
|
- 'x-component-props': { title: '类型', width: '120px' },
|
|
|
|
|
|
|
+ 'x-component-props': {title: '类型', width: '120px'},
|
|
|
properties: {
|
|
properties: {
|
|
|
type: {
|
|
type: {
|
|
|
type: 'string',
|
|
type: 'string',
|
|
@@ -765,11 +746,11 @@ const Detail = observer(() => {
|
|
|
'x-component': 'Select',
|
|
'x-component': 'Select',
|
|
|
required: true,
|
|
required: true,
|
|
|
enum: [
|
|
enum: [
|
|
|
- { label: '字符串', value: 'string' },
|
|
|
|
|
- { label: '时间', value: 'date' },
|
|
|
|
|
- { label: '数字', value: 'number' },
|
|
|
|
|
- { label: '文件', value: 'file' },
|
|
|
|
|
- { label: '其他', value: 'other' },
|
|
|
|
|
|
|
+ {label: '字符串', value: 'string'},
|
|
|
|
|
+ {label: '时间', value: 'date'},
|
|
|
|
|
+ {label: '数字', value: 'number'},
|
|
|
|
|
+ {label: '文件', value: 'file'},
|
|
|
|
|
+ {label: '其他', value: 'other'},
|
|
|
],
|
|
],
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -777,7 +758,7 @@ const Detail = observer(() => {
|
|
|
column4: {
|
|
column4: {
|
|
|
type: 'void',
|
|
type: 'void',
|
|
|
'x-component': 'ArrayTable.Column',
|
|
'x-component': 'ArrayTable.Column',
|
|
|
- 'x-component-props': { title: '格式', width: '150px' },
|
|
|
|
|
|
|
+ 'x-component-props': {title: '格式', width: '150px'},
|
|
|
required: true,
|
|
required: true,
|
|
|
properties: {
|
|
properties: {
|
|
|
format: {
|
|
format: {
|