From 45dc2fa45b942701336ffd40e66add1f8eca8d0d Mon Sep 17 00:00:00 2001 From: qkiroc <30946345+qkiroc@users.noreply.github.com> Date: Wed, 26 Jun 2024 20:44:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(editor):=20optionControl=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=94=AF=E6=8C=81=E9=85=8D=E7=BD=AEcustomEdi?= =?UTF-8?q?t=20(#10522)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(editor): optionControl批量添加支持配置customEdit * bugfix --------- Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com> --- packages/amis-editor/src/renderer/OptionControl.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/amis-editor/src/renderer/OptionControl.tsx b/packages/amis-editor/src/renderer/OptionControl.tsx index 64b0f7ffa..f4c55acf5 100644 --- a/packages/amis-editor/src/renderer/OptionControl.tsx +++ b/packages/amis-editor/src/renderer/OptionControl.tsx @@ -244,13 +244,13 @@ class CustomOptionControl extends React.Component { @autobind handleBatchAdd(values: {batchOption: string}[], action: any) { - const {onChange} = this.props; + const {onChange, customEdit = true} = this.props; const options = this.props.data.options || []; const addedOptions: Array = values[0].batchOption .split('\n') .map(option => { const item = option.trim(); - if (~item.indexOf(' ')) { + if (~item.indexOf(' ') && customEdit) { let [label, value] = item.split(' '); return {label: label.trim(), value: value.trim(), checked: false}; } @@ -489,6 +489,7 @@ class CustomOptionControl extends React.Component { } buildBatchAddSchema() { + const {customEdit = true} = this.props; return { type: 'action', actionType: 'dialog', @@ -507,7 +508,11 @@ class CustomOptionControl extends React.Component { body: [ { type: 'tpl', - tpl: '每个选项单列一行,将所有值不重复的项加为新的选项;
每行可通过空格来分别设置label和value,例:"张三 zhangsan"' + tpl: + '每个选项单列一行,将所有值不重复的项加为新的选项;' + + (customEdit + ? '
每行可通过空格来分别设置label和value,例:"张三 zhangsan"' + : '') } ], showIcon: true,