浏览代码

上传

tags/v1.0.0
吴迪 2 年前
父节点
当前提交
b2253e932a
共有 3 个文件被更改,包括 95 次插入59 次删除
  1. +7
    -2
      src/components/UploadOss/fileOss.vue
  2. +9
    -4
      src/components/UploadVod/index.vue
  3. +79
    -53
      src/views/task-manage/components/DrawComp.vue

+ 7
- 2
src/components/UploadOss/fileOss.vue 查看文件

@@ -47,6 +47,10 @@ const props = defineProps({
remBtn: {
type: Boolean,
default: false
},
keyName: {
type: String,
default: 'src'
}
})

@@ -199,8 +203,9 @@ const startUpload = () => {
})
Promise.all(uploads).then((response) => {
/* 获取fileList内的文件存储名称 */
const objectList = data.fileList.map((item) => item.objectName || 'error')
resolve(objectList)
const objectList = data.fileList.map((item) => item.objectName).filter(it => it)
// resolve(objectList)
resolve({ [props.keyName]: objectList.join() })
emit('uploadStatus', 'success')
}).catch((error) => {
console.log('error', error)

+ 9
- 4
src/components/UploadVod/index.vue 查看文件

@@ -16,7 +16,7 @@
</n-button>
</n-upload>

<n-button
<!-- <n-button
v-if="!autoUpload"
type="primary"
:disabled="data.fileList.length === 0"
@@ -28,7 +28,7 @@
<UploadOutlined />
</n-icon>
开始上传
</n-button>
</n-button> -->

</template>

@@ -130,6 +130,7 @@ const createUploader = () => {
// 如果uploadInfo.videoId存在,调用刷新视频上传凭证接口
refreshAuth(uploadInfo.videoId).then(res => {
uploader.setUploadAuthAndAddress(uploadInfo, res.data.uploadAuth, res.data.uploadAddress, res.data.videoId)
data.videoId = res.data.videoId
})
} else {
const params = {
@@ -138,6 +139,7 @@ const createUploader = () => {
}
getAuth(params).then(res => {
uploader.setUploadAuthAndAddress(uploadInfo, res.data.uploadAuth, res.data.uploadAddress, res.data.videoId)
data.videoId = res.data.videoId
})
}
},
@@ -147,7 +149,7 @@ const createUploader = () => {
const fileName = uploadInfo.file.name
data.fileList.forEach((item) => {
if (item.name === fileName) {
data.readyFile[item.uid].url = uploadInfo.object
data.readyFile[item.uid].url = '/' + uploadInfo.object
}
})
},
@@ -185,7 +187,7 @@ const createUploader = () => {
// 全部文件上传结束
onUploadEnd: function(uploadInfo) {
// console.log('onUploadEnd: uploaded all the files', uploadInfo)
emit('uploadStatus', { status: 'success', list: data.readyFile })
emit('uploadStatus', { status: 'success', list: data.readyFile, videoIds: data.videoId })
}
})
return uploader
@@ -224,6 +226,9 @@ const handleUploadStart = () => {
emit('uploadStatus', { status: 'uploading', list: data.readyFile })
}
}

defineExpose({ data })

</script>

<style lang="scss" scoped>

+ 79
- 53
src/views/task-manage/components/DrawComp.vue 查看文件

@@ -105,15 +105,12 @@
<div v-if="current === 5" class="cont">
<div class="title">飞行文件</div>

<UploadVod v-if="data.photographyWay === 1" :auto-upload="true" :upload-name="'选择【视频】'" :limit="1" @upload-status="vodStatusVideo" />
<fileOss v-if="data.photographyWay === 1" ref="srtRefs" :file-type="'srt'" :btn-name="'选择【轨迹】'" :limit="1" :default-list="data.srtUrl" @upload-status="vodStatusSRT" />
<fileOss v-if="data.photographyWay !== 1" ref="ortRefs" :file-type="'tif'" :btn-name="'选择【正射影像】'" :limit="9" :default-list="data.orthoUrl" @upload-status="vodStatusZS" />
<fileOss v-if="data.photographyWay !== 1" ref="inclinedRefs" :file-type="'tif'" :btn-name="'选择【倾斜影像】'" :limit="9" :default-list="data.inclinedUrl" @upload-status="vodStatusQX" />

<!-- <UploadVod v-if="data.photographyWay === 1" :auto-upload="true" :upload-name="'选择【轨迹】'" :limit="1" @upload-status="vodStatusSRT" />
<UploadVod v-if="data.photographyWay !== 1" :auto-upload="true" :upload-name="'选择【正射影像】tif文件'" @upload-status="vodStatusZS" />
<UploadVod v-if="data.photographyWay !== 1" :auto-upload="true" :upload-name="'选择【倾斜影像】tif文件'" @upload-status="vodStatusQX" /> -->
<n-button type="primary" class="btn" @click="submitFile">
<UploadVod v-if="data.photographyWay === 1" ref="videoRefs" :auto-upload="true" :upload-name="'选择【视频】'" :limit="1" @upload-status="vodStatusVideo" />
<fileOss v-if="data.photographyWay === 1" ref="srtRefs" :file-type="'srt'" :key-name="'srtUrl'" :btn-name="'选择【轨迹】'" :limit="1" :default-list="data.srtUrl" @upload-status="vodStatusSRT" />
<fileOss v-if="data.photographyWay === 2" ref="ortRefs" :file-type="'tif'" :key-name="'orthoUrl'" :btn-name="'选择【正射影像】'" :limit="9" :default-list="data.orthoUrl" @upload-status="vodStatusZS" />
<fileOss v-if="data.photographyWay === 3" ref="inclinedRefs" :file-type="'tif'" :key-name="'inclinedUrl'" :btn-name="'选择【倾斜影像】'" :limit="9" :default-list="data.inclinedUrl" @upload-status="vodStatusQX" />

