| | |
| | | @cancel="showPurchaseDate = false" |
| | | /> |
| | | <!-- 所属区域 --> |
| | | <u-cascader |
| | | <u-cascader |
| | | v-model:show="isShowRegion" |
| | | v-model="formParams.regionCode" |
| | | :data="areaData" |
| | |
| | | import { aircraftInfoSaveApi,uploadFileApi, areaDataApi, proTypeApi, manufacturerInfoApi } 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({ |
| | |
| | | isModifiedText: [ |
| | | { required: true, message: '请选择是否改装', trigger: 'change' } |
| | | ], |
| | | type: [ |
| | | { required: true, message: '请选择飞行器类型', trigger: 'change' } |
| | | ], |
| | | |
| | | }) |
| | | // 是否改装 |
| | | const actionsModified = ref([ |
| | |
| | | const findRegionNamesByCodes = (codes, areaData) => { |
| | | const result = [] |
| | | let currentData = areaData |
| | | |
| | | |
| | | for (const code of codes) { |
| | | // 转换为字符串比较(因为code可能是字符串类型) |
| | | const codeStr = code.toString() |
| | | const item = currentData.find(item => item.code === codeStr) |
| | | |
| | | |
| | | if (!item) { |
| | | console.warn(`未找到code为 ${codeStr} 的行政区划`) |
| | | break |
| | | } |
| | | |
| | | |
| | | result.push(item.name) |
| | | currentData = item.children || [] |
| | | } |
| | | |
| | | |
| | | return result |
| | | } |
| | | |
| | | // 所属区域确认 |
| | | const onRegionConfirm = (e) => { |
| | | console.log(e,'888') |
| | | formParams.value.region = e[2] || '' // 用逗号分隔的区域码 |
| | | // 通过arrRegion的数组值为[36,3608,360824] 从areaData里面反查出名称 |
| | | const regionNames = findRegionNamesByCodes(e, areaData.value) |
| | | console.log(regionNames, '77777') |
| | | formParams.value.regionText = regionNames.join('-') || '' // 用连字符连接的区域名称 |
| | | isShowRegion.value = false |
| | | } |
| | |
| | | formParams.value.manufacturerText = selected.label |
| | | showManufacturer.value = false |
| | | } |
| | | // 飞行器型号 |
| | | // 飞行器类型 |
| | | const showType = ref(false); |
| | | const typeList = ref([]) |
| | | // 选择飞行器型号 |
| | | const typeList = ref(appStore.getProType) |
| | | // 选择飞行器类型 |
| | | const onPickerConfirmType = (e) => { |
| | | const selected = e.value[0] |
| | | formParams.value.type = selected.value |
| | | console.log(formParams.value.type,'6666') |
| | | formParams.value.typeText = selected.label |
| | | showType.value = false |
| | | } |
| | |
| | | // 获取上传的文件对象 |
| | | 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.caacRegistrationCodeText = uploadResult.fileName || uploadResult.url || '文件上传成功'; |
| | | |
| | | |
| | | // 可以将完整的上传信息保存到表单中,以便提交时使用 |
| | | formParams.value.caacRegistrationCode= uploadResult.fileUrl || '文件上传成功'; |
| | | |
| | | |
| | | uni.showToast({ |
| | | title: '上传成功', |
| | | icon: 'success' |
| | |
| | | // 获取上传的文件对象 |
| | | 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.deviceImageText = uploadResult.fileName || uploadResult.url || '文件上传成功'; |
| | | |
| | | |
| | | // 可以将完整的上传信息保存到表单中,以便提交时使用 |
| | | formParams.value.deviceImage= uploadResult.fileUrl || '文件上传成功'; |
| | | |
| | | |
| | | uni.showToast({ |
| | | title: '上传成功', |
| | | icon: 'success' |
| | |
| | | } |
| | | } |
| | | // 获取飞行器类型 |
| | | function getProTypeApi() { |
| | | proTypeApi().then(res => { |
| | | typeList.value = res.data.data.map(item => ({ |
| | | ...item, |
| | | label: item.dictLabel, |
| | | value: item.dictValue |
| | | })) |
| | | }) |
| | | } |
| | | // function getProTypeApi() { |
| | | // proTypeApi().then(res => { |
| | | // typeList.value = res.data.data.map(item => ({ |
| | | // ...item, |
| | | // label: item.dictLabel, |
| | | // value: item.dictValue |
| | | // })) |
| | | // }) |
| | | // } |
| | | // 获取无人机厂商 |
| | | function getManufacturerInfoApi() { |
| | | manufacturerInfoApi({ |
| | |
| | | }) |
| | | } |
| | | onMounted(async () => { |
| | | getProTypeApi() |
| | | getManufacturerInfoApi() |
| | | // 动态从外部URL导入xzqhData,确保在使用前已初始化 |
| | | // 注意:直接动态导入外部URL可能会有跨域或构建问题,建议检查服务器CORS设置 |
| | |
| | | display: flex; |
| | | flex-direction: column; |
| | | // padding: 24rpx; |
| | | |
| | | |
| | | .select-wrapper { |
| | | position: relative; |
| | | width: 100%; |
| | | |
| | | |
| | | .select-icon { |
| | | position: absolute; |
| | | right: 20rpx; |
| | |
| | | font-size: 24rpx; |
| | | pointer-events: none; |
| | | } |
| | | } |
| | | |
| | | :deep(.u-toolbar__wrapper__confirm) { |
| | | color: #1D6FE9; |
| | | } |
| | | |
| | | .upload { |
| | |
| | | border-radius: 8rpx 8rpx 8rpx 8rpx; |
| | | margin-bottom: 20rpx; |
| | | } |
| | | |
| | | |
| | | :deep(.u-form-item) { |
| | | margin-bottom: 20rpx; |
| | | padding: 16rpx 24rpx 18rpx 24rpx; |
| | |
| | | border-radius: 8rpx; |
| | | padding: 0 20rpx; |
| | | background-color: #f5f5f5; |
| | | |
| | | |
| | | &::placeholder { |
| | | font-family: Source Han Sans CN, Source Han Sans CN; |
| | | font-weight: 400; |
| | |
| | | color: #D2D2D2; |
| | | } |
| | | } |
| | | |
| | | |
| | | .clickable-input { |
| | | width: 100%; |
| | | cursor: pointer; |
| | | } |
| | | |
| | | |
| | | :deep(.u-form-item__label) { |
| | | margin-bottom: 20rpx; |
| | | // font-weight: bold; |
| | |
| | | font-size: 30rpx; |
| | | color: #222324; |
| | | } |
| | | |
| | | |
| | | :deep(.u-form-item__required) { |
| | | color: #FF2600; |
| | | margin-right: 8rpx; |