xinelu-applet-ui/pagesC/testreport/testreport.vue

177 lines
3.9 KiB
Vue
Raw Normal View History

2023-11-09 15:41:55 +08:00
<template>
<view class="app">
<view class="item" v-for="item in list">
<view class="time">
{{item.date}}
</view>
<view class="name">
2024-01-22 22:11:26 +08:00
<!-- {{item.reportId}} -->
检测报告
2023-11-09 15:41:55 +08:00
</view>
<view class="btn" v-if="item.existReport==1" @tap='lookReport(item)'>
<span>查看报告</span>
</view>
<view class="btn2" v-if="item.existReport==2">
<span>暂无报告</span>
</view>
</view>
</view>
</template>
<script>
import {
dyrecord,
dzrecord,
dyreport,
dzreport
} from '@/api/pagesC/testreport/index.js'
2024-01-22 22:11:26 +08:00
import baseurl from '@/api/baseurl.js'
2023-11-09 15:41:55 +08:00
export default {
data() {
return {
list: [],
region: undefined,
2024-01-22 22:11:26 +08:00
baseurl: '',
2023-11-09 15:41:55 +08:00
};
},
onLoad() {
2024-01-22 22:11:26 +08:00
this.baseurl = baseurl
2024-01-23 11:49:47 +08:00
this.region = Number(uni.getStorageSync('region'))
2023-11-09 15:41:55 +08:00
if (this.region == 1) {
2023-11-13 11:31:54 +08:00
dzrecord(uni.getStorageSync('userinfo').cardNo).then(res => {
2023-11-09 15:41:55 +08:00
res.data.forEach(e => {
e.existReport = Number(e.existReport)
})
this.list = res.data
})
} else if (this.region == 2) {
2023-11-13 11:31:54 +08:00
dyrecord(uni.getStorageSync('userinfo').cardNo).then(res => {
2023-11-09 15:41:55 +08:00
res.data.forEach(e => {
e.existReport = Number(e.existReport)
})
this.list = res.data
})
}
},
methods: {
2023-11-13 11:52:09 +08:00
// 东营获取驿站报告接口http://218.58.213.15:8009/fd/sh05/report/download/{reportId}
// 德州获取驿站报告接口http://112.6.122.71:8009/fd/sh05/report/download/{reportId}
2023-11-09 15:41:55 +08:00
lookReport(item) {
if (this.region == 1) {
uni.downloadFile({
2024-01-22 22:11:26 +08:00
url: `${this.baseurl}/fado/dz/sh05/report/download/${item.reportId}`,
2023-11-09 15:41:55 +08:00
success: function(res) {
console.log(res)
var filePath = res.tempFilePath;
uni.openDocument({
filePath: filePath,
showMenu: true,
fileType: 'pdf',
success: function(resp) {
console.log(resp)
console.log('打开文档成功');
}
});
}
});
} else if (this.region == 2) {
uni.downloadFile({
2024-01-22 22:11:26 +08:00
url: `${this.baseurl}/fado/dy/sh05/report/download/${item.reportId}`,
2023-11-09 15:41:55 +08:00
success: function(res) {
console.log(res)
var filePath = res.tempFilePath;
uni.openDocument({
filePath: filePath,
fileType: 'pdf',
showMenu: true,
success: function(resp) {
console.log(resp)
console.log('打开文档成功');
}
});
}
});
}
},
}
}
</script>
<style lang="scss">
.app {
.item {
height: 200rpx;
width: 96%;
background-color: #fff;
border-radius: 5rpx;
margin: 20rpx auto 0;
position: relative;
overflow: hidden;
.btn2 {
/* 左上角飘带 */
background-color: #A4A0A0;
/* 左上角飘带的背景颜色 */
overflow: hidden;
white-space: nowrap;
/* 文字不换行*/
position: absolute;
/* 绝对定位 */
right: -60rpx;
top: 20rpx;
transform: rotate(45deg);
/* 旋转45°*/
box-shadow: 0 0 10rpx #888;
/* 飘带的阴影*/
}
.btn2 span {
border: 1rpx solid #A4A0A0;
color: #fff;
display: block;
font: bold 100% 'Helvetica Neue', Helvetica, Arial, sans-serif;
margin: 1rpx 0;
padding: 10rpx 50rpx;
text-align: center;
text-shadow: 0 0 5rpx #444;
}
.btn {
/* 左上角飘带 */
background-color: #FFA115;
/* 左上角飘带的背景颜色 */
overflow: hidden;
white-space: nowrap;
/* 文字不换行*/
position: absolute;
/* 绝对定位 */
right: -60rpx;
top: 20rpx;
transform: rotate(45deg);
/* 旋转45°*/
box-shadow: 0 0 10rpx #888;
/* 飘带的阴影*/
}
.btn span {
border: 1rpx solid #FFA115;
color: #fff;
display: block;
font: bold 100% 'Helvetica Neue', Helvetica, Arial, sans-serif;
margin: 1rpx 0;
padding: 10rpx 50rpx;
text-align: center;
text-shadow: 0 0 5rpx #444;
}
.name {
2024-01-22 22:11:26 +08:00
font-size: 40rpx;
margin: 40rpx 0 0 20rpx;
2023-11-09 15:41:55 +08:00
}
.time {
margin: 20rpx 0 0 20rpx;
}
}
}
2023-11-13 11:52:09 +08:00
</style>