From aff0d1dbfb86274d92aafa9938f3f97a3fe95a3e Mon Sep 17 00:00:00 2001 From: cs Date: Wed, 18 Sep 2024 17:52:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/message/my/index.tsx | 64 ++++++++++-------------------------- src/pages/message/template/index.tsx | 15 +++------ 2 files changed, 21 insertions(+), 58 deletions(-) diff --git a/src/pages/message/my/index.tsx b/src/pages/message/my/index.tsx index f1f4080..3915f36 100644 --- a/src/pages/message/my/index.tsx +++ b/src/pages/message/my/index.tsx @@ -16,7 +16,7 @@ const i18nPrefix = 'msgMy.list' const MdwMessage = () => { - const {styles, cx} = useStyle() + const {styles} = useStyle() const {t} = useTranslation() const [form] = Form.useForm() const [filterForm] = Form.useForm() @@ -31,13 +31,6 @@ const MdwMessage = () => { const [searchKey, setSearchKey] = useState(search?.title) const [templateType, setTemplateType] = useState('') - const typeHandlerChange = (value: string) => { - if (value !== 'EMAIL') { - setTemplateTitle('') - form.setFieldsValue({'title': undefined}) - } - setTemplateType(value) - } const templateChange = (index: number) => { if (templateList && index !== undefined) { @@ -51,8 +44,6 @@ const MdwMessage = () => { setCurrentTemplate(templateList[index]) form.setFieldsValue({...templateList[index], 'fieldList': result}) setTemplateType(templateList[index].type) - setTemplateTitle(templateList[index].title) - setTemplateContent(templateList[index].content) } else { form.resetFields() setTemplateType('') @@ -60,44 +51,10 @@ const MdwMessage = () => { } } - const [templateTitle, setTemplateTitle] = useState(''); - const [templateContent, setTemplateContent] = useState(''); - - useEffect(() => { - handleChange() - }, [templateTitle, templateContent]); - - const handleContentChange = (e) => { - const value = e.target.value; - setTemplateContent(value) - }; - - const titheHandleContentChange = (e) => { - const value = e.target.value; - setTemplateTitle(value) - }; - - const handleChange = () => { - // 使用正则表达式匹配 ${var} 格式的变量 - const regex = /\${\.([a-zA-Z0-9_]+)}/g; - const matches = [...(templateTitle + templateContent).matchAll(regex)]; - - // 提取变量名 - const variables = Array.from(new Set(matches.map(match => match[1]))); - const result = variables.map(item => { - return { - field_key: item, - field_value: '' - }; - }); - form.setFieldsValue({'fieldList': result}) - }; - const handleInputChange = (index, e) => { form.getFieldValue("fieldList")[index].field_value = e.target.value } - const drawerColumns = useMemo(() => { return [ { @@ -136,7 +93,7 @@ const MdwMessage = () => { {label: 'Telegram', value: 'TG'} ], allowClear: false, - onChange: typeHandlerChange + disabled: true, }, formItemProps: { rules: [ @@ -147,13 +104,26 @@ const MdwMessage = () => { } }, { + title: t(`${i18nPrefix}.columns.token`, 'Telegram Token'), + dataIndex: 'token', + valueType: 'text', + formItemProps: { + hidden: templateType != 'TG', + rules: [ + { + required: templateType == 'TG', + } + ] + }, + }, + { title: t(`${i18nPrefix}.columns.title`, '标题'), dataIndex: 'title', valueType: 'text', fieldProps: { maxLength: 100, showCount: true, - onChange: titheHandleContentChange, + disabled: true, }, formItemProps: { tooltip: '支持邮件类型', @@ -174,7 +144,7 @@ const MdwMessage = () => { maxLength: 1000, showCount: true, rows: 15, - onChange: handleContentChange, + disabled: true, }, formItemProps: { rules: [ diff --git a/src/pages/message/template/index.tsx b/src/pages/message/template/index.tsx index c481efc..d925110 100644 --- a/src/pages/message/template/index.tsx +++ b/src/pages/message/template/index.tsx @@ -77,6 +77,10 @@ const MdwMessage = () => { }; const typeHandlerChange = (value) => { + if (value !== 'EMAIL') { + setTemplateTitle('') + form.setFieldsValue({'title': undefined}) + } setTemplateType(value) } @@ -184,17 +188,6 @@ const MdwMessage = () => { ); } }, - { - title: t(`${i18nPrefix}.columns.dest`, '收件人(多个收件人用英文逗号隔开,如果类型是TG,则填token)'), - dataIndex: 'dest', - valueType: 'textarea', - fieldProps: { - maxLength: 1000, - showCount: true, - rows: 15, - placeholder: 'aaa@qq.com,bbb@gmail.com', - }, - }, ] as ProColumns[] }, [isDeleting, currentTemplate, search, templateField, templateType])