1
wwl
2025-07-31 c3c6cf8cb3f73755ac9fad29f2b2c0cf64f27979
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
<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>