<template>
|
<view class="box">
|
<!-- 顶部固定栏 -->
|
<view class="Fixed">
|
<view class="Fixed_left">
|
<view class="Fixed_left_txt">体检报告</view>
|
</view>
|
<view class="Fixed_right" @tap="getDownload">
|
<view class="Fixed_right_sty">
|
<img class="Fixed_right_img" src="https://ltpeis.xaltjdkj.cn:5502/static/xiazai.png" alt="">
|
<view class="Fixed_right_txt">下载</view>
|
</view>
|
|
<!-- <div class="Fixed_right_sty">
|
<img class="Fixed_right_img" src="https://ltpeis.xaltjdkj.cn:5502/static/gengduo.png" alt="">
|
<span class="Fixed_right_txt">更多</span>
|
</div> -->
|
</view>
|
</view>
|
|
<!-- 基本健康数据 -->
|
<div class="data">
|
<div class="data_left">
|
<img v-if="customer.cusSex==0" class="data_img" src="https://ltpeis.xaltjdkj.cn:5502/static/4.png"
|
alt="">
|
<img v-else class="data_img" src="https://ltpeis.xaltjdkj.cn:5502/static/5.png" alt="">
|
<div class="data_left_sty1">
|
<span class="data_left_txt1">{{customer.cusName}}</span>
|
<div class="data_left_sty">
|
<span class="data_left_txt2">{{customer.cusBrithday}}</span>
|
</div>
|
<span class="data_left_txt2">{{customer.cusSex == "1" ? "女" :"男" }}</span>
|
</div>
|
</div>
|
<div class="data_right" v-if="jicuList.length >= 1">
|
<span class="data_right_txt1">基本健康数据</span>
|
|
<div class="data_right_sty">
|
<span class="data_right_txt2">身高(cm)</span>
|
<span class="data_right_txt3">{{jicuList[0].shenggao || ""}}</span>
|
</div>
|
<div class="data_right_sty">
|
<span class="data_right_txt2">体重(kg)</span>
|
<span class="data_right_txt3">{{jicuList[0].tizhong || ""}}</span>
|
</div>
|
<div class="data_right_sty">
|
<span class="data_right_txt4">体重指数</span>
|
<span class="data_right_txt5">{{jicuList[0].tizhongzhishu || ""}}</span>
|
</div>
|
<div class="data_right_sty">
|
<span class="data_right_txt2">收缩压(mmHg)</span>
|
<span class="data_right_txt3">{{jicuList[0].shousuoya || ""}}</span>
|
</div>
|
<div class="data_right_sty">
|
<span class="data_right_txt2">舒张压(mmHg)</span>
|
<span class="data_right_txt3">{{jicuList[0].shuzhangya || ""}}</span>
|
</div>
|
</div>
|
</div>
|
|
<!-- 总检建议 -->
|
<div class="bottom">
|
<uni-collapse class="bottom_sty">
|
<uni-collapse-item title="总检建议" thumb="https://ltpeis.xaltjdkj.cn:5502/static/baogao.png">
|
<view class="content" style="margin-left:15px ;">
|
<text class="text">{{checkAdvice}}</text>
|
</view>
|
</uni-collapse-item>
|
</uni-collapse>
|
|
<div class="bottom_sty">
|
<view class="content">
|
<text class="text">检验结果</text>
|
</view>
|
</div>
|
<uni-collapse class="bottom_sty">
|
<uni-collapse-item :title="item.parent" thumb="https://ltpeis.xaltjdkj.cn:5502/static/baogao.png"
|
v-for="(item,index) in alist1" :key="index">
|
|
<view class="content" v-for="(son,aindex) in item.sons" :key="aindex"
|
style="margin-left:15px ;display: flex;">
|
|
<text style="margin-left: 5px;width: 40%;">{{son.proName}}</text>
|
|
<view style="margin-left: 5px;width: 40%;" class="">
|
<text>
|
{{son.proResult}}
|
</text>
|
</view>
|
<view style="margin-left: 5px;width: 40%;" class="">
|
<text>
|
{{son.proAdvice}}
|
</text>
|
</view>
|
|
|
</view>
|
</uni-collapse-item>
|
</uni-collapse>
|
<div class="bottom_sty" v-if="alistss != []">
|
<view class="content">
|
<text class="text">检查</text>
|
</view>
|
</div>
|
<uni-collapse class="bottom_sty">
|
<uni-collapse-item :title="item.parent" thumb="https://ltpeis.xaltjdkj.cn:5502/static/baogao.png"
|
v-for="(item,index) in alistss" :key="index">
|
|
<view class="content" v-for="(son,aindex) in item.sons" :key="aindex"
|
style="margin-left:15px ;display: flex;flex-direction: column;">
|
|
<text style="margin-left: 5px;">检查所见:{{son.yxbx}}</text>
|
<text style="margin-left: 5px;">检查提示:{{son.yxzd}}</text>
|
<text style="margin-left: 5px;">主检医师:{{son.shysxm}}</text>
|
|
<!-- <view style="margin-left: 5px;width: 40%;" class="">
|
<text>
|
{{son.fwz}}
|
</text>
|
</view> -->
|
</view>
|
</uni-collapse-item>
|
</uni-collapse>
|
|
<div class="bottom_sty">
|
<view class="content">
|
<span class="text1">报告阅读说明</span>
|
<div>
|
<span
|
class="text2">1.以上报告结果,仅针对本次检查、检验样本负责。本报告不能用于二次会诊、用药、或其他任何医学判断目的的使用。如您有不适症状,或需要医疗服务,请及时到医院就医并遵医嘱。</span>
|
<span class="text3">查看更多</span>
|
<img class="img" src="https://ltpeis.xaltjdkj.cn:5502/static/youjiantou1.png" alt="">
|
</div>
|
<div>
|
<span class="text2">如需了解更多关于检测方法和检测结果参考值得信息,</span>
|
<span class="text3">请点这里</span>
|
<img class="img" src="https://ltpeis.xaltjdkj.cn:5502/static/youjiantou1.png" alt="">
|
</div>
|
</view>
|
</div>
|
</div>
|
|
<!-- <view class="" v-if="url">
|
<web-view :src="url"></web-view>
|
</view> -->
|
|
</view>
|
</template>
|
|
<script>
|
import {
|
PDF,
|
getShenGaoTiZhong1,
|
getreportData
|
} from "@/api/system/report";
|
|
export default {
|
components: {},
|
data() {
|
return {
|
jicuList: [],
|
customer: '',
|
alist: [],
|
alist1: [],
|
alistss: [],
|
url: "",
|
checkAdvice: "",
|
zjadvice: '',
|
yclist: [],
|
value: ['0'],
|
accordionVal: '1',
|
content: '',
|
tjNumber: "",
|
extraIcon: {
|
color: '#4cd964',
|
size: '26',
|
type: 'image'
|
},
|
isDownloading: false, // 防止重复点击
|
};
|
},
|
onLoad(options) {
|
// this.tjNumber = options.tjNum;
|
this.tjNumber = JSON.parse(localStorage.getItem('tjNum'))
|
this.getOrderDetailList();
|
this.getjichu();
|
},
|
methods: {
|
getOrderDetailList() {
|
uni.showLoading({
|
title: '请稍等!'
|
});
|
let data = {
|
tjNum: this.tjNumber
|
};
|
getreportData(data).then(res => {
|
uni.hideLoading();
|
this.alist1 = res.data;
|
this.checkAdvice = "";
|
// 使用 Set 去重
|
const uniqueAdvices = [...new Set(res.data.map(item => item.checkAdvice).filter(advice =>
|
advice))];
|
this.checkAdvice = uniqueAdvices.join(""); // 拼接所有唯一建议
|
});
|
},
|
getjichu() {
|
let tjNumber = this.tjNumber;
|
getShenGaoTiZhong1(tjNumber).then(res => {
|
if (res.data) {
|
this.jicuList = res.data;
|
}
|
});
|
},
|
getDownload() {
|
if (this.isDownloading) return; // 防止重复点击
|
this.isDownloading = true;
|
uni.showLoading({
|
title: '加载中...'
|
});
|
|
// 调用 PDF 接口获取文件路径
|
PDF({
|
tjNum: this.tjNumber
|
})
|
.then((res) => {
|
// 检查返回的 PDF 文件路径是否有效
|
if (!res.msg || typeof res.msg !== 'string') {
|
console.error('无效的 PDF 文件路径:', res.msg);
|
uni.showToast({
|
title: 'PDF 文件路径无效',
|
icon: 'error',
|
duration: 2000
|
});
|
this.isDownloading = false;
|
uni.hideLoading();
|
return;
|
}
|
|
// 动态拼接 PDF URL
|
const pdfPath = encodeURIComponent(res.msg);
|
const isTestEnv = process.env.VUE_APP_ENV === 'test' || process.env.NODE_ENV === 'development';
|
const pdfUrl = isTestEnv ?
|
`http://ltpeis.xaltjdkj.cn:5904/report-file/${pdfPath}` :
|
`${window.location.origin}/report-file/${pdfPath}`;
|
const fileName = res.msg;
|
console.log('Generated PDF URL:', pdfUrl);
|
|
// 测试 URL 状态码
|
fetch(pdfUrl, {
|
method: 'HEAD',
|
credentials: 'include' // 包含 cookie(如需认证)
|
// 如果需要 token,取消注释并替换
|
// headers: { 'Authorization': `Bearer ${yourToken}` }
|
})
|
.then(response => {
|
console.log('URL 状态码:', response.status);
|
|
if (response.status === 404) {
|
uni.showToast({
|
title: '文件不存在,请联系管理员',
|
duration: 2000
|
});
|
this.isDownloading = false;
|
uni.hideLoading();
|
console.log('加载完成');
|
return;
|
}
|
|
if (response.status >= 300 && response.status < 400) {
|
const redirectUrl = response.headers.get('Location') || '未知重定向地址';
|
console.warn('URL 被重定向:', redirectUrl);
|
uni.showToast({
|
title: `文件请求被重定向到: ${redirectUrl}`,
|
duration: 2000
|
});
|
this.isDownloading = false;
|
uni.hideLoading();
|
console.log('加载完成');
|
return;
|
}
|
|
if (response.status !== 200) {
|
console.error('URL 请求失败,状态码:', response.status);
|
uni.showToast({
|
title: `无法访问文件,状态码: ${response.status}`,
|
duration: 2000
|
});
|
this.isDownloading = false;
|
uni.hideLoading();
|
console.log('加载完成');
|
return;
|
}
|
|
// 状态码为 200,触发下载
|
try {
|
const downloadLink = document.createElement('a');
|
downloadLink.href = pdfUrl;
|
downloadLink.download = fileName;
|
document.body.appendChild(downloadLink);
|
downloadLink.dispatchEvent(new MouseEvent('click', {
|
view: window,
|
bubbles: true,
|
cancelable: true
|
}));
|
document.body.removeChild(downloadLink);
|
uni.showToast({
|
title: 'PDF 下载已触发',
|
icon: 'success',
|
duration: 2000
|
});
|
} catch (e) {
|
console.error('PDF 下载失败:', e);
|
uni.showToast({
|
title: 'PDF 下载失败,请重试',
|
duration: 2000
|
});
|
} finally {
|
this.isDownloading = false;
|
uni.hideLoading();
|
console.log('加载完成');
|
}
|
})
|
.catch(fetchError => {
|
console.error('测试 URL 失败:', fetchError);
|
uni.showToast({
|
title: '无法验证文件状态,请稍后重试',
|
duration: 2000
|
});
|
this.isDownloading = false;
|
uni.hideLoading();
|
console.log('加载完成');
|
});
|
})
|
.catch((err) => {
|
this.isDownloading = false;
|
uni.hideLoading();
|
console.error('PDF 接口错误:', err);
|
uni.showToast({
|
title: err?.msg || '获取 PDF 失败,请稍后重试',
|
icon: 'error',
|
duration: 2000,
|
});
|
console.log('加载完成');
|
});
|
},
|
change(e) {
|
console.log(e);
|
}
|
}
|
}
|
</script>
|
<style lang="scss">
|
.box {
|
width: 100%;
|
height: 850rpx;
|
background: linear-gradient(180deg, #fd8b4d 50%, #fdb753, );
|
}
|
|
.Fixed {
|
width: 100%;
|
height: 80rpx;
|
background-color: #fd8b4d;
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
justify-content: space-between;
|
position: fixed;
|
left: 20;
|
right: 20;
|
bottom: 20;
|
}
|
|
.Fixed_left_txt {
|
margin-left: 286rpx;
|
color: #fff;
|
font-size: 16px;
|
font-weight: 400;
|
}
|
|
.Fixed_right {
|
display: flex;
|
}
|
|
.Fixed_right_sty {
|
display: flex;
|
flex-direction: column;
|
margin-right: 20px;
|
}
|
|
.Fixed_right_img {
|
width: 45rpx;
|
height: 45rpx;
|
}
|
|
.Fixed_right_txt {
|
color: #fff;
|
font-size: 12px;
|
}
|
|
.data {
|
display: flex;
|
justify-content: space-around;
|
padding-top: 102rpx;
|
margin-bottom: 40rpx;
|
}
|
|
.data_left {
|
width: 316rpx;
|
height: 700rpx;
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
}
|
|
.data_img {
|
width: 316rpx;
|
height: 600rpx;
|
}
|
|
.data_left_sty1 {
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
}
|
|
.data_left_txt1 {
|
font-size: 20px;
|
color: #fff;
|
}
|
|
.data_left_sty {
|
width: 180rpx;
|
height: 50rpx;
|
background-color: #f99235;
|
border-radius: 20px 20px 20px 20px;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
}
|
|
.data_left_txt2 {
|
font-size: 14px;
|
color: #fff;
|
}
|
|
.data_right {
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
justify-content: space-around;
|
width: 316rpx;
|
height: 700rpx;
|
background-color: #fff;
|
border-radius: 20px 20px 20px 20px;
|
}
|
|
.data_right_txt1 {
|
font-size: 18px;
|
}
|
|
.data_right_sty {
|
width: 316rpx;
|
display: flex;
|
justify-content: space-around;
|
}
|
|
.data_right_txt2 {
|
font-size: 14px;
|
}
|
|
.data_right_txt3 {
|
font-weight: 600;
|
}
|
|
.data_right_txt4 {
|
color: #f23f45;
|
font-size: 14px;
|
}
|
|
.data_right_txt5 {
|
color: #f23f45;
|
font-weight: 600;
|
}
|
|
.bottom {
|
height: 800px;
|
background-color: #ffffff;
|
}
|
|
.example-body {
|
flex-direction: column;
|
flex: 1;
|
}
|
|
.content {
|
padding: 8px;
|
}
|
|
.text1 {
|
font-size: 14px;
|
font-weight: 600;
|
}
|
|
.text2 {
|
font-size: 12px;
|
color: #8a8a8a;
|
}
|
|
.text3 {
|
font-size: 12px;
|
color: #1d6ebf;
|
}
|
|
.img {
|
width: 10px;
|
height: 10px;
|
}
|
|
// table {
|
// width: 100%;
|
// border-collapse: collapse;
|
// }
|
|
// th,
|
// td {
|
// border: 1px solid black;
|
// padding: 8px;
|
// text-align: left;
|
// }
|
|
// th {
|
// background-color: #f2f2f2;
|
// }
|
</style>
|