From 5fe88759ff433830c6d24fce8e3b0f6ecaff66e4 Mon Sep 17 00:00:00 2001
From: husq <931347610@qq.com>
Date: Thu, 14 Sep 2023 18:21:13 +0800
Subject: [PATCH] 功能修改、接口修改
---
src/types/task.ts | 88 +-----
src/components/task/TaskPanel.vue | 71 +---
src/pages/page-web/index.vue | 2
src/components/task/CreatePlan.vue | 508 ++++++------------------------------
src/api/wayline.ts | 33 +
src/pages/page-web/projects/wayline.vue | 86 +-----
src/router/index.ts | 2
src/components/g-map/DroneControlPanel.vue | 2
src/pages/page-web/projects/project_list/list_page/components/ProjectList.vue | 3
9 files changed, 165 insertions(+), 630 deletions(-)
diff --git a/src/api/wayline.ts b/src/api/wayline.ts
index cb685db..7ce981c 100644
--- a/src/api/wayline.ts
+++ b/src/api/wayline.ts
@@ -3,12 +3,12 @@
import { TaskType, TaskStatus, OutOfControlAction } from '/@/types/task'
import { WaylineType } from '/@/types/wayline'
-const HTTP_PREFIX = '/api/drone'
+const HTTP_PREFIX = '/wayline/api/v1'
// Get Wayline Files
-export const getWaylineFiles = async function (params:any): Promise<IWorkspaceResponse<any>> {
- const url = `${HTTP_PREFIX}/waylineFile/getList`
- const result = await request.get(url, { params })
+export const getWaylineFiles = async function (wid: string, body: {}): Promise<IWorkspaceResponse<any>> {
+ const url = `${HTTP_PREFIX}/workspaces/${wid}/waylines?order_by=${body.order_by}&page=${body.page}&page_size=${body.page_size}`
+ const result = await request.get(url)
return result.data
}
@@ -59,10 +59,20 @@
finishAction: number
breakContinue: number
}
-
+export interface CreatePlan {
+ name: string,
+ file_id: string,
+ dock_sn: string,
+ task_type: TaskType, // 任务类型
+ wayline_type: WaylineType, // 航线类型
+ task_days?: number[] // 执行任务的日期(秒)
+ task_periods?: number[][] // 执行任务的时间点(秒)
+ rth_altitude: number // 相对机场返航高度 20 - 500
+ out_of_control_action: OutOfControlAction // 失控动作
+}
// 新增计划
-export const createPlan = async function (plan:any): Promise<IWorkspaceResponse<any>> {
- const url = `${HTTP_PREFIX}/waylineJob/add`
+export const createPlan = async function (workspaceId: string, plan: CreatePlan): Promise<IWorkspaceResponse<any>> {
+ const url = `${HTTP_PREFIX}/workspaces/${workspaceId}/flight-tasks`
const result = await request.post(url, plan)
return result.data
}
@@ -94,8 +104,8 @@
// 获取计划列表(分页)
export const getWaylineJobs = async function (workspaceId: string, page: IPage): Promise<IListWorkspaceResponse<Task>> {
- const url = `${HTTP_PREFIX}/waylineJob/getPage`
- const result = await request.get(url, { params: { workspaceId } })
+ const url = `${HTTP_PREFIX}/workspaces/${workspaceId}/jobs?page=${page.page}&page_size=${page.page_size}`
+ const result = await request.get(url)
return result.data
}
@@ -132,11 +142,8 @@
// Upload Wayline file
export const importKmzFile = async function (workspaceId: string, file: {}): Promise<IWorkspaceResponse<any>> {
- const url = `${HTTP_PREFIX}/waylineFile/upload`
+ const url = `${HTTP_PREFIX}/workspaces/${workspaceId}/waylines/file/upload`
const result = await request.post(url, file, {
- params: {
- projectId: workspaceId
- },
headers: {
'Content-Type': 'multipart/form-data',
}
diff --git a/src/components/g-map/DroneControlPanel.vue b/src/components/g-map/DroneControlPanel.vue
index 1956f4c..266589d 100644
--- a/src/components/g-map/DroneControlPanel.vue
+++ b/src/components/g-map/DroneControlPanel.vue
@@ -127,7 +127,7 @@
<div class="row">
<Select v-model:value="payloadSelectInfo.value" style="width: 110px; marginRight: 5px" :options="payloadSelectInfo.options" @change="handlePayloadChange"/>
<div class="drone-control">
- <Button type="primary" size="small" @click="onAuthPayload">有效载荷控制</Button>
+ <Button type="primary" size="small" @click="onAuthPayload">负载控制</Button>
</div>
</div>
<div class="row">
diff --git a/src/components/task/CreatePlan.vue b/src/components/task/CreatePlan.vue
index 473e0f3..33c1ef6 100644
--- a/src/components/task/CreatePlan.vue
+++ b/src/components/task/CreatePlan.vue
@@ -1,48 +1,41 @@
<template>
<div class="create-plan-wrapper">
<div class="header">
- 新建计划
+ 创建计划
</div>
<div class="content">
- <a-form ref="valueRef" layout="horizontal" :hideRequiredMark="true" :rules="rules" :model="planForm"
+ <a-form ref="valueRef" layout="horizontal" :hideRequiredMark="true" :rules="rules" :model="planBody"
labelAlign="left">
<a-form-item label="计划名称" name="name" :labelCol="{ span: 23 }">
- <a-input style="background: black;" placeholder="请输入计划名称" v-model:value="planForm.name" />
+ <a-input style="background: black;" placeholder="请输入计划名称" v-model:value="planBody.name" />
</a-form-item>
-
<!-- 航线 -->
- <a-form-item label="执行航线" :wrapperCol="{ offset: 12 }" name="fileId">
+ <a-form-item class="text-r" label="执行航线" :wrapperCol="{ offset: 7 }" name="file_id">
<router-link :to="{ name: 'select-plan' }" @click="selectRoute">
选择航线
</router-link>
</a-form-item>
-
- <a-form-item v-if="planForm.fileId" style="margin-top: -15px;">
+ <a-form-item v-if="planBody.file_id" style="margin-top: -15px;">
<div class="wayline-panel" style="padding-top: 5px;">
<div class="title">
<a-tooltip :title="wayline.name">
- <div class="pr10" style="width: 120px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden;">
- {{ wayline.name }}
- </div>
+ <div class="pr10" style="width: 120px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden;">{{
+ wayline.name }}</div>
</a-tooltip>
-
<div class="ml10">
<UserOutlined />
</div>
-
<a-tooltip :title="wayline.user_name">
<div class="ml5 pr10"
- style="width: 80px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden;">
- {{ wayline.user_name }}
- </div>
+ style="width: 80px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden;">{{
+ wayline.user_name }}</div>
</a-tooltip>
</div>
<div class="ml10 mt5" style="color: hsla(0,0%,100%,0.65);">
<span>
<RocketOutlined />
</span>
- <span class="ml5">{{
- Object.keys(EDeviceType)[Object.values(EDeviceType).indexOf(wayline.drone_model_key)]
+ <span class="ml5">{{ Object.keys(EDeviceType)[Object.values(EDeviceType).indexOf(wayline.drone_model_key)]
}}</span>
<span class="ml10">
<CameraFilled style="border-top: 1px solid; padding-top: -3px;" />
@@ -56,19 +49,18 @@
</div>
</div>
</a-form-item>
-
<!-- 设备 -->
- <a-form-item label="执行设备" :wrapperCol="{ offset: 12 }" v-model:value="planForm.dockSn" name="dockSn">
- <router-link :to="{ name: 'select-plan' }" @click="selectDevice">选择设备
- </router-link>
+ <a-form-item class="text-r" label="执行设备" :wrapperCol="{ offset: 10 }" v-model:value="planBody.dock_sn"
+ name="dock_sn">
+ <router-link :to="{ name: 'select-plan' }" @click="selectDevice"
+ style="width: 100%;flex:1;text-align: right;">选择设备</router-link>
</a-form-item>
- <a-form-item v-if="planForm.dockSn" style="margin-top: -15px;">
+ <a-form-item v-if="planBody.dock_sn" style="margin-top: -15px;">
<div class="panel" style="padding-top: 5px;" @click="selectDock(dock)">
<div class="title">
<a-tooltip :title="dock.nickname">
- <div class="pr10" style="width: 120px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden;">
- {{ dock.nickname }}
- </div>
+ <div class="pr10" style="width: 120px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden;">{{
+ dock.nickname }}</div>
</a-tooltip>
</div>
<div class="ml10 mt5" style="color: hsla(0,0%,100%,0.65);">
@@ -79,168 +71,36 @@
</div>
</div>
</a-form-item>
-
- <!-- 任务策略 -->
- <a-form-item label="任务策略" name="taskType" class="plan-timer-form-item" :labelCol="{ span: 23 }">
+ <!-- 任务类型 -->
+ <a-form-item label="任务策略" class="plan-timer-form-item" :labelCol="{ span: 23 }">
<div style="white-space: nowrap;">
- <a-radio-group class="group_radio" v-model:value="planForm.taskType" button-style="solid"
- @change="taskTypeChange">
- <a-radio-button v-for="type in TaskTypeOptions" :value="type.value" :key="type.value">{{
- type.label
- }}
- </a-radio-button>
+ <a-radio-group v-model:value="planBody.task_type" button-style="solid">
+ <a-radio-button v-for="type in TaskTypeOptions" :value="type.value" :key="type.value">{{ type.label
+ }}</a-radio-button>
</a-radio-group>
-
</div>
-
</a-form-item>
-
- <!-- 单次定时- -->
- <a-form-item label="执行时间" v-if="planForm.taskType === TaskType.Timed" name="executeSingleTime"
+ <!-- 执行时间 -->
+ <a-form-item label="Start Time" v-if="planBody.task_type === TaskType.Timed" name="select_execute_time"
:labelCol="{ span: 23 }">
- <a-date-picker v-model:value="planForm.executeSingleTime" format="YYYY-MM-DD HH:mm"
- valueFormat="YYYY-MM-DD HH:mm" show-time placeholder="请选择日期" />
+ <a-date-picker v-model:value="planBody.select_execute_time" format="YYYY-MM-DD HH:mm:ss" show-time
+ placeholder="Select Time" />
</a-form-item>
-
- <!--重复定时-->
- <!--执行日期-->
- <a-form-item v-if="planForm.taskType === TaskType.RepeatTimed || planForm.taskType === TaskType.Continuous"
- label="执行日期" name="repeatExecuteTimeArr" :labelCol="{ span: 23 }">
- <a-range-picker v-model:value="planForm.repeatExecuteTimeArr" format="YYYY-MM-DD" valueFormat="YYYY-MM-DD"
- :placeholder="['开始日期', '结束日期']" />
+ <!-- RTH Altitude Relative to Dock -->
+ <a-form-item label="相对机场返航高度(ALT)" :labelCol="{ span: 23 }" name="rth_altitude">
+ <a-input-number v-model:value="planBody.rth_altitude" :min="20" :max="1500" class="width-100" required>
+ </a-input-number>
</a-form-item>
-
- <!--执行时间-->
- <a-form-item v-if="planForm.taskType === TaskType.RepeatTimed" label="执行时间" name="repeatTimeArr"
- :labelCol="{ span: 23 }">
- <div v-for="(item, index) in repeatTimeArr" :key="index">
- <a-time-picker style="background: black" v-model:value="item.value" placeholder="请选择时间" format="HH:mm"
- valueFormat="HH:mm" />
-
- <a-button @click="addTime" type="default" shape="circle" :size="btnSize">
- <template #icon>
- <PlusCircleOutlined />
- </template>
- </a-button>
-
- <a-button @click="deleteTime(item)" type="default" shape="circle" :size="btnSize">
- <template #icon>
- <MinusCircleOutlined />
- </template>
- </a-button>
- </div>
- </a-form-item>
- <a-form-item v-if="planForm.taskType === TaskType.Continuous" label="执行时间" name="repeatTimeArr"
- :labelCol="{ span: 23 }">
- <div v-for="(item, index) in repeatTimeArr" :key="index">
- <a-time-picker style="background: black" v-model:value="item.value[0]" placeholder="请选择时间" format="HH:mm"
- valueFormat="HH:mm" />
- <div style="color: white">-</div>
- <a-time-picker style="background: black" v-model:value="item.value[1]" placeholder="请选择时间" format="HH:mm"
- valueFormat="HH:mm" />
-
- <a-button @click="addTime" type="default" shape="circle" :size="btnSize">
- <template #icon>
- <PlusCircleOutlined />
- </template>
- </a-button>
-
- <a-button @click="deleteTime(item)" type="default" shape="circle" :size="btnSize">
- <template #icon>
- <MinusCircleOutlined />
- </template>
- </a-button>
- </div>
- </a-form-item>
-
- <!-- 任务开始执行的电量 -->
- <a-form-item v-if="planForm.taskType === TaskType.Continuous" label="任务开始执行的电量" :labelCol="{ span: 23 }"
- name="startPower">
- <a-input style="background: black;" placeholder="请输入计划名称" v-model:value="planForm.startPower" />
-
- </a-form-item>
-
- <!--重复频率-->
- <a-form-item v-if="planForm.taskType === TaskType.RepeatTimed || planForm.taskType === TaskType.Continuous"
- label="重复频率" name="frequencyValue" :labelCol="{ span: 23 }">
- <div>
- <div style="color: white">每</div>
- <a-input style="background-color: black;" placeholder="请输入计划名称" v-model:value="planForm.frequencyValue" />
- <a-select v-model:value="planForm.frequencyType" style="width: 200px"
- :options="FrequencyTypeOptions"></a-select>
- </div>
- </a-form-item>
-
- <!--重复规则-->
- <a-form-item v-if="planForm.taskType === TaskType.RepeatTimed || planForm.taskType === TaskType.Continuous"
- label="重复规则" name="repeatRuleType" :labelCol="{ span: 23 }">
- <div>
- <a-select v-model:value="planForm.repeatRuleType" style="background-color:black;width: 200px"
- @change="repeatRuleTypeChange" :options="RepeatRuleTypeOptions"></a-select>
- </div>
-
- <div v-if="planForm.repeatRuleType === RepeatRuleType.day">
- <a-button class="btn" :class="[item.checked ? 'btn-selected' : 'btn-unselected']"
- v-for="(item, index) in dayNumArr" :key="index" size="small" @click="selectBtn(item)">
- {{ item.value }}
- </a-button>
- </div>
-
- <div v-if="planForm.repeatRuleType === RepeatRuleType.week">
- <a-select v-model:value="planForm.repeatRuleValueWeek[0]" style="width: 200px"
- :options="WhichWeekOptions"></a-select>
- <a-select v-model:value="planForm.repeatRuleValueWeek[1]" style="width: 200px"
- :options="WhichDayOptions"></a-select>
- </div>
-
- </a-form-item>
-
- <!-- 相对机场返航高度 -->
- <a-form-item label="相对机场返航高度(ALT)" :labelCol="{ span: 23 }" name="rthAltitude">
- <div class="form-alt">
- <a-button class="alt-btn" type="primary" size="small" :disabled="calculateDisabled('-', 100)"
- @click="calculate('-', 100)">-100</a-button>
- <a-button class="alt-btn" type="primary" size="small" :disabled="calculateDisabled('-', 10)"
- @click="calculate('-', 10)">-10</a-button>
- <a-button class="alt-btn" type="primary" size="small" :disabled="calculateDisabled('-', 1)"
- @click="calculate('-', 1)">-1</a-button>
-
- <a-input class="alt-input" v-model:value="planForm.rthAltitude" :min="20" :max="1500" required />
-
- <a-button class="alt-btn" type="primary" size="small" :disabled="calculateDisabled('+', 1)"
- @click="calculate('+', 1)">+1</a-button>
- <a-button class="alt-btn" type="primary" size="small" :disabled="calculateDisabled('+', 10)"
- @click="calculate('+', 10)">+10</a-button>
- <a-button class="alt-btn" type="primary" size="small" :disabled="calculateDisabled('+', 100)"
- @click="calculate('+', 100)"> +100</a-button>
- </div>
-
- </a-form-item>
-
<!-- Lost Action -->
- <a-form-item label="航线飞行中失联" :labelCol="{ span: 23 }" name="outOfControl">
- <div class="form-outOfControl" style="white-space: nowrap;">
- <a-radio-group v-model:value="planForm.outOfControl" button-style="solid">
- <a-radio-button v-for="(action, acIndex) in OutOfControlActionOptions " :value="action.value"
- :key="action.value" :style="{ marginRight: ( acIndex === 0 ? '10px' : '0px' ) }">
+ <a-form-item label="航线飞行中失联" :labelCol="{ span: 23 }" name="out_of_control_action">
+ <div style="white-space: nowrap;">
+ <a-radio-group v-model:value="planBody.out_of_control_action" button-style="solid">
+ <a-radio-button v-for="action in OutOfControlActionOptions" :value="action.value" :key="action.value">
{{ action.label }}
</a-radio-button>
</a-radio-group>
</div>
</a-form-item>
-
- <!--完成动作-->
- <a-form-item label="完成动作" :labelCol="{ span: 23 }" name="finishAction">
- <a-select disabled v-model:value="planForm.finishAction" style="width: 200px"
- :options="FinishActionOptions"></a-select>
- </a-form-item>
-
- <!--断点续飞-->
- <a-form-item label="自动断点续飞" :labelCol="{ span: 20 }" name="breakContinue">
- <a-switch v-model:checked="planForm.breakContinue" :checkedValue="1" :unCheckedValue="2" />
- </a-form-item>
-
- <!--提交,取消按钮-->
<a-form-item class="width-100" style="margin-bottom: 40px;">
<div class="footer">
<a-button class="mr10" style="background: #3c3c3c;" @click="closePlan">取消
@@ -253,7 +113,7 @@
</div>
</div>
<div v-if="drawerVisible"
- style="position: absolute; left: 370px; width: 280px; height: 100vh; float: right; top: 0; z-index: 1000; color: white; background: #282828;">
+ style="position: absolute; left: 335px; width: 280px; height: 100vh; float: right; top: 0; z-index: 1000; color: white; background: #282828;">
<div>
<router-view :name="routeName" />
</div>
@@ -266,119 +126,26 @@
</template>
<script lang="ts" setup>
-import { computed, onMounted, onUnmounted, reactive, ref, toRaw, UnwrapRef, watch } from 'vue'
-import {
- CloseOutlined,
- RocketOutlined,
- CameraFilled,
- UserOutlined,
- PlusCircleOutlined,
- MinusCircleOutlined
-} from '@ant-design/icons-vue'
+import { computed, onMounted, onUnmounted, reactive, ref, toRaw, UnwrapRef } from 'vue'
+import { CloseOutlined, RocketOutlined, CameraFilled, UserOutlined, PlusCircleOutlined, MinusCircleOutlined } from '@ant-design/icons-vue'
import { ELocalStorageKey, ERouterName } from '/@/types'
import { useMyStore } from '/@/store'
import { WaylineType, WaylineFile } from '/@/types/wayline'
import { Device, EDeviceType } from '/@/types/device'
-import { createPlan, waylineJob } from '/@/api/wayline'
+import { createPlan, CreatePlan } from '/@/api/wayline'
import { getRoot } from '/@/root'
-import {
- TaskType,
- OutOfControlActionOptions,
- OutOfControlAction,
- TaskTypeOptions,
- FrequencyTypeOptions,
- RepeatRuleTypeOptions,
- RepeatRuleType,
- WhichWeekOptions, WhichDayOptions, FinishActionOptions, FrequencyType
-} from '/@/types/task'
+import { TaskType, OutOfControlActionOptions, OutOfControlAction, TaskTypeOptions } from '/@/types/task'
import moment, { Moment } from 'moment'
import { RuleObject } from 'ant-design-vue/es/form/interface'
-import { clickPoint, pointCenter } from '/@/hooks/use-center-point'
-const btnSize = 'size'
const root = getRoot()
const store = useMyStore()
+
const workspaceId = localStorage.getItem(ELocalStorageKey.WorkspaceId)!
+
const wayline = computed<WaylineFile>(() => {
return store.state.waylineInfo
})
-watch(() => wayline, (newVal) => {
- if (newVal.value.id) {
- planForm.fileId = newVal.value.id
- }
-}, {
- deep: true
-})
-
-const calculateDisabled = computed(() => {
- return function (a: string, b: number) {
- return a === '-' ? planForm.rthAltitude - b < 20 : planForm.rthAltitude + b > 1500
- }
-})
-
-// 表单对象
-
-const planForm = reactive<waylineJob>({
- name: '新建计划',
- fileId: '',
- dockSn: '',
- workspaceId: '',
- waylineId: '',
- taskType: TaskType.Immediate,
-
- executeSingleTime: '',
- repeatExecuteTimeArr: [],
- executeStartTime: '',
- executeEndTime: '',
- executeRepeatTime: [],
- frequencyValue: 1,
- frequencyType: FrequencyType.month,
- repeatRuleType: RepeatRuleType.day,
- repeatRuleValueWeek: [1, 1],
- startPower: 90,
- rthAltitude: 20,
- outOfControl: 0,
- finishAction: 1,
- breakContinue: 2,
-})
-
-interface commonObj {
- index: number
- value: any
- checked?: boolean
-}
-
-const dayNumArr = ref<commonObj[]>([])
-
-initDayNumArr()
-
-function initDayNumArr () {
- dayNumArr.value = []
- for (let i = 0; i < 31; i++) {
- dayNumArr.value.push({
- index: i + 1,
- value: i + 1,
- checked: false
- })
- }
-}
-
-// 重复定时的执行时间
-const repeatTimeArr = ref<commonObj[]>([
- { index: 0, value: '' },
-])
-
-function taskTypeChange (e: any) {
- if (e.target.value === TaskType.Continuous) {
- repeatTimeArr.value = [
- { index: 0, value: [] }
- ]
- } else if (e.target.value === TaskType.RepeatTimed) {
- repeatTimeArr.value = [
- { index: 0, value: '' }
- ]
- }
-}
const dock = computed<Device>(() => {
return store.state.dockInfo
@@ -387,95 +154,60 @@
const disabled = ref(false)
const routeName = ref('')
+const planBody = reactive({
+ name: '',
+ file_id: computed(() => store.state.waylineInfo.id),
+ dock_sn: computed(() => store.state.dockInfo.device_sn),
+ task_type: TaskType.Immediate,
+ select_execute_time: undefined as Moment | undefined,
+ rth_altitude: '',
+ out_of_control_action: OutOfControlAction.ReturnToHome,
+})
const drawerVisible = ref(false)
const valueRef = ref()
const rules = {
name: [
{ required: true, message: '请输入计划名称' },
- { max: 20, message: '长度不能超过20个字符', trigger: 'blur' }
+ { max: 20, message: '计划名称长度在2-20之间', trigger: 'blur' }
],
- // fileId: [{ required: true, message: 'Select Route' }],
- // dockSn: [{ required: true, message: 'Select Device' }],
- // select_execute_time: [{ required: true, message: 'Select start time' }],
- rthAltitude: [
+ file_id: [{ required: true, message: '请选择航线' }],
+ dock_sn: [{ required: true, message: '请选择设备' }],
+ select_execute_time: [{ required: true, message: '请选择任务策略' }],
+ rth_altitude: [
{
validator: async (rule: RuleObject, value: string) => {
if (!/^[0-9]{1,}$/.test(value)) {
- throw new Error('RTH Altitude Relative Require number')
+ throw new Error('相对机场返航高度需为数字类型')
}
},
}
],
- outOfControl: [{ required: true, message: 'Select Lost Action' }],
+ out_of_control_action: [{ required: true, message: '请选择航线飞行中失联' }],
}
function onSubmit () {
valueRef.value.validate().then(() => {
disabled.value = true
- const form = buildForm()
- createPlan(form).then(res => {
- disabled.value = false
- }).finally(() => {
- closePlan()
- })
+ const createPlanBody = { ...planBody } as unknown as CreatePlan
+ if (planBody.select_execute_time) {
+ createPlanBody.task_days = [moment(planBody.select_execute_time).unix()]
+ createPlanBody.task_periods = [createPlanBody.task_days]
+ }
+ createPlanBody.rth_altitude = Number(createPlanBody.rth_altitude)
+ if (wayline.value && wayline.value.template_types && wayline.value.template_types.length > 0) {
+ createPlanBody.wayline_type = wayline.value.template_types[0]
+ }
+ // console.log('planBody', createPlanBody)
+ createPlan(workspaceId, createPlanBody)
+ .then(res => {
+ disabled.value = false
+ }).finally(() => {
+ closePlan()
+ })
}).catch((e: any) => {
console.log('validate err', e)
})
-}
-
-// 构建表单
-function buildForm () {
- const form: any = {}
-
- // 公共字段
- form.name = planForm.name
- form.workspaceId = store.state.common.projectId
- form.fileId = planForm.fileId
- form.dockSn = planForm.dockSn
- form.taskType = planForm.taskType
- form.rthAltitude = planForm.rthAltitude
- form.outOfControl = planForm.outOfControl
- form.breakContinue = planForm.breakContinue
- form.finishAction = planForm.finishAction
- form.status = 1
-
- // 根据不同任务策略给form添加不同字段
- if (planForm.taskType === TaskType.Timed) {
- form.executeSingleTime = planForm.executeSingleTime
- } else if (planForm.taskType === TaskType.RepeatTimed) {
- form.executeStartTime = planForm.repeatExecuteTimeArr[0]
- form.executeEndTime = planForm.repeatExecuteTimeArr[1]
-
- form.executeRepeatTime = repeatTimeArr.value.map(e => e.value)
-
- form.frequencyType = planForm.frequencyType
- form.frequencyValue = planForm.frequencyValue
- form.repeatRuleType = planForm.repeatRuleType
- if (planForm.repeatRuleType === 1) {
- form.repeatRuleValue = planForm.repeatRuleValueDay
- } else {
- form.repeatRuleValue = planForm.repeatRuleValueWeek
- }
- } else if (planForm.taskType === TaskType.Continuous) {
- form.executeStartTime = planForm.repeatExecuteTimeArr[0]
- form.executeEndTime = planForm.repeatExecuteTimeArr[1]
- form.executeRepeatTime = planForm.executeRepeatTime
- form.frequencyType = planForm.frequencyType
- form.frequencyValue = planForm.frequencyValue
- form.startPower = planForm.startPower
-
- form.executeRepeatTime = repeatTimeArr.value.map(e => e.value)
- form.repeatRuleType = planForm.repeatRuleType
- if (planForm.repeatRuleType === 1) {
- form.repeatRuleValue = planForm.repeatRuleValueDay
- } else {
- form.repeatRuleValue = planForm.repeatRuleValueWeek
- }
- }
-
- console.log('表单:', form)
- return form
}
function closePlan () {
@@ -496,50 +228,6 @@
drawerVisible.value = true
routeName.value = 'DockPanel'
}
-
-// 重复定时添加执行时间
-function addTime () {
- const index = repeatTimeArr.value[repeatTimeArr.value.length - 1].index
- if (planForm.taskType === TaskType.RepeatTimed) {
- repeatTimeArr.value.push({
- index: index + 1,
- value: ''
- })
- } else if (planForm.taskType === TaskType.Continuous) {
- repeatTimeArr.value.push({
- index: index + 1,
- value: []
- })
- }
-}
-
-// 重复定时删除执行时间
-function deleteTime (item: commonObj) {
- repeatTimeArr.value = repeatTimeArr.value.filter(e => e.index !== item.index)
-}
-
-// 重复规则变更
-function repeatRuleTypeChange (value: any, option: any) {
-
-}
-
-// 计算高度
-function calculate (operator: string, num: number) {
- if (operator === '+') {
- planForm.rthAltitude = planForm.rthAltitude + num
- } else {
- planForm.rthAltitude = planForm.rthAltitude - num
- }
-}
-
-function selectBtn (item: commonObj) {
- console.log(item, '++++++++++++++++++++++')
- item.checked = !item.checked
- planForm.repeatRuleValueDay = dayNumArr.value.filter(e => e.checked).map(e => e.value)
- console.log('dayNumArr', dayNumArr.value)
- console.log('重复规则值:', planForm.repeatRuleValueDay)
-}
-
</script>
<style lang="scss">
@@ -550,7 +238,7 @@
height: 100vh;
display: flex;
flex-direction: column;
- width: 320px;
+ width: 285px;
.header {
height: 52px;
@@ -594,19 +282,12 @@
.ant-radio-button-wrapper {
background-color: #232323;
color: #fff;
- width: 23%;
+ width: 80%;
text-align: center;
- padding: 0;
&.ant-radio-button-wrapper-checked {
background-color: #1890ff;
}
- }
-
- .group_radio {
- display: flex;
- align-items: center;
- justify-content: space-between;
}
}
}
@@ -645,6 +326,15 @@
}
}
+.text-r {
+ :deep(.ant-form-item-control-input-content) {
+ text-align: right;
+ }
+ .ant-form-item-control-input-content {
+ text-align: right;
+ }
+}
+
.panel {
background: #3c3c3c;
margin-left: auto;
@@ -665,32 +355,4 @@
font-weight: bold;
margin: 0px 10px 0 10px;
}
-}
-
-.form-alt {
- display: flex;
- align-items: center;
-
- .alt-btn {
- margin: 0 2px 0 2px;
- width: 45px;
- padding: 0 4px;
- }
-
- .alt-input {
- width: 50px;
- padding: 0;
- text-align: center;
- }
-}
-
-.btn-selected {
- background: #2d8cf0 !important;
- color: white !important;
-}
-
-.btn-unselected {
- background: #3c3c3c !important;
- color: white !important;
-}
-</style>
+}</style>
diff --git a/src/components/task/TaskPanel.vue b/src/components/task/TaskPanel.vue
index 2955392..a2a42e5 100644
--- a/src/components/task/TaskPanel.vue
+++ b/src/components/task/TaskPanel.vue
@@ -6,12 +6,9 @@
<!-- 执行时间 -->
<template #duration="{ record }">
<div class="flex-row" style="white-space: pre-wrap">
- <div v-if="record.taskType >2">
- <div>{{ formatTaskTime(record.executeStartTime) }}</div>
- <div>{{ formatTaskTime(record.executeEndTime) }}</div>
- </div>
- <div v-else>
- <div>{{formatTaskTime(record.executeSingleTime)}}</div>
+ <div>
+ <div>{{ formatTaskTime(record.begin_time) }}</div>
+ <div>{{ formatTaskTime(record.end_time) }}</div>
</div>
<div class="ml10">
<div>{{ formatTaskTime(record.execute_time) }}</div>
@@ -68,30 +65,30 @@
<div class="action-area">
<a-popconfirm
v-if="record.status === TaskStatus.Wait"
- title="是否删除飞行计划?"
- ok-text="是"
- cancel-text="否"
+ title="你确定要删除该计划吗?"
+ ok-text="确定"
+ cancel-text="取消"
@confirm="onDeleteTask(record.job_id)"
>
<a-button type="primary" size="small">删除</a-button>
</a-popconfirm>
<a-popconfirm
v-if="record.status === TaskStatus.Carrying"
- title="是否暂停?"
- ok-text="是"
- cancel-text="否"
+ title="你确定要暂停该任务吗?"
+ ok-text="确定"
+ cancel-text="取消"
@confirm="onSuspendTask(record.job_id)"
>
<a-button type="primary" size="small">暂停</a-button>
</a-popconfirm>
<a-popconfirm
v-if="record.status === TaskStatus.Paused"
- title="是否重新开始?"
- ok-text="是"
- cancel-text="否"
+ title="你确定要重新开始吗?"
+ ok-text="确定"
+ cancel-text="取消"
@confirm="onResumeTask(record.job_id)"
>
- <a-button type="primary" size="small">重启</a-button>
+ <a-button type="primary" size="small">重新开始</a-button>
</a-popconfirm>
</div>
</template>
@@ -116,7 +113,7 @@
import { ExclamationCircleOutlined, UploadOutlined } from '@ant-design/icons-vue'
const store = useMyStore()
-const workspaceId = store.state.common.projectId
+const workspaceId = localStorage.getItem(ELocalStorageKey.WorkspaceId)!
const body: IPage = {
page: 1,
@@ -146,37 +143,26 @@
slots: { customRender: 'status' }
},
{
- title: '类型',
- dataIndex: 'taskType',
- width: 100,
- slots: { customRender: 'taskType' },
- },
- {
title: '计划名称',
- dataIndex: 'name',
- width: 100,
- },
- {
- title: '航线名称',
- dataIndex: 'fileName',
+ dataIndex: 'job_name',
width: 100,
},
{
title: '设备名称',
- dataIndex: 'dockName',
+ dataIndex: 'dock_name',
width: 100,
ellipsis: true
},
{
- title: '创建人',
- dataIndex: 'username',
- width: 120,
+ title: '相对机场返航高度',
+ dataIndex: 'rth_altitude',
+ width: 140,
},
{
- title: '媒体上传',
- key: 'media_upload',
- width: 160,
- slots: { customRender: 'media_upload' }
+ title: '航线飞行中失联',
+ dataIndex: 'out_of_control_action',
+ width: 140,
+ slots: { customRender: 'lostAction' },
},
{
title: '操作',
@@ -256,15 +242,12 @@
function getPlans () {
getWaylineJobs(workspaceId, body).then(res => {
- console.log('计划数据', res)
- const data = res.data
-
- if (res.code !== 5000) {
+ if (res.code !== 0) {
return
}
- plansData.data = data.records
- paginationProp.total = data.records.total
- paginationProp.current = data.records.current
+ plansData.data = res.data.list
+ paginationProp.total = res.data.pagination.total
+ paginationProp.current = res.data.pagination.page
})
}
diff --git a/src/pages/page-web/index.vue b/src/pages/page-web/index.vue
index f2c9bcd..d58a466 100644
--- a/src/pages/page-web/index.vue
+++ b/src/pages/page-web/index.vue
@@ -58,7 +58,7 @@
localStorage.setItem(ELocalStorageKey.Username, result.data.username)
localStorage.setItem(ELocalStorageKey.UserId, result.data.user_id)
localStorage.setItem(ELocalStorageKey.Flag, EUserType.Web.toString())
- root.$router.push(ERouterName.MEMBERS)
+ root.$router.push(ERouterName.PROJECT_LIST)
} else {
message.error(result.message)
}
diff --git a/src/pages/page-web/projects/project_list/list_page/components/ProjectList.vue b/src/pages/page-web/projects/project_list/list_page/components/ProjectList.vue
index 8b948d3..023fb6e 100644
--- a/src/pages/page-web/projects/project_list/list_page/components/ProjectList.vue
+++ b/src/pages/page-web/projects/project_list/list_page/components/ProjectList.vue
@@ -128,7 +128,7 @@
}
const goDetail = (item: any) => {
- store.commit('SET_PROJECT_ID', item.id)
+ store.commit('SET_PROJECT_ID', item.workspace_id)
store.commit('SET_POINT_LIST', [])
router.push({
name: ERouterName.WORKSPACE,
@@ -139,7 +139,6 @@
selectIndex.value === index ? selectIndex.value = -1 : selectIndex.value = index
flyTo(global.$viewer, item.longitude, item.latitude)
const flag = isEntityExist(global.$viewer, item.longitude, item.latitude)
- console.log(flag, 'fffff')
}
</script>
diff --git a/src/pages/page-web/projects/wayline.vue b/src/pages/page-web/projects/wayline.vue
index da77c29..ccbe417 100644
--- a/src/pages/page-web/projects/wayline.vue
+++ b/src/pages/page-web/projects/wayline.vue
@@ -40,10 +40,10 @@
<template #overlay>
<a-menu theme="dark" class="more" style="background: #3c3c3c;">
<a-menu-item @click="downloadWayline(wayline.id, wayline.name)">
- <span>Download</span>
+ <span>下载</span>
</a-menu-item>
<a-menu-item @click="showWaylineTip(wayline.id)">
- <span>Delete</span>
+ <span>删除</span>
</a-menu-item>
</a-menu>
</template>
@@ -59,7 +59,7 @@
</span>
</div>
<div class="mt5 ml10" style="color: hsla(0,0%,100%,0.35);">
- <span class="mr10">Update at {{ new Date(wayline.update_time).toLocaleString() }}</span>
+ <span class="mr10">更新时间: {{ new Date(wayline.update_time).toLocaleString() }}</span>
</div>
</div>
</div>
@@ -67,11 +67,11 @@
<div v-else>
<a-empty :image-style="{ height: '60px', marginTop: '60px' }" />
</div>
- <a-modal v-model:visible="deleteTip" width="450px" :closable="false" :maskClosable="false" centered :okButtonProps="{ danger: true }" @ok="deleteWayline">
- <p class="pt10 pl20" style="height: 50px;">Wayline file is unrecoverable once deleted. Continue?</p>
+ <a-modal v-model:visible="deleteTip" okText="确定" cancelText="取消" width="450px" :closable="false" :maskClosable="false" centered :okButtonProps="{ danger: true }" @ok="deleteWayline">
+ <p class="pt10 pl20" style="height: 50px;">确定要删除该文件吗?</p>
<template #title>
<div class="flex-row flex-justify-center">
- <span>Delete</span>
+ <span>删除</span>
</div>
</template>
</a-modal>
@@ -96,15 +96,8 @@
import { load } from '@amap/amap-jsapi-loader'
import { getRoot } from '/@/root'
-import * as Cesium from 'cesium'
-let kmlDataSource = null
-
-const { appContext } = getCurrentInstance()
-const global = appContext.config.globalProperties
-
const loading = ref(false)
const store = useMyStore()
-const projectId = store.state.common.projectId
const pagination :IPage = {
page: 1,
total: -1,
@@ -144,16 +137,17 @@
return
}
canRefresh.value = false
- getWaylineFiles({
- workspaceId: projectId,
+ getWaylineFiles(workspaceId, {
+ page: pagination.page,
+ page_size: pagination.page_size,
+ order_by: 'update_time desc'
}).then(res => {
- if (res.code !== 5000) {
+ if (res.code !== 0) {
return
}
-
- const data = res.data
-
- waylinesData.data = [...waylinesData.data, ...data]
+ waylinesData.data = [...waylinesData.data, ...res.data.list]
+ pagination.total = res.data.pagination.total
+ pagination.page = res.data.pagination.page
}).finally(() => {
canRefresh.value = true
})
@@ -192,57 +186,7 @@
}
function selectRoute (wayline: WaylineFile) {
- initKmlFile('/src/assets/kmz/test.kmz')
store.commit('SET_SELECT_WAYLINE_INFO', wayline)
-}
-
-/**
- * 加载kml文件
- * @param file
- */
-function initKmlFile (file:string) {
- const options = {
- camera: global.$viewer.scene.camera,
- canvas: global.$viewer.scene.canvas,
- screenOverlayContainer: global.$viewer.container,
- }
- global.$viewer.dataSources.add(
- Cesium.KmlDataSource.load(
- file,
- options
- )).then(res => {
- kmlDataSource = res
- kmlDataSource.show = true
-
- console.log('Entits数组', kmlDataSource.entities.values)
-
- const kmlEntityArr = kmlDataSource.entities.values[0]._children
- const cartesianArr = []
- for (let i = 0; i < kmlEntityArr.length; i++) {
- const entity = kmlEntityArr[i]
- entity.point = new Cesium.PointGraphics({
- pixelSize: 12,
- color: Cesium.Color.RED,
- outlineColor: Cesium.Color.WHITE,
- })
- entity.billboard = null
-
- cartesianArr.push(entity.position._value)
- }
-
- const lineEntity = global.$viewer.entities.add({
- name: 'entityLine',
- polyline: {
- positions: cartesianArr,
- width: 10,
- material: new Cesium.PolylineArrowMaterialProperty(Cesium.Color.CYAN),
- },
- })
-
- global.$viewer.flyTo(lineEntity, {
- offset: new Cesium.HeadingPitchRange(0, -90, 1000)
- })
- })
}
function onScroll (e: any) {
@@ -276,7 +220,7 @@
fileList.value.forEach(async (file: FileItem) => {
const fileData = new FormData()
fileData.append('file', file, file.name)
- await importKmzFile(projectId, fileData).then((res) => {
+ await importKmzFile(workspaceId, fileData).then((res) => {
if (res.code === 0) {
message.success(`${file.name} file uploaded successfully`)
canRefresh.value = true
diff --git a/src/router/index.ts b/src/router/index.ts
index 880ba53..ba7d69e 100644
--- a/src/router/index.ts
+++ b/src/router/index.ts
@@ -9,7 +9,7 @@
const routes: Array<RouteRecordRaw> = [
{
path: '/',
- redirect: '/' + ERouterName.MEMBERS
+ redirect: '/' + ERouterName.PROJECT_LIST
},
// // 首页 登陆页面
// {
diff --git a/src/types/task.ts b/src/types/task.ts
index 01816f5..cadb71e 100644
--- a/src/types/task.ts
+++ b/src/types/task.ts
@@ -2,101 +2,41 @@
// 任务类型
export enum TaskType {
- Immediate = 1, // 立即执行
- Timed = 2, // 单次定时任务
- RepeatTimed = 3, // 重复定时任务
- Continuous// 连续执行
+ Immediate = 0, // 立即执行
+ Timed = 1, // 单次定时任务
}
export const TaskTypeMap = {
[TaskType.Immediate]: '立即',
- [TaskType.Timed]: '单次定时',
- [TaskType.RepeatTimed]: '重复定时',
- [TaskType.Continuous]: '连续执行',
+ [TaskType.Timed]: '单次',
}
export const TaskTypeOptions = [
{ value: TaskType.Immediate, label: TaskTypeMap[TaskType.Immediate] },
{ value: TaskType.Timed, label: TaskTypeMap[TaskType.Timed] },
- { value: TaskType.RepeatTimed, label: TaskTypeMap[TaskType.RepeatTimed] },
- { value: TaskType.Continuous, label: TaskTypeMap[TaskType.Continuous] },
-]
-
-// 频率类型
-export enum FrequencyType {
- day = 1, // 日
- week = 2, // 周
- month = 3, // 月
-}
-
-export const FrequencyTypeMap = {
- [FrequencyType.day]: '日',
- [FrequencyType.week]: '周',
- [FrequencyType.month]: '月',
-}
-
-export const FrequencyTypeOptions = [
- { value: FrequencyType.month, label: FrequencyTypeMap[FrequencyType.month] },
- { value: FrequencyType.week, label: FrequencyTypeMap[FrequencyType.week] },
- { value: FrequencyType.day, label: FrequencyTypeMap[FrequencyType.day] },
-]
-
-// 重复规则时间类型
-export enum RepeatRuleType {
- day = 1, // 按日期
- week = 2, // 按星期
-}
-
-export const RepeatRuleTypeMap = {
- [RepeatRuleType.day]: '按日期',
- [RepeatRuleType.week]: '按星期',
-}
-
-export const RepeatRuleTypeOptions = [
- { value: RepeatRuleType.day, label: RepeatRuleTypeMap[RepeatRuleType.day] },
- { value: RepeatRuleType.week, label: RepeatRuleTypeMap[RepeatRuleType.week] },
-]
-
-export const WhichWeekOptions = [
- { value: 1, label: '第一个' },
- { value: 2, label: '第二个' },
- { value: 3, label: '第三个' },
- { value: 4, label: '第四个' },
-]
-export const WhichDayOptions = [
- { value: 7, label: '周日' },
- { value: 1, label: '周一' },
- { value: 2, label: '周二' },
- { value: 3, label: '周三' },
- { value: 4, label: '周四' },
- { value: 5, label: '周五' },
- { value: 6, label: '周六' },
]
// 失控动作
export enum OutOfControlAction {
- ReturnToHome = 0, // 返航
- Hover = 1, // 盘旋
- Land = 2, // 降落
- Continue// 继续执行
+ ReturnToHome = 0,
+ Hover = 1,
+ Land = 2,
}
-
+enum OutOfControlActionText {
+ 返航 = 0,
+ 盘旋 = 1,
+ 降落 = 2,
+}
export const OutOfControlActionMap = {
[OutOfControlAction.ReturnToHome]: '返航',
[OutOfControlAction.Hover]: '盘旋',
[OutOfControlAction.Land]: '降落',
- [OutOfControlAction.Continue]: '继续执行'
}
export const OutOfControlActionOptions = [
{ value: OutOfControlAction.ReturnToHome, label: OutOfControlActionMap[OutOfControlAction.ReturnToHome] },
- // { value: OutOfControlAction.Hover, label: OutOfControlActionMap[OutOfControlAction.Hover] },
- // { value: OutOfControlAction.Land, label: OutOfControlActionMap[OutOfControlAction.Land] },
- { value: OutOfControlAction.Continue, label: OutOfControlActionMap[OutOfControlAction.Continue] },
-]
-
-export const FinishActionOptions = [
- { value: 1, label: '自动返航' }
+ { value: OutOfControlAction.Hover, label: OutOfControlActionMap[OutOfControlAction.Hover] },
+ { value: OutOfControlAction.Land, label: OutOfControlActionMap[OutOfControlAction.Land] },
]
// 任务状态
@@ -111,7 +51,7 @@
export const TaskStatusMap = {
[TaskStatus.Wait]: '待执行',
- [TaskStatus.Carrying]: '进行中',
+ [TaskStatus.Carrying]: '正在进行',
[TaskStatus.Success]: '任务完成',
[TaskStatus.CanCel]: '任务取消',
[TaskStatus.Fail]: '任务失败',
--
Gitblit v1.9.3