diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue b/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue index dad1ed46d9..fd724c9ace 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue @@ -44,6 +44,18 @@ const modalTitle = props.group const handleSave = async () => { try { isSubmitting.value = true; + const existingGroupsResponse = + await coreApiClient.storage.group.listGroup(); + const existingGroups = existingGroupsResponse.data.items || []; + const nameExists = existingGroups.some( + (group) => group.spec.displayName === formState.value.spec.displayName + ); + + if (nameExists) { + alert("该分组名称已存在,请重新创建!"); + return; + } + if (props.group) { await coreApiClient.storage.group.updateGroup({ name: formState.value.metadata.name, diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue b/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue index ec09872025..0cf15cb852 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue @@ -47,6 +47,14 @@ const formState = ref({ const isUpdateMode = !!props.policy; +const { data: policies } = useQuery({ + queryKey: ["core:attachment:policies"], + queryFn: async () => { + const { data } = await coreApiClient.storage.policy.listPolicy(); // 修改为 listPolicy + return data; + }, +}); + onMounted(async () => { if (props.policy) { formState.value = cloneDeep(props.policy); @@ -135,6 +143,14 @@ const submitting = ref(false); const handleSave = async () => { try { submitting.value = true; + const nameExists = policies.value?.items.some( + (policy) => policy.spec.displayName === formState.value.spec.displayName + ); + + if (nameExists) { + alert("该存储策略名称已存在,请重新创建!"); + return; + } const configMapToUpdate = convertToSave();