diff --git a/frontend/src/components/ui/input.tsx b/frontend/src/components/ui/input.tsx index 69b64fb2..35a99e51 100644 --- a/frontend/src/components/ui/input.tsx +++ b/frontend/src/components/ui/input.tsx @@ -8,7 +8,7 @@ const Input = React.forwardRef>( = ({ const handleSubmit = async (values: ApplicationFormValues) => { console.log('Form submitted with values:', values); try { + // 去掉 externalSystemId 字段,不传给后端 + const { externalSystemId, ...submitData } = values; + if (isEdit) { await updateApplication({ - ...values, + ...submitData, id: initialValues!.id, } as any); toast({ @@ -173,7 +176,7 @@ const ApplicationModal: React.FC = ({ duration: 3000, }); } else { - await createApplication(values as any); + await createApplication(submitData as any); toast({ title: "创建成功", description: `应用 ${values.appName} 已创建`, diff --git a/frontend/src/pages/Deploy/Team/List/components/MemberManageDialog.tsx b/frontend/src/pages/Deploy/Team/List/components/MemberManageDialog.tsx index 6831b7bd..f2a5c444 100644 --- a/frontend/src/pages/Deploy/Team/List/components/MemberManageDialog.tsx +++ b/frontend/src/pages/Deploy/Team/List/components/MemberManageDialog.tsx @@ -44,6 +44,7 @@ import { DataTablePagination } from '@/components/ui/pagination'; import { DEFAULT_PAGE_SIZE, DEFAULT_CURRENT } from '@/utils/page'; import { Plus, + Edit, Trash2, Search, Loader2, @@ -54,6 +55,7 @@ import { import { getTeamMembers, createTeamMember, + updateTeamMember, deleteTeamMember } from '../../Member/service'; import type { @@ -67,6 +69,7 @@ interface MemberManageDialogProps { open: boolean; teamId: number; teamName: string; + ownerId?: number; users: UserResponse[]; onOpenChange: (open: boolean) => void; onSuccess?: () => void; @@ -79,6 +82,7 @@ const MemberManageDialog: React.FC = ({ open, teamId, teamName, + ownerId, users, onOpenChange, onSuccess @@ -92,6 +96,9 @@ const MemberManageDialog: React.FC = ({ const [selectedUserIds, setSelectedUserIds] = useState([]); const [popoverOpen, setPopoverOpen] = useState(false); const [adding, setAdding] = useState(false); + const [editDialogOpen, setEditDialogOpen] = useState(false); + const [editRecord, setEditRecord] = useState(null); + const [editRole, setEditRole] = useState(''); // 分页状态 const [pageNum, setPageNum] = useState(DEFAULT_CURRENT - 1); @@ -192,6 +199,43 @@ const MemberManageDialog: React.FC = ({ } }; + // 编辑成员角色 + const handleEditClick = (record: TeamMemberResponse) => { + setEditRecord(record); + setEditRole(record.roleInTeam || ''); + setEditDialogOpen(true); + }; + + // 保存角色编辑 + const handleEditSave = async () => { + if (!editRecord) return; + + try { + await updateTeamMember(editRecord.id, { + teamId, + userId: editRecord.userId, + userName: editRecord.userName || '', + roleInTeam: editRole, + }); + toast({ + title: "更新成功", + description: `成员 "${editRecord.userName}" 的角色已更新`, + }); + setEditDialogOpen(false); + setEditRecord(null); + setEditRole(''); + loadMembers(); + onSuccess?.(); + } catch (error) { + console.error('更新失败:', error); + toast({ + variant: "destructive", + title: "更新失败", + description: error instanceof Error ? error.message : '未知错误', + }); + } + }; + // 删除成员(打开确认对话框) const handleDeleteClick = (record: TeamMemberResponse) => { setDeleteRecord(record); @@ -222,9 +266,9 @@ const MemberManageDialog: React.FC = ({ } }; - // 过滤出未加入的用户 + // 过滤出未加入的用户(排除负责人和已加入的成员) const availableUsers = users.filter(user => - !data?.content?.some(member => member.userId === user.id) + user.id !== ownerId && !data?.content?.some(member => member.userId === user.id) ); return ( @@ -331,7 +375,7 @@ const MemberManageDialog: React.FC = ({ 用户名 团队角色 加入时间 - 操作 + 操作 @@ -361,6 +405,14 @@ const MemberManageDialog: React.FC = ({
+ + +
+ + + {/* 删除确认对话框 */} diff --git a/frontend/src/pages/Deploy/Team/List/components/TeamModal.tsx b/frontend/src/pages/Deploy/Team/List/components/TeamModal.tsx index 548fde5b..78157960 100644 --- a/frontend/src/pages/Deploy/Team/List/components/TeamModal.tsx +++ b/frontend/src/pages/Deploy/Team/List/components/TeamModal.tsx @@ -1,6 +1,8 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useState } from 'react'; import type { TeamResponse } from '../types'; import { createTeam, updateTeam } from '../service'; +import { getUserList } from '@/pages/System/User/service'; +import type { UserResponse } from '@/pages/System/User/types'; import { Dialog, DialogContent, @@ -17,6 +19,13 @@ import { FormMessage, } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; import { Switch } from "@/components/ui/switch"; import { useToast } from "@/components/ui/use-toast"; import { useForm } from "react-hook-form"; @@ -39,6 +48,7 @@ const TeamModal: React.FC = ({ }) => { const { toast } = useToast(); const isEdit = !!initialValues?.id; + const [users, setUsers] = useState([]); const form = useForm({ resolver: zodResolver(teamFormSchema), @@ -53,27 +63,42 @@ const TeamModal: React.FC = ({ }, }); + // 加载用户列表 + const loadUsers = async () => { + try { + const response = await getUserList(); + if (response) { + setUsers(response); + } + } catch (error) { + console.error('加载用户列表失败:', error); + } + }; + useEffect(() => { - if (open && initialValues) { - form.reset({ - teamCode: initialValues.teamCode, - teamName: initialValues.teamName, - description: initialValues.description || "", - ownerId: initialValues.ownerId, - ownerName: initialValues.ownerName || "", - enabled: initialValues.enabled, - sort: initialValues.sort, - }); - } else if (open && !initialValues) { - form.reset({ - teamCode: "", - teamName: "", - description: "", - ownerId: undefined, - ownerName: "", - enabled: true, - sort: 0, - }); + if (open) { + loadUsers(); + if (initialValues) { + form.reset({ + teamCode: initialValues.teamCode, + teamName: initialValues.teamName, + description: initialValues.description || "", + ownerId: initialValues.ownerId, + ownerName: initialValues.ownerName || "", + enabled: initialValues.enabled, + sort: initialValues.sort, + }); + } else { + form.reset({ + teamCode: "", + teamName: "", + description: "", + ownerId: undefined, + ownerName: "", + enabled: true, + sort: 0, + }); + } } }, [open, initialValues, form]); @@ -151,44 +176,46 @@ const TeamModal: React.FC = ({ /> -
- ( - - 负责人ID + ( + + 团队负责人 + { - const value = e.target.value; - field.onChange(value ? Number(value) : undefined); - }} - /> + + + - - - )} - /> - - ( - - 负责人姓名 - - - - - - )} - /> -
+ + 不选择负责人 + {users.map((user) => ( + + {user.nickname || user.username} ({user.username}) + + ))} + + + + + )} + /> { open={memberDialogOpen} teamId={currentTeam.id} teamName={currentTeam.teamName} + ownerId={currentTeam.ownerId} users={users} onOpenChange={setMemberDialogOpen} onSuccess={handleSuccess}