From 94fb3d3d4ffb285487ddd8237a51420ba0b1a221 Mon Sep 17 00:00:00 2001 From: mmc <1556375442@qq.com> Date: Mon, 25 May 2026 11:21:34 +0800 Subject: [PATCH] xxx --- src/components/devices/WayLinePage.tsx | 226 ++++++++++++++++++++++++- 1 file changed, 223 insertions(+), 3 deletions(-) diff --git a/src/components/devices/WayLinePage.tsx b/src/components/devices/WayLinePage.tsx index 495a392..6da4044 100644 --- a/src/components/devices/WayLinePage.tsx +++ b/src/components/devices/WayLinePage.tsx @@ -1,7 +1,8 @@ import React, { useState, useEffect } from 'react'; import { Row, Col, Card, Button, Space, Table, Tag, Typography, Progress, Badge, - Tabs, Input, Switch, Divider, Tooltip, Timeline, Select, message, DatePicker + Tabs, Input, Switch, Divider, Tooltip, Timeline, Select, message, DatePicker, + Modal, InputNumber } from 'antd'; import { PlusOutlined, ImportOutlined, NodeIndexOutlined, @@ -16,7 +17,7 @@ import { LayoutGrid, Clock, CheckCircle2, AlertCircle, Zap, Waves, Calendar, User, TrendingUp, Maximize2, Play, Square, X, MapPin, RotateCw } from 'lucide-react'; -import { getsinglePlan, getsinglePlanTrack, updateFlightTaskStatus, postFlightCommmand } from '@/api/device'; +import { getsinglePlan, getsinglePlanTrack, updateFlightTaskStatus, postFlightCommmand, getWayLine } from '@/api/device'; import dayjs from 'dayjs'; import utils from '@/lib/utils'; import CesiumMap from '../Map'; @@ -52,6 +53,99 @@ export default function WayLinePage({ planedevices }) { const [flightCommandLoading, setFlightCommandLoading] = useState(false); const [loading, setLoading] = useState(false); + // ============================================== + // ✅ 创建任务弹窗相关状态(已完整整合) + // ============================================== + const [createTaskModal, setCreateTaskModal] = useState(false); + const [waylineUuid, setWaylineUuid] = useState(''); + const [waylineList, setWaylineList] = useState([]); // 航线列表 + const [beginTime, setBeginTime] = useState(null); + const [endTime, setEndTime] = useState(null); + const [taskForm, setTaskForm] = useState({ + name: '', + sn: '', + landing_dock_sn: '', + rth_altitude: 0, + 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: Intl.DateTimeFormat().resolvedOptions().timeZone, + }); + + const fetchWaylineList = async () => { + try { + const res = await getWayLine(); + if (res?.code == 0) { + const _list = res?.data?.list.map(item => { + return { + ...item, + label: item.name || `航线_${item.id || '未知'}`, + value: item.id + } + }) + setWaylineList(_list || []); // 取list数组 + } + } catch (err) { + message.error('获取航线列表失败'); + } + }; + + + // 关闭弹窗重置 + const resetModals = () => { + setCreateTaskModal(false); + setWaylineUuid(''); + setTaskForm({ + name: '', + sn: listDrone?.gateway_sn || '', + landing_dock_sn: '', + rth_altitude: 0, + 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: Intl.DateTimeFormat().resolvedOptions().timeZone, + }); + setBeginTime(null); + setEndTime(null); + }; + + // 创建任务提交 + const createFlightTask = async () => { + if (!taskForm.name || !waylineUuid || !taskForm.sn) { + utils.message.warning('请完善必填项'); + return; + } + setLoading(true); + try { + // 这里替换成你的创建任务接口 + utils.message.success('创建任务成功'); + resetModals(); + getListTask(); // 刷新列表 + } catch (err) { + utils.message.error('创建失败'); + } finally { + setLoading(false); + } + }; + + // 选中无人机时自动填充机场SN + useEffect(() => { + if (listDrone) { + setTaskForm(prev => ({ ...prev, sn: listDrone.gateway_sn || '' })); + } + }, [listDrone]); + // ============================================== + // ✅ 创建任务模块结束 + // ============================================== + // 顶部统计 const topCards = [ { title: '今日航线计划', value: '18', unit: '条', trend: '较昨日 +2', trendColor: '#00B42A', icon: , color: '#165DFF' }, @@ -117,6 +211,9 @@ export default function WayLinePage({ planedevices }) { message.error('任务看板数据获取失败'); } }; + useEffect(() => { + fetchWaylineList(); + }, []) // 初始化默认全部设备 useEffect(() => { @@ -374,7 +471,17 @@ export default function WayLinePage({ planedevices }) { } size="small" - extra={} + extra={ + + { + resetModals(); + setCreateTaskModal(true); + }} + /> + + } bordered={false} bodyStyle={{ padding: 0, display: 'flex', flexDirection: 'column', flex: 1 }} style={{ ...cardStyle, flex: 1 }} @@ -798,6 +905,119 @@ export default function WayLinePage({ planedevices }) { + + {/* ============================================== */} + {/* ✅ 创建航线任务弹窗(已放在页面底部) */} + {/* ============================================== */} + +
+ {/* 基础信息 */} +
+
+ + setTaskForm({ ...taskForm, name: e.target.value })} placeholder="请输入航线名称" /> +
+
+ + setTaskForm({ ...taskForm, sn: e.target.value })} placeholder="机场SN" disabled /> +
+
+ + setTaskForm({ ...taskForm, landing_dock_sn: e.target.value })} placeholder="可不填" /> +
+
+ + {/* 飞行参数 */} +
+
+ + setTaskForm({ ...taskForm, rth_altitude: val || 0 })} style={{ width: '100%' }} /> +
+
+ + setTaskForm({ ...taskForm, wayline_precision_type: val })} + options={[ + { label: 'GPS模式(无需RTK收敛)', value: 'gps' }, + { label: 'RTK高精度(需等待收敛)', value: 'rtk' } + ]} + style={{ width: '100%' }} + /> +
+
+ + setTaskForm({ ...taskForm, task_type: val })} + options={[ + { label: '立即任务', value: 'immediate' }, + ]} + style={{ width: '100%' }} + /> +
+
+ +
+
绑定无人机:{listDrone?.drone_callsign || '-'}({listDrone?.gateway_sn || '-'})
+
+ +
+ + +
+
+
+ ); }