|
@@ -3,14 +3,20 @@ import { App, Button } from 'antd';
|
|
|
import {
|
|
|
ActionType,
|
|
|
ModalForm,
|
|
|
- ProFormDependency,
|
|
|
+ ProFormDependency, ProFormDigit,
|
|
|
ProFormRadio,
|
|
|
ProFormSelect,
|
|
|
ProFormText,
|
|
|
} from '@ant-design/pro-components';
|
|
|
import { phoneList, userIdList, validCron, whitespaceForbidden } from '@/constants/rules';
|
|
|
import { addAppTask, updateAppTask } from '@/services/api/appTask';
|
|
|
-import { conversationTypeEnum } from '@/constants/enums';
|
|
|
+import {
|
|
|
+ taskAlertTypeEnum,
|
|
|
+ booleanEnum,
|
|
|
+ conversationTypeEnum,
|
|
|
+ fileMethodEnum,
|
|
|
+ subdirectoryMethodEnum
|
|
|
+} from '@/constants/enums';
|
|
|
import { getAppRobotOptions } from '@/services/api/appRobot';
|
|
|
import { getAppSftpOptions } from '@/services/api/appSftp';
|
|
|
|
|
@@ -26,7 +32,7 @@ const UpdateAppTask: React.FC<{
|
|
|
/** 提交数据 */
|
|
|
const onFinish = async (values: any) => {
|
|
|
if (
|
|
|
- conversationTypeEnum.SINGLE.toString() === values?.conversationType &&
|
|
|
+ conversationTypeEnum.SINGLE === values?.conversationType &&
|
|
|
!values?.phones &&
|
|
|
!values?.userIds
|
|
|
) {
|
|
@@ -96,16 +102,14 @@ const UpdateAppTask: React.FC<{
|
|
|
<ProFormRadio.Group
|
|
|
name="conversationType"
|
|
|
label="会话类型"
|
|
|
- initialValue={
|
|
|
- record?.conversationType ? record.conversationType.toString() : record?.conversationType
|
|
|
- }
|
|
|
+ initialValue={record?.conversationType}
|
|
|
valueEnum={conversationTypeEnum.valueEnum}
|
|
|
rules={[{ required: true }]}
|
|
|
/>
|
|
|
<ProFormDependency name={['conversationType']}>
|
|
|
{({ conversationType }) => {
|
|
|
// 单聊表单项
|
|
|
- if (conversationTypeEnum.SINGLE.toString() === conversationType) {
|
|
|
+ if (conversationTypeEnum.SINGLE === conversationType) {
|
|
|
return (
|
|
|
<>
|
|
|
<ProFormText
|
|
@@ -125,7 +129,7 @@ const UpdateAppTask: React.FC<{
|
|
|
}
|
|
|
|
|
|
// 群聊表单项
|
|
|
- if (conversationTypeEnum.GROUP.toString() === conversationType) {
|
|
|
+ if (conversationTypeEnum.GROUP === conversationType) {
|
|
|
return (
|
|
|
<ProFormText
|
|
|
name="openConversationId"
|
|
@@ -160,26 +164,231 @@ const UpdateAppTask: React.FC<{
|
|
|
}}
|
|
|
/>
|
|
|
<ProFormText
|
|
|
- name="dataDir"
|
|
|
- label="数据文件夹(绝对路径)"
|
|
|
- initialValue={record?.dataDir}
|
|
|
+ name="masterDir"
|
|
|
+ label="数据主文件夹(绝对路径)"
|
|
|
+ initialValue={record?.masterDir}
|
|
|
rules={[
|
|
|
{
|
|
|
required: true,
|
|
|
},
|
|
|
- whitespaceForbidden,
|
|
|
]}
|
|
|
/>
|
|
|
- <ProFormText
|
|
|
- name="filePattern"
|
|
|
- label="文件名匹配正则表达式"
|
|
|
- initialValue={record?.filePattern}
|
|
|
- rules={[
|
|
|
- {
|
|
|
- required: true,
|
|
|
- },
|
|
|
- ]}
|
|
|
+ <ProFormRadio.Group
|
|
|
+ name="hasSubdirectory"
|
|
|
+ label="是否有子文件夹"
|
|
|
+ initialValue={record?.hasSubdirectory}
|
|
|
+ valueEnum={booleanEnum.valueEnum}
|
|
|
+ rules={[{ required: true }]}
|
|
|
+ />
|
|
|
+ <ProFormDependency name={['hasSubdirectory']}>
|
|
|
+ {({ hasSubdirectory }) => {
|
|
|
+ if (booleanEnum.TRUE === hasSubdirectory) {
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <ProFormRadio.Group
|
|
|
+ name="subdirectoryMethod"
|
|
|
+ label="子文件夹匹配方式"
|
|
|
+ initialValue={record?.subdirectoryMethod}
|
|
|
+ valueEnum={subdirectoryMethodEnum.valueEnum}
|
|
|
+ rules={[{ required: true }]}
|
|
|
+ />
|
|
|
+ <ProFormDependency name={['subdirectoryMethod']}>
|
|
|
+ {({ subdirectoryMethod }) => {
|
|
|
+ let t;
|
|
|
+ if (fileMethodEnum.MONTH === subdirectoryMethod) {
|
|
|
+ t = '月'
|
|
|
+ } else if (fileMethodEnum.DAY === subdirectoryMethod) {
|
|
|
+ t = '天'
|
|
|
+ }
|
|
|
+ if (subdirectoryMethodEnum.MONTH === subdirectoryMethod
|
|
|
+ || subdirectoryMethodEnum.DAY === subdirectoryMethod) {
|
|
|
+ return (
|
|
|
+ <ProFormDigit
|
|
|
+ name={'dirTimeDelay'}
|
|
|
+ label={'子文件夹时延(' + t + ')'}
|
|
|
+ initialValue={record?.dirTimeDelay ?? 0}
|
|
|
+ fieldProps={{ precision: 0 }}
|
|
|
+ rules={[{ required: true }]}
|
|
|
+ min={Number.MIN_SAFE_INTEGER}
|
|
|
+ />
|
|
|
+ )
|
|
|
+ }
|
|
|
+ if (subdirectoryMethodEnum.REG_EXP === subdirectoryMethod) {
|
|
|
+ return (
|
|
|
+ <ProFormText
|
|
|
+ name="subdirectoryPattern"
|
|
|
+ label="匹配最新子文件夹正则表达式"
|
|
|
+ initialValue={record?.subdirectoryPattern}
|
|
|
+ rules={[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ )
|
|
|
+ }
|
|
|
+ return (<></>);
|
|
|
+ }}
|
|
|
+ </ProFormDependency>
|
|
|
+ </>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ return (<></>);
|
|
|
+ }}
|
|
|
+ </ProFormDependency>
|
|
|
+ <ProFormRadio.Group
|
|
|
+ name="fileToText"
|
|
|
+ label="txt、md文件是否转为文本"
|
|
|
+ initialValue={record?.fileToText}
|
|
|
+ valueEnum={booleanEnum.valueEnum}
|
|
|
+ rules={[{ required: true }]}
|
|
|
+ />
|
|
|
+ <ProFormRadio.Group
|
|
|
+ name="fileMethod"
|
|
|
+ label="文件匹配方式"
|
|
|
+ initialValue={record?.fileMethod}
|
|
|
+ valueEnum={fileMethodEnum.valueEnum}
|
|
|
+ rules={[{ required: true }]}
|
|
|
/>
|
|
|
+ <ProFormDependency name={['fileMethod']}>
|
|
|
+ {({ fileMethod }) => {
|
|
|
+ let t;
|
|
|
+ if (fileMethodEnum.MONTH === fileMethod) {
|
|
|
+ t = '月'
|
|
|
+ } else if (fileMethodEnum.DAY === fileMethod) {
|
|
|
+ t = '天'
|
|
|
+ }
|
|
|
+ if (fileMethodEnum.MONTH === fileMethod
|
|
|
+ || fileMethodEnum.DAY === fileMethod) {
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <ProFormDigit
|
|
|
+ name={'fileTimeDelay'}
|
|
|
+ label={'文件时延(' + t + ')'}
|
|
|
+ initialValue={record?.fileTimeDelay ?? 0}
|
|
|
+ fieldProps={{ precision: 0 }}
|
|
|
+ rules={[{ required: true }]}
|
|
|
+ min={Number.MIN_SAFE_INTEGER}
|
|
|
+ />
|
|
|
+ <ProFormText
|
|
|
+ name="filePrefix"
|
|
|
+ label="文件前缀"
|
|
|
+ initialValue={record?.filePrefix}
|
|
|
+ rules={[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ <ProFormText
|
|
|
+ name="fileExtension"
|
|
|
+ label="文件扩展名"
|
|
|
+ initialValue={record?.fileExtension}
|
|
|
+ rules={[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ </>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ if (fileMethodEnum.REG_EXP === fileMethod) {
|
|
|
+ return (
|
|
|
+ <ProFormText
|
|
|
+ name="filePattern"
|
|
|
+ label="文件匹配正则表达式"
|
|
|
+ initialValue={record?.filePattern}
|
|
|
+ rules={[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ )
|
|
|
+ }
|
|
|
+ return (<></>);
|
|
|
+ }}
|
|
|
+ </ProFormDependency>
|
|
|
+ <ProFormDigit
|
|
|
+ name={'taskTimeout'}
|
|
|
+ label={'任务超时时间(秒)'}
|
|
|
+ initialValue={record?.taskTimeout ?? 60}
|
|
|
+ fieldProps={{ precision: 0 }}
|
|
|
+ rules={[{ required: true }]}
|
|
|
+ min={1}
|
|
|
+ />
|
|
|
+ <ProFormDigit
|
|
|
+ name={'maxRetryTimes'}
|
|
|
+ label={'最大失败重试次数'}
|
|
|
+ initialValue={record?.maxRetryTimes ?? 0}
|
|
|
+ fieldProps={{ precision: 0 }}
|
|
|
+ rules={[{ required: true }]}
|
|
|
+ min={0}
|
|
|
+ />
|
|
|
+ <ProFormDigit
|
|
|
+ name={'retryInterval'}
|
|
|
+ label={'重试间隔(秒)'}
|
|
|
+ initialValue={record?.retryInterval ?? 3600}
|
|
|
+ fieldProps={{ precision: 0 }}
|
|
|
+ rules={[{ required: true }]}
|
|
|
+ min={0}
|
|
|
+ />
|
|
|
+ <ProFormRadio.Group
|
|
|
+ name="alertType"
|
|
|
+ label="告警方式"
|
|
|
+ initialValue={record?.alertType ?? taskAlertTypeEnum.DEFAULT}
|
|
|
+ valueEnum={taskAlertTypeEnum.valueEnum}
|
|
|
+ rules={[{ required: true }]}
|
|
|
+ />
|
|
|
+ <ProFormDependency name={['alertType']}>
|
|
|
+ {({ alertType }) => {
|
|
|
+ // 自定义
|
|
|
+ if (taskAlertTypeEnum.CUSTOM === alertType) {
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <ProFormSelect
|
|
|
+ name="alertRobotCode"
|
|
|
+ label="告警机器人"
|
|
|
+ initialValue={record?.robotCode}
|
|
|
+ showSearch
|
|
|
+ rules={[{ required: true }]}
|
|
|
+ debounceTime={1000}
|
|
|
+ // @ts-ignore
|
|
|
+ request={async ({ keyWords = '' }) => {
|
|
|
+ const res = await getAppRobotOptions({ appId });
|
|
|
+ return res?.data?.filter(({ value, label }) => {
|
|
|
+ return value?.includes(keyWords) || label?.includes(keyWords);
|
|
|
+ });
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <ProFormText
|
|
|
+ name="alertOpenConversationId"
|
|
|
+ label="告警群id"
|
|
|
+ initialValue={record?.alertOpenConversationId}
|
|
|
+ rules={[
|
|
|
+ whitespaceForbidden,
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ <ProFormText
|
|
|
+ name="alertPhones"
|
|
|
+ label="告警手机号列表"
|
|
|
+ initialValue={record?.alertPhones}
|
|
|
+ rules={[phoneList]}
|
|
|
+ />
|
|
|
+ <ProFormText
|
|
|
+ name="alertUserIds"
|
|
|
+ label="告警userId列表"
|
|
|
+ initialValue={record?.alertUserIds}
|
|
|
+ rules={[userIdList]}
|
|
|
+ />
|
|
|
+ </>
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ return <></>;
|
|
|
+ }}
|
|
|
+ </ProFormDependency>
|
|
|
</ModalForm>
|
|
|
);
|
|
|
};
|