1788 lines
68 KiB
TypeScript
1788 lines
68 KiB
TypeScript
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
||
import {
|
||
Row, Col, Card, Button, Space, Table, Tag, Typography, Progress, Badge,
|
||
Tabs, Input, Switch, Divider, Tooltip, Timeline, Select, message, DatePicker,
|
||
Modal, InputNumber
|
||
} from 'antd';
|
||
import {
|
||
PlusOutlined, ImportOutlined, NodeIndexOutlined,
|
||
SaveOutlined, FullscreenOutlined, EnvironmentOutlined,
|
||
BranchesOutlined, CloudOutlined, ThunderboltOutlined, CheckCircleOutlined,
|
||
InfoCircleOutlined, ClockCircleOutlined,
|
||
SettingOutlined, WarningOutlined, ArrowRightOutlined,
|
||
SearchOutlined, MoreOutlined, AimOutlined, PlayCircleOutlined,
|
||
DeleteOutlined
|
||
} from '@ant-design/icons';
|
||
import {
|
||
Plane, Navigation, Wind, Thermometer, Droplets, Satellite,
|
||
LayoutGrid, Clock, CheckCircle2, AlertCircle, Zap, Waves,
|
||
Calendar, User, TrendingUp, Maximize2, Play, Square, X, MapPin, RotateCw
|
||
} from 'lucide-react';
|
||
import {
|
||
getsinglePlan, getsinglePlanTrack, updateFlightTaskStatus, postFlightCommmand, getWayLine, createWaylineTask, getFlightTaskDetail, getSiteUAVList
|
||
} from '@/api/device';
|
||
import dayjs from 'dayjs';
|
||
import utils from '@/lib/utils';
|
||
import CesiumMap from '../Map';
|
||
import { getUAVState } from '@/api/device';
|
||
import { fix2, getVal } from '@/lib/utils';
|
||
import { useMqtt } from '@/hooks/useMqtt';
|
||
import envConfig from '../../../env';
|
||
import { useSelector } from 'react-redux';
|
||
import { RootState } from '@/store';
|
||
import { useTranslation } from 'react-i18next';
|
||
|
||
const { Text, Title } = Typography;
|
||
const { RangePicker } = DatePicker;
|
||
|
||
export default function WayLinePage({ onRefresh }) {
|
||
const { t } = useTranslation();
|
||
const { userInfo } = useSelector((state: RootState) => state.user);
|
||
const { timezone } = useSelector((state: RootState) => state.preferences);
|
||
const { stationId } = useSelector((state: RootState) => state.station);
|
||
const { currentStation } = useSelector((state: RootState) => state.station);
|
||
|
||
|
||
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 [planedevices, setPlaneDevices] = useState([]);
|
||
const [listDrone, setListDrone] = useState(null);
|
||
const [listDroneRealtime, setListDroneRealtime] = useState(null);
|
||
const [listDateRange, setListDateRange] = useState(null);
|
||
const [taskList, setTaskList] = useState([]);
|
||
const [persistentDroneData, setPersistentDroneData] = useState(null); // 持久化无人机数据
|
||
const [persistentHostData, setPersistentHostData] = useState(null); // 持久化机场数据
|
||
const [clearNavLine, setClearNavLine] = useState(0);
|
||
const [clearPlanLine, setClearPlanLine] = useState(0);
|
||
|
||
// 获取数据
|
||
const fetchAllData = async () => {
|
||
if (!stationId) return;
|
||
|
||
try {
|
||
const planeRes = await getSiteUAVList(stationId);
|
||
|
||
// 处理无人机 + 自动补全地图需要的字段
|
||
let planeData = planeRes?.code === 200 ? (planeRes?.rows || []) : [];
|
||
|
||
planeData = planeData.map(item => ({
|
||
...item,
|
||
type: 'plane',
|
||
lastRunningStatus: {
|
||
longitude: item.longitude || 0,
|
||
latitude: item.latitude || 0,
|
||
},
|
||
deviceAlias: item.drone_callsign || item.device_sn
|
||
|| t('constants.uav'),
|
||
|
||
}));
|
||
|
||
setPlaneDevices(planeData);
|
||
|
||
} catch (err) {
|
||
console.error('数据请求失败', err);
|
||
}
|
||
};
|
||
|
||
useEffect(() => {
|
||
fetchAllData();
|
||
}, [userInfo, stationId]);
|
||
|
||
|
||
// 当MQTT数据更新时,更新持久化数据(只在有新数据时更新)
|
||
const handleMqttMessage = useCallback((topic, message) => {
|
||
|
||
try {
|
||
const parsedMessage = JSON.parse(message);
|
||
|
||
if (parsedMessage.data && parsedMessage.data.host) {
|
||
const { host } = parsedMessage.data;
|
||
if (host?.job_number) { return; }
|
||
|
||
// 判断是无人机数据还是机场数据:无人机数据有 battery 字段
|
||
const isDroneData = host.battery !== undefined;
|
||
|
||
if (isDroneData) {
|
||
// 处理无人机数据
|
||
setPersistentDroneData(prevData => {
|
||
const newData = { ...prevData };
|
||
|
||
// 无人机特有字段
|
||
if (host.battery?.capacity_percent !== undefined) {
|
||
newData.capacity_percent = host.battery.capacity_percent;
|
||
}
|
||
if (host.attitude_head !== undefined) {
|
||
newData.heading = host.attitude_head;
|
||
}
|
||
if (host.horizontal_speed !== undefined) {
|
||
newData.horizontal_speed = host.horizontal_speed;
|
||
}
|
||
if (host.vertical_speed !== undefined) {
|
||
newData.vertical_speed = host.vertical_speed;
|
||
}
|
||
if (host.total_flight_time !== undefined) {
|
||
newData.total_flight_time = host.total_flight_time;
|
||
}
|
||
if (host.total_flight_sorties !== undefined) {
|
||
newData.total_flight_sorties = host.total_flight_sorties;
|
||
}
|
||
if (host.mode_code !== undefined) {
|
||
newData.mode_code = host.mode_code;
|
||
}
|
||
|
||
// 通用字段
|
||
if (host.height !== undefined) {
|
||
newData.height = host.height;
|
||
}
|
||
if (host.wind_speed !== undefined) {
|
||
newData.wind_speed = host.wind_speed;
|
||
}
|
||
if (host.position_state !== undefined) {
|
||
newData.position_state = host.position_state;
|
||
}
|
||
if (host.longitude !== undefined) {
|
||
newData.longitude = host.longitude;
|
||
}
|
||
if (host.latitude !== undefined) {
|
||
newData.latitude = host.latitude;
|
||
}
|
||
|
||
return newData;
|
||
});
|
||
} else {
|
||
// 处理机场数据
|
||
setPersistentHostData(prevData => {
|
||
const newData = { ...prevData };
|
||
|
||
// 机场特有字段
|
||
if (host.drone_charge_state?.capacity_percent !== undefined) {
|
||
newData.capacity_percent = host.drone_charge_state.capacity_percent;
|
||
}
|
||
if (host.air_conditioner?.air_conditioner_state !== undefined) {
|
||
newData.air_conditioner_state = host.air_conditioner.air_conditioner_state;
|
||
}
|
||
if (host.air_conditioner_state !== undefined) {
|
||
newData.air_conditioner_state = host.air_conditioner_state;
|
||
}
|
||
|
||
// 通用字段
|
||
if (host.environment_temperature !== undefined) {
|
||
newData.environment_temperature = host.environment_temperature;
|
||
}
|
||
if (host.wind_speed !== undefined) {
|
||
newData.wind_speed = host.wind_speed;
|
||
}
|
||
if (host.rainfall !== undefined) {
|
||
newData.rainfall = host.rainfall === 0 ? 'no_rain' : 'rain';
|
||
}
|
||
if (host.humidity !== undefined) {
|
||
newData.humidity = host.humidity;
|
||
}
|
||
if (host.drone_in_dock !== undefined) {
|
||
newData.drone_in_dock = host.drone_in_dock;
|
||
}
|
||
if (host.cover_state !== undefined) {
|
||
newData.cover_state = host.cover_state;
|
||
}
|
||
if (host.temperature !== undefined) {
|
||
newData.temperature = host.temperature;
|
||
}
|
||
if (host.home_distance !== undefined) {
|
||
newData.home_distance = host.home_distance;
|
||
}
|
||
|
||
return newData;
|
||
});
|
||
}
|
||
}
|
||
} catch (err) {
|
||
console.error('WayLinePage MQTT 消息解析失败:', err);
|
||
}
|
||
}, []);
|
||
|
||
// 根据选中设备动态构建MQTT主题
|
||
const mqttTopics = React.useMemo(() => {
|
||
if (!listDrone) {
|
||
return [];
|
||
}
|
||
const topics = [];
|
||
if (listDrone.device_sn) {
|
||
topics.push(`thing/product/${listDrone.device_sn}/osd`);
|
||
}
|
||
if (listDrone.gateway_sn && listDrone.gateway_sn !== listDrone.device_sn) {
|
||
topics.push(`thing/product/${listDrone.gateway_sn}/osd`);
|
||
}
|
||
return topics;
|
||
}, [listDrone]);
|
||
|
||
// 订阅MQTT消息
|
||
useMqtt({
|
||
url: envConfig.mqtt_url,
|
||
topic: mqttTopics,
|
||
onMessage: handleMqttMessage,
|
||
enabled: mqttTopics.length > 0,
|
||
});
|
||
|
||
// 优先使用持久化数据,保持显示稳定
|
||
const mqttDerivedData = React.useMemo(() => {
|
||
return { ...persistentHostData, ...persistentDroneData };
|
||
}, [persistentDroneData, persistentHostData]);
|
||
|
||
// 定时获取任务列表所选无人机的实时状态
|
||
useEffect(() => {
|
||
const fetchRealtime = async () => {
|
||
if (listDrone?.gateway_sn && listDrone?.device_sn) {
|
||
try {
|
||
const res = await getUAVState({
|
||
sn: listDrone.gateway_sn,
|
||
droneSn: listDrone.device_sn
|
||
});
|
||
if (res.code === 200) {
|
||
setListDroneRealtime(res.data);
|
||
}
|
||
} catch (err) {
|
||
console.error('获取列表无人机实时状态失败', err);
|
||
}
|
||
} else {
|
||
setListDroneRealtime(null);
|
||
}
|
||
};
|
||
|
||
fetchRealtime();
|
||
}, [listDrone]);
|
||
|
||
// 工作看板 独立筛选状态
|
||
const [boardDrone, setBoardDrone] = useState(null);
|
||
const [boardDateRange, setBoardDateRange] = useState(null);
|
||
const [boardTaskList, setBoardTaskList] = useState([]);
|
||
|
||
// ✅ 航线列表 独立无人机筛选(新增)
|
||
const [waylineDrone, setWaylineDrone] = useState(null);
|
||
const [focusLocation, setFocusLocation] = useState(null);
|
||
|
||
const [points, setPoints] = useState([]);
|
||
|
||
const fetchAndFocusDrone = async (drone) => {
|
||
if (!drone?.gateway_sn || !drone?.device_sn) return;
|
||
try {
|
||
const res = await getUAVState({
|
||
sn: drone.gateway_sn,
|
||
droneSn: drone.device_sn
|
||
});
|
||
if (res.code === 200 && res.data) {
|
||
setFocusLocation({
|
||
lon: res.data.longitude,
|
||
lat: res.data.latitude,
|
||
type: drone.type || 'plane',
|
||
name: drone.drone_callsign || drone.name || drone.device_sn
|
||
});
|
||
}
|
||
} catch (err) {
|
||
console.error('获取无人机位置失败', err);
|
||
}
|
||
};
|
||
|
||
// 航线列表相关状态
|
||
const [selectedWayline, setSelectedWayline] = useState(null);
|
||
const [rthModalVisible, setRthModalVisible] = useState(false);
|
||
const [tempRthAltitude, setTempRthAltitude] = useState(100);
|
||
const [waylineSearch, setWaylineSearch] = useState('');
|
||
|
||
// 任务控制相关状态
|
||
const [selectedTask, setSelectedTask] = useState(null);
|
||
const [taskstatus, setTaskStatus] = useState('suspended');
|
||
const [isReturningHome, setIsReturningHome] = useState(false);
|
||
const [isTaskPaused, setIsTaskPaused] = useState(false);
|
||
const [flightCommandLoading, setFlightCommandLoading] = useState(false);
|
||
const [loading, setLoading] = useState(false);
|
||
|
||
// ==============================================
|
||
// ✅ 创建任务弹窗相关状态(已完整整合)
|
||
// ==============================================
|
||
const [createTaskModal, setCreateTaskModal] = useState(false);
|
||
const [taskDetail, setTaskDetail] = useState(null);
|
||
const [waylineUuid, setWaylineUuid] = useState('');
|
||
const [waylineList, setWaylineList] = useState([]); // 航线列表
|
||
const [taskForm, setTaskForm] = useState({
|
||
name: '',
|
||
sn: '',
|
||
landing_dock_sn: '',
|
||
rth_altitude: 10,
|
||
rth_mode: 'optimal',
|
||
wayline_precision_type: 'gps',
|
||
resumable_status: 'auto',
|
||
min_battery_capacity: 50,
|
||
task_type: 'immediate',
|
||
repeat_type: 'nonrepeating',
|
||
repeat_option: {
|
||
interval: 1,
|
||
days_of_week: [],
|
||
days_of_month: [],
|
||
week_of_month: 1,
|
||
},
|
||
time_zone: timezone,
|
||
|
||
recurring_task_start_time_list: [],
|
||
});
|
||
// 根据 repeat_type 自动构建接口需要的 repeat_option
|
||
const buildRepeatOption = () => {
|
||
const { repeat_type, repeat_option } = taskForm;
|
||
const { interval, days_of_week, days_of_month, week_of_month } = repeat_option;
|
||
|
||
if (repeat_type === 'nonrepeating') return undefined;
|
||
|
||
switch (repeat_type) {
|
||
case 'daily':
|
||
return { interval: Math.max(1, interval) };
|
||
|
||
case 'weekly':
|
||
return { interval, days_of_week };
|
||
|
||
case 'absolute_monthly':
|
||
return { interval, days_of_month };
|
||
|
||
case 'relative_monthly':
|
||
return { interval, week_of_month, days_of_week };
|
||
|
||
default:
|
||
return undefined;
|
||
}
|
||
};
|
||
|
||
const fetchWaylineList = async () => {
|
||
try {
|
||
const res = await getWayLine();
|
||
if (res?.code == 200 || res?.code == 0) {
|
||
const _list = res?.data?.list.map(item => {
|
||
return {
|
||
...item,
|
||
label: item.name || t('devices.waylineFallback', { id: item.id || t('constants.locationUnknown') }),
|
||
value: item.id
|
||
}
|
||
})
|
||
setWaylineList(_list || []);
|
||
}
|
||
} catch (err) {
|
||
message.error(t('devices.waylineListFetchFail'));
|
||
}
|
||
};
|
||
|
||
|
||
// 关闭弹窗重置
|
||
const resetModals = () => {
|
||
setCreateTaskModal(false);
|
||
setWaylineUuid('');
|
||
setTaskForm({
|
||
name: '',
|
||
sn: waylineDrone?.gateway_sn || '',
|
||
landing_dock_sn: '',
|
||
rth_altitude: 10,
|
||
rth_mode: 'optimal',
|
||
wayline_precision_type: 'gps',
|
||
resumable_status: 'auto',
|
||
min_battery_capacity: 50,
|
||
task_type: 'immediate',
|
||
repeat_type: 'nonrepeating',
|
||
repeat_option: { interval: 1 },
|
||
time_zone: timezone,
|
||
begin_at: null,
|
||
end_at: null,
|
||
recurring_task_start_time_list: [],
|
||
});
|
||
};
|
||
|
||
// 创建任务提交
|
||
const createFlightTask = async () => {
|
||
if (!taskForm.name || !waylineUuid || !taskForm.sn) {
|
||
utils.message.warning(t('devices.fillRequiredFields'));
|
||
return;
|
||
}
|
||
setLoading(true);
|
||
try {
|
||
const payload = {
|
||
...taskForm,
|
||
wayline_uuid: waylineUuid,
|
||
repeat_type: taskForm.repeat_type,
|
||
repeat_option: buildRepeatOption(),
|
||
recurring_task_start_time_list: taskForm.recurring_task_start_time_list.map(t => dayjs(t).unix()),
|
||
};
|
||
|
||
const res: any = await createWaylineTask(payload);
|
||
if (res.code === 200 || res.code === 0) {
|
||
utils.message.success(t('devices.createTaskSuccess'));
|
||
resetModals();
|
||
getListTask();
|
||
if (onRefresh) onRefresh();
|
||
} else {
|
||
utils.message.error(res.msg || t('devices.createTaskFail'));
|
||
}
|
||
} catch (err) {
|
||
utils.message.error(t('devices.createTaskException'));
|
||
} finally {
|
||
setLoading(false);
|
||
}
|
||
};
|
||
|
||
// 航线列表无人机变更时同步到表单
|
||
useEffect(() => {
|
||
if (waylineDrone) {
|
||
setTaskForm(prev => ({
|
||
...prev,
|
||
sn: waylineDrone.gateway_sn || ''
|
||
}));
|
||
}
|
||
}, [waylineDrone]);
|
||
|
||
// 顶部统计
|
||
const [todayCount, setTodayCount] = useState(0);
|
||
const [yesterdayCount, setYesterdayCount] = useState(0);
|
||
const [trend, setTrend] = useState('');
|
||
const [trendColor, setTrendColor] = useState('');
|
||
|
||
// 计算今日/昨日任务数量
|
||
const calcTodayTaskCount = () => {
|
||
if (!taskList?.length) return;
|
||
|
||
const todayStart = dayjs().startOf('day').valueOf();
|
||
const todayEnd = dayjs().endOf('day').valueOf();
|
||
const yesterdayStart = dayjs().subtract(1, 'day').startOf('day').valueOf();
|
||
const yesterdayEnd = dayjs().subtract(1, 'day').endOf('day').valueOf();
|
||
|
||
const todayTotal = taskList.filter(t => {
|
||
const time = dayjs(t.begin_at).valueOf();
|
||
return time >= todayStart && time <= todayEnd;
|
||
}).length;
|
||
|
||
const yesterdayTotal = taskList.filter(t => {
|
||
const time = dayjs(t.begin_at).valueOf();
|
||
return time >= yesterdayStart && time <= yesterdayEnd;
|
||
}).length;
|
||
|
||
const diff = todayTotal - yesterdayTotal;
|
||
let trendText = '';
|
||
let color = '#00B42A';
|
||
|
||
if (diff > 0) {
|
||
trendText = t('devices.trendYesterday', { diff: `+${diff}` });
|
||
color = '#00B42A';
|
||
} else if (diff < 0) {
|
||
trendText = t('devices.trendYesterday', { diff });
|
||
color = '#F53F3F';
|
||
} else {
|
||
trendText = t('devices.trendFlat');
|
||
color = '#86909C';
|
||
}
|
||
|
||
setTodayCount(todayTotal);
|
||
setYesterdayCount(yesterdayTotal);
|
||
setTrend(trendText);
|
||
setTrendColor(color);
|
||
};
|
||
|
||
useEffect(() => {
|
||
calcTodayTaskCount();
|
||
}, [taskList]);
|
||
|
||
|
||
// 获取任务列表数据
|
||
const getListTask = async () => {
|
||
if (!planedevices?.length) return;
|
||
try {
|
||
const defaultStart = dayjs().startOf('day').unix();
|
||
const defaultEnd = dayjs().endOf('day').unix();
|
||
|
||
const [beginAt, endAt] = listDateRange?.length === 2
|
||
? [dayjs(listDateRange[0]).unix(), dayjs(listDateRange[1]).unix()]
|
||
: [defaultStart, defaultEnd];
|
||
|
||
const sns = listDrone ? [listDrone.gateway_sn] : planedevices.map(item => item.gateway_sn);
|
||
const res = await getsinglePlan({ sns, beginAt, endAt });
|
||
if (res?.code === 200) {
|
||
let combinedList = [];
|
||
if (res.data) {
|
||
Object.values(res.data).forEach((item: any) => {
|
||
if (item.list) combinedList = combinedList.concat(item.list);
|
||
});
|
||
}
|
||
setTaskList(combinedList);
|
||
}
|
||
} catch (err) {
|
||
message.error(t('devices.taskListFetchFail'));
|
||
}
|
||
};
|
||
|
||
// 获取看板任务数据
|
||
const getBoardTask = async () => {
|
||
if (!planedevices?.length) return;
|
||
try {
|
||
|
||
const defaultStart = dayjs().startOf('day').unix();
|
||
const defaultEnd = dayjs().endOf('day').unix();
|
||
|
||
const [beginAt, endAt] = boardDateRange?.length === 2
|
||
? [dayjs(boardDateRange[0]).unix(), dayjs(boardDateRange[1]).unix()]
|
||
: [defaultStart, defaultEnd];
|
||
|
||
const sns = boardDrone ? [boardDrone.gateway_sn] : planedevices.map(item => item.gateway_sn);
|
||
const res = await getsinglePlan({ sns, beginAt, endAt });
|
||
if (res?.code === 200) {
|
||
let combinedList = [];
|
||
if (res.data) {
|
||
Object.values(res.data).forEach((item: any) => {
|
||
if (item.list) combinedList = combinedList.concat(item.list);
|
||
});
|
||
}
|
||
setBoardTaskList(combinedList);
|
||
}
|
||
} catch (err) {
|
||
message.error(t('devices.boardTaskFetchFail'));
|
||
}
|
||
};
|
||
|
||
useEffect(() => {
|
||
fetchWaylineList();
|
||
}, [])
|
||
|
||
|
||
// 初始化默认设备
|
||
useEffect(() => {
|
||
if (planedevices?.length) {
|
||
setListDrone(planedevices[0]);
|
||
setWaylineDrone(planedevices[0]); // 航线列表默认选中第一个
|
||
setBoardDrone(null);
|
||
}
|
||
}, [planedevices]);
|
||
|
||
useEffect(() => {
|
||
getListTask();
|
||
}, [listDrone, listDateRange]);
|
||
|
||
useEffect(() => {
|
||
getBoardTask();
|
||
}, [boardDrone, boardDateRange, planedevices?.length]);
|
||
const realtimePosition = React.useMemo(() => {
|
||
|
||
if (persistentDroneData?.longitude && persistentDroneData?.latitude) {
|
||
return {
|
||
lon: persistentDroneData.longitude,
|
||
lat: persistentDroneData.latitude,
|
||
heading: persistentDroneData.heading || 0,
|
||
};
|
||
}
|
||
}, [persistentDroneData]);
|
||
|
||
// 任务状态标签
|
||
const getStatusTag = (status) => {
|
||
const statusMap = {
|
||
success: { color: 'success', text: t('devices.statusExecSuccess') },
|
||
preparing: { color: 'blue', text: t('devices.statusPreparing') },
|
||
running: { color: 'processing', text: t('workOrder.inProgress') },
|
||
failed: { color: 'error', text: t('devices.statusExecFailed') },
|
||
waiting: { color: 'default', text: t('devices.statusWaitingStart') },
|
||
starting_failure: { color: 'error', text: t('devices.statusStartFailed') },
|
||
executing: { color: 'processing', text: t('workOrder.inProgress') },
|
||
suspended: { color: 'warning', text: t('workOrder.suspended') },
|
||
restored: { color: 'processing', text: t('devices.statusRestored') },
|
||
terminated: { color: 'default', text: t('devices.statusTerminated') },
|
||
timeout: { color: 'error', text: t('devices.statusTimeout') },
|
||
};
|
||
const item = statusMap[status] || { color: 'default', text: status };
|
||
return <Tag color={item.color}>{item.text}</Tag>;
|
||
};
|
||
|
||
// 列表表格列
|
||
const taskColumns = [
|
||
{ title: t('devices.taskName'), dataIndex: 'name', width: 260, ellipsis: true, fixed: "left" },
|
||
{ title: t('devices.deviceSn'), dataIndex: 'sn', width: 140 },
|
||
{ title: t('roles.status'), dataIndex: 'status', width: 80, render: getStatusTag },
|
||
{
|
||
title: t('devices.startTime'), dataIndex: 'begin_at', width: 170,
|
||
render: t => t ? dayjs(t).format('YYYY-MM-DD HH:mm:ss') : '-'
|
||
},
|
||
{
|
||
title: t('devices.endTime'), dataIndex: 'end_at', width: 170,
|
||
render: t => t ? dayjs(t).format('YYYY-MM-DD HH:mm:ss') : '-'
|
||
},
|
||
];
|
||
const getTrackFn = async (record) => {
|
||
const res = await getsinglePlanTrack(record);
|
||
if (res.code === 0 && res.data.track?.points?.length) {
|
||
const points = res.data.track.points.map(item => ({
|
||
lng: item.longitude || item.lon,
|
||
lat: item.latitude || item.lat
|
||
}));
|
||
setPoints(points);
|
||
} else {
|
||
utils.message.warning(t('devices.noWaylineData'));
|
||
setPoints([]);
|
||
}
|
||
}
|
||
|
||
// 表格行点击查看轨迹
|
||
const handleRowClick = async (record) => {
|
||
setSelectedTask(record);
|
||
try {
|
||
getTaskDetail(record.uuid);
|
||
await getTrackFn(record);
|
||
|
||
} catch (err) {
|
||
message.error(t('devices.requestFail'));
|
||
}
|
||
};
|
||
|
||
// 航线列表点击处理
|
||
const handleWaylineClick = (wayline) => {
|
||
setSelectedWayline(wayline);
|
||
if (wayline.points && wayline.points.length > 0) {
|
||
const mapPoints = wayline.points.map(p => ({
|
||
lon: p.longitude || p.lon,
|
||
lat: p.latitude || p.lat
|
||
}));
|
||
setPoints(mapPoints);
|
||
} else if (wayline.track?.points?.length > 0) {
|
||
const mapPoints = wayline.track.points.map(p => ({
|
||
lon: p.longitude || p.lon,
|
||
lat: p.latitude || p.lat
|
||
}));
|
||
setPoints(mapPoints);
|
||
}
|
||
};
|
||
|
||
|
||
// 执行航线按钮点击(改为图标)
|
||
const handleExecuteClick = (e, wayline) => {
|
||
e.stopPropagation();
|
||
// ✅ 使用航线列表自己的无人机
|
||
if (!waylineDrone?.gateway_sn) {
|
||
utils.message.warning(t('devices.selectExecuteDroneFirst'));
|
||
return;
|
||
}
|
||
setSelectedWayline(wayline);
|
||
setTempRthAltitude(100);
|
||
setRthModalVisible(true);
|
||
};
|
||
useEffect(() => {
|
||
fetchAndFocusDrone(waylineDrone);
|
||
}, [waylineDrone])
|
||
|
||
// 确认执行航线任务
|
||
const confirmExecuteWayline = async () => {
|
||
if (!selectedWayline || !waylineDrone?.gateway_sn) return;
|
||
|
||
setLoading(true);
|
||
try {
|
||
const payload = {
|
||
name: `${selectedWayline.name}_${dayjs().format('MMDDHHmm')}`,
|
||
sn: waylineDrone.gateway_sn, // ✅ 使用航线列表无人机
|
||
wayline_uuid: selectedWayline.id || selectedWayline.uuid,
|
||
rth_altitude: tempRthAltitude,
|
||
task_type: 'immediate',
|
||
rth_mode: 'optimal',
|
||
wayline_precision_type: 'gps',
|
||
resumable_status: 'auto',
|
||
min_battery_capacity: 50,
|
||
repeat_type: 'nonrepeating',
|
||
time_zone: timezone,
|
||
};
|
||
|
||
const res: any = await createWaylineTask(payload);
|
||
if (res.code === 200 || res.code === 0) {
|
||
utils.message.success(t('devices.waylineTaskCreated'));
|
||
setRthModalVisible(false);
|
||
getListTask();
|
||
//if (onRefresh) {
|
||
// setTimeout(() => {
|
||
// onRefresh();
|
||
// }, 1500)
|
||
//}
|
||
|
||
//await getTrackFn({
|
||
// uuid: res.data.task_uuid
|
||
|
||
//});
|
||
} else {
|
||
utils.message.error(res.msg || t('devices.waylineExecFail'));
|
||
}
|
||
} catch (err) {
|
||
utils.message.error(t('devices.createTaskException'));
|
||
} finally {
|
||
setLoading(false);
|
||
}
|
||
};
|
||
|
||
// 看板数据分组处理
|
||
const groupBoardData = () => {
|
||
const waitList = boardTaskList.filter(item =>
|
||
['preparing', 'waiting', 'suspended', 'terminated'].includes(item.status)
|
||
);
|
||
const runList = boardTaskList.filter(item =>
|
||
['running', 'executing', 'restored'].includes(item.status)
|
||
);
|
||
const finishList = boardTaskList.filter(item =>
|
||
['success'].includes(item.status)
|
||
);
|
||
return { waitList, runList, finishList };
|
||
};
|
||
const { waitList, runList, finishList } = groupBoardData();
|
||
|
||
const topCards = [
|
||
{
|
||
title: t('devices.todayWaylinePlan'), value: todayCount, unit: t('devices.unitTiao'), desc: t('devices.inProgressDesc'), trend: trend, trendColor: trendColor,
|
||
icon: <LayoutGrid size={22} />, color: '#165DFF'
|
||
},
|
||
{ title: t('devices.executingTasks'), value: runList.length, unit: t('devices.unitGe'), desc: t('devices.inProgressDesc'), icon: <Plane size={22} />, color: '#165DFF' },
|
||
{ title: t('devices.pendingApprovalTasks'), value: '4', unit: t('devices.unitGe'), trend: t('devices.trendYesterday', { diff: '-1' }), trendColor: '#F53F3F', icon: <Calendar size={22} />, color: '#FF7D00' },
|
||
{ title: t('devices.taskCompletionRate'), value: finishList.length ? Math.round((finishList.length / taskList.length) * 100) : 0, unit: '%', trend: t('devices.trendYesterday', { diff: '+6%' }), trendColor: '#00B42A', icon: <CheckCircle2 size={22} />, color: '#00B42A' },
|
||
{ title: t('devices.aiOptimizeGain'), value: '+7.8', unit: '%', trend: t('devices.trendYesterday', { diff: '+1.2%' }), trendColor: '#00B42A', icon: <TrendingUp size={22} />, color: '#722ED1' },
|
||
{ title: t('devices.coverageEquipment'), value: t('devices.coverageValue', { types: '4', units: '9' }), unit: '', desc: t('devices.allOnline'), icon: <Satellite size={22} />, color: '#165DFF' },
|
||
];
|
||
|
||
// 指令下发逻辑
|
||
const sendFlightCommand = async (command: 'return_home' | 'return_home_cancel' | 'flighttask_pause' | 'flighttask_recovery') => {
|
||
if (!listDrone?.device_sn) {
|
||
utils.message.warning(t('devices.noDroneSelected'));
|
||
return;
|
||
}
|
||
|
||
setFlightCommandLoading(true);
|
||
const data = {
|
||
command,
|
||
deviceSn: listDrone.device_sn,
|
||
}
|
||
try {
|
||
const res: any = await postFlightCommmand(data);
|
||
if (res.code === 200 || res.code === 0) {
|
||
utils.message.success(t('devices.commandSent'));
|
||
if (command === 'return_home') setIsReturningHome(true);
|
||
if (command === 'return_home_cancel') setIsReturningHome(false);
|
||
if (command === 'flighttask_pause') setIsTaskPaused(true);
|
||
if (command === 'flighttask_recovery') setIsTaskPaused(false);
|
||
} else {
|
||
utils.message.error(res.msg || t('devices.commandSendFail'));
|
||
}
|
||
} catch (err) {
|
||
utils.message.error(t('devices.apiRequestException'));
|
||
} finally {
|
||
setFlightCommandLoading(false);
|
||
}
|
||
};
|
||
|
||
const getTaskDetail = async (taskId) => {
|
||
if (!taskId) return;
|
||
setTaskDetail(null);
|
||
setLoading(true);
|
||
try {
|
||
const res = await getFlightTaskDetail(taskId);
|
||
if (res.code === 0) {
|
||
setTaskDetail(res.data);
|
||
} else {
|
||
setTaskDetail(null);
|
||
utils.message.error(t('devices.noDetail'));
|
||
}
|
||
} catch (err) {
|
||
setTaskDetail(null);
|
||
utils.message.error(t('devices.fetchDetailException'));
|
||
} finally {
|
||
setLoading(false);
|
||
}
|
||
};
|
||
|
||
// 任务状态更新逻辑
|
||
const updateTaskStatus = async (taskId: string, status: string) => {
|
||
if (!taskId) {
|
||
utils.message.warning(t('devices.selectTaskFirst'));
|
||
return;
|
||
}
|
||
setLoading(true);
|
||
try {
|
||
const res: any = await updateFlightTaskStatus(taskId, status);
|
||
if (res.code === 200 || res.code === 0) {
|
||
const statusText = {
|
||
executing: t('devices.taskExecSuccess'),
|
||
suspended: t('devices.taskSuspended2'),
|
||
restored: t('devices.taskRestored2'),
|
||
return_home: t('devices.taskReturnedHome2')
|
||
}[status] || t('devices.statusUpdateSuccess');
|
||
|
||
if (status === "suspended") {
|
||
setTaskStatus('suspended');
|
||
} else {
|
||
setTaskStatus('restored');
|
||
}
|
||
utils.message.success(statusText);
|
||
getListTask();
|
||
} else {
|
||
utils.message.error(res.msg || t('devices.operationFail'));
|
||
}
|
||
} catch (err) {
|
||
utils.message.error(t('devices.operationApiException'));
|
||
} finally {
|
||
setLoading(false);
|
||
}
|
||
};
|
||
|
||
return (
|
||
<div className="normal-spacing" style={{ background: '#f5f7fa', minHeight: '100%', padding: '0px', paddingTop: 0 }}>
|
||
<div style={{ padding: '4px 0px 8px' }}>
|
||
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>{t('devices.waylineTask')}</Typography.Title>
|
||
</div>
|
||
<Row gutter={[16, 16]} style={{ marginBottom: 8 }}>
|
||
{topCards.map((item, index) => (
|
||
<Col xs={12} sm={8} md={4} key={index}>
|
||
<Card variant="borderless" styles={{ body: { padding: '12px 14px' } }} style={cardStyle}>
|
||
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
|
||
<div style={{ width: 36, height: 36, background: item.bg, borderRadius: 10, display: 'flex', justifyContent: 'center', alignItems: 'center', color: item.color }}>
|
||
{React.cloneElement(item.icon, { size: 18 })}
|
||
</div>
|
||
<div style={{ flex: 1 }}>
|
||
<div style={{ fontSize: 13, color: '#86909C' }}>{item.title}</div>
|
||
<div style={{ display: 'flex', alignItems: 'baseline', gap: 4 }}>
|
||
<span style={{ fontSize: 'clamp(16px, 1vw, 20px)', fontWeight: 700, color: '#1D2129' }}>{item.value}</span>
|
||
<span style={{ fontSize: 9, color: '#4E5969' }}>{item.unit}</span>
|
||
</div>
|
||
<div style={{ fontSize: 9, color: item.trendColor || '#86909C', fontWeight: 500 }}>
|
||
{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 }}>{t('devices.waylineEditPlan')}</span>}
|
||
size="small"
|
||
extra={
|
||
<Space size={4}>
|
||
<Button
|
||
size="small"
|
||
icon={<DeleteOutlined />}
|
||
type="primary"
|
||
style={{ borderRadius: 4 }}
|
||
onClick={() => {
|
||
setClearNavLine((v) => v + 1);
|
||
}}
|
||
>
|
||
{t('devices.clearRealtimeTrack')}
|
||
</Button>
|
||
<Button
|
||
size="small"
|
||
icon={<DeleteOutlined />}
|
||
danger
|
||
style={{ borderRadius: 4 }}
|
||
onClick={() => {
|
||
setPoints([]);
|
||
setClearPlanLine((v) => v + 1);
|
||
}}
|
||
>
|
||
{t('devices.clearPlanRoute')}
|
||
</Button>
|
||
<Button size="small" icon={<PlusOutlined />} style={{ borderRadius: 4 }}>{t('common.addNew')}</Button>
|
||
<Button size="small" icon={<ImportOutlined />} style={{ borderRadius: 4 }}>{t('common.import')}</Button>
|
||
<Button size="small" icon={<NodeIndexOutlined />} style={{ borderRadius: 4 }}>{t('devices.optimize')}</Button>
|
||
<Button size="small" icon={<SaveOutlined />} style={{ borderRadius: 4 }}>{t('common.save')}</Button>
|
||
<Button size="small" icon={<Maximize2 size={12} />} />
|
||
</Space>
|
||
}
|
||
variant="borderless"
|
||
styles={{ body: { padding: 0, position: 'relative' } }}
|
||
style={{ ...cardStyle, marginBottom: 10 }}
|
||
>
|
||
<div style={{ width: '100%', height: 420, background: '#e8f3ff url(https://picsum.photos/seed/solar_map_v2/1600/1000) center/cover', position: 'relative' }}>
|
||
<CesiumMap realtimePosition={realtimePosition} drawRealTime={true} mapLayer={currentStation?.siteMapName}
|
||
|
||
points={points} focusLocation={focusLocation} from="device-control" realtimeType='plane' ifClearNavLine={clearNavLine} ifClearPlanLine={clearPlanLine} />
|
||
<div style={{ position: 'absolute', top: 16, left: 16, background: 'rgba(255,255,255,0.92)', backdropFilter: 'blur(8px)', padding: '14px 16px', borderRadius: 10, width: 150, boxShadow: '0 4px 12px rgba(0,0,0,0.1)' }}>
|
||
<div style={{ fontSize: fontSmall, display: 'flex', flexDirection: 'column', gap: 10 }}>
|
||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><span style={{ width: 14, height: 2, background: '#165DFF' }}></span> {t('devices.droneWayline')}</div>
|
||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><span style={{ width: 14, height: 2, background: '#FF7D00' }}></span> {t('devices.inspectRoute')}</div>
|
||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><span style={{ width: 14, height: 2, background: '#00B42A' }}></span> {t('devices.mowRoute')}</div>
|
||
<Divider style={{ margin: '6px 0' }} />
|
||
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}><div style={{ width: 18, height: 18, background: '#165DFF', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center', color: '#fff', fontSize: 10 }}>H</div> <span>{t('devices.droneAirport')}</span></div>
|
||
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}><Zap size={14} color="#00B42A" /> <span>{t('devices.chargePoint')}</span></div>
|
||
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}><AlertCircle size={14} color="#F53F3F" /> <span>{t('devices.noFlyZone')}</span></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</Card>
|
||
|
||
{/* 独立筛选 - 设备任务列表 */}
|
||
<Card
|
||
title={
|
||
<div className="flex justify-between w-full items-center">
|
||
<span style={{ fontSize: 14, fontWeight: 700 }}>{t('devices.deviceTaskList')}</span>
|
||
<Space size={12}>
|
||
<RangePicker
|
||
size="small"
|
||
showTime
|
||
format="YYYY-MM-DD HH:mm:ss"
|
||
value={listDateRange}
|
||
onChange={(val) => setListDateRange(val)}
|
||
placeholder={[t('devices.startTime'), t('devices.endTime')]}
|
||
/>
|
||
<Select
|
||
style={{ width: 180 }}
|
||
size="small"
|
||
placeholder={t('devices.allDrones')}
|
||
showSearch
|
||
allowClear
|
||
options={planedevices?.map(item => ({
|
||
value: item.device_sn,
|
||
label: item.drone_callsign || item.device_sn || item.callsign
|
||
}))}
|
||
value={listDrone?.device_sn}
|
||
onChange={(val) => {
|
||
const find = planedevices.find(i => i.device_sn === val);
|
||
setListDrone(find || null);
|
||
|
||
}}
|
||
/>
|
||
</Space>
|
||
</div>
|
||
}
|
||
size="small"
|
||
extra={
|
||
<Tooltip title={t('devices.createTask')}>
|
||
<PlusOutlined
|
||
style={{ cursor: 'pointer', color: '#165DFF', fontSize: 12, marginLeft: 10 }}
|
||
onClick={() => {
|
||
resetModals();
|
||
setCreateTaskModal(true);
|
||
}}
|
||
/>
|
||
</Tooltip>
|
||
}
|
||
variant="borderless"
|
||
styles={{ body: { padding: 0, display: 'flex', flexDirection: 'column', height: "calc(100% - 40px)", overflow: "auto" } }}
|
||
style={{ ...cardStyle, maxHeight: "250px", flex: 1, marginBottom: 0 }}
|
||
>
|
||
<Table
|
||
size="small"
|
||
rowKey="uuid"
|
||
columns={taskColumns}
|
||
dataSource={taskList}
|
||
pagination={false}
|
||
style={{ height: "calc(100% - 40px)" }}
|
||
rowClassName={(record) =>
|
||
selectedTask?.uuid === record.uuid ? 'table-row-highlight' : ''
|
||
}
|
||
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 }}>{t('devices.taskOrchestrationAI')}</span>}
|
||
variant="borderless"
|
||
styles={{ body: { padding: '12px 16px' } }}
|
||
style={{ ...cardStyle, marginBottom: 8 }}
|
||
>
|
||
<Table
|
||
size="small"
|
||
pagination={false}
|
||
dataSource={[
|
||
{ key: '1', id: 'FL-03', device: 'UAV-A01', type: t('devices.typeDroneHotspot'), level: t('devices.levelHigh'), time: '10:00 - 11:20', duration: '1h20m', status: t('devices.statusSuggestExec') },
|
||
{ key: '2', id: 'RB-02', device: 'RBT-01', type: t('devices.typeFenceInspect'), level: t('devices.levelHigh'), time: '11:30 - 12:30', duration: '1h00m', status: t('devices.statusSuggestExec') },
|
||
{ key: '3', id: 'CL-05', device: 'UAV-C01', type: t('devices.typeComponentClean'), level: t('devices.levelMid'), time: '14:00 - 16:00', duration: '2h00m', status: t('devices.statusWaitExec') },
|
||
{ key: '4', id: 'GR-04', device: 'GR-01', type: t('devices.typeArrayMow'), level: t('devices.levelMid'), time: '09:30 - 11:30', duration: '2h00m', status: t('devices.statusSuggestExec') },
|
||
{ key: '5', id: 'FL-07', device: 'UAV-A01', type: t('devices.typeAIRecheck'), level: t('devices.levelLow'), time: '16:30 - 17:10', duration: '0h40m', status: t('devices.statusPendingApproval') },
|
||
]}
|
||
columns={[
|
||
{ title: t('devices.colNo'), dataIndex: 'id', width: 70, render: (t) => <Text style={{ color: '#165DFF', fontWeight: 600 }}>{t}</Text> },
|
||
{ title: t('constants.sourceEquipment'), dataIndex: 'device', width: 80 },
|
||
{ title: t('common.type'), dataIndex: 'type', ellipsis: true },
|
||
{ title: t('workOrder.priority'), dataIndex: 'level', width: 80, render: (l) => <span style={{ color: l === t('devices.levelHigh') ? '#F53F3F' : l === t('devices.levelMid') ? '#FF7D00' : '#86909C', fontSize: 11, fontWeight: 600 }}>▲ {l}</span> },
|
||
{ title: t('devices.suggestTime'), dataIndex: 'time', width: 110 },
|
||
{ title: t('roles.status'), dataIndex: 'status', width: 90, render: (s) => <Text style={{ color: s.includes(t('devices.statusSuggestExec')) ? '#165DFF' : '#86909C', fontSize: 11, fontWeight: 500 }}>{s}</Text> },
|
||
]}
|
||
/>
|
||
<div style={{ background: '#F8F9FB', padding: '2px 14px', borderRadius: 8, marginTop: 8, border: '1px solid #F1F2F5' }}>
|
||
<div style={{ display: 'flex', gap: 12, fontSize: fontSmall, alignItems: 'center' }}>
|
||
<span style={{ fontWeight: 700, color: '#1D2129' }}>{t('devices.aiSuggestionColon')}</span>
|
||
<Space split={<Divider type="vertical" style={{ margin: 0 }} />}>
|
||
<Space size={4}><CheckCircle2 size={13} color="#165DFF" /> <span>{t('devices.aiAdvice1')}</span></Space>
|
||
<Space size={4}><Clock size={13} color="#165DFF" /> <span>{t('devices.aiAdvice2')}</span></Space>
|
||
<Space size={4}><AlertCircle size={13} color="#FF7D00" /> <span>{t('devices.aiAdvice3')}</span></Space>
|
||
</Space>
|
||
</div>
|
||
</div>
|
||
<Row gutter={12} style={{ marginTop: 8 }}>
|
||
<Col span={8}><Button type="primary" block style={{ background: '#165DFF', height: 28, borderRadius: 18, fontWeight: 600 }}>{t('devices.oneClickSchedule')}</Button></Col>
|
||
<Col span={8}><Button type="primary" block style={{ background: '#165DFF', height: 28, borderRadius: 18, fontWeight: 600 }}>{t('devices.smartAssign')}</Button></Col>
|
||
<Col span={8}><Button type="primary" block style={{ background: '#165DFF', height: 28, borderRadius: 18, fontWeight: 600 }}>{t('clean.generateOrder')}</Button></Col>
|
||
</Row>
|
||
</Card>
|
||
|
||
<Card
|
||
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.waylineParamsTitle')}</span>}
|
||
extra={<Text type="secondary" style={{ fontSize: 12 }}>{t('devices.currentWayline')}{selectedTask?.name || '-'}</Text>}
|
||
variant="borderless"
|
||
styles={{ body: { padding: '16px' } }}
|
||
style={{ ...cardStyle, marginBottom: 8 }}
|
||
>
|
||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: '8px', marginBottom: 8 }}>
|
||
{[
|
||
{ label: t('devices.flightAltitude'), value: taskDetail?.rth_altitude ?? '-', unit: 'm' },
|
||
{ label: t('devices.rthMode'), value: taskDetail?.rth_mode === 'preset' ? t('devices.rthPreset') : taskDetail?.rth_mode === 'optimal' ? t('devices.rthOptimal') : '-', unit: '' },
|
||
{ label: t('devices.waylinePrecision'), value: taskDetail?.wayline_precision_type === 'gps' ? 'GPS' : taskDetail?.wayline_precision_type === 'rtk' ? 'RTK' : '-', unit: '' },
|
||
{ label: t('devices.resumeBreakpoint'), value: taskDetail?.resumable_status === 'auto' ? t('devices.resumeAuto') : taskDetail?.resumable_status === 'manual' ? t('devices.resumeManual') : '-', unit: '' },
|
||
{ label: t('devices.safeRthBattery'), value: taskDetail?.min_battery_capacity ?? '-', unit: '%' },
|
||
{
|
||
label: t('devices.taskTypeLabel'), value:
|
||
taskDetail?.task_type === 'immediate' ? t('devices.taskImmediate') :
|
||
taskDetail?.task_type === 'timed' ? t('devices.taskTimed') :
|
||
taskDetail?.task_type === 'recurring' ? t('devices.taskRecurring') :
|
||
taskDetail?.task_type === 'continuous' ? t('devices.taskContinuous') : '-',
|
||
unit: ''
|
||
},
|
||
{
|
||
label: t('devices.repeatTypeLabel'), value:
|
||
taskDetail?.repeat_type === 'nonrepeating' ? t('devices.repeatNone') :
|
||
taskDetail?.repeat_type === 'daily' ? t('devices.repeatDaily') :
|
||
taskDetail?.repeat_type === 'weekly' ? t('devices.repeatWeekly') :
|
||
taskDetail?.repeat_type === 'absolute_monthly' ? t('devices.repeatMonthlyByDate') :
|
||
taskDetail?.repeat_type === 'relative_monthly' ? t('devices.repeatMonthlyByWeek') : '-',
|
||
unit: ''
|
||
},
|
||
{ label: t('devices.lostControlAction'), value: taskDetail?.out_of_control_action_in_flight === 'return_home' ? t('devices.returnHome') : '-', unit: '' },
|
||
].map((item, idx) => (
|
||
<div
|
||
key={idx}
|
||
style={{
|
||
background: '#F7F8FA',
|
||
borderRadius: 8,
|
||
padding: '4px 10px',
|
||
display: 'flex',
|
||
alignItems: 'center',
|
||
justifyContent: 'space-between'
|
||
}}
|
||
>
|
||
<span style={{ fontSize: 12, color: '#4E5969' }}>{item.label}</span>
|
||
<div style={{ display: 'flex', alignItems: 'baseline', gap: 4 }}>
|
||
<span style={{ fontSize: 14, fontWeight: 600, color: '#1D2129' }}>{item.value}</span>
|
||
<span style={{ fontSize: 11, color: '#86909C' }}>{item.unit}</span>
|
||
</div>
|
||
</div>
|
||
))}
|
||
</div>
|
||
|
||
<div style={{ display: 'flex', gap: 32, marginBottom: 8 }}>
|
||
<Space size={8}>
|
||
<span style={{ fontSize: fontNormal, color: '#4E5969' }}>{t('devices.obstacleAvoidSwitch')}</span>
|
||
<Switch size="small" defaultChecked />
|
||
</Space>
|
||
<Space size={8}>
|
||
<span style={{ fontSize: fontNormal, color: '#4E5969' }}>{t('devices.nightFlightLimit')}</span>
|
||
<Switch size="small" />
|
||
</Space>
|
||
</div>
|
||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: '8px' }}>
|
||
{selectedTask?.status === 'executing' || selectedTask?.status === 'running' || selectedTask?.status === 'restored' ? (
|
||
<Button
|
||
type="primary"
|
||
danger
|
||
icon={<Square size={16} />}
|
||
onClick={() => updateTaskStatus(selectedTask?.uuid, 'suspended')}
|
||
loading={loading}
|
||
style={{ height: 28, borderRadius: 18, fontWeight: 600, display: 'inline-flex', alignItems: 'center', gap: 4 }}
|
||
>
|
||
{t('devices.suspendTask')}
|
||
</Button>
|
||
) : (
|
||
<Button
|
||
type="primary"
|
||
icon={<Play size={16} />}
|
||
onClick={() => {
|
||
//if (selectedTask?.status === 'suspended') {
|
||
updateTaskStatus(selectedTask?.uuid, 'restored');
|
||
//}
|
||
//else {
|
||
// updateTaskStatus(selectedTask?.uuid, 'executing');
|
||
//}
|
||
}}
|
||
loading={loading}
|
||
style={{ background: '#165DFF', height: 28, borderRadius: 18, fontWeight: 600, display: 'inline-flex', alignItems: 'center', gap: 4 }}
|
||
>
|
||
{t('devices.resumeTask')}
|
||
{/*{selectedTask?.status === 'suspended' ? '继续任务' : t('devices.executeTask')}*/}
|
||
</Button>
|
||
)}
|
||
<Button
|
||
type="primary"
|
||
danger={isReturningHome}
|
||
icon={isReturningHome ? <X size={16} /> : <MapPin size={16} />}
|
||
onClick={() => sendFlightCommand(isReturningHome ? 'return_home_cancel' : 'return_home')}
|
||
loading={flightCommandLoading}
|
||
style={{ background: '#165DFF', height: 28, borderRadius: 18, fontWeight: 600, display: 'inline-flex', alignItems: 'center', gap: 4 }}
|
||
>
|
||
{isReturningHome ? t('devices.cancelReturnHome') : t('devices.returnHome')}
|
||
</Button>
|
||
|
||
<Button
|
||
type="default"
|
||
icon={isTaskPaused ? <RotateCw size={16} /> : <Square size={16} />}
|
||
onClick={() => sendFlightCommand(isTaskPaused ? 'flighttask_recovery' : 'flighttask_pause')}
|
||
loading={flightCommandLoading}
|
||
style={{ height: 28, borderRadius: 18, fontWeight: 600, display: 'inline-flex', alignItems: 'center', gap: 4 }}
|
||
>
|
||
{isTaskPaused ? t('devices.resumeTask') : t('devices.pauseTask')}
|
||
</Button>
|
||
</div>
|
||
</Card>
|
||
|
||
<Card
|
||
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.weatherWindowTitle')}</span>}
|
||
variant="borderless"
|
||
styles={{ body: { padding: '16px' } }}
|
||
style={{ ...cardStyle, flex: 1, }}
|
||
>
|
||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(5, 1fr)', gap: '8px', marginBottom: 16 }}>
|
||
<div style={{ background: '#F7F8FA', borderRadius: 10, padding: '12px', display: 'flex', alignItems: 'center', gap: 10 }}>
|
||
<div style={{ width: 40, height: 40, borderRadius: '50%', background: 'rgba(22, 93, 255, 0.1)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||
<CloudOutlined size={20} style={{ color: '#165DFF' }} />
|
||
</div>
|
||
<div>
|
||
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.suitability')}</div>
|
||
<div style={{ fontSize: 14, fontWeight: 700, color: '#00B42A' }}>{t('devices.suitableExec2')}</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div style={{ background: '#F7F8FA', borderRadius: 10, padding: '12px', display: 'flex', alignItems: 'center', gap: 10 }}>
|
||
<div style={{ width: 40, height: 40, borderRadius: '50%', background: 'rgba(22, 93, 255, 0.1)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||
<Wind size={20} style={{ color: '#165DFF' }} />
|
||
</div>
|
||
<div>
|
||
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.windSpeed')}</div>
|
||
<div style={{ fontSize: 14, fontWeight: 700, color: '#1D2129' }}>{fix2((mqttDerivedData || listDroneRealtime || listDrone)?.wind_speed)} m/s</div>
|
||
<div style={{ fontSize: 12, color: '#00B42A' }}>{t('devices.suitable')}</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div style={{ background: '#F7F8FA', borderRadius: 10, padding: '12px', display: 'flex', alignItems: 'center', gap: 10 }}>
|
||
<div style={{ width: 40, height: 40, borderRadius: '50%', background: 'rgba(255, 125, 0, 0.1)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||
<Thermometer size={20} style={{ color: '#FF7D00' }} />
|
||
</div>
|
||
<div>
|
||
<div style={{ fontSize: 12, color: '#86909C' }}>{t('home.temperature')}</div>
|
||
<div style={{ fontSize: 14, fontWeight: 700, color: '#1D2129' }}>{fix2((mqttDerivedData || listDroneRealtime || listDrone)?.environment_temperature)}℃</div>
|
||
<div style={{ fontSize: 12, color: '#00B42A' }}>{t('devices.suitable')}</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div style={{ background: '#F7F8FA', borderRadius: 10, padding: '12px', display: 'flex', alignItems: 'center', gap: 10 }}>
|
||
<div style={{ width: 40, height: 40, borderRadius: '50%', background: 'rgba(255, 125, 0, 0.1)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||
<Droplets size={20} style={{ color: '#FF7D00' }} />
|
||
</div>
|
||
<div>
|
||
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.precipStatus')}</div>
|
||
<div style={{ fontSize: 14, fontWeight: 700, color: '#1D2129' }}>{getVal((mqttDerivedData || listDroneRealtime || listDrone)?.rainfall)}</div>
|
||
<div style={{ fontSize: 12, color: (mqttDerivedData || listDroneRealtime || listDrone)?.rainfall === 'no_rain' ? '#00B42A' : '#F53F3F' }}>
|
||
{(mqttDerivedData || listDroneRealtime || listDrone)?.rainfall === 'no_rain' ? t('aiAnalysis.lowRisk') : t('devices.hasRain')}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div style={{ background: '#F7F8FA', borderRadius: 10, padding: '12px', display: 'flex', alignItems: 'center', gap: 10 }}>
|
||
<div style={{ width: 40, height: 40, borderRadius: '50%', background: 'rgba(0, 180, 42, 0.1)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||
<Satellite size={20} style={{ color: '#00B42A' }} />
|
||
</div>
|
||
<div>
|
||
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.gnssQuality')}</div>
|
||
<div style={{ fontSize: 14, fontWeight: 700, color: '#1D2129' }}>
|
||
{(mqttDerivedData || listDroneRealtime || listDrone)?.position_state?.rtk_number ?? 0} RTK
|
||
</div>
|
||
<div style={{ fontSize: 12, color: (mqttDerivedData || listDroneRealtime || listDrone)?.position_state?.is_fixed === 'fixing_successful' ? '#00B42A' : '#FF7D00' }}>
|
||
{(mqttDerivedData || listDroneRealtime || listDrone)?.position_state?.is_fixed === 'fixing_successful' ? t('devices.fixed2') : t('devices.notFixed2')}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div style={{ display: 'flex', gap: '12px' }}>
|
||
<div style={{ flex: 1, background: 'rgba(255, 125, 0, 0.1)', borderRadius: 8, padding: '10px 12px', display: 'flex', alignItems: 'center', gap: 8 }}>
|
||
<AlertCircle size={16} style={{ color: '#FF7D00' }} />
|
||
<span style={{ fontSize: 13, color: '#FF7D00', fontWeight: 500 }}>{t('devices.weatherAdvice1')}</span>
|
||
</div>
|
||
<div style={{ flex: 1, background: 'rgba(22, 93, 255, 0.1)', borderRadius: 8, padding: '10px 12px', display: 'flex', alignItems: 'center', gap: 8 }}>
|
||
<InfoCircleOutlined size={16} style={{ color: '#165DFF' }} />
|
||
<span style={{ fontSize: 13, color: '#165DFF', fontWeight: 500 }}>{t('devices.weatherAdvice2')}</span>
|
||
</div>
|
||
</div>
|
||
</Card>
|
||
</Col>
|
||
</Row>
|
||
|
||
{/* 底部内容区 */}
|
||
<Row gutter={16}>
|
||
<Col xs={24} xl={4}>
|
||
<Card
|
||
title={
|
||
<div className="flex justify-between items-center w-full">
|
||
<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.waylineList')}</span>
|
||
{/* ✅ 航线列表独立无人机筛选 */}
|
||
<Select
|
||
size="small"
|
||
style={{ width: 120 }}
|
||
placeholder={t('devices.selectDrone')}
|
||
showSearch
|
||
allowClear
|
||
options={planedevices?.map(item => ({
|
||
value: item.device_sn,
|
||
label: item.drone_callsign || item.device_sn || item.callsign
|
||
}))}
|
||
value={waylineDrone?.device_sn}
|
||
onChange={(val) => {
|
||
const find = planedevices.find(i => i.device_sn === val);
|
||
setWaylineDrone(find || null);
|
||
|
||
}}
|
||
/>
|
||
</div>
|
||
}
|
||
variant="borderless"
|
||
styles={{ body: { padding: '12px', display: 'flex', flexDirection: 'column', height: 480 } }}
|
||
style={{ ...cardStyle, height: '100%' }}
|
||
>
|
||
<Input
|
||
placeholder={t('devices.searchWaylinePlaceholder')}
|
||
prefix={<SearchOutlined style={{ color: '#86909C' }} />}
|
||
style={{ marginBottom: 12, borderRadius: 6 }}
|
||
size="small"
|
||
value={waylineSearch}
|
||
onChange={e => setWaylineSearch(e.target.value)}
|
||
/>
|
||
<div style={{ flex: 1, overflowY: 'auto', paddingRight: 4 }} className="custom-scrollbar">
|
||
{waylineList
|
||
.filter(item => item.name?.toLowerCase().includes(waylineSearch.toLowerCase()))
|
||
.map((item) => (
|
||
<div
|
||
key={item.id || item.uuid}
|
||
onClick={() => handleWaylineClick(item)}
|
||
style={{
|
||
padding: '10px 12px',
|
||
borderRadius: 8,
|
||
marginBottom: 8,
|
||
cursor: 'pointer',
|
||
background: selectedWayline?.id === item.id ? '#E8F3FF' : '#F7F8FA',
|
||
border: selectedWayline?.id === item.id ? '1px solid #165DFF' : '1px solid transparent',
|
||
transition: 'all 0.2s',
|
||
position: 'relative'
|
||
}}
|
||
>
|
||
<div style={{ fontSize: 13, fontWeight: 600, color: '#1D2129', marginBottom: 4, paddingRight: 40 }}>
|
||
{item.name}
|
||
</div>
|
||
<div style={{ fontSize: 11, color: '#86909C', display: 'flex', alignItems: 'center', gap: 4 }}>
|
||
<Clock size={12} /> {item.update_time ? dayjs(item.update_time).format('MM-DD HH:mm') : t('devices.unknownTime')}
|
||
</div>
|
||
{/* ✅ 执行按钮改为图标 */}
|
||
<Tooltip title={t('devices.executeWayline')}>
|
||
<Button
|
||
type="text"
|
||
icon={<PlayCircleOutlined style={{ color: '#165DFF', fontSize: 18 }} />}
|
||
style={{
|
||
position: 'absolute',
|
||
right: 8,
|
||
top: '50%',
|
||
transform: 'translateY(-50%)',
|
||
}}
|
||
onClick={(e) => handleExecuteClick(e, item)}
|
||
/>
|
||
</Tooltip>
|
||
</div>
|
||
))}
|
||
{waylineList.length === 0 && (
|
||
<div style={{ textAlign: 'center', padding: '20px 0', color: '#86909C', fontSize: 12 }}>
|
||
{t('devices.noWaylineData')}
|
||
</div>
|
||
)}
|
||
</div>
|
||
</Card>
|
||
</Col>
|
||
|
||
<Col xs={24} xl={12}>
|
||
<Card
|
||
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.ganttViewTitle')} <Text type="secondary" style={{ fontSize: 11, fontWeight: 400, marginLeft: 12 }}></Text></span>}
|
||
extra={<MoreOutlined style={{ cursor: 'pointer', fontSize: 18 }} />}
|
||
variant="borderless"
|
||
styles={{ body: { padding: 16 } }}
|
||
style={{ ...cardStyle, height: '100%' }}
|
||
>
|
||
<div style={{ position: 'relative', border: '1px solid #F2F3F5', borderRadius: 8, padding: '16px 12px' }}>
|
||
<div style={{ display: 'flex', fontSize: 10, color: '#86909C', borderBottom: '1px solid #F2F3F5', paddingBottom: 10, textAlign: 'center' }}>
|
||
<div style={{ width: 140 }}></div>
|
||
<div style={{ flex: 1, display: 'flex', justifyContent: 'space-around' }}>
|
||
<span>08:00</span><span>10:00</span><span>12:00</span><span>14:00</span><span>16:00</span><span>18:00</span>
|
||
</div>
|
||
</div>
|
||
<div style={{ display: 'flex', flexDirection: 'column', gap: 16, marginTop: 16 }}>
|
||
{[
|
||
{ label: t('devices.dronePortA01'), sub: '(UAV-A01)', tasks: [{ start: '25%', width: '18%', title: 'FL-03 ' + t('devices.typeHotspotInspect'), time: '10:00-11:20', color: '#165DFF' }, { start: '75%', width: '12%', title: 'FL-07 ' + t('devices.typeRecheck'), time: '16:30-17:10', color: '#165DFF' }] },
|
||
{ label: t('devices.inspectRobotRbt'), sub: '', tasks: [{ start: '45%', width: '15%', title: 'RB-02 ' + t('devices.typeFenceInspect'), time: '11:30-12:30', color: '#FF7D00' }] },
|
||
{ label: t('devices.mowRobotGr'), sub: '', tasks: [{ start: '10%', width: '22%', title: 'GR-04 ' + t('devices.typeArrayMow'), time: '09:30-11:30', color: '#00B42A' }] },
|
||
{ label: t('devices.washDroneUav'), sub: '', tasks: [{ start: '65%', width: '20%', title: 'CL-05 ' + t('devices.typeComponentClean'), time: '14:00-16:00', color: '#13C2C2' }] },
|
||
].map((row, idx) => (
|
||
<div key={idx} style={{ display: 'flex', alignItems: 'center' }}>
|
||
<div style={{ width: 140, paddingRight: 12 }}>
|
||
<div style={{ fontSize: 11, fontWeight: 600, color: '#1D2129' }}>{row.label}</div>
|
||
<div style={{ fontSize: 10, color: '#86909C' }}>{row.sub}</div>
|
||
</div>
|
||
<div style={{ flex: 1, height: 40, background: '#F7F8FA', borderRadius: 6, position: 'relative' }}>
|
||
{row.tasks.map((task, tidx) => (
|
||
<div key={tidx} style={{
|
||
position: 'absolute', left: task.start, width: task.width, height: '100%',
|
||
background: task.color, borderRadius: 6, color: '#fff',
|
||
padding: '4px 8px', display: 'flex', flexDirection: 'column', justifyContent: 'center',
|
||
boxShadow: '0 2px 6px rgba(0,0,0,0.1)', zIndex: 2
|
||
}}>
|
||
<div style={{ fontSize: 10, fontWeight: 700, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>{task.title}</div>
|
||
<div style={{ fontSize: 9, opacity: 0.9 }}>{task.time}</div>
|
||
</div>
|
||
))}
|
||
</div>
|
||
</div>
|
||
))}
|
||
</div>
|
||
<div style={{ position: 'absolute', left: '38%', top: 0, bottom: 0, width: 2, background: '#F53F3F', zIndex: 1, opacity: 0.6 }}>
|
||
<div style={{ width: 6, height: 6, borderRadius: '50%', background: '#F53F3F', position: 'absolute', top: -3, left: -2 }} />
|
||
</div>
|
||
</div>
|
||
</Card>
|
||
</Col>
|
||
|
||
<Col xs={24} xl={8}>
|
||
<Card
|
||
title={
|
||
<div className="flex justify-between items-center w-full">
|
||
<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.workTaskBoard')}</span>
|
||
<Space size={8}>
|
||
<RangePicker
|
||
size="small"
|
||
showTime
|
||
format="YYYY-MM-DD HH:mm:ss"
|
||
value={boardDateRange}
|
||
onChange={(val) => setBoardDateRange(val)}
|
||
placeholder={[t('devices.startLabel'), t('devices.endLabel')]}
|
||
/>
|
||
<Select
|
||
style={{ width: 140 }}
|
||
size="small"
|
||
placeholder={t('devices.allDrones')}
|
||
showSearch
|
||
allowClear
|
||
options={planedevices?.map(item => ({
|
||
value: item.device_sn,
|
||
label: item.drone_callsign || item.device_sn
|
||
}))}
|
||
value={boardDrone?.device_sn}
|
||
onChange={(val) => {
|
||
const find = planedevices.find(i => i.device_sn === val);
|
||
setBoardDrone(find || null);
|
||
|
||
}}
|
||
/>
|
||
</Space>
|
||
</div>
|
||
}
|
||
variant="borderless"
|
||
styles={{ body: { padding: 16 } }}
|
||
style={{ ...cardStyle, height: '100%', maxHeight: 480, overflow: "auto" }}
|
||
>
|
||
<Row gutter={10}>
|
||
{[
|
||
{
|
||
title: t('devices.pendingExec'), count: waitList.length, color: '#4E5969', bg: '#F7F8FA',
|
||
list: waitList.map(item => ({
|
||
id: item.sn?.slice(-5) || '',
|
||
name: item.name,
|
||
device: item.sn,
|
||
begin_at: ''
|
||
}))
|
||
},
|
||
{
|
||
title: t('workOrder.inProgress'), count: runList.length, color: '#165DFF', bg: '#E8F3FF',
|
||
list: runList.map(item => ({
|
||
id: item.sn?.slice(-5) || '',
|
||
name: item.name,
|
||
device: item.sn,
|
||
begin_at: ''
|
||
}))
|
||
},
|
||
{
|
||
title: t('workOrder.completed'), count: finishList.length, color: '#00B42A', bg: '#E8FFEA',
|
||
list: finishList.map(item => ({
|
||
id: item.sn?.slice(-5) || '',
|
||
name: item.name,
|
||
device: item.sn,
|
||
begin_at: item.begin_at,
|
||
completed_at: item.completed_at
|
||
}))
|
||
},
|
||
].map((col, idx) => (
|
||
<Col span={8} key={idx}>
|
||
<div style={{ background: col.bg, borderRadius: 10, padding: 10, height: '100%', minHeight: 280 }}>
|
||
<div style={{ fontSize: 12, fontWeight: 700, marginBottom: 12, display: 'flex', justifyContent: 'space-between', color: col.color }}>
|
||
<span>{col.title} ({col.count})</span>
|
||
</div>
|
||
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
||
{col.list.map((task, tidx) => (
|
||
<div key={tidx} style={{ background: '#fff', borderRadius: 8, padding: 10, boxShadow: '0 2px 4px rgba(0,0,0,0.04)', border: '1px solid #F1F2F5' }}>
|
||
{/* 任务名称:自动换行 */}
|
||
<div style={{ fontSize: 11, fontWeight: 700, color: '#165DFF', marginBottom: 6, wordBreak: 'break-all', whiteSpace: 'normal' }}>
|
||
{task.name}
|
||
</div>
|
||
|
||
{/* 设备 & 时间:自动换行 */}
|
||
<div style={{ fontSize: 10, color: '#86909C', lineHeight: '1.4' }}>
|
||
<div style={{ marginBottom: 2, wordBreak: 'break-all', whiteSpace: 'normal' }}>
|
||
{t('devices.equipmentColon')} {task.device || 'UAV-A01'}
|
||
</div>
|
||
{task.begin_at && (
|
||
<div style={{ marginTop: 2, wordBreak: 'break-all', whiteSpace: 'normal' }}>
|
||
{t('devices.startTimeColon')} {task.begin_at}
|
||
</div>
|
||
)}
|
||
{task.completed_at && (
|
||
<div style={{ marginTop: 2, wordBreak: 'break-all', whiteSpace: 'normal' }}>
|
||
{t('devices.completedTimeColon')} {task.completed_at}
|
||
</div>
|
||
)}
|
||
</div>
|
||
</div>
|
||
))}
|
||
</div>
|
||
</div>
|
||
</Col>
|
||
))}
|
||
</Row>
|
||
</Card>
|
||
</Col>
|
||
</Row>
|
||
|
||
{/* 创建任务弹窗 */}
|
||
<Modal
|
||
open={createTaskModal}
|
||
title={t('devices.createWaylineTaskTitle')}
|
||
onCancel={resetModals}
|
||
footer={null}
|
||
maskClosable={false}
|
||
width={650}
|
||
>
|
||
<div className="py-4 space-y-4">
|
||
<div className="grid grid-cols-2 gap-4">
|
||
<div>
|
||
<label className="text-sm block mb-1">{t('devices.waylineName')} <span className="text-red-500">*</span></label>
|
||
<Input
|
||
value={taskForm.name}
|
||
onChange={(e) => setTaskForm({ ...taskForm, name: e.target.value })}
|
||
placeholder={t('common.pleaseInput')}
|
||
/>
|
||
</div>
|
||
<div>
|
||
<label className="text-sm block mb-1">{t('devices.selectWayline')} <span className="text-red-500">*</span></label>
|
||
<Select
|
||
showSearch
|
||
value={waylineUuid}
|
||
onChange={setWaylineUuid}
|
||
options={waylineList}
|
||
style={{ width: '100%' }}
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<div className="grid grid-cols-2 gap-4">
|
||
<div>
|
||
<label className="text-sm block mb-1">{t('devices.airportSn')} <span className="text-red-500">*</span></label>
|
||
<Input value={taskForm.sn} disabled />
|
||
</div>
|
||
<div>
|
||
<label className="text-sm block mb-1">{t('devices.landingDockSn')}</label>
|
||
<Input
|
||
value={taskForm.landing_dock_sn}
|
||
onChange={(e) => setTaskForm({ ...taskForm, landing_dock_sn: e.target.value })}
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<div className="grid grid-cols-2 gap-4">
|
||
<div>
|
||
<label className="text-sm block mb-1">{t('devices.returnHomeAltitude')}</label>
|
||
<InputNumber
|
||
min={0}
|
||
value={taskForm.rth_altitude}
|
||
onChange={(v) => setTaskForm({ ...taskForm, rth_altitude: v })}
|
||
style={{ width: '100%' }}
|
||
/>
|
||
</div>
|
||
<div>
|
||
<label className="text-sm block mb-1">{t('devices.returnHomeMode')}</label>
|
||
<Select
|
||
value={taskForm.rth_mode}
|
||
onChange={(v) => setTaskForm({ ...taskForm, rth_mode: v })}
|
||
options={[{ label: t('devices.rthOptimal'), value: 'optimal' }, { label: t('devices.rthPreset'), value: 'preset' }]}
|
||
style={{ width: '100%' }}
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<div className="grid grid-cols-2 gap-4">
|
||
<div>
|
||
<label className="text-sm block mb-1">{t('devices.waylinePrecision')}</label>
|
||
<Select
|
||
value={taskForm.wayline_precision_type}
|
||
onChange={(v) => setTaskForm({ ...taskForm, wayline_precision_type: v })}
|
||
options={[{ label: 'GPS', value: 'gps' }, { label: 'RTK', value: 'rtk' }]}
|
||
style={{ width: '100%' }}
|
||
/>
|
||
</div>
|
||
<div>
|
||
<label className="text-sm block mb-1">{t('devices.resumeBreakpoint')}</label>
|
||
<Select
|
||
value={taskForm.resumable_status}
|
||
onChange={(v) => setTaskForm({ ...taskForm, resumable_status: v })}
|
||
options={[{ label: t('devices.resumeAuto'), value: 'auto' }, { label: t('devices.resumeManual'), value: 'manual' }]}
|
||
style={{ width: '100%' }}
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<div className="grid grid-cols-2 gap-4">
|
||
<div>
|
||
<label className="text-sm block mb-1">{t('devices.minBattery')}</label>
|
||
<InputNumber
|
||
min={50}
|
||
max={100}
|
||
value={taskForm.min_battery_capacity}
|
||
onChange={(v) => setTaskForm({ ...taskForm, min_battery_capacity: v })}
|
||
style={{ width: '100%' }}
|
||
/>
|
||
</div>
|
||
<div>
|
||
<label className="text-sm block mb-1">{t('devices.taskTypeLabel')}</label>
|
||
<Select
|
||
value={taskForm.task_type}
|
||
onChange={(v) => setTaskForm({ ...taskForm, task_type: v })}
|
||
options={[
|
||
{ label: t('devices.taskImmediate'), value: 'immediate' },
|
||
]}
|
||
style={{ width: '100%' }}
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
{/* 时间选择 */}
|
||
{(taskForm.task_type === 'timed' || taskForm.task_type === 'recurring' || taskForm.task_type === 'continuous') && (
|
||
<div className="grid grid-cols-2 gap-4">
|
||
<div>
|
||
<label className="text-sm block mb-1">{t('devices.startTime')}</label>
|
||
<DatePicker
|
||
showTime
|
||
value={taskForm.begin_at}
|
||
onChange={(v) => setTaskForm({ ...taskForm, begin_at: v })}
|
||
style={{ width: '100%' }}
|
||
/>
|
||
</div>
|
||
{(taskForm.task_type === 'recurring' || taskForm.task_type === 'continuous') && (
|
||
<div>
|
||
<label className="text-sm block mb-1">{t('devices.endTime')}</label>
|
||
<DatePicker
|
||
showTime
|
||
value={taskForm.end_at}
|
||
onChange={(v) => setTaskForm({ ...taskForm, end_at: v })}
|
||
style={{ width: '100%' }}
|
||
/>
|
||
</div>
|
||
)}
|
||
</div>
|
||
)}
|
||
|
||
{/* 重复任务配置 repeat_option 对象绑定 */}
|
||
{taskForm.task_type === 'recurring' && (
|
||
<>
|
||
<div className="grid grid-cols-2 gap-4">
|
||
<div>
|
||
<label className="text-sm block mb-1">{t('devices.repeatMode')}</label>
|
||
<Select
|
||
value={taskForm.repeat_type}
|
||
onChange={(v) => setTaskForm({ ...taskForm, repeat_type: v })}
|
||
options={[
|
||
{ label: t('devices.repeatNone'), value: 'nonrepeating' },
|
||
{ label: t('devices.repeatDaily'), value: 'daily' },
|
||
{ label: t('devices.repeatWeekly'), value: 'weekly' },
|
||
{ label: t('devices.repeatMonthlyByDate'), value: 'absolute_monthly' },
|
||
{ label: t('devices.repeatMonthlyByWeek'), value: 'relative_monthly' },
|
||
]}
|
||
style={{ width: '100%' }}
|
||
/>
|
||
</div>
|
||
<div>
|
||
<label className="text-sm block mb-1">{t('devices.repeatInterval')}</label>
|
||
<InputNumber
|
||
min={1}
|
||
value={taskForm.repeat_option.interval}
|
||
onChange={(v) => setTaskForm({
|
||
...taskForm,
|
||
repeat_option: { ...taskForm.repeat_option, interval: v }
|
||
})}
|
||
style={{ width: '100%' }}
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
{/* 每周 */}
|
||
{taskForm.repeat_type === 'weekly' && (
|
||
<div>
|
||
<label className="text-sm block mb-1">{t('devices.weekdayExec')}</label>
|
||
<Select
|
||
mode="multiple"
|
||
value={taskForm.repeat_option.days_of_week}
|
||
onChange={(v) => setTaskForm({
|
||
...taskForm,
|
||
repeat_option: { ...taskForm.repeat_option, days_of_week: v }
|
||
})}
|
||
options={[
|
||
{ label: t('devices.weekSun'), value: 0 },
|
||
{ label: t('devices.weekMon'), value: 1 },
|
||
{ label: t('devices.weekTue'), value: 2 },
|
||
{ label: t('devices.weekWed'), value: 3 },
|
||
{ label: t('devices.weekThu'), value: 4 },
|
||
{ label: t('devices.weekFri'), value: 5 },
|
||
{ label: t('devices.weekSat'), value: 6 }
|
||
]}
|
||
style={{ width: '100%' }}
|
||
/>
|
||
</div>
|
||
)}
|
||
|
||
{/* 按月日期 */}
|
||
{taskForm.repeat_type === 'absolute_monthly' && (
|
||
<div>
|
||
<label className="text-sm block mb-1">{t('devices.monthDays')}</label>
|
||
<Select
|
||
mode="multiple"
|
||
value={taskForm.repeat_option.days_of_month}
|
||
onChange={(v) => setTaskForm({
|
||
...taskForm,
|
||
repeat_option: { ...taskForm.repeat_option, days_of_month: v }
|
||
})}
|
||
options={Array.from({ length: 31 }, (_, i) => ({ label: i + 1, value: i + 1 }))}
|
||
style={{ width: '100%' }}
|
||
/>
|
||
</div>
|
||
)}
|
||
|
||
{/* 按月星期 */}
|
||
{taskForm.repeat_type === 'relative_monthly' && (
|
||
<div className="grid grid-cols-2 gap-4">
|
||
<div>
|
||
<label className="text-sm block mb-1">{t('devices.whichWeek')}</label>
|
||
<Select
|
||
value={taskForm.repeat_option.week_of_month}
|
||
onChange={(v) => setTaskForm({
|
||
...taskForm,
|
||
repeat_option: { ...taskForm.repeat_option, week_of_month: v }
|
||
})}
|
||
options={[1, 2, 3, 4].map(w => ({ label: t('devices.weekNo', { w }), value: w }))}
|
||
style={{ width: '100%' }}
|
||
/>
|
||
</div>
|
||
<div>
|
||
<label className="text-sm block mb-1">{t('devices.weekday')}</label>
|
||
<Select
|
||
mode="multiple"
|
||
value={taskForm.repeat_option.days_of_week}
|
||
onChange={(v) => setTaskForm({
|
||
...taskForm,
|
||
repeat_option: { ...taskForm.repeat_option, days_of_week: v }
|
||
})}
|
||
options={[
|
||
{ label: t('devices.weekSun'), value: 0 },
|
||
{ label: t('devices.weekMon'), value: 1 },
|
||
{ label: t('devices.weekTue'), value: 2 },
|
||
{ label: t('devices.weekWed'), value: 3 },
|
||
{ label: t('devices.weekThu'), value: 4 },
|
||
{ label: t('devices.weekFri'), value: 5 },
|
||
{ label: t('devices.weekSat'), value: 6 }
|
||
]}
|
||
style={{ width: '100%' }}
|
||
/>
|
||
</div>
|
||
</div>
|
||
)}
|
||
|
||
<div>
|
||
<label className="text-sm block mb-1">{t('devices.execTimePoint')}</label>
|
||
<Select
|
||
mode="tags"
|
||
value={taskForm.recurring_task_start_time_list}
|
||
onChange={(v) => setTaskForm({
|
||
...taskForm,
|
||
recurring_task_start_time_list: v
|
||
})}
|
||
placeholder={t('devices.inputTimestamp')}
|
||
style={{ width: '100%' }}
|
||
/>
|
||
</div>
|
||
</>
|
||
)}
|
||
|
||
{/* 按钮 */}
|
||
<div className="flex justify-end gap-2 mt-4">
|
||
<Button onClick={resetModals}>{t('common.cancel')}</Button>
|
||
<Button type="primary" loading={loading} onClick={createFlightTask}>{t('devices.confirmCreate')}</Button>
|
||
</div>
|
||
</div>
|
||
</Modal>
|
||
|
||
{/* 执行航线设置返航高度 Modal */}
|
||
<Modal
|
||
title={t('devices.executeWaylineTask')}
|
||
open={rthModalVisible}
|
||
onOk={confirmExecuteWayline}
|
||
onCancel={() => setRthModalVisible(false)}
|
||
confirmLoading={loading}
|
||
okText={t('devices.executeNow')}
|
||
cancelText={t('common.cancel')}
|
||
centered
|
||
width={400}
|
||
>
|
||
<div style={{ padding: '10px 0' }}>
|
||
<div style={{ marginBottom: 16 }}>
|
||
<Text strong>{t('devices.selectedWaylineColon')}</Text>
|
||
<Text>{selectedWayline?.name}</Text>
|
||
</div>
|
||
<div style={{ marginBottom: 16 }}>
|
||
<Text strong>{t('devices.executeDeviceColon')}</Text>
|
||
<Text>{waylineDrone?.drone_callsign || waylineDrone?.device_sn || t('devices.noDeviceSelected')}</Text>
|
||
</div>
|
||
<div>
|
||
<div style={{ marginBottom: 8 }}><Text strong>{t('devices.returnHomeAltitudeColon')}</Text></div>
|
||
<InputNumber
|
||
min={10}
|
||
max={500}
|
||
value={tempRthAltitude}
|
||
onChange={val => setTempRthAltitude(val || 20)}
|
||
style={{ width: '100%' }}
|
||
/>
|
||
|
||
</div>
|
||
</div>
|
||
</Modal>
|
||
</div>
|
||
);
|
||
}
|