diff --git a/packages/amis-editor/src/plugin/Form/Combo.tsx b/packages/amis-editor/src/plugin/Form/Combo.tsx index b0501bdac..a37a29a5e 100644 --- a/packages/amis-editor/src/plugin/Form/Combo.tsx +++ b/packages/amis-editor/src/plugin/Form/Combo.tsx @@ -518,6 +518,40 @@ export class ComboControlPlugin extends BasePlugin { ] }, + { + type: 'select', + name: '__uniqueItems', + label: '配置唯一项', + source: '${items|pick:name}', + pipeIn: (value: any, form: any) => { + // 从 items 中获取设置了 unique: true 的项的 name + const items = form.data.items || []; + return items + .filter((item: any) => item.unique) + .map((item: any) => item.name); + }, + onChange: ( + value: string[], + oldValue: any, + model: any, + form: any + ) => { + // 获取当前的 items + const items = [...(form.data.items || [])]; + // 修改 items 中的 unique 属性 + const updatedItems = items.map(item => { + if (value === item.name) { + return {...item, unique: true}; + } else { + const newItem = {...item}; + delete newItem.unique; + return newItem; + } + }); + // 更新 items + form.setValueByName('items', updatedItems); + } + }, getSchemaTpl('labelRemark'), getSchemaTpl('remark'),