超管后台 - 编辑项目设备列表内容丰富

This commit is contained in:
柳清爽
2025-04-25 10:04:46 +08:00
parent dbc94e4823
commit 218862a7c8
2 changed files with 40 additions and 8 deletions

View File

@@ -22,7 +22,7 @@ class GetCompanyDetailForUpdateController extends BaseController
{
return DeviceModel::alias('d')
->field([
'd.id', 'd.memo',
'd.id', 'd.memo', 'd.model', 'd.brand', 'd.phone', 'd.imei', 'd.createTime', 'd.alive',
])
->where('companyId', $companyId)
->select()

View File

@@ -23,6 +23,12 @@ declare module 'react' {
interface Device {
id: number
memo: string
imei: string
phone: string
model: string
brand: string
alive: number
createTime: number
}
interface Project {
@@ -264,14 +270,40 @@ export default function EditProjectPage({ params }: { params: { id: string } })
<div className="space-y-2">
<Label></Label>
<div className="space-y-3">
{project && project.devices && project.devices.length > 0 && project.devices.map((device) => (
<div key={device.id} className="flex items-center gap-2">
<Input
value={device.memo}
readOnly
/>
{project && project.devices && project.devices.length > 0 && (
<div className="border rounded-md">
<table className="w-full">
<thead className="bg-muted">
<tr>
<th className="text-left p-2"></th>
<th className="text-left p-2">IMEI</th>
<th className="text-left p-2"></th>
<th className="text-left p-2"></th>
<th className="text-left p-2"></th>
<th className="text-left p-2"></th>
<th className="text-left p-2"></th>
</tr>
</thead>
<tbody>
{project.devices.map((device) => (
<tr key={device.id} className="border-t">
<td className="p-2">{device.memo}</td>
<td className="p-2">{device.imei || '-'}</td>
<td className="p-2">{device.phone || '-'}</td>
<td className="p-2">{device.model || '-'}</td>
<td className="p-2">{device.brand || '-'}</td>
<td className="p-2">
<span className={`inline-block px-2 py-1 text-xs rounded-full ${device.alive === 1 ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800'}`}>
{device.alive === 1 ? '在线' : '离线'}
</span>
</td>
<td className="p-2">{device.createTime || '-'}</td>
</tr>
))}
</tbody>
</table>
</div>
))}
)}
<Button
type="button"
variant="outline"