实现文件全量下载功能,清除代码中的输出

This commit is contained in:
wangchengming 2025-09-15 23:14:03 +08:00
parent f6b907eff0
commit 451454634d
26 changed files with 228 additions and 90 deletions

View File

@ -0,0 +1,28 @@
import request from '@/utils/request'
// 分页获取下载任务
export function busDownloadRecordPage(query) {
return request({
url: '/admin/busDownloadRecord/getBusDownloadRecordPage',
method: 'post',
data: query
})
}
// 批量添加任务
export function addBusDownloadRecord(query) {
return request({
url: '/admin/busDownloadRecord/addBatch',
method: 'post',
data: query
})
}
// 修改下载任务状态
export function updateBusDownloadRecord(query) {
return request({
url: '/admin/busDownloadRecord/updateBusDownloadRecord',
method: 'post',
data: query
})
}

View File

@ -36,15 +36,13 @@ const scale = ref(1)
const progress = ref(0)
const loading = ref(false)
const handlePdfLoaded = (pdf) => {
console.log('PDF 加载完成', pdf)
const handlePdfLoaded = (pdf) => {
loading.value = false
pageCount.value = pdf.numPages
}
const handleProgress = (progressData) => {
progress.value = Math.round(progressData.loaded / progressData.total * 100)
console.log(progress.value)
progress.value = Math.round(progressData.loaded / progressData.total * 100)
if(progress.value < 100) loading.value = true
else loading.value = false
}

View File

@ -66,8 +66,7 @@ const setFileInfo = (files) => {
}
//
const isImageFile = (suffix) => {
console.log('是否图片', suffix, ['jpeg', 'jpg', 'png'].includes(suffix.toLowerCase()))
const isImageFile = (suffix) => {
return ['jpeg', 'jpg', 'png'].includes(suffix.toLowerCase())
}

View File

@ -54,8 +54,7 @@ const viewTitle = ref('查看文件')
const viewFileOpen = ref(false)
const fileList = ref([])
//
const isImageFile = (suffix) => {
console.log('是否图片', suffix, ['jpeg', 'jpg', 'png'].includes(suffix.toLowerCase()))
const isImageFile = (suffix) => {
return ['jpeg', 'jpg', 'png'].includes(suffix.toLowerCase())
}
//

View File

@ -60,6 +60,14 @@ export default {
type: "warning",
})
},
myConfirm(content, option) {
return ElMessageBox.confirm(content, "系统提示", {
confirmButtonText: option.confirmButtonText,
// cancelButtonText: '取消',
closeOnClickModal: false, // 禁止点击遮罩层关闭
type: "warning",
})
},
// 提交内容
prompt(content) {
return ElMessageBox.prompt(content, "系统提示", {

View File

@ -268,8 +268,7 @@ const handleSubmit = () => {
const getMediaPrice = (_mediaId, _showOptionColumn) => {
showOptionColumn.value = _showOptionColumn
if (_mediaId) {
mediaPrice({ mediaId: _mediaId }).then(res => {
console.log('历史报价', res)
mediaPrice({ mediaId: _mediaId }).then(res => {
quotationList.value = res.data.filter(item => item.mediaType == 1)
quotationList.value.forEach(element => {
element.currentImageSrc = defaultImageSrc.value

View File

@ -246,8 +246,7 @@ const handleSubmit = () => {
const getMediaPrice = (_mediaId, _showOptionColumn) => {
showOptionColumn.value = _showOptionColumn
if (_mediaId) {
mediaPrice({ mediaId: _mediaId }).then(res => {
console.log('历史报价', res)
mediaPrice({ mediaId: _mediaId }).then(res => {
quotationList.value = res.data.filter(item => item.mediaType == 3)
quotationList.value.forEach(element => {
element.currentImageSrc = defaultImageSrc.value

View File

@ -278,17 +278,14 @@ const handleSubmit = () => {
})
}
//
const getMediaPrice = (_mediaId, _showOptionColumn) => {
console.log('进来了?', _mediaId, _showOptionColumn)
const getMediaPrice = (_mediaId, _showOptionColumn) => {
showOptionColumn.value = _showOptionColumn
if (_mediaId) {
mediaPrice({ mediaId: _mediaId }).then(res => {
console.log('历史报价', res)
mediaPrice({ mediaId: _mediaId }).then(res => {
quotationList.value = res.data.filter(item => item.mediaType == 0)
quotationList.value.forEach(element => {
element.currentImageSrc = defaultImageSrc.value
});
console.log('历史报价结果', quotationList.value)
});
})
}
}

View File

@ -259,8 +259,7 @@ const handleSubmit = () => {
const getMediaPrice = (_mediaId, _showOptionColumn) => {
showOptionColumn.value = _showOptionColumn
if (_mediaId) {
mediaPrice({ mediaId: _mediaId }).then(res => {
console.log('历史报价', res)
mediaPrice({ mediaId: _mediaId }).then(res => {
quotationList.value = res.data.filter(item => item.mediaType == 7)
quotationList.value.forEach(element => {
element.currentImageSrc = defaultImageSrc.value

View File

@ -253,8 +253,7 @@ const handleSubmit = () => {
const getMediaPrice = (_mediaId, _showOptionColumn) => {
showOptionColumn.value = _showOptionColumn
if (_mediaId) {
mediaPrice({ mediaId: _mediaId }).then(res => {
console.log('历史报价', res)
mediaPrice({ mediaId: _mediaId }).then(res => {
quotationList.value = res.data.filter(item => item.mediaType == 5)
quotationList.value.forEach(element => {
element.currentImageSrc = defaultImageSrc.value

View File

@ -259,8 +259,7 @@ const handleSubmit = () => {
const getMediaPrice = (_mediaId, _showOptionColumn) => {
showOptionColumn.value = _showOptionColumn
if (_mediaId) {
mediaPrice({ mediaId: _mediaId }).then(res => {
console.log('历史报价', res)
mediaPrice({ mediaId: _mediaId }).then(res => {
quotationList.value = res.data.filter(item => item.mediaType == 6)
quotationList.value.forEach(element => {
element.currentImageSrc = defaultImageSrc.value

View File

@ -358,8 +358,7 @@ const handleSubmit = () => {
const getMediaPrice = (_mediaId, _showOptionColumn) => {
showOptionColumn.value = _showOptionColumn
if (_mediaId) {
mediaPrice({ mediaId: _mediaId }).then(res => {
console.log('历史报价', res)
mediaPrice({ mediaId: _mediaId }).then(res => {
quotationList.value = res.data.filter(item => item.mediaType == 4)
quotationList.value.forEach(element => {
element.currentImageSrc = defaultImageSrc.value

View File

@ -319,8 +319,7 @@ const handleSubmit = () => {
const getMediaPrice = (_mediaId, _showOptionColumn) => {
showOptionColumn.value = _showOptionColumn
if (_mediaId) {
mediaPrice({ mediaId: _mediaId }).then(res => {
console.log('历史报价', res)
mediaPrice({ mediaId: _mediaId }).then(res => {
quotationList.value = res.data.filter(item => item.mediaType == 2)
quotationList.value.forEach(element => {
element.currentImageSrc = defaultImageSrc.value

View File

@ -55,8 +55,10 @@ import iconTxt from '@/assets/images/iconTxt.png'
import iconPpt from '@/assets/images/iconPpt.png'
import { mediaFiles } from "@/api/mediaLibrary"
import { downFile } from "@/api/common"
import { addBusDownloadRecord } from "@/api/mediaDownRecord"
const { proxy } = getCurrentInstance()
const emit = defineEmits(['downBack']);
const downFileOpen = ref(false)
//
const allFileList = ref([])
@ -76,8 +78,10 @@ const fileTypeArr = ref([
{ fileType: 12, fileTypeName: 'MR和制作要求', typeFileList: [] }
])
const downloadRecords = ref([])
//
const isImageFile = (suffix) => {
const isImageFile = (suffix) => {
return ['jpeg', 'jpg', 'png'].includes(suffix.toLowerCase())
}
//
@ -95,7 +99,18 @@ const handleDownFile = (fileUrl, downLoadName) => {
}
//
const handleDownAllFile = () => {
allFileList.value.forEach(item => {
downloadRecords.value.push({ filePath: item.fileUrl, fileName: item.originalFileName, state: 0 })
})
if (downloadRecords.value.length > 0) {
addBusDownloadRecord({ downloadRecordList: downloadRecords.value }).then(res => {
if (res.code == 200) {
downloadRecords.value = []
emit('downBack')
downFileOpen.value = false
}
})
}
}
//
const getMediaFileList = (_mediaId, itemFileType) => {
@ -109,6 +124,7 @@ const getMediaFileList = (_mediaId, itemFileType) => {
//
const initFileList = (_open, _mediaId) => {
downFileOpen.value = true
allFileList.value = []
nextTick(() => {
fileTypeArr.value.forEach(item => {
getMediaFileList(_mediaId, item)

View File

@ -0,0 +1,104 @@
<template>
<el-drawer v-model="open" title="下载任务" direction="ltr" :before-close="handleClose">
<el-table v-loading="loading" :data="downRecords">
<el-table-column label="文件名称" align="left" prop="fileName" />
<el-table-column label="进度" align="left" prop="progress" width="180">
<template #default="scope">
<el-progress :text-inside="true" :stroke-width="24" :percentage="scope.row.progress"
status="success" />
</template>
</el-table-column>
</el-table>
</el-drawer>
</template>
<script setup name="Post">
import { onMounted, defineExpose, nextTick, ref } from 'vue'
import { busDownloadRecordPage, updateBusDownloadRecord } from "@/api/mediaDownRecord"
const { proxy } = getCurrentInstance()
const open = ref(false)
const downRecords = ref([])
const loading = ref(false)
const handleClose = () => {
open.value = false
}
const getDownRecords = () => {
loading.value = true
busDownloadRecordPage({ pageIndex: 1, pageSize: 500, state: 0 }).then(res => {
if (res.code == 200) {
res.data.list.forEach(item => {
item.progress = 0
});
downRecords.value = res.data.list
loading.value = false
startDown()
}
})
}
//
const startDown = async () => {
for (const itemRecord of downRecords.value) { // &#9989; for...of
downFiles(itemRecord); //
await sleep(1000); // &#10004; 1
}
};
//
const downFiles = (itemRecord) => {
const xhr = new XMLHttpRequest();
xhr.open('GET', itemRecord.filePath, true);
xhr.responseType = 'blob';
//
xhr.onprogress = (event) => {
if (event.lengthComputable) {
var downloadProgress = (event.loaded / event.total) * 100;
itemRecord.progress = downloadProgress
if (downloadProgress == 100) {
updateBusDownloadRecord({ id: itemRecord.id, state: 2 }).then(res => { })
}
}
};
//
xhr.onload = () => {
if (xhr.status === 200) {
const blob = xhr.response;
const link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = itemRecord.fileName;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
};
//
xhr.onerror = () => {
console.error('下载失败');
};
xhr.send();
}
// sleep
const sleep = (ms) => {
return new Promise(resolve => setTimeout(resolve, ms)); // ms
}
//
const initDownList = (_open) => {
open.value = true
downRecords.value = []
nextTick(() => {
getDownRecords()
})
}
// \
defineExpose({
initDownList
});
</script>

View File

@ -39,14 +39,12 @@ const mediaType = ref(null)
const docUploadList = ref([])
//
const requestDocUpload = (options) => {
console.log('options', options)
const requestDocUpload = (options) => {
proxy.$modal.loading('正在上传文件,请耐心等待...')
const { file } = options
var formData = new FormData();
formData.append('mediaType', mediaType.value);
formData.append('file', file);
console.log('formData', formData)
formData.append('file', file);
importPriceByExcel(formData).then(res => {
if (res.code == 200) {
proxy.$modal.msgSuccess("导入成功")

View File

@ -259,18 +259,18 @@
<media-logs ref="mediaLogsRef" v-if="showLogs" @handleShowList="handleCloseLogs" />
<abolish-dialog ref="abolishRef" @handleReloadList="getMediaPageList" />
<history-data ref="historyDataRef" />
<down-files ref="downFileRef" />
<down-files ref="downFileRef" @downBack="handleDownBack" />
<view-file-dialog ref="viewFileRef" />
<export-dialog ref="exportDialogRef" />
<export-p-p-t-dialog ref="exportPPTDialogRef" />
<importPrice ref="importPriceRef" />
<down-records ref="downRecordsRef" />
</div>
</template>
<script setup name="Post">
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router'
import { useRouter } from 'vue-router'
import { ElMessageBox } from 'element-plus'
import { Search } from '@element-plus/icons-vue'
import optionIcon from '@/assets/images/optionIcon.png'
import optionIconHover from '@/assets/images/optionIconHover.png'
@ -284,6 +284,7 @@ import { busTradingAreaPage } from "@/api/system/businessArea"
import { mediaPageList } from "@/api/mediaLibrary"
import { listDept } from "@/api/system/dept"
import { pptTemplatePage } from "@/api/system/pptTemplate"
import { busDownloadRecordPage } from "@/api/mediaDownRecord"
//
import mediaForm from "./mediaForm.vue";
import mediaDetail from "./mediaDetail.vue";
@ -295,9 +296,9 @@ import exportDialog from './exportDialog.vue';
import abolishDialog from './abolishDialog.vue';
import exportPPTDialog from './exportPPTDialog.vue';
import importPrice from './importPrice.vue';
import downRecords from './downRecords.vue';
import { useBackgroundStore } from '@/store/modules/background'
const router = useRouter()
const bgStore = useBackgroundStore()
const { proxy } = getCurrentInstance()
@ -362,9 +363,9 @@ const mediaLogsRef = ref(null)
// ppt
const templateList = ref([])
//
const multipleChoseArr = ref([])
const multipleChoseArr = ref([])
const unfoldFlag = ref(false)
const importPriceRef = ref(null)
const abolishRef = ref(null)
const historyDataRef = ref(null)
@ -372,6 +373,7 @@ const downFileRef = ref(null)
const viewFileRef = ref(null)
const exportDialogRef = ref(null)
const exportPPTDialogRef = ref(null)
const downRecordsRef = ref(null)
// PPT
const getpptTemplatePageList = () => {
@ -471,7 +473,7 @@ const getbusinessAreaList = (val) => {
//
const handleFlod = () => {
unfoldFlag.value = !unfoldFlag.value
}
}
/** 查询媒体信息列表 */
const getMediaPageList = () => {
loading.value = true
@ -492,7 +494,7 @@ const getMediaPageList = () => {
const handleQuery = () => {
queryParams.value.pageNum = 1
getMediaPageList()
}
}
/** 重置按钮操作 */
const resetQuery = () => {
queryParams.value = {
@ -512,7 +514,7 @@ const resetQuery = () => {
businessDistrictId: undefined
}
handleQuery()
}
}
//
const handleSelectionChange = (selection) => {
multipleChoseArr.value = selection
@ -577,12 +579,28 @@ const handleHistoryChart = (row) => {
}
//
const handleDownFiles = (row) => {
downFileRef.value.initFileList(true, row.id)
}
busDownloadRecordPage({ pageIndex: 1, pageSize: 1, state: 0 }).then(res => {
if (res.code == 200) {
if (res.data.list.length == 0) downFileRef.value.initFileList(true, row.id)
else {
ElMessageBox.alert('您有待下载的文件等待下载...', '系统消息', {
confirmButtonText: '查看下载任务',
callback: (action) => {
downRecordsRef.value.initDownList()
},
})
}
}
})
}
//
const handleDownBack = () => {
downRecordsRef.value.initDownList()
}
//
const handleViewPhoto = (_fileType, row) => {
viewFileRef.value.initFileList(_fileType, row.id)
}
}
/** 导出Excel按钮操作 */
const handleExportExcel = () => {
if (multipleChoseArr.value.length == 0) {
@ -598,13 +616,13 @@ const handleExportPPT = (tempId) => {
proxy.$modal.msgWarning("请选择要导出的媒体!!!")
return false
}
const mediaIds = multipleChoseArr.value.map(item => item.id);
const mediaIds = multipleChoseArr.value.map(item => item.id);
exportPPTDialogRef.value.initExportPPT(tempId, mediaIds, multipleChoseArr.value)
}
}
/** 导入按钮操作 */
const handleImport = (val) => {
importPriceRef.value.initImportPriceExcel(val)
}
}
//
const handleGoMediaMap = () => {
router.push('/mediaMap')

View File

@ -517,13 +517,11 @@ const handleClose = () => {
emit('handleShowList')
}
//
const handleChange = (val) => {
console.log(val)
const handleChange = (val) => {
activeNames.value = val
}
//
const handlePriceTypeClick = (tab, event) => {
console.log(tab, event)
const handlePriceTypeClick = (tab, event) => {
activePriceType.value = tab
}
//

View File

@ -48,8 +48,7 @@ const getLocaleListList = (searchValue) => {
selectLoading.value = true
if (searchValue !== "") {
placeSearch.value.search(searchValue, function (status, result) {
// resultPOI
console.log(result.poiList, result.poiList.pois, result.poiList.pois?.length)
// resultPOI
if (result.poiList.pois?.length) {
localeList.value = result.poiList?.pois
}
@ -60,8 +59,7 @@ const getLocaleListList = (searchValue) => {
//
const currentSelect = (val) => {
console.log('val', val)
const currentSelect = (val) => {
localeKeyWord.value = val.name
pickLatLableValue.value = { lng: val.location.lng, lat: val.location.lat }
addmark(val)

View File

@ -216,8 +216,7 @@ const handleViewMedia = (_mediaId) => {
mediaDetail({ mediaId: _mediaId }).then(res => {
detailForm.value = res.data
if (detailForm.value.mediaFile && detailForm.value.mediaFile.length > 0) {
fileList.value = detailForm.value.mediaFile.filter(item => item.fileType == 6)
console.log('图片', fileList.value)
fileList.value = detailForm.value.mediaFile.filter(item => item.fileType == 6)
}
open.value = true
})
@ -229,8 +228,7 @@ const getLocaleListList = (searchValue) => {
selectLoading.value = true
if (searchValue !== "") {
placeSearch.value.search(searchValue, function (status, result) {
// resultPOI
console.log(result.poiList, result.poiList.pois, result.poiList.pois?.length)
// resultPOI
if (result.poiList.pois?.length) {
localeList.value = result.poiList?.pois
}
@ -239,8 +237,7 @@ const getLocaleListList = (searchValue) => {
}
}
//
const currentSelect = (val) => {
console.log('val', val)
const currentSelect = (val) => {
selectConfig.value = val
centerPointName.value = val.name
// queryParams.value.keyword = val.name
@ -315,8 +312,7 @@ const createCircleHandle = () => {
const handlePosition = new AMap.LngLat(
center.lng + radius / (111320 * Math.cos(center.lat * Math.PI / 180)),
center.lat
);
console.log('手柄', handlePosition)
);
//
circleHandle.value = new AMap.Marker({
position: [handlePosition.lng, handlePosition.lat],
@ -635,8 +631,7 @@ const renderMassMarks = () => {
if (itemPoint.businessType == 2) points.value.push({ "lnglat": [itemPoint.x, itemPoint.y], "mediaId": itemPoint.mediaId, "style": 1 })
});
}
}).then(res => {
console.log('points', points.value)
}).then(res => {
// MassMarks
massMarks.value = new AMap.MassMarks(points.value, {
opacity: 1,
@ -649,8 +644,7 @@ const renderMassMarks = () => {
massMarks.value.setMap(mapInstance.value);
//
massMarks.value.on('click', function (e) {
console.log('点击了节点', e.data)
massMarks.value.on('click', function (e) {
handleViewMedia(e.data.mediaId)
});
})

View File

@ -86,8 +86,7 @@ const getMediaDetail = (_mediaId) => {
mediaDetail({ mediaId: _mediaId }).then(res => {
detailForm.value = res.data
if (detailForm.value.mediaFile && detailForm.value.mediaFile.length > 0) {
fileList.value = detailForm.value.mediaFile.filter(item => item.fileType == 6)
console.log('图片', fileList.value)
fileList.value = detailForm.value.mediaFile.filter(item => item.fileType == 6)
}
loading.value = false
})

View File

@ -633,12 +633,10 @@ const renderMassMarks = () => {
];
//
points.value = []
outdoorMediaList.value.forEach(itemPoint => {
console.log('itemPoint', itemPoint)
outdoorMediaList.value.forEach(itemPoint => {
if (itemPoint.businessType == 1) points.value.push({ "lnglat": [itemPoint.mapX, itemPoint.mapY], "name": itemPoint.mediaName, "mediaId": itemPoint.id, "style": 0 })
if (itemPoint.businessType == 2) points.value.push({ "lnglat": [itemPoint.mapX, itemPoint.mapY], "name": itemPoint.mediaName, "mediaId": itemPoint.id, "style": 1 })
});
console.log('points', points.value)
});
// MassMarks
massMarks.value = new AMap.MassMarks(points.value, {
opacity: 1,
@ -651,8 +649,7 @@ const renderMassMarks = () => {
massMarks.value.setMap(mapInstance.value);
//
massMarks.value.on('click', function (e) {
console.log('点击了节点', e.data)
massMarks.value.on('click', function (e) {
handleViewMedia(e.data.mediaId)
});
}

View File

@ -384,15 +384,13 @@ const requestDocUpload = (options) => {
const { file } = options
var formData = new FormData();
formData.append('file', file);
importSupplierComparePrice(formData).then(res => {
console.log('接口接口', res)
importSupplierComparePrice(formData).then(res => {
if (res.code == 200) {
proxy.$modal.msgSuccess("导入成功")
proxy.$modal.closeLoading()
uploadOpen.value = false
getPitchPricePage()
} else {
console.log('接口异常', res)
} else {
proxy.$modal.closeLoading()
proxy.$modal.msgError(res.msg);
}

View File

@ -388,15 +388,13 @@ const requestDocUpload = (options) => {
const { file } = options
var formData = new FormData();
formData.append('file', file);
importSupplier(formData).then(res => {
console.log('接口接口', res)
importSupplier(formData).then(res => {
if (res.code == 200) {
proxy.$modal.msgSuccess("导入成功")
proxy.$modal.closeLoading()
uploadOpen.value = false
getSupplierPageList()
} else {
console.log('接口异常', res)
} else {
proxy.$modal.closeLoading()
proxy.$modal.msgError(res.msg);
}

View File

@ -195,8 +195,7 @@ const getSupplierList = () => {
loading.value = true
listBusSupplierLog(queryParams.value).then(res => {
res.data.forEach(item => {
item.supplierName = supplierName.value
console.log(JSON.parse(item.updateContent))
item.supplierName = supplierName.value
});
supplierLogList.value = res.data
loading.value = false

View File

@ -173,8 +173,7 @@ const handleAdd = () => {
const handleUpdate = (row) => {
reset()
getPptTemplate(row.id).then(response => {
form.value = response.data
console.log('请求结果', form.value)
form.value = response.data
docUploadList.value.push({
name: form.value.originalFileName,
url: form.value.fileUrl,