diff --git a/nkebao/src/components/FriendSelection/index.tsx b/nkebao/src/components/FriendSelection/index.tsx index 13090569..51598c53 100644 --- a/nkebao/src/components/FriendSelection/index.tsx +++ b/nkebao/src/components/FriendSelection/index.tsx @@ -29,6 +29,7 @@ interface FriendSelectionProps { showInput?: boolean; showSelectedList?: boolean; readonly?: boolean; + onConfirm?: (selectedIds: string[], selectedItems: WechatFriend[]) => void; // 新增 } export default function FriendSelection({ @@ -45,6 +46,7 @@ export default function FriendSelection({ showInput = true, showSelectedList = true, readonly = false, + onConfirm, }: FriendSelectionProps) { const [popupVisible, setPopupVisible] = useState(false); const [friends, setFriends] = useState([]); @@ -168,8 +170,12 @@ export default function FriendSelection({ onSelect(selectedFriends.filter((f) => f !== id)); }; + // 确认按钮逻辑 const handleConfirm = () => { - setPopupVisible(false); + setRealVisible(false); + if (onConfirm) { + onConfirm(selectedFriends, selectedFriendObjs); + } }; // 清空搜索 @@ -404,7 +410,7 @@ export default function FriendSelection({
-
diff --git a/nkebao/src/components/GroupSelection/index.tsx b/nkebao/src/components/GroupSelection/index.tsx index 2027ef90..15d2222a 100644 --- a/nkebao/src/components/GroupSelection/index.tsx +++ b/nkebao/src/components/GroupSelection/index.tsx @@ -35,6 +35,7 @@ interface GroupSelectionProps { showInput?: boolean; showSelectedList?: boolean; readonly?: boolean; + onConfirm?: (selectedIds: string[], selectedItems: WechatGroup[]) => void; // 新增 } export default function GroupSelection({ @@ -49,6 +50,7 @@ export default function GroupSelection({ showInput = true, showSelectedList = true, readonly = false, + onConfirm, }: GroupSelectionProps) { const [popupVisible, setPopupVisible] = useState(false); const [groups, setGroups] = useState([]); @@ -160,8 +162,12 @@ export default function GroupSelection({ return `已选择 ${selectedGroups.length} 个群聊`; }; + // 确认按钮逻辑 const handleConfirm = () => { setRealVisible(false); + if (onConfirm) { + onConfirm(selectedGroups, selectedGroupObjs); + } }; // 清空搜索 @@ -395,7 +401,7 @@ export default function GroupSelection({ setRealVisible(false)}> 取消 - setRealVisible(false)}> + 确定