diff --git a/Server/application/superadmin/controller/company/GetCompanySubusersForProfileController.php b/Server/application/superadmin/controller/company/GetCompanySubusersForProfileController.php index a6949d7b..ad81e182 100644 --- a/Server/application/superadmin/controller/company/GetCompanySubusersForProfileController.php +++ b/Server/application/superadmin/controller/company/GetCompanySubusersForProfileController.php @@ -24,7 +24,7 @@ class GetCompanySubusersForProfileController extends Controller 'isAdmin' => 0 ]; - return UserModel::field('id,account,username,avatar,status,createTime,typeId')->where($where)->select()->toArray(); + return UserModel::field('id,account,phone,username,avatar,status,createTime,typeId')->where($where)->select()->toArray(); } /** diff --git a/SuperAdmin/app/dashboard/projects/[id]/page.tsx b/SuperAdmin/app/dashboard/projects/[id]/page.tsx index b33b6cc7..80a97fb9 100644 --- a/SuperAdmin/app/dashboard/projects/[id]/page.tsx +++ b/SuperAdmin/app/dashboard/projects/[id]/page.tsx @@ -10,6 +10,7 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@ import { ArrowLeft, Edit } from "lucide-react" import { toast } from "sonner" import { use } from "react" +import Image from "next/image" interface ProjectProfile { id: number @@ -38,16 +39,31 @@ interface Device { imei: string } +interface SubUser { + id: number + account: string + username: string + phone: string + avatar: string + status: number + createTime: string + typeId: number +} + export default function ProjectDetailPage({ params }: { params: { id: string } }) { const router = useRouter() const [isLoading, setIsLoading] = useState(true) + const [isDevicesLoading, setIsDevicesLoading] = useState(false) + const [isSubUsersLoading, setIsSubUsersLoading] = useState(false) const [profile, setProfile] = useState(null) const [devices, setDevices] = useState([]) + const [subUsers, setSubUsers] = useState([]) const [activeTab, setActiveTab] = useState("overview") const { id } = use(params) useEffect(() => { const fetchProjectProfile = async () => { + setIsLoading(true) try { const response = await fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/company/profile/${id}`) const data = await response.json() @@ -70,6 +86,7 @@ export default function ProjectDetailPage({ params }: { params: { id: string } } useEffect(() => { const fetchDevices = async () => { if (activeTab === "devices") { + setIsDevicesLoading(true) try { const response = await fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/company/devices?companyId=${id}`) const data = await response.json() @@ -81,6 +98,8 @@ export default function ProjectDetailPage({ params }: { params: { id: string } } } } catch (error) { toast.error("网络错误,请稍后重试") + } finally { + setIsDevicesLoading(false) } } } @@ -88,6 +107,38 @@ export default function ProjectDetailPage({ params }: { params: { id: string } } fetchDevices() }, [activeTab, id]) + useEffect(() => { + const fetchSubUsers = async () => { + if (activeTab === "accounts") { + setIsSubUsersLoading(true) + try { + const response = await fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/company/subusers`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + companyId: parseInt(id) + }) + }) + const data = await response.json() + + if (data.code === 200) { + setSubUsers(data.data) + } else { + toast.error(data.msg || "获取子账号列表失败") + } + } catch (error) { + toast.error("网络错误,请稍后重试") + } finally { + setIsSubUsersLoading(false) + } + } + } + + fetchSubUsers() + }, [activeTab, id]) + if (isLoading) { return
加载中...
} @@ -187,32 +238,36 @@ export default function ProjectDetailPage({ params }: { params: { id: string } } 项目关联的所有设备及其微信好友数量 - - - - 设备名称 - 设备型号 - 品牌 - IMEI - 设备状态 - 微信状态 - 微信好友数量 - - - - {devices.map((device) => ( - - {device.memo} - {device.model} - {device.brand} - {device.imei} - {device.alive === 1 ? "在线" : "离线"} - {device.wAlive === 1 ? "在线" : device.wAlive === 0 ? "离线" : "未登录微信"} - {device.friendCount || 0} + {isDevicesLoading ? ( +
加载中...
+ ) : ( +
+ + + 设备名称 + 设备型号 + 品牌 + IMEI + 设备状态 + 微信状态 + 微信好友数量 - ))} - -
+ + + {devices.map((device) => ( + + {device.memo} + {device.model} + {device.brand} + {device.imei} + {device.alive === 1 ? "在线" : "离线"} + {device.wAlive === 1 ? "在线" : device.wAlive === 0 ? "离线" : "未登录微信"} + {device.friendCount || 0} + + ))} + + + )}
@@ -224,24 +279,48 @@ export default function ProjectDetailPage({ params }: { params: { id: string } } 项目下的所有子账号 - - - - 账号名称 - 创建时间 - - - - {/* Assuming subAccounts are fetched from the profile */} - {/* Replace with actual subAccounts data */} - {/* {profile.subAccounts.map((account) => ( - - {account.username} - {account.createdAt} + {isSubUsersLoading ? ( +
加载中...
+ ) : subUsers.length === 0 ? ( +
暂无数据
+ ) : ( +
+ + + 头像 + 账号ID + 登录账号 + 昵称 + 手机号 + 状态 + 账号类型 + 创建时间 - ))} */} - -
+ + + {subUsers.map((user) => ( + + + {user.username} + + {user.id} + {user.account} + {user.username} + {user.phone} + {user.status === 1 ? "登录" : "禁用"} + {user.typeId === 1 ? "操盘手" : "门店顾问"} + {user.createTime} + + ))} + + + )}