xx
This commit is contained in:
@@ -17,7 +17,7 @@ import {
|
|||||||
LayoutGrid, Clock, CheckCircle2, AlertCircle, Zap, Waves,
|
LayoutGrid, Clock, CheckCircle2, AlertCircle, Zap, Waves,
|
||||||
Calendar, User, TrendingUp, Maximize2, Play, Square, X, MapPin, RotateCw
|
Calendar, User, TrendingUp, Maximize2, Play, Square, X, MapPin, RotateCw
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { getsinglePlan, getsinglePlanTrack, updateFlightTaskStatus, postFlightCommmand, getWayLine } from '@/api/device';
|
import { getsinglePlan, getsinglePlanTrack, updateFlightTaskStatus, postFlightCommmand, getWayLine, createWaylineTask } from '@/api/device';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import utils from '@/lib/utils';
|
import utils from '@/lib/utils';
|
||||||
import CesiumMap from '../Map';
|
import CesiumMap from '../Map';
|
||||||
@@ -59,13 +59,11 @@ export default function WayLinePage({ planedevices }) {
|
|||||||
const [createTaskModal, setCreateTaskModal] = useState(false);
|
const [createTaskModal, setCreateTaskModal] = useState(false);
|
||||||
const [waylineUuid, setWaylineUuid] = useState('');
|
const [waylineUuid, setWaylineUuid] = useState('');
|
||||||
const [waylineList, setWaylineList] = useState([]); // 航线列表
|
const [waylineList, setWaylineList] = useState([]); // 航线列表
|
||||||
const [beginTime, setBeginTime] = useState(null);
|
|
||||||
const [endTime, setEndTime] = useState(null);
|
|
||||||
const [taskForm, setTaskForm] = useState({
|
const [taskForm, setTaskForm] = useState({
|
||||||
name: '',
|
name: '',
|
||||||
sn: '',
|
sn: '',
|
||||||
landing_dock_sn: '',
|
landing_dock_sn: '',
|
||||||
rth_altitude: 0,
|
rth_altitude: 100,
|
||||||
rth_mode: 'optimal',
|
rth_mode: 'optimal',
|
||||||
wayline_precision_type: 'gps',
|
wayline_precision_type: 'gps',
|
||||||
resumable_status: 'auto',
|
resumable_status: 'auto',
|
||||||
@@ -74,12 +72,15 @@ export default function WayLinePage({ planedevices }) {
|
|||||||
repeat_type: 'nonrepeating',
|
repeat_type: 'nonrepeating',
|
||||||
repeat_option: { interval: 1 },
|
repeat_option: { interval: 1 },
|
||||||
time_zone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
time_zone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||||
|
begin_at: null,
|
||||||
|
end_at: null,
|
||||||
|
recurring_task_start_time_list: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchWaylineList = async () => {
|
const fetchWaylineList = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await getWayLine();
|
const res = await getWayLine();
|
||||||
if (res?.code == 0) {
|
if (res?.code == 200 || res?.code == 0) {
|
||||||
const _list = res?.data?.list.map(item => {
|
const _list = res?.data?.list.map(item => {
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
@@ -103,7 +104,7 @@ export default function WayLinePage({ planedevices }) {
|
|||||||
name: '',
|
name: '',
|
||||||
sn: listDrone?.gateway_sn || '',
|
sn: listDrone?.gateway_sn || '',
|
||||||
landing_dock_sn: '',
|
landing_dock_sn: '',
|
||||||
rth_altitude: 0,
|
rth_altitude: 100,
|
||||||
rth_mode: 'optimal',
|
rth_mode: 'optimal',
|
||||||
wayline_precision_type: 'gps',
|
wayline_precision_type: 'gps',
|
||||||
resumable_status: 'auto',
|
resumable_status: 'auto',
|
||||||
@@ -112,9 +113,10 @@ export default function WayLinePage({ planedevices }) {
|
|||||||
repeat_type: 'nonrepeating',
|
repeat_type: 'nonrepeating',
|
||||||
repeat_option: { interval: 1 },
|
repeat_option: { interval: 1 },
|
||||||
time_zone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
time_zone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||||
|
begin_at: null,
|
||||||
|
end_at: null,
|
||||||
|
recurring_task_start_time_list: [],
|
||||||
});
|
});
|
||||||
setBeginTime(null);
|
|
||||||
setEndTime(null);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 创建任务提交
|
// 创建任务提交
|
||||||
@@ -125,12 +127,25 @@ export default function WayLinePage({ planedevices }) {
|
|||||||
}
|
}
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
// 这里替换成你的创建任务接口
|
const payload = {
|
||||||
utils.message.success('创建任务成功');
|
...taskForm,
|
||||||
resetModals();
|
wayline_uuid: waylineUuid,
|
||||||
getListTask(); // 刷新列表
|
// 如果是立即任务,begin_at 为 null 或当前时间戳
|
||||||
|
begin_at: taskForm.task_type === 'immediate' ? null : (taskForm.begin_at ? dayjs(taskForm.begin_at).unix() : null),
|
||||||
|
end_at: taskForm.end_at ? dayjs(taskForm.end_at).unix() : null,
|
||||||
|
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('创建任务成功');
|
||||||
|
resetModals();
|
||||||
|
getListTask(); // 刷新列表
|
||||||
|
} else {
|
||||||
|
utils.message.error(res.msg || '创建失败');
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
utils.message.error('创建失败');
|
utils.message.error('创建异常');
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -1001,12 +1016,85 @@ export default function WayLinePage({ planedevices }) {
|
|||||||
onChange={(val) => setTaskForm({ ...taskForm, task_type: val })}
|
onChange={(val) => setTaskForm({ ...taskForm, task_type: val })}
|
||||||
options={[
|
options={[
|
||||||
{ label: '立即任务', value: 'immediate' },
|
{ label: '立即任务', value: 'immediate' },
|
||||||
|
{ label: '单次定时任务', value: 'timed' },
|
||||||
|
{ label: '重复任务', value: 'recurring' },
|
||||||
|
{ label: '连续任务', value: 'continuous' },
|
||||||
]}
|
]}
|
||||||
style={{ width: '100%' }}
|
style={{ width: '100%' }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</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 text-black">开始时间 <span className="text-red-500">*</span></label>
|
||||||
|
<DatePicker
|
||||||
|
showTime
|
||||||
|
placeholder="开始时间"
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
value={taskForm.begin_at ? dayjs(taskForm.begin_at) : null}
|
||||||
|
onChange={(val) => setTaskForm({ ...taskForm, begin_at: val })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{(taskForm.task_type === 'recurring' || taskForm.task_type === 'continuous') && (
|
||||||
|
<div>
|
||||||
|
<label className="text-sm block mb-1 text-black">结束时间 <span className="text-red-500">*</span></label>
|
||||||
|
<DatePicker
|
||||||
|
showTime
|
||||||
|
placeholder="结束时间"
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
value={taskForm.end_at ? dayjs(taskForm.end_at) : null}
|
||||||
|
onChange={(val) => setTaskForm({ ...taskForm, end_at: val })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{taskForm.task_type === 'recurring' && (
|
||||||
|
<>
|
||||||
|
<div className="grid grid-cols-2 gap-4">
|
||||||
|
<div>
|
||||||
|
<label className="text-sm block mb-1 text-black">重复模式 <span className="text-red-500">*</span></label>
|
||||||
|
<Select
|
||||||
|
value={taskForm.repeat_type}
|
||||||
|
onChange={(val) => setTaskForm({ ...taskForm, repeat_type: val })}
|
||||||
|
options={[
|
||||||
|
{ label: '不重复', value: 'nonrepeating' },
|
||||||
|
{ label: '每天', value: 'daily' },
|
||||||
|
{ label: '每周', value: 'weekly' },
|
||||||
|
{ label: '每月(按日期)', value: 'absolute_monthly' },
|
||||||
|
{ label: '每月(按星期)', value: 'relative_monthly' },
|
||||||
|
]}
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="text-sm block mb-1 text-black">重复间隔(天/周/月) <span className="text-red-500">*</span></label>
|
||||||
|
<InputNumber
|
||||||
|
min={1}
|
||||||
|
value={taskForm.repeat_option.interval}
|
||||||
|
onChange={(val) => setTaskForm({ ...taskForm, repeat_option: { ...taskForm.repeat_option, interval: val || 1 } })}
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="text-sm block mb-1 text-black">执行时间点列表</label>
|
||||||
|
<Select
|
||||||
|
mode="tags"
|
||||||
|
placeholder="输入秒级时间戳或选择时间 (多选)"
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
value={taskForm.recurring_task_start_time_list}
|
||||||
|
onChange={(val) => setTaskForm({ ...taskForm, recurring_task_start_time_list: val })}
|
||||||
|
/>
|
||||||
|
<Text type="secondary" style={{ fontSize: 11 }}>注:重复任务需指定具体执行的时间点列表。</Text>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="text-xs text-slate-400 mt-2">
|
<div className="text-xs text-slate-400 mt-2">
|
||||||
<div>绑定无人机:{listDrone?.drone_callsign || '-'}({listDrone?.gateway_sn || '-'})</div>
|
<div>绑定无人机:{listDrone?.drone_callsign || '-'}({listDrone?.gateway_sn || '-'})</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user