预设路线搜索功能

This commit is contained in:
mmc
2026-05-29 16:31:14 +08:00
parent 50940baa36
commit e553b9fe20

View File

@@ -539,7 +539,7 @@ export default function RobotTaskPage({ devices }) {
<Input
placeholder="搜索..."
size="small"
style={{ width: 100 }}
style={{ width: 200 }}
value={routeSearch}
onChange={e => setRouteSearch(e.target.value)}
/>
@@ -550,76 +550,84 @@ export default function RobotTaskPage({ devices }) {
style={cardStyle}
>
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
{routeList.map(route => (
<div
key={route.id}
style={{
padding: 12,
borderRadius: 8,
background: '#F7F8FA',
cursor: 'pointer',
border: '1px solid transparent',
display: 'flex',
gap: 12,
alignItems: 'center'
}}
onMouseEnter={e => e.currentTarget.style.borderColor = '#165DFF'}
onMouseLeave={e => e.currentTarget.style.borderColor = 'transparent'}
>
{/* 路线预览图 */}
<div style={{
width: 40,
height: 40,
borderRadius: 6,
background: '#e8f3ff',
overflow: 'hidden',
flexShrink: 0
}}>
{route.imgUrl ? (
<img
src={route.imgUrl}
alt={route.workName || route.name}
style={{ width: '100%', height: '100%', objectFit: 'cover' }}
/>
) : (
<div style={{
width: '100%',
height: '100%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
color: '#165DFF'
}}>
<EyeOutlined />
{routeList
.filter(item => {
if (!routeSearch) return true;
const name = (item.workName || item.name || '').toLowerCase();
const id = String(item.id || '').toLowerCase();
const key = routeSearch.toLowerCase();
return name.includes(key) || id.includes(key);
})
.map(route => (
<div
key={route.id}
style={{
padding: 12,
borderRadius: 8,
background: '#F7F8FA',
cursor: 'pointer',
border: '1px solid transparent',
display: 'flex',
gap: 12,
alignItems: 'center'
}}
onMouseEnter={e => e.currentTarget.style.borderColor = '#165DFF'}
onMouseLeave={e => e.currentTarget.style.borderColor = 'transparent'}
>
{/* 路线预览图 */}
<div style={{
width: 40,
height: 40,
borderRadius: 6,
background: '#e8f3ff',
overflow: 'hidden',
flexShrink: 0
}}>
{route.imgUrl ? (
<img
src={route.imgUrl}
alt={route.workName || route.name}
style={{ width: '100%', height: '100%', objectFit: 'cover' }}
/>
) : (
<div style={{
width: '100%',
height: '100%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
color: '#165DFF'
}}>
<EyeOutlined />
</div>
)}
</div>
{/* 路线信息 */}
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{ fontWeight: 600, fontSize: 14, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>
{route.workName || route.name || '未命名路线'}
</div>
<div style={{ fontSize: 12, color: '#86909C', marginTop: 4 }}>
ID: {route.id}
</div>
)}
</div>
{/* 路线信息 */}
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{ fontWeight: 600, fontSize: 14, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>
{route.workName || route.name || '未命名路线'}
</div>
<div style={{ fontSize: 12, color: '#86909C', marginTop: 4 }}>
ID: {route.id}
</div>
{/* 执行按钮 */}
<Tooltip title="执行航线">
<Button
type="text"
icon={<PlayCircleOutlined style={{ color: '#165DFF', fontSize: 28 }} />}
onClick={(e) => {
e.stopPropagation();
setSelectedPathWork(route);
setIsTaskModalOpen(true);
}}
/>
</Tooltip>
</div>
{/* 执行按钮 */}
<Tooltip title="执行航线">
<Button
type="text"
icon={<PlayCircleOutlined style={{ color: '#165DFF', fontSize: 28 }} />}
onClick={(e) => {
e.stopPropagation();
setSelectedPathWork(route);
setIsTaskModalOpen(true);
}}
/>
</Tooltip>
</div>
))}
))}
</div>
</Card>
</Col>