diff --git a/Server/application/superadmin/controller/company/GetCompanyDevicesForProfileController.php b/Server/application/superadmin/controller/company/GetCompanyDevicesForProfileController.php index 1855ec81..7b134b02 100644 --- a/Server/application/superadmin/controller/company/GetCompanyDevicesForProfileController.php +++ b/Server/application/superadmin/controller/company/GetCompanyDevicesForProfileController.php @@ -23,7 +23,7 @@ class GetCompanyDevicesForProfileController extends Controller { $companyId = $this->request->param('companyId/d', 0); - $devices = DeviceModel::where(compact('companyId'))->field('id,memo,phone,model,brand,alive,id deviceId') + $devices = DeviceModel::where(compact('companyId'))->field('id,memo,imei,phone,model,brand,alive,id deviceId') ->select() ->toArray(); diff --git a/SuperAdmin/app/dashboard/projects/[id]/page.tsx b/SuperAdmin/app/dashboard/projects/[id]/page.tsx index 878d59d0..b33b6cc7 100644 --- a/SuperAdmin/app/dashboard/projects/[id]/page.tsx +++ b/SuperAdmin/app/dashboard/projects/[id]/page.tsx @@ -24,10 +24,25 @@ interface ProjectProfile { userCount: number } +interface Device { + id: number + memo: string + phone: string + model: string + brand: string + alive: number + deviceId: number + wechatId: string + friendCount: number + wAlive: number + imei: string +} + export default function ProjectDetailPage({ params }: { params: { id: string } }) { const router = useRouter() const [isLoading, setIsLoading] = useState(true) const [profile, setProfile] = useState(null) + const [devices, setDevices] = useState([]) const [activeTab, setActiveTab] = useState("overview") const { id } = use(params) @@ -52,6 +67,27 @@ export default function ProjectDetailPage({ params }: { params: { id: string } } fetchProjectProfile() }, [id]) + useEffect(() => { + const fetchDevices = async () => { + if (activeTab === "devices") { + try { + const response = await fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/company/devices?companyId=${id}`) + const data = await response.json() + + if (data.code === 200) { + setDevices(data.data) + } else { + toast.error(data.msg || "获取设备列表失败") + } + } catch (error) { + toast.error("网络错误,请稍后重试") + } + } + } + + fetchDevices() + }, [activeTab, id]) + if (isLoading) { return
加载中...
} @@ -155,18 +191,26 @@ export default function ProjectDetailPage({ params }: { params: { id: string } } 设备名称 + 设备型号 + 品牌 + IMEI + 设备状态 + 微信状态 微信好友数量 - {/* Assuming devices are fetched from the profile */} - {/* Replace with actual devices data */} - {/* {profile.devices.map((device) => ( + {devices.map((device) => ( - {device.name} - {device.wechatFriends} + {device.memo} + {device.model} + {device.brand} + {device.imei} + {device.alive === 1 ? "在线" : "离线"} + {device.wAlive === 1 ? "在线" : device.wAlive === 0 ? "离线" : "未登录微信"} + {device.friendCount || 0} - ))} */} + ))}