修改测试问题
This commit is contained in:
@@ -18,8 +18,8 @@
|
||||
<Cn-filterCriteria @select="select" :showQianTree="false"> </Cn-filterCriteria>
|
||||
</view>
|
||||
<scroll-view scroll-y="true" @scroll="onScroll" :scroll-top="scrollTop" scroll-with-animation
|
||||
@refresherrefresh="refresherrefresh" @scrolltolower="scrolltolower"
|
||||
:refresher-triggered="triggered" refresher-enabled="true" class="record event-list mt20"
|
||||
@refresherrefresh="refresherrefresh" @scrolltolower="scrolltolower" :refresher-triggered="triggered"
|
||||
refresher-enabled="true" class="record event-list mt20"
|
||||
:style="{ height: 'calc(100vh - ' + (navHeight + height) + 'px)', overflow: 'auto' }">
|
||||
<uni-card class="event-item" :class="item.type" v-for="(item, index) in store.data" :key="index">
|
||||
<!-- 头部:图标 + 信息 + 操作 -->
|
||||
@@ -67,7 +67,7 @@
|
||||
<text>报告状态:</text>
|
||||
<text :style="{ color: item.isComplete == 1 ? '#10b981' : '#FF0000' }">{{
|
||||
item.isComplete == 1 ? '已完成' : '未完成'
|
||||
}}</text>
|
||||
}}</text>
|
||||
</view>
|
||||
<view class="device-body-item">
|
||||
<text>申请时间:</text>
|
||||
@@ -192,10 +192,17 @@ export default {
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
mask: true,
|
||||
title: '生成事件报告成功!',
|
||||
title: '生成报告成功!',
|
||||
duration: 1000,
|
||||
})
|
||||
this.store.reload()
|
||||
}).catch((err) => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
mask: true,
|
||||
title: err.message,
|
||||
duration: 1000,
|
||||
})
|
||||
})
|
||||
},
|
||||
// 下载报告
|
||||
@@ -208,46 +215,26 @@ export default {
|
||||
id: item.eventId,
|
||||
})
|
||||
.then((res) => {
|
||||
// 下载文件资源到本地
|
||||
const pathMatch = res.data.match(/excelreport([^?]*)/)
|
||||
if (!pathMatch) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
mask: true,
|
||||
title: '文件地址无效',
|
||||
duration: 1000,
|
||||
})
|
||||
return
|
||||
}
|
||||
const fileMeta = this.getReportFileMeta(pathMatch[1])
|
||||
const match = this.$config.static + pathMatch[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, fileMeta)
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
mask: true,
|
||||
@@ -256,10 +243,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,
|
||||
@@ -268,6 +264,79 @@ export default {
|
||||
})
|
||||
})
|
||||
},
|
||||
getReportFileMeta(filePath) {
|
||||
const lower = (filePath || '').toLowerCase()
|
||||
if (lower.endsWith('.doc')) {
|
||||
return { fileType: 'doc', ext: 'doc' }
|
||||
}
|
||||
return { fileType: 'docx', ext: 'docx' }
|
||||
},
|
||||
openReportFile(tempFilePath, fileMeta) {
|
||||
const previewFile = (filePath) => {
|
||||
uni.hideLoading()
|
||||
uni.openDocument({
|
||||
filePath,
|
||||
fileType: fileMeta.fileType,
|
||||
showMenu: true,
|
||||
success: () => {
|
||||
console.log('成功打开文件')
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log('打开文件失败', err)
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '预览失败',
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
// iOS 需保留 doc/docx 后缀,saveFile 随机路径会导致 openDocument 失败
|
||||
if (plus.os.name === 'iOS') {
|
||||
const fileName = `event_report_${Date.now()}.${fileMeta.ext}`
|
||||
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: '保存失败!',
|
||||
})
|
||||
},
|
||||
})
|
||||
},
|
||||
// 刷新
|
||||
reload() {
|
||||
switch (this.curSub) {
|
||||
@@ -350,9 +419,9 @@ export default {
|
||||
font-size: 26rpx;
|
||||
color: #666666;
|
||||
line-height: 1.5;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// }
|
||||
@@ -418,6 +487,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user