Files
web-Iot/src/components/devices/RobotTaskPage.tsx

779 lines
25 KiB
TypeScript
Raw Normal View History

2026-05-28 16:52:22 +08:00
import React, { useState, useEffect, useRef } from 'react';
import {
Row, Col, Card, Button, Space, Table, Tag, Typography, Progress, Badge,
Tabs, Input, Switch, Divider, Tooltip, Timeline, Select, message, DatePicker,
Modal, InputNumber,
TimePicker
2026-05-28 16:52:22 +08:00
} from 'antd';
import {
PlusOutlined, ImportOutlined, NodeIndexOutlined,
SaveOutlined, PlayCircleOutlined, EyeOutlined
2026-05-28 16:52:22 +08:00
} from '@ant-design/icons';
import {
Car, Navigation, Wind, Thermometer, Droplets, Satellite,
LayoutGrid, Clock, CheckCircle2, AlertCircle, Zap, Waves,
Calendar, User, TrendingUp, Maximize2, Play, Square, X, MapPin, RotateCw
} from 'lucide-react';
2026-05-28 16:52:22 +08:00
import {
getRobotRouteList,
getPlaneDeviceListAll, saveDeviceTask, getRobotTaskList
} from '../../api/device';
2026-05-28 16:52:22 +08:00
import dayjs from 'dayjs';
import utils from '../../lib/utils';
import CesiumMap from '../Map';
import { fix2, getVal } from '../../lib/utils';
import { useSelector } from 'react-redux';
import { RootState } from '@/src/store';
2026-05-28 16:52:22 +08:00
const { Text, Title } = Typography;
const { RangePicker } = DatePicker;
export default function RobotTaskPage({ devices }) {
2026-05-28 16:52:22 +08:00
const fontSmall = 'clamp(10px, 0.7vw, 11px)';
const fontNormal = 'clamp(12px, 0.75vw, 13px)';
const fontTitle = 'clamp(14px, 0.85vw, 16px)';
const fontLarge = 'clamp(18px, 1.1vw, 24px)';
const cardStyle = { borderRadius: 12, border: 'none', boxShadow: '0 2px 12px rgba(0,0,0,0.04)' };
// 任务列表 独立筛选状态
const [listRobot, setListRobot] = useState(null);
const [listDateRange, setListDateRange] = useState(null);
const [taskList, setTaskList] = useState([]);
// 工作看板 独立筛选状态
const [boardRobot, setBoardRobot] = useState(null);
const [boardDateRange, setBoardDateRange] = useState(null);
const [boardTaskList, setBoardTaskList] = useState([]);
const [selectedRoute, setSelectedRoute] = useState(null);
const [focusLocation, setFocusLocation] = useState(null);
const [points, setPoints] = useState([]);
const [loading, setLoading] = useState(false);
const [createTaskModal, setCreateTaskModal] = useState(false);
const [routeSearch, setRouteSearch] = useState('');
const [routeList, setRouteList] = useState([]);
const { stationId } = useSelector((state: RootState) => state.station);
// 新建任务弹窗状态
const [isTaskModalOpen, setIsTaskModalOpen] = useState(false);
const [selectedPathWork, setSelectedPathWork] = useState(null);
2026-05-28 16:52:22 +08:00
// 获取任务列表数据
const fetchTaskList = async () => {
2026-05-28 16:52:22 +08:00
try {
getRobotTaskList({ siteId: String(stationId) }).then(res => {
if (res.code == 200) {
setTaskList(res.data);
}
}).catch(() => setTaskList([]));
2026-05-28 16:52:22 +08:00
} catch (err) {
message.error('任务列表刷新失败');
2026-05-28 16:52:22 +08:00
}
};
// 获取路线列表
const fetchRouteList = async () => {
if (!stationId) return;
getRobotRouteList({ siteId: stationId }).then(res => {
if (res.code === 200 && res.data) {
setRouteList(res.data);
} else {
setRouteList([]);
}
}).catch(() => setRouteList([]));
2026-05-28 16:52:22 +08:00
};
useEffect(() => {
if (devices?.length) {
setListRobot(devices[0]);
setBoardRobot(null);
}
}, [devices]);
useEffect(() => {
if (stationId) {
fetchRouteList();
fetchTaskList()
}
}, [stationId]);
2026-05-28 16:52:22 +08:00
const taskColumns = [
{ title: '任务名称', dataIndex: 'workName', width: 200, ellipsis: true, fixed: "left" },
{ title: '设备名称', dataIndex: 'deviceName', width: 140 },
{ title: '执行人', dataIndex: 'userName', width: 100 },
{
title: '执行时间', dataIndex: 'createTime', width: 170,
render: t => t ? dayjs(t).format('YYYY-MM-DD HH:mm:ss') : '-'
},
{
title: '状态', dataIndex: 'status', width: 100,
render: (s) => <Tag color={s === 'success' ? 'success' : 'processing'}>{s === 'success' ? '完成' : '执行中'}</Tag>
}
];
const handleRowClick = (record) => {
if (record.longitude && record.latitude) {
setFocusLocation({
lon: record.longitude,
lat: record.latitude,
type: 'robot',
name: record.deviceName
});
}
};
const groupBoardData = () => {
const waitList = taskList.filter(item => item.status !== 'success');
const runList = taskList.filter(item => item.status === 'executing');
const finishList = taskList.filter(item => item.status === 'success');
return { waitList, runList, finishList };
};
const { waitList, runList, finishList } = groupBoardData();
const topCards = [
{ title: '今日机器人计划', value: taskList.length, unit: '条', desc: '进行中', icon: <LayoutGrid size={22} />, color: '#165DFF' },
{ title: '作业中机器人', value: runList.length, unit: '台', desc: '作业中', icon: <Car size={22} />, color: '#165DFF' },
{ title: '累计作业里程', value: '12.5', unit: 'km', trend: '较昨日 +1.2', trendColor: '#00B42A', icon: <TrendingUp size={22} />, color: '#722ED1' },
{ title: '任务完成率', value: taskList.length ? Math.round((finishList.length / taskList.length) * 100) : 0, unit: '%', trend: '较昨日 +5%', trendColor: '#00B42A', icon: <CheckCircle2 size={22} />, color: '#00B42A' },
{ title: '异常告警', value: '2', unit: '次', trend: '较昨日 -1', trendColor: '#00B42A', icon: <AlertCircle size={22} />, color: '#F53F3F' },
{ title: '在线率', value: '98', unit: '%', desc: '良好', icon: <Satellite size={22} />, color: '#165DFF' },
];
return (
<div className="normal-spacing" style={{ background: '#f5f7fa', minHeight: '100vh', padding: '0px', paddingTop: 0 }}>
<Row gutter={[16, 16]} style={{ marginBottom: 8 }}>
{topCards.map((item, index) => (
<Col xs={12} sm={8} md={4} key={index}>
<Card
bordered={false}
bodyStyle={{
padding: '12px 14px',
height: '100%',
display: 'flex',
alignItems: 'center'
}}
style={{
...cardStyle,
height: '100%',
minHeight: '84px'
}}
>
<div style={{ display: 'flex', alignItems: 'center', gap: 10, width: '100%' }}>
<div
style={{
width: 36,
height: 36,
background: 'rgba(22, 93, 255, 0.1)',
borderRadius: 10,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
color: item.color,
flexShrink: 0
}}
>
2026-05-28 16:52:22 +08:00
{React.cloneElement(item.icon as React.ReactElement, { size: 18 })}
</div>
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{ fontSize: 13, color: '#86909C', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>
{item.title}
</div>
<div style={{ display: 'flex', alignItems: 'baseline', gap: 4, margin: '2px 0' }}>
<span
style={{
fontSize: 'clamp(16px, 1vw, 20px)',
fontWeight: 700,
color: '#1D2129',
lineHeight: '1.2'
}}
>
{item.value}
</span>
2026-05-28 16:52:22 +08:00
<span style={{ fontSize: 9, color: '#4E5969' }}>{item.unit}</span>
</div>
<div
style={{
fontSize: 9,
color: item.trendColor || '#86909C',
fontWeight: 500,
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis'
}}
>
2026-05-28 16:52:22 +08:00
{item.trend || item.desc}
</div>
</div>
</div>
</Card>
</Col>
))}
</Row>
<Row gutter={10} style={{ marginBottom: 10 }}>
<Col xs={24} xl={14} style={{ display: "flex", flexDirection: "column" }}>
<Card
title={<span style={{ fontSize: fontNormal, fontWeight: 700 }}>机器人路径规划与监控</span>}
size="small"
extra={
<Space size={4}>
<Button size="small" icon={<PlusOutlined />} style={{ borderRadius: 4 }}>新增路线</Button>
<Button size="small" icon={<ImportOutlined />} style={{ borderRadius: 4 }}>导入</Button>
<Button size="small" icon={<SaveOutlined />} style={{ borderRadius: 4 }}>保存</Button>
<Button size="small" icon={<Maximize2 size={12} />} />
</Space>
}
bordered={false}
bodyStyle={{ padding: 0, position: 'relative' }}
style={{ ...cardStyle, marginBottom: 10 }}
>
<div style={{ width: '100%', height: 420, background: '#e8f3ff center/cover', position: 'relative' }}>
<CesiumMap devices={devices} points={points} focusLocation={focusLocation} from="device-control" />
</div>
</Card>
{/* 机器人任务列表 + 右侧 新建任务加号按钮 */}
2026-05-28 16:52:22 +08:00
<Card
title={
<div className="flex justify-between w-full items-center">
<span style={{ fontSize: 14, fontWeight: 700 }}>机器人任务列表</span>
<Space size={12}>
<RangePicker size="small" showTime format="YYYY-MM-DD HH:mm:ss" placeholder={['开始时间', '结束时间']} />
<Select
style={{ width: 180 }}
size="small"
placeholder="全部机器人"
options={devices?.map(item => ({
value: item.device_sn || item.serialNumber,
label: item.deviceAlias || item.deviceName
}))}
value={listRobot?.device_sn || listRobot?.serialNumber}
onChange={(val) => setListRobot(devices.find(i => (i.device_sn || i.serialNumber) === val))}
/>
{/* 🔥 新建任务按钮(加号) */}
<Tooltip title="创建任务">
<PlusOutlined
style={{ cursor: 'pointer', color: '#165DFF', fontSize: 12, marginLeft: 10 }}
onClick={() => setIsTaskModalOpen(true)}
/>
</Tooltip>
2026-05-28 16:52:22 +08:00
</Space>
</div>
}
size="small"
bordered={false}
bodyStyle={{ padding: 0, display: 'flex', flexDirection: 'column', height: "calc(100% - 40px)", overflow: "auto" }}
style={{ ...cardStyle, maxHeight: "250px", flex: 1, marginBottom: 0 }}
>
<Table
size="small"
rowKey="id"
columns={taskColumns}
dataSource={taskList}
pagination={false}
onRow={(record) => ({
onClick: () => handleRowClick(record),
style: { cursor: 'pointer' }
})}
/>
</Card>
</Col>
<Col xs={24} xl={10} style={{ display: "flex", flexDirection: "column" }} >
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>作业编排建议</span>}
bordered={false}
bodyStyle={{ padding: '12px 16px' }}
style={{ ...cardStyle, marginBottom: 8 }}
>
<Timeline mode="left">
<Timeline.Item label="09:30" color="green">
<Text strong>RBT-01 开始除草任务</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>预计耗时 2 小时,当前进度 45%</div>
</Timeline.Item>
<Timeline.Item label="11:00" color="blue">
<Text strong>RBT-02 预定巡检任务</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>待审批,建议执行区域 C</div>
</Timeline.Item>
<Timeline.Item label="14:00" color="gray">
<Text strong>设备例行维护</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>所有割草机返回充电站</div>
</Timeline.Item>
</Timeline>
<Button type="primary" block style={{ marginTop: 16, borderRadius: 18 }}>智能生成今日计划</Button>
</Card>
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>设备环境与状态</span>}
bordered={false}
bodyStyle={{ padding: '16px' }}
style={{ ...cardStyle, flex: 1 }}
>
<Row gutter={[16, 16]}>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>当前温度</div>
<div style={{ fontSize: 18, fontWeight: 700 }}>24.5 ℃</div>
</div>
</Col>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>环境湿度</div>
<div style={{ fontSize: 18, fontWeight: 700 }}>65 %</div>
</div>
</Col>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>定位精度</div>
<div style={{ fontSize: 18, fontWeight: 700, color: '#00B42A' }}>RTK 固定</div>
</div>
</Col>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>网络延迟</div>
<div style={{ fontSize: 18, fontWeight: 700 }}>45 ms</div>
</div>
</Col>
</Row>
<div style={{ marginTop: 20, padding: 12, background: 'rgba(255, 125, 0, 0.1)', borderRadius: 8, display: 'flex', alignItems: 'center', gap: 8 }}>
<AlertCircle size={16} style={{ color: '#FF7D00' }} />
<span style={{ fontSize: 13, color: '#FF7D00' }}>注意:区域 B 存在积水风险,建议避开</span>
</div>
</Card>
</Col>
</Row>
<Row gutter={16}>
<Col xs={24} xl={6}>
<Card
title={
<div className="flex justify-between items-center w-full">
<span style={{ fontSize: fontTitle, fontWeight: 700 }}>预设路线</span>
<Input
placeholder="搜索..."
size="small"
style={{ width: 100 }}
value={routeSearch}
onChange={e => setRouteSearch(e.target.value)}
/>
</div>
}
bordered={false}
bodyStyle={{ padding: '12px', height: 400, overflow: 'auto' }}
style={cardStyle}
>
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
2026-05-28 16:52:22 +08:00
{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'
2026-05-28 16:52:22 +08:00
}}
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>
2026-05-28 16:52:22 +08:00
</div>
{/* 执行按钮 */}
<Tooltip title="执行航线">
<Button
type="text"
icon={<PlayCircleOutlined style={{ color: '#165DFF', fontSize: 28 }} />}
onClick={(e) => {
e.stopPropagation();
setSelectedPathWork(route);
setIsTaskModalOpen(true);
}}
/>
</Tooltip>
2026-05-28 16:52:22 +08:00
</div>
))}
</div>
</Card>
</Col>
<Col xs={24} xl={18}>
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>任务看板</span>}
bordered={false}
bodyStyle={{ padding: '12px' }}
style={{ ...cardStyle, height: '100%' }}
>
<Row gutter={16}>
<Col span={8}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 8, height: 400 }}>
<Title level={5} style={{ fontSize: 14, marginBottom: 12 }}><Badge color="#86909C" text="待执行" /></Title>
{waitList.slice(0, 3).map((item, idx) => (
<Card key={idx} size="small" style={{ marginBottom: 8, borderRadius: 6 }}>
<div style={{ fontWeight: 600 }}>{item.workName}</div>
<div style={{ fontSize: 12, color: '#86909C' }}>设备: {item.deviceName}</div>
</Card>
))}
</div>
</Col>
<Col span={8}>
<div style={{ background: '#E8F3FF', padding: 12, borderRadius: 8, height: 400 }}>
<Title level={5} style={{ fontSize: 14, marginBottom: 12 }}><Badge color="#165DFF" text="进行中" /></Title>
{runList.map((item, idx) => (
<Card key={idx} size="small" style={{ marginBottom: 8, borderRadius: 6 }}>
<div style={{ fontWeight: 600 }}>{item.workName}</div>
<div style={{ fontSize: 12, color: '#165DFF' }}>正在执行...</div>
</Card>
))}
</div>
</Col>
<Col span={8}>
<div style={{ background: '#F6FFED', padding: 12, borderRadius: 8, height: 400 }}>
<Title level={5} style={{ fontSize: 14, marginBottom: 12 }}><Badge color="#52C41A" text="已完成" /></Title>
{finishList.slice(0, 3).map((item, idx) => (
<Card key={idx} size="small" style={{ marginBottom: 8, borderRadius: 6 }}>
<div style={{ fontWeight: 600 }}>{item.workName}</div>
<div style={{ fontSize: 12, color: '#52C41A' }}>已完成</div>
</Card>
))}
</div>
</Col>
</Row>
</Card>
</Col>
</Row>
{/* 🔥 传递 routeList 给弹窗 */}
<NewTaskModal
isOpen={isTaskModalOpen}
onClose={() => setIsTaskModalOpen(false)}
robots={devices}
selectedPathWork={selectedPathWork}
handlGetTaskList={fetchTaskList}
routeList={routeList}
stationId={stationId}
/>
2026-05-28 16:52:22 +08:00
</div>
);
}
const NewTaskModal = ({ isOpen, onClose, robots, selectedPathWork, handlGetTaskList, routeList, stationId }) => {
const [formData, setFormData] = useState({
path: selectedPathWork || null,
device: null,
repeatPlan: 'DAY',
days: [],
dayOfMonth: [],
startDate: '',
dayTime: '',
planName: '',
excuteDayStartTime: '',
excuteDayEndTime: '',
});
useEffect(() => {
if (selectedPathWork) {
setFormData(prev => ({ ...prev, path: selectedPathWork }));
}
}, [selectedPathWork]);
// ====================== 周/月选择 ======================
const weekDays = [
{ label: '日', value: 'SUNDAY' },
{ label: '一', value: 'MONDAY' },
{ label: '二', value: 'TUESDAY' },
{ label: '三', value: 'WEDNESDAY' },
{ label: '四', value: 'THURSDAY' },
{ label: '五', value: 'FRIDAY' },
{ label: '六', value: 'SATURDAY' },
];
const monthDays = Array.from({ length: 31 }, (_, i) => (i + 1).toString());
const handleToggleDay = (val) => {
setFormData(prev => {
const exists = prev.days.includes(val);
const newDays = exists ? prev.days.filter(d => d !== val) : [...prev.days, val];
return { ...prev, days: newDays };
});
};
const handleToggleMonthDay = (val) => {
setFormData(prev => {
const exists = prev.dayOfMonth.includes(val);
const newDays = exists ? prev.dayOfMonth.filter(d => d !== val) : [...prev.dayOfMonth, val];
return { ...prev, dayOfMonth: newDays };
});
};
// ====================== 日期时间 ======================
const handleDateChange = (date) => {
if (!date) return;
setFormData({ ...formData, startDate: date.format('YYYY-MM-DD') });
};
const handleTimeChange = (time, timeString) => {
setFormData({ ...formData, dayTime: timeString });
};
const handleCycleChange = (dates) => {
if (!dates || !dates[0] || !dates[1]) return;
setFormData({
...formData,
excuteDayStartTime: dates[0].format('YYYY-MM-DD'),
excuteDayEndTime: dates[1].format('YYYY-MM-DD')
});
};
// ====================== 保存 ======================
const handleSave = () => {
const missingFields = [];
if (!formData.device?.serialNumber) missingFields.push('设备编号');
if (!formData.planName) missingFields.push('任务名称');
if (!formData.path?.id) missingFields.push('路线');
if (!formData.excuteDayStartTime) missingFields.push('执行开始时间');
if (!formData.excuteDayEndTime) missingFields.push('执行结束时间');
if (missingFields.length > 0) {
utils.message.error({ title: '提示', content: `请填写:${missingFields.join('、')}` });
return;
}
const finalData = {
deviceId: formData.device.serialNumber,
planName: formData.planName,
routeId: formData.path.id,
siteId: stationId,
deviceTaskPlanRules: { type: formData.repeatPlan },
endTime: formData.excuteDayEndTime,
};
if (formData.repeatPlan === 'DAY') {
finalData.deviceTaskPlanRules = {
type: 'DAY',
startDate: formData.startDate,
dayTime: formData.dayTime
};
} else if (formData.repeatPlan === 'WEEK') {
finalData.deviceTaskPlanRules = {
type: 'WEEK',
days: formData.days,
dayTime: formData.dayTime
};
} else if (formData.repeatPlan === 'MONTH') {
finalData.deviceTaskPlanRules = {
type: 'MONTH',
dayOfMonth: formData.dayOfMonth,
dayTime: formData.dayTime
};
}
saveDeviceTask(finalData).then(res => {
if (res.code === 200) {
utils.message.success('任务创建成功');
onClose();
handlGetTaskList();
} else {
utils.message.error(res.data.msg || '创建失败');
}
}).catch(() => utils.message.error('创建任务异常'));
};
// ====================== 渲染 ======================
return (
<Modal
title="新建任务"
open={isOpen}
onCancel={onClose}
width={500}
maskClosable={false}
footer={null}
>
<div className="space-y-4">
{/* 任务名称 */}
<div>
<label className="block mb-2 font-medium">任务名称</label>
<Input
value={formData.planName}
onChange={(e) => setFormData({ ...formData, planName: e.target.value })}
placeholder="请输入任务名称"
/>
</div>
{/* 执行路线 */}
<div>
<label className="block mb-2 font-medium">执行路线</label>
<Select
className="w-full"
placeholder="选择路线"
onSelect={(_, option) => {
const route = routeList.find(r => r.id === option.value);
setFormData(prev => ({ ...prev, path: route }));
}}
value={formData.path?.id}
>
{routeList.map(route => (
<Select.Option
key={route.id}
value={route.id}
>
{route.workName || route.name}
</Select.Option>
))}
</Select>
</div>
{/* 选择设备 */}
<div className="relative">
<label className="block mb-2 font-medium">选择设备</label>
<Select
className="w-full"
placeholder="选择设备"
onSelect={(_, option) => {
const robot = robots.find(r => r.serialNumber === option.value);
setFormData(prev => ({ ...prev, device: robot }));
}}
value={formData.device?.serialNumber}
>
{robots.map(robot => (
<Select.Option
key={robot.serialNumber}
value={robot.serialNumber}
>
{robot.deviceAlias} ({robot.serialNumber})
</Select.Option>
))}
</Select>
</div>
{/* 重复计划 */}
<div>
<label className="block mb-2 font-medium">重复计划</label>
<Select
value={formData.repeatPlan}
onChange={(val) => setFormData({ ...formData, repeatPlan: val })}
className="w-full"
>
<Select.Option value="DAY">天</Select.Option>
<Select.Option value="WEEK">周</Select.Option>
<Select.Option value="MONTH">月</Select.Option>
</Select>
</div>
{/* 周选择 */}
{formData.repeatPlan === 'WEEK' && (
<div className="flex gap-1 flex-wrap">
{weekDays.map(day => (
<Button
key={day.value}
type={formData.days.includes(day.value) ? 'primary' : 'default'}
onClick={() => handleToggleDay(day.value)}
size="small"
shape="circle"
>
{day.label}
</Button>
))}
</div>
)}
{/* 月选择 */}
{formData.repeatPlan === 'MONTH' && (
<div className="grid grid-cols-7 gap-1">
{monthDays.map(day => (
<Button
key={day}
type={formData.dayOfMonth.includes(day) ? 'primary' : 'default'}
onClick={() => handleToggleMonthDay(day)}
size="small"
>
{day}
</Button>
))}
</div>
)}
{/* 按天:选择日期 */}
{formData.repeatPlan === 'DAY' && (
<>
<label className="block mb-2 font-medium">执行日期</label>
<DatePicker
onChange={handleDateChange}
className="w-full"
placeholder="选择执行日期"
/>
</>
)}
{/* 时间 */}
<label className="block mb-2 font-medium">执行时间</label>
<TimePicker
format="HH:mm:ss"
onChange={handleTimeChange}
className="w-full"
placeholder="选择执行时间"
/>
{/* 执行周期 */}
<label className="block mb-2 font-medium">执行周期</label>
<RangePicker
onChange={handleCycleChange}
className="w-full"
placeholder={['开始日期', '结束日期']}
/>
{/* 底部按钮 */}
<div className="flex justify-end gap-2 mt-6">
<Button onClick={onClose}>取消</Button>
<Button type="primary" onClick={handleSave}>保存任务</Button>
</div>
</div>
</Modal>
);
};