Commit 6ac9878f by cen

fix: 分享pdf

1 parent 32f322be
......@@ -4,14 +4,17 @@
<view class="back" @click.stop="back">
<uni-icons type="left" :size="20" color="#000"></uni-icons>
</view>
{{ title }}
<view class="nav-title">{{ title }}</view>
<!-- 从报告管理跳转时,右上角显示保存按钮 -->
<view v-if="showSaveBtn && reportImageUrl" class="nav-save-btn" @click.stop="saveReportImage">保存图片</view>
</view>
<web-view v-if="fileUrltype === 'html'" :src="url"></web-view>
<!-- html 报告:统一用 web-view 展示内容,按钮放在导航栏,避免被覆盖 -->
<web-view v-if="fileUrltype === 'html'" :src="previewUrl"></web-view>
<view v-else-if="fileUrltype !== 'pdf'">
<lk-preview-office :url="url" :fileType="fileType"></lk-preview-office>
<lk-preview-office :url="previewUrl" :fileType="fileType"></lk-preview-office>
</view>
<view v-else>
<lk-preview-office :url="url" fileType="pdf"></lk-preview-office>
<lk-preview-office :url="previewUrl" fileType="pdf"></lk-preview-office>
</view>
</view>
</template>
......@@ -23,28 +26,33 @@ export default {
mixins: [report],
data () {
return {
url: '',
previewUrl: '',
title: '',
fileType: 'pdf',
Signature: true,
fileUrltype:'pdf'
fileUrltype:'pdf',
showSaveBtn: false,
reportImageUrl: ''
}
},
onLoad (options) {
console.log(options)
this.fileUrltype = options.fileUrltype || 'pdf'
this.fileType = options.fileType || 'pdf'
this.Signature = options.Signature === 'false' ? false : (options.Signature || true);
if(this.fileType === 'docx') {
this.url = options.fileUrl
}else if(!this.Signature) {
this.url = options.fileUrl
}else {
this.url = options.fileUrl + '&OSSAccessKeyId='+ options.OSSAccessKeyId + '&Signature=' + options.Signature
}
console.log(options)
this.fileUrltype = options.fileUrltype || 'pdf'
this.fileType = options.fileType || 'pdf'
this.Signature = options.Signature === 'false' ? false : (options.Signature || true);
if(this.fileType === 'docx') {
this.previewUrl = options.fileUrl
}else if(!this.Signature) {
this.previewUrl = options.fileUrl
}else {
this.previewUrl = options.fileUrl + '&OSSAccessKeyId='+ options.OSSAccessKeyId + '&Signature=' + options.Signature
}
this.title = options.fileName
console.log(this.url)
this.title = options.fileName
// 来自报告管理的额外参数:是否显示保存按钮 & 报告图片地址
this.showSaveBtn = options.showSaveBtn === '1'
this.reportImageUrl = options.reportImageUrl ? decodeURIComponent(options.reportImageUrl) : ''
console.log(this.previewUrl)
// else this.setWv()
},
mounted () {
......@@ -57,6 +65,40 @@ this.url = options.fileUrl
animationDuration: 100
})
},
// 保存报告图片到相册
saveReportImage () {
if (!this.reportImageUrl) {
uni.showToast({ title: '暂无可保存的图片', icon: 'none' })
return
}
uni.showLoading({ title: '保存中...', mask: true })
uni.downloadFile({
url: this.reportImageUrl,
success: res => {
if (res.statusCode === 200) {
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: () => {
uni.showToast({ title: '已保存到相册', icon: 'none' })
},
fail: () => {
uni.showToast({ title: '保存失败', icon: 'none' })
},
complete: () => {
uni.hideLoading()
}
})
} else {
uni.hideLoading()
uni.showToast({ title: '下载失败', icon: 'none' })
}
},
fail: () => {
uni.hideLoading()
uni.showToast({ title: '下载失败', icon: 'none' })
}
})
},
setWebviewStyle () {
const setWebviewStyleWithRetry = () => {
const currentWebview = this.$scope.$getAppWebview()
......@@ -97,11 +139,12 @@ this.url = options.fileUrl
left: 0;
top: toRpx(48);
z-index: 9;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
font-weight: 700;
font-size: toRpx(32);
color: #1a1a1a;
line-height: toRpx(96);
.back {
position: absolute;
left: 0;
......@@ -113,6 +156,26 @@ this.url = options.fileUrl
justify-content: center;
}
}
.nav-title {
max-width: 60%;
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.nav-save-btn {
position: absolute;
right: toRpx(24);
top: 50%;
transform: translateY(-50%);
padding: 0 toRpx(24);
height: toRpx(64);
line-height: toRpx(64);
border-radius: toRpx(32);
background: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
color: #ffffff;
font-size: toRpx(24);
}
.file-box {
position: fixed;
top: 5.2vh;
......
......@@ -157,12 +157,33 @@
</view>
</view>
<view v-else-if="activeTabKey == 'evaluation'">
<StepperNavigation :currentStep="currentStep" :steps="detailsInfo.priceHistory" direction="vertical">
<template v-slot="{ step, indexContent }">
<!-- priceHistory 字段废弃:按轮展示 priceHistoryByRound,每轮内展示多次报价 -->
<StepperNavigation :currentStep="currentStep" :steps="detailsInfo.priceHistoryByRound" direction="vertical">
<template v-slot="{ step }">
<view class="gridBox mb-48 padBox">
<view v-for="(item, index) in priceItems" :key="index" :class="['flex align-center', { 'full-width': item.fullWidth }]">
<!-- 多次评估师报价(opType 10):评估价1/2/3…,每条用 priceItems -->
<view v-for="(h, hIndex) in getRoundQuotes(step)" :key="`quote_block_${hIndex}`">
<view
v-for="(item, index) in priceItems"
:key="`quote_${hIndex}_${index}`"
:class="['flex align-center', { 'full-width': item.fullWidth }]"
>
<view class="title-label-see mr-16">
{{ item.label }}<text v-if="getRoundQuotes(step).length > 1">{{ hIndex + 1 }}</text>
</view>
<view class="flex-1 break-word">{{ h[item.key] || '-' }} {{ item.cell || '' }}</view>
</view>
</view>
<!-- 每轮底部汇总区:客户报价 / 报价反馈 / 核价金额 / 核价意见 -->
<view
v-for="(item, index) in roundSummaryItems"
:key="`summary_${index}`"
:class="['flex align-center', { 'full-width': item.fullWidth }]"
>
<view class="title-label-see mr-16">{{ item.label }}</view>
<view class="flex-1 break-word">{{ detailsInfo.priceHistory[indexContent][item.key] || '-' }} {{ item.cell || '' }}</view>
<view class="flex-1 break-word">
{{ getRoundSummaryValue(step, item.opType, item.key) || '-' }} {{ item.cell || '' }}
</view>
</view>
</view>
</template>
......@@ -560,12 +581,19 @@ export default {
{ label: '原车主电话', key: 'carLicense.previousOwnerPhone', fullWidth: true },
{ label: '原车主住址', key: 'carLicense.previousOwnerAddress', fullWidth: true }
],
// 评估师单次报价展示字段(仅用于 opType = 10)
priceItems: [
{ label: '评估价格', key: 'evalPriceDisplay' },
{ label: '客户意向报价', key: 'customerTargetPriceDisplay' },
{ label: '报价反馈', key: 'customerTargetPriceFeedback', fullWidth: true },
{ label: '评估意见', key: 'evalOpinion', fullWidth: true }
],
// 每轮底部汇总信息(来自不同 opType)
roundSummaryItems: [
{ label: '客户报价', key: 'customerTargetPriceDisplay', opType: 20 },
{ label: '报价反馈', key: 'customerTargetPriceFeedback', opType: 20, fullWidth: true },
{ label: '核价金额', key: 'evalPriceDisplay', opType: 40 },
// 核价意见同样来自核价记录(opType 40)
{ label: '核价意见', key: 'evalOpinion', opType: 40, fullWidth: true }
],
editItems: [
{ label: '订单状态', key: 'status' },
{ label: '编辑人员', key: 'editor' }
......@@ -809,9 +837,33 @@ export default {
})
.then(res => {
if (res.data.code == 0) {
that.detailsInfo = res.data.data
const data = res.data.data || {}
// priceHistory 字段废弃:统一使用 priceHistoryByRound(按轮分组)
if (!Array.isArray(data.priceHistoryByRound)) data.priceHistoryByRound = []
// 规范化每轮数据:保证 priceHistoryList 为数组,且按 quoteTime 倒序(同一轮最新在前)
// 不再改变后端轮次顺序,保持后端返回的倒序(最新轮在最上方)
data.priceHistoryByRound = data.priceHistoryByRound.map(r => {
const list = Array.isArray(r?.priceHistoryList) ? r.priceHistoryList.filter(Boolean) : []
list.sort((a, b) => {
const ta = a?.quoteTime || ''
const tb = b?.quoteTime || ''
if (ta === tb) return 0
return ta < tb ? 1 : -1
})
const quoteTime = list[0]?.quoteTime || r?.quoteTime || ''
return {
...r,
roundNo: r?.roundNo,
quoteTime,
priceHistoryList: list
}
})
that.detailsInfo = data
// 判断评估信息
if (that.detailsInfo.priceHistory && that.detailsInfo.priceHistory.length > 0) {
if (that.detailsInfo.priceHistoryByRound && that.detailsInfo.priceHistoryByRound.length > 0) {
that.tabs.find(i => i.key === 'evaluation').hidden = false
}
if (that.detailsInfo.paymentList && that.detailsInfo.paymentList.length > 0) {
......@@ -871,6 +923,17 @@ export default {
console.log('rawValue:', rawValue === 0 ? 0 : item.type === 'image' || item.accept === 'video' ? rawValue : rawValue || '-', item.key, item)
return rawValue === 0 ? 0 : item.type === 'image' || item.accept === 'video' ? rawValue : rawValue || '-'
},
// 取当前轮次中所有评估师报价(opType = 10)
getRoundQuotes(step) {
const list = Array.isArray(step?.priceHistoryList) ? step.priceHistoryList : []
return list.filter(i => String(i.opType) === '10')
},
// 取当前轮次底部汇总字段(根据 opType + 字段名)
getRoundSummaryValue(step, opType, key) {
const list = Array.isArray(step?.priceHistoryList) ? step.priceHistoryList : []
const record = list.find(i => String(i.opType) === String(opType))
return record ? record[key] : ''
},
getImageBySubtype(subtype) {
if (!this.detailsInfo.images) return []
if (subtype === 41 || subtype === 22 || subtype === 51) {
......@@ -1039,7 +1102,7 @@ export default {
background: #ffffff;
box-sizing: border-box;
.title-label-see {
width: toRpx(168);
width: toRpx(198);
color: #999999;
font-size: toRpx(28);
font-weight: 400;
......@@ -1081,7 +1144,7 @@ export default {
padding-bottom: toRpx(28);
box-sizing: border-box;
.title-label-see {
width: toRpx(168);
width: toRpx(198);
color: #999999;
font-size: toRpx(28);
font-weight: 400;
......
......@@ -567,7 +567,8 @@ export default {
toDetail(i) {
if (i.status === 1) {
const reportUrl = i.reportUrl
const url = `/pages/evaluationForm/components/pdfPreView?fileUrl=${reportUrl}&fileUrltype=html&Signature=false`
const reportImageUrl = encodeURIComponent(i.reportImageUrl || '')
const url = `/pages/evaluationForm/components/pdfPreView?fileUrl=${reportUrl}&fileUrltype=html&Signature=false&showSaveBtn=1&reportImageUrl=${reportImageUrl}`
uni.navigateTo({
url: `${url}`
})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!