feat(editor): optionControl批量添加支持配置customEdit (#10522)

* feat(editor): optionControl批量添加支持配置customEdit

* bugfix

---------

Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com>
This commit is contained in:
qkiroc 2024-06-26 20:44:04 +08:00 committed by GitHub
parent c276aa21e2
commit 45dc2fa45b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -244,13 +244,13 @@ class CustomOptionControl extends React.Component<OptionSourceControlProps> {
@autobind @autobind
handleBatchAdd(values: {batchOption: string}[], action: any) { handleBatchAdd(values: {batchOption: string}[], action: any) {
const {onChange} = this.props; const {onChange, customEdit = true} = this.props;
const options = this.props.data.options || []; const options = this.props.data.options || [];
const addedOptions: Array<OptionControlItem> = values[0].batchOption const addedOptions: Array<OptionControlItem> = values[0].batchOption
.split('\n') .split('\n')
.map(option => { .map(option => {
const item = option.trim(); const item = option.trim();
if (~item.indexOf(' ')) { if (~item.indexOf(' ') && customEdit) {
let [label, value] = item.split(' '); let [label, value] = item.split(' ');
return {label: label.trim(), value: value.trim(), checked: false}; return {label: label.trim(), value: value.trim(), checked: false};
} }
@ -489,6 +489,7 @@ class CustomOptionControl extends React.Component<OptionSourceControlProps> {
} }
buildBatchAddSchema() { buildBatchAddSchema() {
const {customEdit = true} = this.props;
return { return {
type: 'action', type: 'action',
actionType: 'dialog', actionType: 'dialog',
@ -507,7 +508,11 @@ class CustomOptionControl extends React.Component<OptionSourceControlProps> {
body: [ body: [
{ {
type: 'tpl', type: 'tpl',
tpl: '每个选项单列一行,将所有值不重复的项加为新的选项;<br/>每行可通过空格来分别设置label和value,例:"张三 zhangsan"' tpl:
'每个选项单列一行,将所有值不重复的项加为新的选项;' +
(customEdit
? '<br/>每行可通过空格来分别设置label和value,例:"张三 zhangsan"'
: '')
} }
], ],
showIcon: true, showIcon: true,