}
open={selectDeviceModalVisible}
closeIcon={}
onCancel={() => {
setSelectDeviceModalVisible(false);
setDeviceFilterType('all');
setDevicePage(1);
setSelectedRowKeys([]);
setGuidedDeviceType(null);
setSelectedRoomId(null);
setSelectedRackId(null);
}}
footer={null}
width={620}
style={{ top: 100 }}
bodyStyle={{ padding: '0 24px 24px' }}
>
{guidedDeviceType && (
{guidedDeviceType === 'switch' ? (
) : (
)}
{guidedDeviceType === 'switch' ? '添加交换机端口' : '添加服务器端口'}
{guidedDeviceType === 'switch'
? '(交换机端口可直接创建,无需关联网卡)'
: '(服务器端口需关联网卡)'}
)}
}
allowClear
onChange={e => handleDeviceSearch(e.target.value)}
style={{
flex: 1,
borderRadius: '10px',
border: '1px solid #e8ecf4',
height: '40px',
fontSize: '14px',
}}
/>
{(() => {
const rackRoomMap = {};
rackList.forEach(rack => {
rackRoomMap[rack.rackId] = rack.roomId;
});
const allDevices = devices.filter(d => {
const type = getDeviceType(d);
if (type !== 'switch' && type !== 'server') return false;
if (selectedRackId && d.rackId !== selectedRackId) return false;
if (selectedRoomId && d.rackId && rackRoomMap[d.rackId] !== selectedRoomId)
return false;
return true;
});
const switchCount = allDevices.filter(d => getDeviceType(d) === 'switch').length;
const serverCount = allDevices.filter(d => getDeviceType(d) === 'server').length;
const showSwitchTab = guidedDeviceType === null || guidedDeviceType === 'switch';
const showServerTab = guidedDeviceType === null || guidedDeviceType === 'server';
return (
{guidedDeviceType === null && (
)}
{showSwitchTab && (
)}
{showServerTab && (
)}
);
})()}
{deviceSearching ? (
) : paginatedDevices.list.length === 0 ? (
未找到设备
{deviceFilterType === 'all'
? '暂无可添加端口的设备'
: deviceFilterType === 'switch'
? '暂无可添加端口的交换机'
: '暂无可添加端口的服务器'}
) : (
<>
共 {paginatedDevices.total} 个设备
{paginatedDevices.list.map(device => (
handleSelectDeviceForPort(device)}
style={{
padding: '14px 16px',
marginBottom: '10px',
borderRadius: '12px',
border: '1px solid #e8ecf4',
cursor: 'pointer',
transition: 'all 0.2s',
background: '#fff',
}}
onMouseEnter={e => {
e.currentTarget.style.borderColor = '#667eea';
e.currentTarget.style.background = '#f8f9ff';
e.currentTarget.style.transform = 'translateY(-1px)';
e.currentTarget.style.boxShadow = '0 4px 12px rgba(102, 126, 234, 0.15)';
}}
onMouseLeave={e => {
e.currentTarget.style.borderColor = '#e8ecf4';
e.currentTarget.style.background = '#fff';
e.currentTarget.style.transform = 'none';
e.currentTarget.style.boxShadow = 'none';
}}
>
{getDeviceIcon(device)}
{device.name || '未命名设备'}
{device.Rack?.Room?.name && (
📍
{device.Rack.Room.name}
)}
{device.Rack?.name && (
🗄️
{device.Rack.name}
)}
{device.ipAddress && (
🌐
{device.ipAddress}
)}
{isServerDevice(device) ? '服务器' : '交换机'}
))}
{paginatedDevices.hasMore && (
setDevicePage(p => p + 1)}
>
{
e.currentTarget.style.background = '#667eea';
e.currentTarget.style.color = '#fff';
}}
onMouseLeave={e => {
e.currentTarget.style.background = '#f5f7fa';
e.currentTarget.style.color = '#666';
}}
>
点击加载更多
({Math.min(devicePage * 100, paginatedDevices.total)} /{' '}
{paginatedDevices.total})
)}
{!paginatedDevices.hasMore && paginatedDevices.total > 0 && (
已加载全部
共 {paginatedDevices.total} 个设备
)}
>
)}
{/* 网卡管理模态框 */}