Files
app-govern/pages/index/comp/steadyState.vue

347 lines
12 KiB
Vue
Raw Normal View History

2026-03-17 14:00:55 +08:00
<template>
<view class="dateReport">
2026-04-13 10:12:04 +08:00
<!-- {{ height }} -->
2026-04-17 08:50:07 +08:00
<view class="pd20">
2026-03-17 14:00:55 +08:00
<uni-segmented-control
:current="curSub"
class="subsection"
active-color="#376cf3"
:values="subsectionList"
@clickItem="sectionChange"
/>
2026-04-17 08:50:07 +08:00
</view>
2026-03-30 08:43:13 +08:00
<view class="filterCriteria">
<!-- 筛选条件 -->
2026-04-17 08:50:07 +08:00
<Cn-filterCriteria @select="select" :singleChoice="true" :showDatetime="curSub == 0"> </Cn-filterCriteria>
2026-03-17 14:00:55 +08:00
</view>
2026-03-30 08:43:13 +08:00
2026-03-17 14:00:55 +08:00
<!-- 卡片 -->
2026-03-30 08:43:13 +08:00
<scroll-view
scroll-y="true"
@refresherrefresh="refresherrefresh"
:refresher-triggered="triggered"
refresher-enabled="true"
class="event-list mt20"
2026-04-01 10:00:04 +08:00
:style="{ height: 'calc(100vh - ' + (navHeight + height) + 'px)', overflow: 'auto' }"
2026-03-17 14:00:55 +08:00
>
<!-- 循环渲染事件项 -->
2026-03-30 08:43:13 +08:00
<uni-card class="event-item" :class="item.type" v-for="(item, index) in store.data" :key="index">
2026-03-17 14:00:55 +08:00
<!-- 头部图标 + 信息 + 操作 -->
<view class="event-header">
2026-04-17 08:50:07 +08:00
<view class="event-icon">
<!-- 动态图标根据类型切换 -->
<!-- <uni-icons
custom-prefix="iconfont"
type="icon-kouanjiancedian"
size="40"
color="#E6A23C"
></uni-icons> -->
<Cn-icon-transient :name="`报告`" />
<view class="badge1" v-if="item.isRead == 0"> </view>
</view>
2026-03-17 14:00:55 +08:00
<view class="event-info">
<view class="event-title">
2026-03-30 08:43:13 +08:00
<text class="event-id">{{ item.lineName }}</text>
2026-04-17 08:50:07 +08:00
<!-- <view class="event-tags"
2026-03-30 08:43:13 +08:00
>{{ selectValue.report == 0 ? item.startTime : item.startTime + '至' + item.endTime }}
2026-04-17 08:50:07 +08:00
</view> -->
</view>
<view class="event-desc">
<text
>统计时间{{
curSub == 0 ? item.startTime : item.startTime + ' 至 ' + item.endTime
}}</text
>
</view>
</view>
<view class="event-action" v-if="curSub == 0 ? monthFlag : item.endTime != thisMonth01">
<view class="iconText" @click="download(item)"
><uni-icons type="arrow-down" color="#fff" size="16"></uni-icons>
2026-03-17 14:00:55 +08:00
</view>
</view>
</view>
<!-- 详情区域 -->
2026-04-17 08:50:07 +08:00
<view class="event-detail textBox" @touchmove.stop>
<text v-if="curSub == 0 ? monthFlag : item.endTime != thisMonth01">{{
item.overLimitDesc == '' ? '该监测点暂无指标越限' : item.overLimitDesc
}}</text>
<text v-else>数据未生成暂不支持下载</text>
2026-03-17 14:00:55 +08:00
</view>
2026-03-30 08:43:13 +08:00
<!-- <view class="downloadReport" @click="download">
2026-03-17 14:00:55 +08:00
<uni-icons type="download" size="16" color="#376cf3"></uni-icons>下载报告
2026-03-30 08:43:13 +08:00
</view> -->
2026-03-17 14:00:55 +08:00
</uni-card>
2026-03-30 08:43:13 +08:00
<uni-load-more
v-if="store.status == 'loading' || (store.data && store.data.length > 0)"
:status="store.status"
></uni-load-more>
<Cn-empty v-else style="top: 20%"></Cn-empty>
</scroll-view>
2026-03-17 14:00:55 +08:00
</view>
</template>
<script>
2026-03-30 08:43:13 +08:00
import list from '@/common/js/list'
import { downloadHarmonicReport } from '@/common/api/report.js'
2026-03-17 14:00:55 +08:00
export default {
components: {},
props: {
indexList: {
type: Array,
default: () => [],
},
total: {
type: Number,
default: 0,
},
navHeight: {
type: Number,
default: 0,
},
},
2026-03-30 08:43:13 +08:00
mixins: [list],
2026-03-17 14:00:55 +08:00
data() {
return {
status: 'noMore',
curSub: 0,
subsectionList: ['周报', '月报'],
2026-03-30 08:43:13 +08:00
thisSelectValue: {},
triggered: true,
height: 0,
2026-04-17 08:50:07 +08:00
thisMonth01: '',
monthFlag: true,
2026-03-17 14:00:55 +08:00
}
},
created() {},
2026-03-30 08:43:13 +08:00
mounted() {
2026-04-17 08:50:07 +08:00
this.thisMonth01 = this.$util.getToday().slice(0, -3) + '-01'
this.monthFlag = this.$util.getToday() != this.$util.getToday().slice(0, -3) + '-01'
2026-04-13 10:12:04 +08:00
// this.setHeight()
2026-03-30 08:43:13 +08:00
},
2026-03-17 14:00:55 +08:00
methods: {
2026-03-30 08:43:13 +08:00
setHeight() {
uni.createSelectorQuery()
.select('.filterCriteria')
.boundingClientRect((rect) => {
//
// #ifdef H5
2026-04-17 08:50:07 +08:00
this.height = rect?.height + 140 || 0
2026-03-30 08:43:13 +08:00
// #endif
// #ifdef APP-PLUS
2026-04-17 08:50:07 +08:00
this.height = rect?.height + 70 || 0
2026-03-30 08:43:13 +08:00
// #endif
})
.exec()
},
2026-03-17 14:00:55 +08:00
sectionChange(index) {
this.curSub = index.currentIndex
2026-04-17 08:50:07 +08:00
this.init()
2026-03-17 14:00:55 +08:00
},
2026-03-30 08:43:13 +08:00
init() {
if (this.selectValue.lineId == '') return
this.store = this.DataSource('/cs-report-boot/csAppReport/reportList')
2026-04-17 08:50:07 +08:00
// this.store.params.pageSize = 10000
this.store.params.timeType = this.curSub //this.selectValue.report
2026-03-30 08:43:13 +08:00
this.store.params.engineerId = this.selectValue.engineeringId
this.store.params.projectId = this.selectValue.projectId
this.store.params.devId = this.selectValue.deviceId
this.store.params.lineId = this.selectValue.lineId
2026-04-17 08:50:07 +08:00
if (this.curSub == 0) {
this.store.params.time = this.selectValue.date
} else {
this.store.params.time = this.selectValue.range + '-01'
}
2026-03-30 08:43:13 +08:00
// this.store.params.startTime = this.selectValue.range[0]
// this.store.params.endTime = this.selectValue.range[1]
this.store.loadedCallback = () => {}
this.store.reload()
},
select(value) {
this.selectValue = value
2026-04-17 08:50:07 +08:00
setTimeout(() => {
2026-03-30 08:43:13 +08:00
this.setHeight()
2026-04-13 10:12:04 +08:00
}, 200)
this.init()
2026-03-30 08:43:13 +08:00
},
// 下载
download(item) {
uni.showLoading({
title: '下载中,请稍等...',
mask: true,
})
downloadHarmonicReport({
devId: this.selectValue.deviceId,
endTime: item.endTime,
engineerId: this.selectValue.engineeringId,
lineId: this.selectValue.lineId,
list: [],
projectId: this.selectValue.projectId,
startTime: item.startTime,
time: '',
timeType: this.selectValue.report,
2026-04-01 10:00:04 +08:00
})
.then((res) => {
// 下载文件资源到本地
uni.downloadFile({
url: res.data, // 后端返回的线上文件路径
success: function (res) {
if (res.statusCode === 200) {
// 文件到本地
uni.saveFile({
tempFilePath: res.tempFilePath, //临时路径
success: function (data) {
var savedFilePath = data.savedFilePath
// 在app端执行
// #ifdef APP-PLUS
let osname = plus.os.name
// 如果是安卓的话弹出提示
2026-03-30 08:43:13 +08:00
2026-04-01 10:00:04 +08:00
uni.showToast({
icon: 'success',
mask: true,
title: '下载成功!',
duration: 1000,
2026-03-30 08:43:13 +08:00
})
2026-04-01 10:00:04 +08:00
// #endif
//ios手机直接打开文件手动存储文件到手机Android手机从根目录创建文件夹保存文件并改名
setTimeout(() => {
//打开文档查看
uni.openDocument({
filePath: data.savedFilePath,
success: function (ress) {
console.log('成功打开文件')
},
fail() {
console.log('打开文件失败')
},
})
}, 500)
},
})
console.log('下载成功')
} else {
uni.showToast({
icon: 'none',
mask: true,
title: '下载失败!',
duration: 1000,
})
}
},
fail: function (res) {},
})
})
.catch((err) => {
uni.showToast({
icon: 'none',
mask: true,
title: err.message,
duration: 1000,
})
2026-03-30 08:43:13 +08:00
})
},
// 下拉
refresherrefresh() {
this.triggered = true
uni.startPullDownRefresh()
setTimeout(() => {
this.triggered = false
}, 500)
2026-03-17 14:00:55 +08:00
},
},
computed: {},
watch: {},
}
</script>
<style lang="scss" scoped>
@import '@/pages/message1/index.scss';
.event-title {
justify-content: space-between;
}
.event-tags {
2026-03-30 08:43:13 +08:00
display: flex;
font-size: 27rpx !important ;
2026-04-01 10:00:04 +08:00
line-height: 50rpx;
2026-03-17 14:00:55 +08:00
}
.event-detail {
2026-03-30 08:43:13 +08:00
font-size: 25rpx !important;
// display: grid;
// grid-template-columns: 1fr 1fr;
2026-03-17 14:00:55 +08:00
}
.downloadReport {
width: 100%;
background: #376cf320;
height: 60rpx;
line-height: 60rpx;
color: #376cf3;
font-weight: 600;
border-radius: 15rpx;
margin-top: 10rpx;
display: flex;
justify-content: center;
}
2026-03-30 08:43:13 +08:00
.filterCriteria {
.nav {
background-color: #fff;
}
.choose1 {
background-color: #fff;
padding: 0 20rpx;
display: flex;
justify-content: space-between;
/deep/ .uni-checkbox-input {
width: 30rpx;
height: 30rpx;
}
font-size: 26rpx;
}
}
/deep/ .uni-scroll-view-refresher {
display: none;
}
.iconText {
width: 45rpx;
height: 45rpx;
border-radius: 50%;
background-color: $uni-theme-color;
text-align: center;
2026-04-17 08:50:07 +08:00
line-height: 40rpx;
}
.segmented-control {
flex: 1;
margin-right: 24rpx;
height: 60rpx;
}
/* 列表容器 */
.event-list {
/* 头部:图标 + 信息 + 操作 */
.event-header {
display: flex;
align-items: center;
margin-bottom: 10rpx;
}
/* 图标区域(按类型区分背景色) */
.event-icon {
background-color: #376cf320;
}
.event-tags {
font-size: 24rpx;
}
}
.textBox {
// @touchmove.stop
max-height: 110rpx;
overflow-y: auto;
2026-03-30 08:43:13 +08:00
}
2026-03-17 14:00:55 +08:00
</style>