|
|
@@ -52,9 +52,9 @@
|
|
|
<view class="kr-box adffcac report-selector-box">
|
|
|
<view class="kr-title">查看报告</view>
|
|
|
<view class="report-selector-tip">请选择要查看的报告</view>
|
|
|
- <view class="report-selector-btn" :class="{disabled: reportSelectorUnavailable('background')}" @click="selectReportArtifact('background')">背景报告</view>
|
|
|
- <view class="report-selector-btn" :class="{disabled: reportSelectorUnavailable('professional')}" @click="selectReportArtifact('professional')">教练报告</view>
|
|
|
- <view class="report-selector-btn" @click="selectReportArtifact('public')">团队报告</view>
|
|
|
+ <view class="report-selector-btn" :class="{disabled: reportSelectorUnavailable('background')}" @click="selectReportArtifact('background')">{{reportSelectorLabel(reportSelectorItem, 'background')}}</view>
|
|
|
+ <view class="report-selector-btn" :class="{disabled: reportSelectorUnavailable('professional')}" @click="selectReportArtifact('professional')">{{reportSelectorLabel(reportSelectorItem, 'professional')}}</view>
|
|
|
+ <view class="report-selector-btn" @click="selectReportArtifact('public')">{{reportSelectorLabel(reportSelectorItem, 'public')}}</view>
|
|
|
<view class="report-selector-cancel" @click="closeReportSelector">取消</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -100,7 +100,12 @@
|
|
|
|
|
|
<script>
|
|
|
import { getPlatformInfo } from '@/utils/platform.js';
|
|
|
- import { reportArtifactUrl, reportArtifactDownloadUrl } from '@/utils/reportArtifactLinks.js'
|
|
|
+ import {
|
|
|
+ reportArtifactUrl,
|
|
|
+ reportArtifactDownloadUrl,
|
|
|
+ reportPreviewName,
|
|
|
+ reportSelectorLabel as artifactSelectorLabel
|
|
|
+ } from '@/utils/reportArtifactLinks.js'
|
|
|
import { canEditEvaluation, isReportGenerating, EVALUATION_PROCESSING_PROMPT, normalizeEvaluationForm } from '@/utils/reportEvaluationEdit.js'
|
|
|
import CusSelectTeamUser from '@/components/CusSelectTeamUser/index.vue'
|
|
|
export default {
|
|
|
@@ -238,6 +243,9 @@
|
|
|
return this.reportSelectorItem && String(this.reportSelectorItem.type) === '1'
|
|
|
&& ['background', 'professional'].indexOf(kind) !== -1;
|
|
|
},
|
|
|
+ reportSelectorLabel(item, kind){
|
|
|
+ return artifactSelectorLabel(item, kind);
|
|
|
+ },
|
|
|
selectReportArtifact(kind){
|
|
|
const item = this.reportSelectorItem;
|
|
|
this.closeReportSelector();
|
|
|
@@ -324,13 +332,13 @@
|
|
|
if (isPC) {
|
|
|
this.$showModal('请在手机端该微信小程序中查看报告')
|
|
|
} else if (isMobile||platform==='devtools') {
|
|
|
- this.openReportDocument(url)
|
|
|
+ this.openReportDocument(url, reportPreviewName(item, kind))
|
|
|
// uni.navigateTo({
|
|
|
// url:'/pages/webView?src='+item.fileUrl
|
|
|
// })
|
|
|
}
|
|
|
},
|
|
|
- async openReportDocument(fileUrl) {
|
|
|
+ async openReportDocument(fileUrl, previewName) {
|
|
|
try {
|
|
|
// 1. 显示加载提示
|
|
|
uni.showLoading({ title: '加载中...' });
|
|
|
@@ -349,9 +357,11 @@
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 3. 按实际扩展名使用微信原生文档预览
|
|
|
- const openRes = await uni.openDocument({
|
|
|
- filePath: dres.tempFilePath,
|
|
|
+ // 3. 微信下载路径使用随机名;复制为业务名称后再预览,便于原生查看器展示可读标题
|
|
|
+ const previewPath = this.createNamedPreviewFile(dres.tempFilePath, previewName);
|
|
|
+ // 4. 按实际扩展名使用微信原生文档预览
|
|
|
+ await uni.openDocument({
|
|
|
+ filePath: previewPath,
|
|
|
fileType: this.documentType(fileUrl),
|
|
|
showMenu: false
|
|
|
});
|
|
|
@@ -362,6 +372,25 @@
|
|
|
uni.showToast({ title: '加载失败,请重试', icon: 'none' });
|
|
|
}
|
|
|
},
|
|
|
+ createNamedPreviewFile(tempFilePath, previewName) {
|
|
|
+ if (!tempFilePath || !previewName || typeof wx === 'undefined'
|
|
|
+ || !wx.env || !wx.env.USER_DATA_PATH || !wx.getFileSystemManager) {
|
|
|
+ return tempFilePath;
|
|
|
+ }
|
|
|
+ const previewPath = `${wx.env.USER_DATA_PATH}/${previewName}`;
|
|
|
+ try {
|
|
|
+ const fileSystemManager = wx.getFileSystemManager();
|
|
|
+ const previousPath = uni.getStorageSync('perillReportPreviewPath');
|
|
|
+ if (previousPath) {
|
|
|
+ try { fileSystemManager.unlinkSync(previousPath); } catch (error) {}
|
|
|
+ }
|
|
|
+ fileSystemManager.copyFileSync(tempFilePath, previewPath);
|
|
|
+ uni.setStorageSync('perillReportPreviewPath', previewPath);
|
|
|
+ return previewPath;
|
|
|
+ } catch (error) {
|
|
|
+ return tempFilePath;
|
|
|
+ }
|
|
|
+ },
|
|
|
documentType(fileUrl) {
|
|
|
const path = (fileUrl || '').split('?')[0].toLowerCase()
|
|
|
return path.endsWith('.docx') ? 'docx' : 'pdf'
|