From 85247e683759cf42d7c4e1e9382186bc070a6eb2 Mon Sep 17 00:00:00 2001 From: balibabu Date: Wed, 21 Aug 2024 15:01:11 +0800 Subject: [PATCH] feat: Add SwitchOperatorOptions to Select of Switch #1739 (#2033) ### What problem does this PR solve? feat: Add SwitchOperatorOptions to Select of Switch #1739 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- web/.umirc.ts | 2 +- web/src/locales/en.ts | 18 ++++++++++ web/src/locales/zh-traditional.ts | 18 ++++++++++ web/src/locales/zh.ts | 18 ++++++++++ web/src/pages/flow/constant.tsx | 17 +++++++++ web/src/pages/flow/exesql-form/index.tsx | 2 +- web/src/pages/flow/switch-form/index.tsx | 45 +++++++++++++++++++----- 7 files changed, 110 insertions(+), 10 deletions(-) diff --git a/web/.umirc.ts b/web/.umirc.ts index b30d25d7d..a3e42026e 100644 --- a/web/.umirc.ts +++ b/web/.umirc.ts @@ -30,7 +30,7 @@ export default defineConfig({ copy: ['src/conf.json'], proxy: { '/v1': { - target: 'http://localhost:9380/', + target: 'http://123.60.95.134:9380/', changeOrigin: true, ws: true, logger: console, diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts index d705b22e8..a7d30b442 100644 --- a/web/src/locales/en.ts +++ b/web/src/locales/en.ts @@ -815,6 +815,24 @@ The above is the content you need to summarize.`, password: 'Password', switch: 'Switch', logicalOperator: 'Logical operator', + switchOperatorOptions: { + equal: 'equal', + notEqual: 'notEqual', + gt: 'Greater than', + ge: 'Greater equal', + lt: 'Less than', + le: 'Less equal', + contains: 'Contains', + notContains: 'Not contains', + startWith: 'Start with', + endWith: 'End with', + empty: 'Empty', + notEmpty: 'Not empty', + }, + switchLogicOperatorOptions: { + and: 'And', + or: 'Or', + }, }, footer: { profile: 'All rights reserved @ React', diff --git a/web/src/locales/zh-traditional.ts b/web/src/locales/zh-traditional.ts index 5c6d9ccf5..48297322d 100644 --- a/web/src/locales/zh-traditional.ts +++ b/web/src/locales/zh-traditional.ts @@ -773,6 +773,24 @@ export default { password: '密碼', switch: '條件', logicalOperator: '操作符', + switchOperatorOptions: { + equal: '等於', + notEqual: '不等於', + gt: '大於', + ge: '大於等於', + lt: '小於', + le: '小於等於', + contains: '包含', + notContains: '不包含', + startWith: '開始是', + endWith: '結束是', + empty: '為空', + notEmpty: '不為空', + }, + switchLogicOperatorOptions: { + and: '與', + or: '或', + }, }, footer: { profile: '“保留所有權利 @ react”', diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts index 61d52c6e1..ddfcda14d 100644 --- a/web/src/locales/zh.ts +++ b/web/src/locales/zh.ts @@ -791,6 +791,24 @@ export default { password: '密码', switch: '条件', logicalOperator: '操作符', + switchOperatorOptions: { + equal: '等于', + notEqual: '不等于', + gt: '大于', + ge: '大于等于', + lt: '小于', + le: '小于等于', + contains: '包含', + notContains: '不包含', + startWith: '开始是', + endWith: '结束是', + empty: '为空', + notEmpty: '不为空', + }, + switchLogicOperatorOptions: { + and: '与', + or: '或', + }, }, footer: { profile: 'All rights reserved @ React', diff --git a/web/src/pages/flow/constant.tsx b/web/src/pages/flow/constant.tsx index a975a538b..83f6f4a4d 100644 --- a/web/src/pages/flow/constant.tsx +++ b/web/src/pages/flow/constant.tsx @@ -2635,3 +2635,20 @@ export const ExeSQLOptions = ['mysql', 'postgresql', 'mariadb'].map((x) => ({ })); export const SwitchElseTo = 'end_cpn_id'; + +export const SwitchOperatorOptions = [ + { value: '=', label: 'equal' }, + { value: '≠', label: 'notEqual' }, + { value: '>', label: 'gt' }, + { value: '≥', label: 'ge' }, + { value: '<', label: 'lt' }, + { value: '≤', label: 'le' }, + { value: 'contains', label: 'contains' }, + { value: 'not contains', label: 'notContains' }, + { value: 'start with', label: 'startWith' }, + { value: 'end with', label: 'endWith' }, + { value: 'empty', label: 'empty' }, + { value: 'not empty', label: 'notEmpty' }, +]; + +export const SwitchLogicOperatorOptions = ['and', 'or']; diff --git a/web/src/pages/flow/exesql-form/index.tsx b/web/src/pages/flow/exesql-form/index.tsx index 9aa80f402..f884d8dd3 100644 --- a/web/src/pages/flow/exesql-form/index.tsx +++ b/web/src/pages/flow/exesql-form/index.tsx @@ -58,7 +58,7 @@ const ExeSQLForm = ({ onValuesChange, form }: IOperatorForm) => { > - + ); }; diff --git a/web/src/pages/flow/switch-form/index.tsx b/web/src/pages/flow/switch-form/index.tsx index cb1840151..5e5f1f7eb 100644 --- a/web/src/pages/flow/switch-form/index.tsx +++ b/web/src/pages/flow/switch-form/index.tsx @@ -1,7 +1,13 @@ import { CloseOutlined } from '@ant-design/icons'; import { Button, Card, Form, Input, Select, Typography } from 'antd'; +import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; -import { Operator, SwitchElseTo } from '../constant'; +import { + Operator, + SwitchElseTo, + SwitchLogicOperatorOptions, + SwitchOperatorOptions, +} from '../constant'; import { useBuildFormSelectOptions } from '../form-hooks'; import { IOperatorForm, ISwitchForm } from '../interface'; import { getOtherFieldValues } from '../utils'; @@ -28,6 +34,20 @@ const SwitchForm = ({ onValuesChange, node, form }: IOperatorForm) => { return conditions?.filter((x) => !!x).map((x) => x?.to) ?? []; }; + const switchOperatorOptions = useMemo(() => { + return SwitchOperatorOptions.map((x) => ({ + value: x.value, + label: t(`flow.switchOperatorOptions.${x.label}`), + })); + }, [t]); + + const switchLogicOperatorOptions = useMemo(() => { + return SwitchLogicOperatorOptions.map((x) => ({ + value: x, + label: t(`flow.switchLogicOperatorOptions.${x}`), + })); + }, [t]); + return (
{ /> } > - - + + {({ getFieldValue }) => + getFieldValue(['conditions', field.name, 'items'])?.length > + 1 && ( + + { labelCol={subLabelCol} wrapperCol={subWrapperCol} > - +