From 8d66c55dc645f3ad02259b465f949fea30ef3eaf Mon Sep 17 00:00:00 2001 From: Dora <53067150+Dora-boots@users.noreply.github.com> Date: Wed, 9 Aug 2023 10:52:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9D=A1=E4=BB=B6=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E4=BD=9C=E4=B8=BA=E8=A1=A8=E5=8D=95=E9=A1=B9=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E9=9A=90=E8=97=8F=E6=9E=81=E5=B0=8F=E5=AE=BD?= =?UTF-8?q?=E5=BA=A6=20&=20=E5=A2=9E=E5=8A=A0=E5=BF=85=E9=80=89=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=20(#7743)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: yanglu19 --- packages/amis-editor/src/plugin/Form/Item.tsx | 23 +++++++++++++- packages/amis-ui/src/locale/de-DE.ts | 1 + packages/amis-ui/src/locale/en-US.ts | 1 + packages/amis-ui/src/locale/zh-CN.ts | 1 + .../src/renderers/Form/ConditionBuilder.tsx | 30 ++++++++++++++++++- 5 files changed, 54 insertions(+), 2 deletions(-) diff --git a/packages/amis-editor/src/plugin/Form/Item.tsx b/packages/amis-editor/src/plugin/Form/Item.tsx index 175a08729..3ad0118b1 100644 --- a/packages/amis-editor/src/plugin/Form/Item.tsx +++ b/packages/amis-editor/src/plugin/Form/Item.tsx @@ -132,7 +132,28 @@ export class ItemPlugin extends BasePlugin { }), renderer.sizeMutable !== false - ? getSchemaTpl('formItemSize') + ? getSchemaTpl('formItemSize', { + options: [ + { + label: '小', + value: 'sm' + }, + + { + label: '中', + value: 'md' + }, + + { + label: '大', + value: 'lg' + }, + { + label: '默认(占满)', + value: 'full' + } + ] + }) : null, getSchemaTpl('formItemInline'), diff --git a/packages/amis-ui/src/locale/de-DE.ts b/packages/amis-ui/src/locale/de-DE.ts index 395b88c65..dab20d894 100644 --- a/packages/amis-ui/src/locale/de-DE.ts +++ b/packages/amis-ui/src/locale/de-DE.ts @@ -375,6 +375,7 @@ register('de-DE', { 'Condition.formula_placeholder': 'Bitte geben Sie eine Formel ein', 'Condition.fun_error': 'Funktion ist undefiniert', 'Condition.configured': 'Konfiguriert', + 'Condition.isRequired': 'Bedingung kann nicht leer sein', 'InputTable.uniqueError': 'Column `{{label}}` unique validate failed', 'Timeline.collapseText': 'Falten', 'Timeline.expandText': 'Entfalten', diff --git a/packages/amis-ui/src/locale/en-US.ts b/packages/amis-ui/src/locale/en-US.ts index a18c92606..76c6969fb 100644 --- a/packages/amis-ui/src/locale/en-US.ts +++ b/packages/amis-ui/src/locale/en-US.ts @@ -363,6 +363,7 @@ register('en-US', { 'Condition.formula_placeholder': 'Please enter a formula', 'Condition.fun_error': 'Function is undefined', 'Condition.configured': 'Configured', + 'Condition.isRequired': 'Condition is required', 'InputTable.uniqueError': 'Column `{{label}}` unique validate failed', 'Timeline.collapseText': 'Unfold', 'Timeline.expandText': 'Fold', diff --git a/packages/amis-ui/src/locale/zh-CN.ts b/packages/amis-ui/src/locale/zh-CN.ts index c4588a393..474c2a672 100644 --- a/packages/amis-ui/src/locale/zh-CN.ts +++ b/packages/amis-ui/src/locale/zh-CN.ts @@ -356,6 +356,7 @@ register('zh-CN', { 'Condition.formula_placeholder': '请输入公式', 'Condition.fun_error': '方法未定义', 'Condition.configured': '已配置', + 'Condition.isRequired': '条件不可为空', 'InputTable.uniqueError': '列`{{label}}`没有通过唯一验证', 'Timeline.collapseText': '收起', 'Timeline.expandText': '展开', diff --git a/packages/amis/src/renderers/Form/ConditionBuilder.tsx b/packages/amis/src/renderers/Form/ConditionBuilder.tsx index de204445d..5e8614b4a 100644 --- a/packages/amis/src/renderers/Form/ConditionBuilder.tsx +++ b/packages/amis/src/renderers/Form/ConditionBuilder.tsx @@ -7,7 +7,8 @@ import { isPureVariable, resolveVariableAndFilter, createObject, - evalExpression + evalExpression, + ConditionRule } from 'amis-core'; import { FormBaseControlSchema, @@ -140,6 +141,33 @@ export default class ConditionBuilderControl extends React.PureComponent { + // 如果左侧、操作符为空,必填不通过 + if ( + item.op && + (item.right || !!~allowRightEmpty.indexOf(item.op as string)) + ) { + isEmpty = false; + return; + } + }); + return isEmpty ? __('Condition.isRequired') : null; + } + + return; + } + render() { const { className,