吴迪 пре 1 година
родитељ
комит
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 Прегледај датотеку

remBtn: { remBtn: {
type: Boolean, type: Boolean,
default: false default: false
},
keyName: {
type: String,
default: 'src'
} }
}) })


}) })
Promise.all(uploads).then((response) => { Promise.all(uploads).then((response) => {
/* 获取fileList内的文件存储名称 */ /* 获取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') emit('uploadStatus', 'success')
}).catch((error) => { }).catch((error) => {
console.log('error', error) console.log('error', error)

+ 9
- 4
src/components/UploadVod/index.vue Прегледај датотеку

</n-button> </n-button>
</n-upload> </n-upload>


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


</template> </template>


// 如果uploadInfo.videoId存在,调用刷新视频上传凭证接口 // 如果uploadInfo.videoId存在,调用刷新视频上传凭证接口
refreshAuth(uploadInfo.videoId).then(res => { refreshAuth(uploadInfo.videoId).then(res => {
uploader.setUploadAuthAndAddress(uploadInfo, res.data.uploadAuth, res.data.uploadAddress, res.data.videoId) uploader.setUploadAuthAndAddress(uploadInfo, res.data.uploadAuth, res.data.uploadAddress, res.data.videoId)
data.videoId = res.data.videoId
}) })
} else { } else {
const params = { const params = {
} }
getAuth(params).then(res => { getAuth(params).then(res => {
uploader.setUploadAuthAndAddress(uploadInfo, res.data.uploadAuth, res.data.uploadAddress, res.data.videoId) uploader.setUploadAuthAndAddress(uploadInfo, res.data.uploadAuth, res.data.uploadAddress, res.data.videoId)
data.videoId = res.data.videoId
}) })
} }
}, },
const fileName = uploadInfo.file.name const fileName = uploadInfo.file.name
data.fileList.forEach((item) => { data.fileList.forEach((item) => {
if (item.name === fileName) { if (item.name === fileName) {
data.readyFile[item.uid].url = uploadInfo.object
data.readyFile[item.uid].url = '/' + uploadInfo.object
} }
}) })
}, },
// 全部文件上传结束 // 全部文件上传结束
onUploadEnd: function(uploadInfo) { onUploadEnd: function(uploadInfo) {
// console.log('onUploadEnd: uploaded all the files', 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 return uploader
emit('uploadStatus', { status: 'uploading', list: data.readyFile }) emit('uploadStatus', { status: 'uploading', list: data.readyFile })
} }
} }

defineExpose({ data })

</script> </script>


<style lang="scss" scoped> <style lang="scss" scoped>

+ 79
- 53
src/views/task-manage/components/DrawComp.vue Прегледај датотеку

<div v-if="current === 5" class="cont"> <div v-if="current === 5" class="cont">
<div class="title">飞行文件</div> <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> <n-icon>
<UploadOutlined /> <UploadOutlined />
</n-icon> </n-icon>
</template> </template>


<script setup name="DrawComp"> <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 { TASK_STATUS } from '@/utils/dictionary'
import { distributionPilot, pilotOrder, pilotStart, pilotEnd, uploadFlightUrl } from '@/api/task/index.js' import { distributionPilot, pilotOrder, pilotStart, pilotEnd, uploadFlightUrl } from '@/api/task/index.js'
import { form, getPilotList, getEquipment, getEquipmentMount, getCloudMount } from '../tools/drawForm' import { form, getPilotList, getEquipment, getEquipmentMount, getCloudMount } from '../tools/drawForm'
const executionInfo = execution(data) // 执行中信息 const executionInfo = execution(data) // 执行中信息


const videoUrl = ref('') // 视频文件 const videoUrl = ref('') // 视频文件
const videoId = ref('') // 视频文件
const srtUrl = ref('') // srt文件 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 srtRefs = ref(null) // srt refs
const ortRefs = ref(null) // 正射 refs const ortRefs = ref(null) // 正射 refs
const inclinedRefs = ref(null) // 倾斜 refs const inclinedRefs = ref(null) // 倾斜 refs


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

const emit = defineEmits(['close']) const emit = defineEmits(['close'])


// 分配飞手 // 分配飞手
} }


// 上传 - 视频 // 上传 - 视频
const vodStatusVideo = ({ status, list }) => {
const vodStatusVideo = ({ status, list, videoIds }) => {
console.log(status, list, videoIds)
const arr = [] const arr = []
for (var key in list) { for (var key in list) {
arr.push(list[key].url) arr.push(list[key].url)
} }
if (status === 'success') { if (status === 'success') {
videoUrl.value = arr.join(',') videoUrl.value = arr.join(',')
videoId.value = videoIds
} }
} }
// 上传 - SRT // 上传 - SRT
const vodStatusSRT = async(status) => { 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 = () => { 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> </script>
} }


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

Loading…
Откажи
Сачувај