diff --git a/src/locale/en-US/common.ts b/src/locale/en-US/common.ts index 8349f272..fdf0c0fe 100644 --- a/src/locale/en-US/common.ts +++ b/src/locale/en-US/common.ts @@ -53,6 +53,7 @@ export default { placeholder: { input: 'Please input {{name}}', select: 'Please select {{name}}', + upload: 'Please upload {{name}}', searchInput: 'Input the {{name}} to search', searchSelect: 'Select the {{name}} to search', }, diff --git a/src/locale/en-US/order.ts b/src/locale/en-US/order.ts index 94aa5db8..7c900259 100644 --- a/src/locale/en-US/order.ts +++ b/src/locale/en-US/order.ts @@ -153,7 +153,6 @@ export default { instanceSchema: '数据库', sql: 'SQL语句', sqlFile: 'SQL文件', - validateSqlFileMsg: '请上传SQL文件', mybatisFile: 'Mybatis的XML文件', zipFile: 'ZIP文件', diff --git a/src/locale/zh-CN/common.ts b/src/locale/zh-CN/common.ts index 189fe4a6..db6bc9f1 100644 --- a/src/locale/zh-CN/common.ts +++ b/src/locale/zh-CN/common.ts @@ -95,6 +95,7 @@ export default { placeholder: { input: '请输入{{name}}', select: '请选择{{name}}', + upload: '请上传{{name}}', searchInput: '请输入要搜索的 {{name}}', searchSelect: '请选择要搜索的 {{name}}', }, diff --git a/src/locale/zh-CN/order.ts b/src/locale/zh-CN/order.ts index 94aa5db8..7c900259 100644 --- a/src/locale/zh-CN/order.ts +++ b/src/locale/zh-CN/order.ts @@ -153,7 +153,6 @@ export default { instanceSchema: '数据库', sql: 'SQL语句', sqlFile: 'SQL文件', - validateSqlFileMsg: '请上传SQL文件', mybatisFile: 'Mybatis的XML文件', zipFile: 'ZIP文件', diff --git a/src/page/Order/SqlStatementFormTabs/SqlStatementForm.tsx b/src/page/Order/SqlStatementFormTabs/SqlStatementForm.tsx index f5ecebb6..19944b85 100644 --- a/src/page/Order/SqlStatementFormTabs/SqlStatementForm.tsx +++ b/src/page/Order/SqlStatementFormTabs/SqlStatementForm.tsx @@ -59,7 +59,7 @@ const SqlStatementForm: React.FC = ({ const resetUploadTypeContent = () => { setCurrentSQLInputTYpe(SQLInputType.manualInput); - } + }; const { editorDidMount } = useMonacoEditor(form, { formName: generateFieldName('sql'), @@ -88,8 +88,7 @@ const SqlStatementForm: React.FC = ({ ); }; // eslint-disable-next-line react-hooks/exhaustive-deps - }, []) - + }, []); return ( <> @@ -126,9 +125,9 @@ const SqlStatementForm: React.FC = ({ }} rules={[ { - required: true + required: true, }, - ...whiteSpaceSql() + ...whiteSpaceSql(), ]} > = ({ rules={[ { required: true, - message: t('order.sqlInfo.validateSqlFileMsg') + message: t('common.form.placeholder.upload', { + name: t('order.sqlInfo.sqlFile'), + }), }, ]} getValueFromEvent={getFileFromUploadChangeEvent} @@ -173,7 +174,9 @@ const SqlStatementForm: React.FC = ({ rules={[ { required: true, - message: t('order.sqlInfo.validateSqlFileMsg') + message: t('common.form.placeholder.upload', { + name: t('order.sqlInfo.mybatisFile'), + }), }, ]} getValueFromEvent={getFileFromUploadChangeEvent} @@ -196,7 +199,9 @@ const SqlStatementForm: React.FC = ({ rules={[ { required: true, - message: t('order.sqlInfo.validateSqlFileMsg') + message: t('common.form.placeholder.upload', { + name: t('order.sqlInfo.zipFile'), + }), }, ]} getValueFromEvent={getFileFromUploadChangeEvent} diff --git a/src/page/SqlAuditRecord/Create/SQLInfoForm.tsx b/src/page/SqlAuditRecord/Create/SQLInfoForm.tsx index 481da5fa..a1de7952 100644 --- a/src/page/SqlAuditRecord/Create/SQLInfoForm.tsx +++ b/src/page/SqlAuditRecord/Create/SQLInfoForm.tsx @@ -12,7 +12,11 @@ import { Tooltip, Upload, } from 'antd'; -import { PageFormLayout, ResponseCode, SqlFiledInitialValue } from '../../../data/common'; +import { + PageFormLayout, + ResponseCode, + SqlFiledInitialValue, +} from '../../../data/common'; import { AuditTypeEnum, SQLInfoFormFields, @@ -49,7 +53,7 @@ import { RuleUrlParamKey } from '../../Rule/useRuleFilterForm'; import { Link } from 'react-router-dom'; import { getInstanceTipListV1FunctionalModuleEnum } from '../../../api/instance/index.enum'; import EmptyBox from '../../../components/EmptyBox'; -import { whiteSpaceSql } from '../../../utils/FormRule'; +import { whiteSpaceSql, nameRule } from '../../../utils/FormRule'; const MonacoEditorFunComponent = MonacoEditor as ComponentType; @@ -95,7 +99,6 @@ const SQLInfoForm: React.ForwardRefRenderFunction< rules: [ { required: true, - message: t('order.sqlInfo.validateSqlFileMsg') }, ], }; @@ -108,7 +111,12 @@ const SQLInfoForm: React.ForwardRefRenderFunction< ...PageFormLayout.wrapperCol, className: theme.editor, }, - rules: [{ required: uploadType === UploadTypeEnum.sql }, ...whiteSpaceSql()], + rules: [ + { + required: uploadType === UploadTypeEnum.sql, + }, + ...whiteSpaceSql(), + ], children: (