FenXiNspUniapp/packDetail/pages/analysis/index.vue

1034 lines
23 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="container">
<!-- <image src="../../static/sjfx.png" mode="" class="bgimg"></image> -->
<view class="pj">
<view class="pjtitle">
面源污染治理效果评价
</view>
<view class="ybecharts">
<image src="../../static/data_bg_img.png" mode=""></image>
<view class="ybechartstext">
{{pjnr}}
</view>
</view>
<view class="bot3">
<view class="bot3_left" v-for="(item,index) in pjlist.slice(0,3)" :key="index">
<view class="bfb">
{{item.detailValue}}
</view>
<view class="bfbname">
{{item.detailCode}}
</view>
</view>
</view>
</view>
<view class="qst">
<view class="qsttitle">
重要污染物趋势图
</view>
<view class="sxbox wrwCov">
<view class="leftsxbox">
<picker @change="bindPickerChange" :value="index" :range="array">
<view class="uni-input">{{array[index]}}
<image src="../../static/data_btn_sanjiao_xia.png"></image>
</view>
</picker>
</view>
<view class="rightsxbox">
<picker mode="date" :value="dateqs" :start="startDate" :end="endDate" @change="bindDateqsChange">
<view class="uni-input">{{dateqs}} <image src="../../static/data_btn_sanjiao_xia.png"></image></view>
</picker>
</view>
</view>
<!-- 年月日选择器 -->
<view class="uni-form-item uni-column">
<radio-group class="radio-group" @change="radioChange">
<label class="radio-label" v-for="(item, index) in timList" :key="item.value">
<radio :value="item.value" :checked="index === current" class="radio-item" />
<view class="radio-text">{{item.name}}</view>
</label>
</radio-group>
</view>
<view class="qstcontent">
<qiun-data-charts
type="line"
:opts="opts"
:chartData="chartData"
:enableScroll="true"
:ontouch="true"
canvas2d
/>
</view>
</view>
<view class="znyj">
<view class="znyj_top">
<view class="znyjtop_left">
智能预警
</view>
<view class="znyjtop_right">
预警次数 <span class="numbers">{{cutMoneyFiter(total) || 0}}</span>次
</view>
</view>
<view class="sxbox">
<view class="leftsxbox">
<picker @change="bindPickerChange1" :value="index1" :range="array1">
<view class="uni-input1">{{array1[index1]}}
<image src="../../static/data_btn_sanjiao_xia.png"></image>
</view>
</picker>
</view>
<view class="rightsxbox">
<picker mode="date" fields="year" :value="date" :start="startDate" :end="endDate"
@change="bindDateChange">
<view class="uni-input2">{{date}}
<image src="../../static/data_btn_sanjiao_xia.png"></image>
</view>
</picker>
</view>
</view>
<view style="width: 100%;height: 12rpx;border-bottom: 2rpx solid #f6f8f8;"></view>
<view class="list_item_bot">
<scroll-view style="height: 530rpx;" scroll-y="true" class="scroll-Y" @scrolltolower="lower">
<view class="lists_item" v-for="(item,index) in list" :key="index">
<view class="litCovv">
<text class="yujTit">{{item.fullDeviceName?item.fullDeviceName:''}}</text>
<view class="yujTwo">
<text class="yujxiangm">{{item.alertContent[0].name?item.alertContent[0].name:''}}</text>
<text class="yujdanw">{{item.alertContent[0].val}}{{item.alertContent[0].unit}}</text>
<text class="yujiTime">{{item.datetime}}</text>
</view>
</view>
</view>
<view class="load">
<uni-load-more :status="loadStatus"></uni-load-more>
</view>
</scroll-view>
</view>
</view>
<view class="pagebot">
</view>
</view>
</template>
<script>
import uniEcCanvas from '../../components/uni-ec-canvas/uni-ec-canvas.vue'
import * as echarts from '../../components/uni-ec-canvas/echarts.js'
export default {
components: {
uniEcCanvas,
},
data() {
const currentDate = this.getDate({
format: true
})
return {
height: 0,
scorllheight: 0,
zt: '',
date: new Date().getFullYear(),
array: [],
index: 0, // 改为0默认选择第一个
index1: 0,
array1: [],
arrays: [],
list: [],
tabList: ['站点名称', '告警指标', '指标值', '告警时间'],
pjlist: [],
chartData: {},
opts: {
color: ["#1890FF","#91CB74","#FAC858","#EE6666","#73C0DE","#3CA272","#FC8452","#9A60B4","#ea7ccc"],
padding: [15,10,0,15],
dataLabel: false,
dataPointShape: false,
enableScroll: false,
legend: {},
xAxis: {
disabled: false,
gridType: 'dash',
dashLength: 2,
},
yAxis: {
gridType: "dash",
dashLength: 2,
data: [
{
min: 0,
max: 150
}
]
},
extra: {
line: {
type: "curve",
width: 2,
activeType: "hollow",
linearType: "custom",
onShadow: true,
animation: "horizontal"
}
}
},
pjnr: '',
pageNo: 1,
pageSize: 9,
allNum: '',
isLastpage: '',
intervalId: null,
loadStatus: 'more',
isLoadMore: false,
show: false,
show1: false,
top: 0,
total: 0,
yearStr: null,
stationName1: '',
stationCode1: null,
stationCode: '', // 趋势图站点编码
arrays1: [],
zxtdata: [],
timList: [{
value: 'yearMonth',
name: '年',
checked: 'true'
},
{
value: 'monthDays',
name: '月'
},
{
value: 'dayhours',
name: '日'
},
],
current: 0,
dateqs: new Date().getFullYear().toString(), // 改为字符串
datetwo: currentDate,
riqinumber: 'yearMonth',
startDate: '', // 添加起始日期
endDate: '', // 添加结束日期
}
},
onLoad() {
uni.getSystemInfo({
success: res => {
var pxToRpxScale = 750 / res.windowWidth
var ktxStatusHeight = res.statusBarHeight * pxToRpxScale
var navigationHeight = 44 * pxToRpxScale
this.height = res.windowHeight * pxToRpxScale
this.scorllheight = this.height
}
});
// 设置日期范围
const currentYear = new Date().getFullYear();
this.startDate = `${currentYear - 10}-01-01`;
this.endDate = `${currentYear + 10}-12-31`;
// 先获取评价数据
this.getpj()
// 获取站点列表(内部会调用趋势图)
this.importWyw()
// 获取预警设备列表
this.getazsurvMulchRecord()
// 获取预警列表
this.getyjList()
},
methods: {
// 获取站点列表
importWyw() {
this.array = []
this.arrays = []
this.arrays1 = [{
label: '全部监测设备',
value: ''
}]
this.$http.get('/applet/survStationInfo/list').then(res => {
const dataList = res.data.data || []
for (var i = 0; i < dataList.length; i++) {
this.arrays.push({
label: dataList[i].stationName,
value: dataList[i].stationCode
})
this.arrays1.push({
label: dataList[i].stationName,
value: dataList[i].stationCode
})
this.array.push(dataList[i].stationName)
}
// 设置默认第一个站点
if (this.array.length > 0) {
this.stationCode = this.arrays[0].value
// 调用趋势图获取数据
this.qushicov()
} else {
console.warn('没有获取到站点数据')
}
}).catch(err => {
console.error('获取站点列表失败:', err)
})
},
// 获取监测站点设备数据
getazsurvMulchRecord() {
this.arrays = []
this.array1 = ['全部监测设备']
this.arrays1 = [{
label: '全部监测设备',
value: ''
}]
this.$http.get('/applet/survDeviceDeploy/survDeviceList').then(res => {
const dataList = res.data.data || []
for (var i = 0; i < dataList.length; i++) {
this.arrays.push({
label: dataList[i].fullDeviceName,
value: dataList[i].id
})
this.arrays1.push({
label: dataList[i].fullDeviceName,
value: dataList[i].id
})
this.array1.push(dataList[i].fullDeviceName)
}
}).catch(err => {
console.error('获取设备列表失败:', err)
})
},
// 获取预警列表
getyjList() {
let params = {
pageNo: this.pageNo,
pageSize: this.pageSize,
deployId: this.stationCode1,
yearStr: this.yearStr
}
uni.showLoading({
title: '加载中'
});
this.list = []
this.$http.get('/applet/wxclient/alertRecord', {
params: params
}).then(res => {
if (res.data.code == 0) {
var data = res.data.data.records || []
for (var i = 0; i < data.length; i++) {
data[i].times = data[i].alertTime.replace(" ", ":").replace(/\:/g, "-").split("-");
data[i].nian = data[i].times[0];
data[i].yue = data[i].times[1] - 1;
data[i].ri = data[i].times[2];
data[i].shi = data[i].times[3];
data[i].fen = data[i].times[4];
data[i].miao = data[i].times[5];
data[i].datetime = data[i].yue + '-' + data[i].ri + ' ' + data[i].shi + ':' + data[i].fen
if (data[i].alertContent && data[i].alertContent.indexOf('监测数据名称:') != -1) {
data[i].alertContent = data[i].alertContent.replace('监测数据名称:', '')
}
}
this.list = this.list.concat(data)
this.total = res.data.data.total || 0
if (this.total != 0) {
this.allNum = Number(this.total) / Number(this.pageSize) + '';
if (this.allNum.indexOf('.') == -1) {
this.allNum = this.allNum;
} else {
this.allNum = parseInt(Number(this.allNum) + 1);
}
if (this.pageNo == this.allNum) {
this.isLastpage = true;
this.loadStatus = 'nomore'
} else {
this.isLastpage = false;
this.loadStatus = 'more'
}
} else {
this.isLastpage = true;
this.loadStatus = 'nomore'
}
}
uni.hideLoading();
this.isRefresher = false
}).catch(err => {
uni.hideLoading();
console.error('获取预警列表失败:', err)
})
},
// 分页加载
lower() {
if (this.isLastpage) {
return
}
clearInterval(this.intervalId);
var num = 1;
this.intervalId = setInterval(() => {
num = num + 1;
}, 1000)
this.pageNo = this.pageNo + 1;
let params = {
pageNo: this.pageNo,
pageSize: this.pageSize,
deployId: this.stationCode1,
yearStr: this.yearStr
}
this.$http.get('/applet/wxclient/alertRecord', {
params: params
}).then(res => {
if (res.data.code == 0) {
var data = res.data.data.records || []
for (var i = 0; i < data.length; i++) {
data[i].times = data[i].alertTime.replace(" ", ":").replace(/\:/g, "-").split("-");
data[i].nian = data[i].times[0];
data[i].yue = data[i].times[1] - 1;
data[i].ri = data[i].times[2];
data[i].shi = data[i].times[3];
data[i].fen = data[i].times[4];
data[i].miao = data[i].times[5];
data[i].datetime = data[i].yue + '-' + data[i].ri + ' ' + data[i].shi + ':' + data[i].fen
if (data[i].alertContent && data[i].alertContent.indexOf('监测数据名称:') != -1) {
data[i].alertContent = data[i].alertContent.replace('监测数据名称:', '')
}
}
this.list = this.list.concat(data)
if (this.total != 0) {
if (this.pageNo == this.allNum) {
this.isLastpage = true;
this.loadStatus = 'nomore'
} else {
this.isLastpage = false;
this.loadStatus = 'more'
}
} else {
this.isLastpage = true;
this.loadStatus = 'nomore'
}
}
}).catch(err => {
console.error('加载更多失败:', err)
})
},
// 获取评价
getpj() {
this.$http.post('/applet/wxclient/displayInfo?infoType=' + 'effect_assess').then(res => {
let data = res.data.data.effect_assess.detailList || []
this.pjlist = data
for (var i = 0; i < data.length; i++) {
if (data[i].detailCode == '综合评价') {
this.pjnr = data[i].detailValue
}
}
}).catch(err => {
console.error('获取评价数据失败:', err)
})
},
// 选择年月日
radioChange(e) {
this.riqinumber = e.detail.value
this.current = this.timList.findIndex(item => item.value === e.detail.value)
// 重新调用趋势图
this.qushicov()
},
// 趋势时间切换
bindDateqsChange(e) {
let selectedDate = e.detail.value;
// 根据选择的维度格式化日期
if (this.riqinumber === 'monthDays') {
this.dateqs = selectedDate.slice(0, 7); // YYYY-MM
} else if (this.riqinumber === 'yearMonth') {
this.dateqs = selectedDate.slice(0, 4); // YYYY
} else {
this.dateqs = selectedDate; // YYYY-MM-DD
}
// 重新获取趋势数据
this.qushicov();
},
// 趋势接口
qushicov() {
// 检查是否有站点编码
if (!this.stationCode) {
console.warn('站点编码为空,无法获取趋势数据')
return
}
let data = {
summrayMode: this.riqinumber,
startTime: this.dateqs,
stationCode: this.stationCode,
}
uni.showLoading({
title: '加载趋势数据...'
});
this.$http.post('/applet/survDeviceDeploy/waterIntegrateStatistic', data).then(iem => {
let lynum = iem.data.data
setTimeout(() => {
let categories = [];
let displayCategories = [];
let series = [];
let allValues = [];
if (lynum.tableHead && lynum.tableHead.length > 0) {
categories = lynum.tableIndex || [];
if (categories.length > 0) {
const first = categories[0];
const middle = categories[Math.floor(categories.length / 2)];
const last = categories[categories.length - 1];
displayCategories = categories.map((item, index) => {
if (index === 0 || index === Math.floor(categories.length / 2) || index === categories.length - 1) {
return item;
}
return '';
});
}
lynum.tableHead.forEach((header, index) => {
const seriesData = lynum.tableData2.map(row => {
const value = row[index] === "0" ? 0 : parseFloat(row[index]) || 0;
allValues.push(value);
return value;
});
series.push({
name: header.eleDesc || header,
data: seriesData
});
});
// 动态计算Y轴范围
if (allValues.length > 0) {
const maxValue = Math.max(...allValues);
const minValue = Math.min(...allValues);
const padding = maxValue * 0.1;
const yAxisMax = maxValue + padding;
const yAxisMin = Math.max(0, minValue - padding);
this.opts = {
...this.opts,
yAxis: {
gridType: "dash",
dashLength: 2,
data: [
{
min: yAxisMin,
max: yAxisMax
}
]
}
};
}
}
let res = {
categories: displayCategories,
series: series
};
this.chartData = JSON.parse(JSON.stringify(res));
uni.hideLoading();
}, 500);
}).catch(err => {
uni.hideLoading();
console.error('获取趋势数据失败:', err)
// 显示错误提示
uni.showToast({
title: '获取趋势数据失败',
icon: 'none'
})
})
},
// 折线图切换站点
bindPickerChange: function(e) {
this.index = e.detail.value
this.stationName = this.array[this.index]
for (var i = 0; i < this.arrays.length; i++) {
if (this.stationName == this.arrays[i].label) {
this.stationCode = this.arrays[i].value
break
}
}
// 切换站点后重新获取趋势数据
this.qushicov()
},
// 预警切换站点
bindPickerChange1: function(e) {
this.index1 = e.detail.value
this.stationName1 = this.array1[this.index1]
for (var i = 0; i < this.arrays.length; i++) {
if (this.stationName1 == this.arrays1[i].label) {
this.stationCode1 = this.arrays1[i].value
break
}
}
if (this.stationName1 == '全部监测设备') {
this.stationCode1 = null
}
this.pageNo = 1
this.getyjList()
},
// 预警切换日期
bindDateChange: function(e) {
this.yearStr = e.detail.value
this.date = e.detail.value
this.pageNo = 1
this.getyjList()
},
getDate(type) {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (type === 'start') {
year = year - 10;
} else if (type === 'end') {
year = year + 10;
}
month = month > 9 ? month : '0' + month;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
},
// 格式化数字(如果组件中有使用)
cutMoneyFiter(val) {
if (!val) return 0
return val
}
}
}
</script>
<style lang="scss">
page {
background-color: #0f6efe;
}
.container {
padding: 0 32rpx;
box-sizing: border-box;
overflow-y: scroll;
overflow-x: hidden;
}
.bgimg {
width: 100%;
height: 2022rpx;
}
.pj {
background: #FFFFFF;
border-radius: 34rpx;
padding: 41rpx 31rpx 33rpx;
}
.pjtitle {
font-size: 32rpx;
font-family: Source Han Sans SC;
font-weight: bold;
color: #2F3841;
margin-bottom: 31rpx;
}
.ybecharts {
width: 100%;
height: 279rpx;
margin-bottom: 38rpx;
display: flex;
justify-content: center;
position: relative;
}
.ybecharts image {
width: 90%;
height: 100%;
}
.ybechartstext {
color: #2DC37B;
font-size: 60rpx;
position: absolute;
bottom: 13rpx;
left: 50%;
transform: translateX(-50%);
}
.bot3 {
width: 100%;
display: flex;
justify-content: space-between;
}
.bot3_left {
border-right: 2rpx solid #E6E9EF;
display: flex;
flex-direction: column;
align-items: center;
width: 33%;
}
.bot3_left:last-child {
border: none;
}
.bfb {
font-size: 42rpx;
font-family: DIN Next LT Pro;
font-weight: 500;
color: #184C9A;
}
.bfbname {
font-size: 24rpx;
font-family: Source Han Sans SC;
font-weight: 400;
color: #9CA9BE
}
.qst {
background: #FFFFFF;
border-radius: 34rpx;
padding-top: 43rpx;
padding-bottom: 34rpx;
margin-top: 26rpx;
}
.qsttitle {
font-size: 32rpx;
font-family: Source Han Sans SC;
font-weight: bold;
color: #2F3841;
padding-left: 33rpx;
}
.qstcontent {
height: 400rpx;
width: 98%;
padding-left: 20rpx;
}
.uni-ec-canvas {
width: 100%;
height: 500rpx;
}
.search {
height: 72rpx;
padding: 0 32rpx 0;
margin-top: 32rpx;
}
.wrwCov{
width: 94%!important;
margin: 0 auto;
margin-top: 20rpx;
}
.uni-input {
width: 100%;
height: 72rpx;
font-size: 28rpx;
font-family: Source Han Sans SC;
font-weight: 500;
color: #667482;
background: #F6F6F6;
border-radius: 16rpx;
display: flex;
justify-content: space-between;
align-items: center;
padding: 22rpx 25rpx;
}
.uni-input image {
width: 44rpx;
height: 44rpx;
}
.znyj {
padding: 43rpx 31rpx 43rpx 32rpx;
background: #FFFFFF;
border-radius: 34rpx;
margin-top: 26rpx;
}
.znyj_top {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 32rpx;
}
.znyjtop_left {
font-size: 32rpx;
font-family: Source Han Sans SC;
font-weight: bold;
color: #2F3841;
}
.znyjtop_right {
font-size: 24rpx;
font-family: Source Han Sans SC;
font-weight: 500;
color: #B3C1D1;
}
.numbers {
font-size: 34rpx;
font-family: DIN Next LT Pro;
font-weight: 500;
color: #FF4343;
margin-left: 9rpx;
margin-right: 11rpx;
}
.sxbox {
width: 100%;
display: flex;
justify-content: space-between;
}
.leftsxbox {
width: 60%;
}
.rightsxbox {
width: 35%;
}
.uni-input1 {
width: 100%;
height: 72rpx;
background: #F6F6F6;
border-radius: 16rpx;
font-size: 24rpx;
font-family: Source Han Sans SC;
font-weight: 500;
color: #667482;
padding: 22rpx 24rpx;
display: flex;
justify-content: space-between;
align-items: center;
}
.uni-input1 image {
width: 44rpx;
height: 44rpx;
}
.uni-input2 {
width: 100%;
height: 72rpx;
background: #F6F6F6;
border-radius: 16rpx;
font-size: 24rpx;
font-family: Source Han Sans SC;
font-weight: 500;
color: #667482;
padding: 22rpx 24rpx;
display: flex;
justify-content: space-between;
align-items: center;
}
.uni-input2 image {
width: 44rpx;
height: 44rpx;
}
.scrolltop {
padding: 34rpx 0rpx 16rpx 0rpx;
display: flex;
justify-content: space-between;
border-bottom: 2rpx solid #F6F8FB;
}
.tabitem {
font-size: 26rpx;
font-family: Source Han Sans SC;
font-weight: 500;
color: #2F3841;
display: inline-block;
padding-bottom: 26rpx;
}
.tabitem:first-child {
width: 31%;
}
.tabitem:nth-child(2) {
width: 27%;
}
.tabitem:nth-child(3) {
width: 19%;
}
.tabitem:nth-child(4) {
flex: 1
}
.scroll-Y {
box-sizing: border-box;
}
.lists_item {
padding-top: 35rpx;
box-sizing: border-box;
.litCovv{
width: 100%;
height: 120rpx;
border-radius: 16rpx;
background-color: #f6f6f6;
overflow: hidden;
.yujTit{
display: block;
margin-left: 2%;
margin-top: 10rpx;
font-size: 28rpx;
color: #333;
margin-bottom: 10rpx;
font-weight: 500;
}
.yujTwo{
width: 96%;
height: 60rpx;
line-height: 60rpx;
margin-left: 2%;
overflow: hidden;
.yujxiangm{
display: inline-block;
padding: 6rpx 10rpx;
background-color: #22BB8A;
height: 30rpx;
line-height: 30rpx;
color: #fff;
font-size: 24rpx;
border-radius: 10rpx;
}
.yujdanw{
height: 50rpx;
line-height: 50rpx;
color:#FF4242;
font-size: 28rpx;
margin-left: 3%;
}
.yujiTime{
font-size: 16rpx;
color: #999;
float: right;
height: 50rpx;
line-height: 50rpx;
font-size: 24rpx;
}
}
}
}
.jczbs {
width: 32%;
font-size: 24rpx;
font-family: Source Han Sans SC;
font-weight: 400;
color: #667482;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.zbz {
width: 27%;
font-size: 24rpx;
font-family: DIN Next LT Pro;
font-weight: 400;
padding-right: 10rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.sbsj {
font-size: 24rpx;
font-family: Source Han Sans SC;
font-weight: 400;
color: #667482;
flex: 1;
}
.szqss {
width: 24rpx;
}
.zbzs {
width: 19%;
font-size: 24rpx;
font-family: DIN Next LT Pro;
font-weight: 400;
padding-right: 10rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.load {
text-align: center;
color: #c6c6c6;
}
.pagebot {
height: 100rpx;
}
// 选择年月日
.radio-group {
display: flex;
justify-content: space-around;
border-radius: 20rpx;
padding: 8rpx;
.radio-label {
display: flex;
align-items: center;
padding: 12rpx 24rpx;
border-radius: 16rpx;
transition: all 0.3s ease;
flex: 1;
justify-content: center;
margin: 0 4rpx;
&:active {
background: rgba(15, 110, 254, 0.1);
}
&.checked {
background: #0f6efe;
.radio-text {
color: #ffffff;
font-weight: 600;
}
}
.radio-item {
transform: scale(0.8);
margin-right: 8rpx;
&[checked] {
color: #ffffff;
}
}
.radio-text {
font-size: 24rpx;
font-family: Source Han Sans SC;
font-weight: 500;
color: #667482;
transition: color 0.3s ease;
white-space: nowrap;
}
}
}
.qstim{
width: 40%;
display: block;
margin: 0 auto;
margin-top: 20rpx;
}
.qstim image {
width: 44rpx;
height: 44rpx;
}
</style>