吉安感知网项目-前端
张含笑
2026-01-23 9197799574b4e1cb918771f424b93c11c7da8317
uniapps/work-wx/src/subPackages/flightApplication/add.vue
@@ -1,6 +1,6 @@
<template>
<view class="flightApplication-add">
    <u-form labelPosition="top" :model="formParams" :rules="rules" ref="formRef">
         <view class="title form-title">基本信息</view>
        <u-form-item
@@ -101,7 +101,7 @@
        >
            <u-input v-model="formParams.flightEndTime" border="none" placeholder="请选择日期" suffixIcon="calendar"></u-input>
        </u-form-item>
        <u-form-item
                label="计划类型"
                labelWidth="200rpx"
@@ -386,16 +386,20 @@
</view>
</template>
<script setup>
import { flightPlanSaveApi,
    flightRoutePageInfoApi,
    aircraftInfoPageInfoOfMyApi,
    pilotInfoPageInfoOfMyApi,
    droneFlightTaskApi,
    uploadFileApi,
    flightTaskApi,flightRulesApi,flightModeApi,flightPlanApi
import {
    flightPlanSaveApi,
    flightRoutePageInfoApi,
    aircraftInfoPageInfoOfMyApi,
    pilotInfoPageInfoOfMyApi,
    droneFlightTaskApi,
    uploadFileApi
 } from '@/api/index'
import { ref, computed, onMounted } from 'vue'
import dayjs from 'dayjs'
// 获取store中的数据 字典
import { useAppStore, useUserStore } from "@/store";
const appStore = useAppStore()
const formRef = ref(null);
const formParams = ref({
@@ -498,7 +502,7 @@
})
// 任务类型
const isShowFlightTaskType = ref(false)
const actionsFlightTaskType = ref([])
const actionsFlightTaskType = ref(appStore.getTaskType)
const onPickerFlightTaskType = (e) => {
  const selected = e.value[0]
  formParams.value.flightTaskType = selected.value
@@ -508,7 +512,7 @@
// 飞行规则
const isShowFlightRule = ref(false)
const actionsFlightRule = ref([])
const actionsFlightRule = ref(appStore.getFlightRules)
const onPickerFlightRule = (e) => {
  const selected = e.value[0]
  formParams.value.flightRule = selected.value
@@ -517,7 +521,7 @@
}
// 飞行方式
const isShowFlightMode = ref(false)
const actionsFlightMode = ref([])
const actionsFlightMode = ref(appStore.getFlightMode)
const onPickerFlightMode = (e) => {
  const selected = e.value[0]
  formParams.value.flightMode = selected.value
@@ -526,7 +530,7 @@
}
// 计划类型
const isShowPlanType = ref(false)
const actionsPlanType = ref([])
const actionsPlanType = ref(appStore.getFlightPlan)
const onPickerPlanType = (e) => {
  const selected = e.value[0]
  formParams.value.planType = selected.value
@@ -637,36 +641,36 @@
    // 获取上传的文件对象
    const file = event.file;
    console.log('上传的文件:', file);
    // 显示加载提示
    uni.showLoading({
        title: '上传中...'
    });
    // 准备上传参数
    const uploadParams = {
        name: 'file', // 服务器端接收文件的字段名
        file: file, // 传入文件对象
        filePath: file.path || file.url, // 文件路径
    };
    // 调用上传文件接口
    uploadFileApi(uploadParams).then(res => {
        uni.hideLoading();
        console.log('上传成功结果:', res);
        // 根据接口返回的数据结构处理结果
        if (res.data && res.data.code === 200) {
            // 假设接口返回的数据结构是 { url, fileName } 等
            const uploadResult = res.data.data;
            // 更新表单数据,将上传结果展示在input内
            formParams.value.tempAirspaceApprovalText = uploadResult.fileName || uploadResult.url || '文件上传成功';
            // 可以将完整的上传信息保存到表单中,以便提交时使用
            formParams.value.tempAirspaceApproval = uploadResult.fileUrl || '文件上传成功';
            uni.showToast({
                title: '上传成功',
                icon: 'success'
@@ -712,52 +716,12 @@
    }
  })
}
// 获取任务类型
function getTaskType() {
    flightTaskApi().then(res => {
        actionsFlightTaskType.value = res.data.data.map(item => ({
            ...item,
            label: item.dictLabel || '暂无',
            value: item.dictValue || '暂无',
        }))
    })
}
// 获取飞行模式
function getFlightMode() {
    flightModeApi().then(res => {
        actionsFlightMode.value = res.data.data.map(item => ({
            ...item,
            label: item.dictLabel || '暂无',
            value: item.dictValue || '暂无',
        }))
    })
}
// 获取飞行规则
function getFlightRules() {
    flightRulesApi().then(res => {
        actionsFlightRule.value = res.data.data.map(item => ({
            ...item,
            label: item.dictLabel || '暂无',
            value: item.dictValue || '暂无',
        }))
    })
}
// 获取飞行计划
function getFlightPlan() {
    flightPlanApi().then(res => {
        actionsPlanType.value = res.data.data.map(item => ({
            ...item,
            label: item.dictLabel || '暂无',
            value: item.dictValue || '暂无',
        }))
    })
}
onMounted(() => {
    // getProTypeApi()
    getTaskType()
    getFlightMode()
    getFlightRules()
    getFlightPlan()
    // getTaskType()
    // getFlightMode()
    // getFlightRules()
    // getFlightPlan()
    getAircraftInfo()
    getPilotInfo()
    getAirspaceInfo()
@@ -787,6 +751,9 @@
        border-radius: 8rpx 8rpx 8rpx 8rpx;
        // margin-bottom: 20rpx;
    }
    :deep(.u-toolbar__wrapper__confirm) {
        color: #1D6FE9;
    }
    .custom-label {
        .label-tip {
            font-family: Source Han Sans CN, Source Han Sans CN;
@@ -795,7 +762,7 @@
            color: #3A3A3A;
        }
    }
    .attention {
        font-family: Source Han Sans CN, Source Han Sans CN;
        font-weight: 400;
@@ -807,7 +774,7 @@
    .select-wrapper {
        position: relative;
        width: 100%;
        .select-icon {
            position: absolute;
            right: 20rpx;
@@ -853,7 +820,7 @@
            border-radius: 8rpx;
            padding: 0 20rpx;
            background-color: #f5f5f5;
            &::placeholder {
                font-family: Source Han Sans CN, Source Han Sans CN;
                font-weight: 400;
@@ -861,12 +828,12 @@
                color: #D2D2D2;
            }
        }
        .clickable-input {
            width: 100%;
            cursor: pointer;
        }
        :deep(.u-form-item__label) {
            margin-bottom: 20rpx;
            // font-weight: bold;
@@ -876,7 +843,7 @@
            font-size: 30rpx;
            color: #222324;
        }
        :deep(.u-form-item__required) {
            color: #FF2600;
            margin-right: 8rpx;