<n-button v-if="isAdmin" type="primary" class="btn" :loading="loading" @click="submitFile">
<n-icon>
<UploadOutlined />
</n-icon>
@@ -124,7 +121,7 @@
</template>

<script setup name="DrawComp">
import { ref, defineProps, reactive, defineEmits } from 'vue'
import { ref, defineProps, reactive, defineEmits, watchEffect } from 'vue'
import { TASK_STATUS } from '@/utils/dictionary'
import { distributionPilot, pilotOrder, pilotStart, pilotEnd, uploadFlightUrl } from '@/api/task/index.js'
import { form, getPilotList, getEquipment, getEquipmentMount, getCloudMount } from '../tools/drawForm'
@@ -162,14 +159,19 @@ const equipmentInfo = equipment(data) // 设备/影响基本信息
const executionInfo = execution(data) // 执行中信息

const videoUrl = ref('') // 视频文件
const videoId = ref('') // 视频文件
const srtUrl = ref('') // srt文件
const inclinedUrl = ref('') // 倾斜摄影
const orthoUrl = ref('') // 正射影像
// const inclinedUrl = ref('') // 倾斜摄影
// const orthoUrl = ref('') // 正射影像

const videoRefs = ref(null) // video refs
const srtRefs = ref(null) // srt refs
const ortRefs = ref(null) // 正射 refs
const inclinedRefs = ref(null) // 倾斜 refs

const loading = ref(false)
const isBtn = ref(false)

const emit = defineEmits(['close'])

// 分配飞手
@@ -229,60 +231,84 @@ const endFly = () => {
}

// 上传 - 视频
const vodStatusVideo = ({ status, list }) => {
const vodStatusVideo = ({ status, list, videoIds }) => {
console.log(status, list, videoIds)
const arr = []
for (var key in list) {
arr.push(list[key].url)
}
if (status === 'success') {
videoUrl.value = arr.join(',')
videoId.value = videoIds
}
}
// 上传 - SRT
const vodStatusSRT = async(status) => {
const res = await srtRefs.value.startUpload()
console.log('status: ', status)
console.log(res)
if (status === 'success' && res.includes('error')) {
$message.error('上传失败,请稍后重试')
} else if (status === 'success') {
srtUrl.value = res.join()
}
srtUrl.value = status
console.log('srtUrl: ---------------', srtUrl.value, status)
// const res = await srtRefs.value.startUpload()
// console.log('status: ', status)
// console.log(res)
// if (status === 'success' && res.includes('error')) {
// $message.error('上传失败,请稍后重试')
// } else if (status === 'success') {
// srtUrl.value = res.join()
// }
}

// 上传 - 倾斜
const vodStatusQX = async(status) => {
const res = await inclinedRefs.value.startUpload()
if (status === 'success' && res.includes('error')) {
$message.error('上传失败,请稍后重试')
} else if (status === 'success') {
inclinedUrl.value = res.join()
}
}
// 上传 - 正射
const vodStatusZS = async(status) => {
const res = await ortRefs.value.startUpload()
if (status === 'success' && res.includes('error')) {
$message.error('上传失败,请稍后重试')
} else if (status === 'success') {
orthoUrl.value = res.join()
}
}
// watchEffect(() => [videoUrl, srtUrl], ([videoVal], [srtVal]) => {
// console.log('watchEffect-videoVal:', videoVal)
// console.log('watchEffect-srtVal:', srtVal)
// if (videoUrl.value === 'success' && srtVal === 'success') {
// console.log('watchEffect-success all')
// isBtn.value = true
// }
// })

// 上传
const submitFile = () => {
uploadFlightUrl({
id: data.id,
videoUrl: videoUrl.value ? videoUrl.value : data.videoUrl,
srtUrl: srtUrl.value ? srtUrl.value : data.srtUrl,
inclinedUrl: data.inclinedUrl + ',' + inclinedUrl.value,
orthoUrl: data.orthoUrl + ',' + orthoUrl.value
}).then(({ code }) => {
console.log(code)
if (code === 0) {
emit('close')
}
})
if (data.photographyWay === 1) { // 视频 和 srt
// videoRefs.value.data.uploader.startUpload()
srtRefs.value?.startUpload().then(res => {
console.log('res:', res)
if (!res.includes('error')) {
uploadFlightUrl({
id: data.id,
videoUrl: videoUrl.value,
videoId: videoId.value,
...res
}).then(({ code }) => {
if (code === 0) {
emit('close')
}
})
}
})
} else {
loading.value = true
const queue = []
// queue.push(videoRefs.value?.data.uploader.startUpload())
// queue.push(srtRefs.value?.startUpload())
queue.push(inclinedRefs.value?.startUpload())
queue.push(ortRefs.value?.startUpload())
Promise.all(queue).then(res => {
loading.value = false
const params = {}
res.filter(it => it).forEach(el => {
Object.keys(el).map(dom => {
params[dom] = el[dom]
})
})
uploadFlightUrl({
id: data.id,
...params
}).then(({ code }) => {
if (code === 0) {
emit('close')
}
})
})
}
}

</script>
@@ -306,8 +332,8 @@ const submitFile = () => {
}

.btn {
width: 90px;
margin-left: calc(50% - 45px);
width: 110px;
margin-left: calc(50% - 55px);
margin-top: 10px;
margin-bottom: 30px;
}

正在加载...
取消
保存