修改测试问题

This commit is contained in:
guanj
2026-07-02 09:55:30 +08:00
parent 1d73755a43
commit 40899e6d55
21 changed files with 380 additions and 157 deletions

View File

@@ -41,7 +41,7 @@
<view class="event-desc">
<text>统计时间{{
curSub == 0 ? item.startTime : item.startTime + ' 至 ' + item.endTime
}}</text>
}}</text>
</view>
</view>
<view class="event-action" v-if="!showNotGenerated(item)">
@@ -54,7 +54,7 @@
<view class="event-detail textBox" @touchmove.stop>
<text v-if="!showNotGenerated(item)">{{
item.overLimitDesc == '' ? '该监测点暂无指标越限' : item.overLimitDesc
}}</text>
}}</text>
<text v-else>数据未生成暂不支持下载</text>
</view>
<!-- <view class="downloadReport" @click="download">
@@ -180,46 +180,14 @@ export default {
timeType: this.selectValue.report,
})
.then((res) => {
// 下载文件资源到本地
const match = this.$config.static + res.data.match(/excelreport([^?]*)/)[1]
uni.downloadFile({
url: res.data, // 后端返回的线上文件路径
success: function (res) {
if (res.statusCode === 200) {
// 文件到本地
uni.saveFile({
tempFilePath: res.tempFilePath, //临时路径
success: function (data) {
var savedFilePath = data.savedFilePath
// 在app端执行
// #ifdef APP-PLUS
let osname = plus.os.name
// 如果是安卓的话弹出提示
uni.showToast({
icon: 'success',
mask: true,
title: '下载成功!',
duration: 1000,
})
// #endif
//ios手机直接打开文件手动存储文件到手机Android手机从根目录创建文件夹保存文件并改名
setTimeout(() => {
//打开文档查看
uni.openDocument({
filePath: data.savedFilePath,
success: function (ress) {
console.log('成功打开文件')
},
fail() {
console.log('打开文件失败')
},
})
}, 500)
},
})
console.log('下载成功')
url: match,
success: (downloadRes) => {
if (downloadRes.statusCode === 200) {
this.openReportFile(downloadRes.tempFilePath)
} else {
uni.hideLoading()
uni.showToast({
icon: 'none',
mask: true,
@@ -228,10 +196,19 @@ export default {
})
}
},
fail: function (res) { },
fail: () => {
uni.hideLoading()
uni.showToast({
icon: 'none',
mask: true,
title: '下载失败!',
duration: 1000,
})
},
})
})
.catch((err) => {
uni.hideLoading()
uni.showToast({
icon: 'none',
mask: true,
@@ -240,6 +217,72 @@ export default {
})
})
},
openReportFile(tempFilePath) {
const previewFile = (filePath) => {
uni.hideLoading()
uni.openDocument({
filePath,
fileType: 'xlsx',
showMenu: true,
success: () => {
console.log('成功打开文件')
},
fail: (err) => {
console.log('打开文件失败', err)
uni.showToast({
icon: 'none',
title: '预览失败',
})
},
})
}
// #ifdef APP-PLUS
// iOS 需保留 xlsx 后缀saveFile 随机路径会导致 openDocument 失败
if (plus.os.name === 'iOS') {
const fileName = `harmonic_report_${Date.now()}.xlsx`
plus.io.resolveLocalFileSystemURL(
tempFilePath,
(entry) => {
plus.io.resolveLocalFileSystemURL(
'_doc/',
(docEntry) => {
entry.copyTo(
docEntry,
fileName,
(newEntry) => previewFile(newEntry.fullPath),
() => previewFile(tempFilePath)
)
},
() => previewFile(tempFilePath)
)
},
() => previewFile(tempFilePath)
)
return
}
// #endif
uni.saveFile({
tempFilePath,
success: (data) => {
uni.showToast({
icon: 'success',
mask: true,
title: '下载成功!',
duration: 1000,
})
setTimeout(() => previewFile(data.savedFilePath), 500)
},
fail: () => {
uni.hideLoading()
uni.showToast({
icon: 'none',
title: '保存失败!',
})
},
})
},
// 下拉
refresherrefresh() {
this.triggered = true
@@ -386,6 +429,7 @@ export default {
box-shadow: 0 4rpx 16rpx rgba(55, 108, 243, 0.35);
z-index: 1;
}
/deep/ .segmented-control__text {
line-height: 60rpx !important;
}