|
|
@@ -16,21 +16,21 @@
|
|
|
<el-col :span="8" class="label-col">
|
|
|
<div class="label">实时高程:</div>
|
|
|
<div class="value">
|
|
|
- <span>{{ swInfo.realTimeElevation }}</span
|
|
|
+ <span>{{ swInfo.realTimeElevation !== undefined ? parseFloat(swInfo.realTimeElevation).toFixed(2) : '' }}</span
|
|
|
><span>m</span>
|
|
|
</div>
|
|
|
</el-col>
|
|
|
<el-col :span="8" class="label-col">
|
|
|
<div class="label">昨日雨量:</div>
|
|
|
<div class="value">
|
|
|
- <span>{{ swInfo.precipitationYesterday }}</span
|
|
|
+ <span>{{ swInfo.precipitationYesterday !== undefined ? parseFloat(swInfo.precipitationYesterday).toFixed(2) : '' }}</span
|
|
|
><span>mm</span>
|
|
|
</div>
|
|
|
</el-col>
|
|
|
<el-col :span="8" class="label-col">
|
|
|
<div class="label">实时流量:</div>
|
|
|
<div class="value">
|
|
|
- <span>{{ swInfo.realTimeDischarge }}</span
|
|
|
+ <span>{{ swInfo.realTimeDischarge !== undefined ? parseFloat(swInfo.realTimeDischarge).toFixed(2) : '' }}</span
|
|
|
><span>m³/s</span>
|
|
|
</div>
|
|
|
</el-col>
|
|
|
@@ -39,21 +39,21 @@
|
|
|
<el-col :span="8" class="label-col">
|
|
|
<div class="label">昨日最高:</div>
|
|
|
<div class="value">
|
|
|
- <span>{{ swInfo.maxElevationYesterday }}</span
|
|
|
+ <span>{{ swInfo.maxElevationYesterday !== undefined ? parseFloat(swInfo.maxElevationYesterday).toFixed(2) : '' }}</span
|
|
|
><span>m</span>
|
|
|
</div>
|
|
|
</el-col>
|
|
|
<el-col :span="8" class="label-col">
|
|
|
<div class="label">当天雨量:</div>
|
|
|
<div class="value">
|
|
|
- <span>{{ swInfo.precipitationToday }}</span
|
|
|
+ <span>{{ swInfo.precipitationToday !== undefined ? parseFloat(swInfo.precipitationToday).toFixed(2) : '' }}</span
|
|
|
><span>mm</span>
|
|
|
</div>
|
|
|
</el-col>
|
|
|
<el-col :span="8" class="label-col">
|
|
|
<div class="label">实时流速:</div>
|
|
|
<div class="value">
|
|
|
- <span>{{ swInfo.realTimeVelocity }}</span
|
|
|
+ <span>{{ swInfo.realTimeVelocity !== undefined ? parseFloat(swInfo.realTimeVelocity).toFixed(2) : '' }}</span
|
|
|
><span>m³/s</span>
|
|
|
</div>
|
|
|
</el-col>
|
|
|
@@ -151,19 +151,32 @@ export default {
|
|
|
this.$globalEventBus.$on('clickWaterStation', (data) => {
|
|
|
this.chartShow = false
|
|
|
this.visible = true
|
|
|
- if (data.layer.id == '2-2') {
|
|
|
- this.getMonitoringStatistics(19)
|
|
|
+ // 从图层属性中获取站点ID,而不是硬编码
|
|
|
+ const stationId = data.layer.options.stationId
|
|
|
+ if (stationId) {
|
|
|
+ this.getMonitoringStatistics(stationId)
|
|
|
} else {
|
|
|
- this.getMonitoringStatistics(18)
|
|
|
+ // 如果没有找到站点ID,尝试从图层ID映射获取
|
|
|
+ let mappedId = null
|
|
|
+ if (data.layer.id == '2-2') {
|
|
|
+ mappedId = 19
|
|
|
+ } else if (data.layer.id == '2-1') {
|
|
|
+ mappedId = 18
|
|
|
+ }
|
|
|
+ if (mappedId) {
|
|
|
+ this.getMonitoringStatistics(mappedId)
|
|
|
+ }
|
|
|
}
|
|
|
this.stationGraphic = data.graphic
|
|
|
this.title = data.layer.options.name
|
|
|
})
|
|
|
},
|
|
|
destroyed() {
|
|
|
- this.stopTimer()
|
|
|
+ this.stopTimer() // 停止所有定时器
|
|
|
this.$globalEventBus.$off('clickWaterStation')
|
|
|
- window.map.removeLayer(graphicsLayer)
|
|
|
+ if (graphicsLayer) {
|
|
|
+ window.map.removeLayer(graphicsLayer)
|
|
|
+ }
|
|
|
this.graphicsLayer = null
|
|
|
},
|
|
|
methods: {
|
|
|
@@ -181,22 +194,49 @@ export default {
|
|
|
this.chartShow = true
|
|
|
if (res.data) {
|
|
|
this.swInfo = res.data.info
|
|
|
+ // 格式化数值字段,保留2位小数
|
|
|
+ if (this.swInfo.realTimeElevation !== undefined) {
|
|
|
+ this.swInfo.realTimeElevation = parseFloat(this.swInfo.realTimeElevation).toFixed(2);
|
|
|
+ }
|
|
|
+ if (this.swInfo.realTimeDischarge !== undefined) {
|
|
|
+ this.swInfo.realTimeDischarge = parseFloat(this.swInfo.realTimeDischarge).toFixed(2);
|
|
|
+ }
|
|
|
+ if (this.swInfo.realTimeVelocity !== undefined) {
|
|
|
+ this.swInfo.realTimeVelocity = parseFloat(this.swInfo.realTimeVelocity).toFixed(2);
|
|
|
+ }
|
|
|
+ if (this.swInfo.precipitationYesterday !== undefined) {
|
|
|
+ this.swInfo.precipitationYesterday = parseFloat(this.swInfo.precipitationYesterday).toFixed(2);
|
|
|
+ }
|
|
|
+ if (this.swInfo.maxElevationYesterday !== undefined) {
|
|
|
+ this.swInfo.maxElevationYesterday = parseFloat(this.swInfo.maxElevationYesterday).toFixed(2);
|
|
|
+ }
|
|
|
+ if (this.swInfo.precipitationToday !== undefined) {
|
|
|
+ this.swInfo.precipitationToday = parseFloat(this.swInfo.precipitationToday).toFixed(2);
|
|
|
+ }
|
|
|
this.startTimer('realTimeElevation',{
|
|
|
value: this.swInfo.realTimeElevation,
|
|
|
callback: (newValue, amount, isIncrement) => {
|
|
|
- this.swInfo.realTimeElevation = newValue
|
|
|
+ this.swInfo.realTimeElevation = parseFloat(newValue).toFixed(2)
|
|
|
}
|
|
|
})
|
|
|
this.startTimer('realTimeDischarge',{
|
|
|
value: this.swInfo.realTimeDischarge,
|
|
|
callback: (newValue, amount, isIncrement) => {
|
|
|
- this.swInfo.realTimeDischarge = newValue
|
|
|
+ this.swInfo.realTimeDischarge = parseFloat(newValue).toFixed(2)
|
|
|
}
|
|
|
})
|
|
|
this.startTimer('realTimeVelocity',{
|
|
|
- value: this.swInfo.realTimeDischarge,
|
|
|
+ value: this.swInfo.realTimeVelocity,
|
|
|
callback: (newValue, amount, isIncrement) => {
|
|
|
- this.swInfo.realTimeVelocity = (this.swInfo.realTimeVelocity + Math.random() * 0.2).toFixed(2);
|
|
|
+ const increment = Math.random() > 0.5;
|
|
|
+ const changeAmount = Math.random() * 0.2;
|
|
|
+ let newVelocity;
|
|
|
+ if (increment) {
|
|
|
+ newVelocity = parseFloat(this.swInfo.realTimeVelocity) + changeAmount;
|
|
|
+ } else {
|
|
|
+ newVelocity = Math.max(0, parseFloat(this.swInfo.realTimeVelocity) - changeAmount); // 防止负数
|
|
|
+ }
|
|
|
+ this.swInfo.realTimeVelocity = newVelocity.toFixed(2);
|
|
|
}
|
|
|
})
|
|
|
const option = {
|
|
|
@@ -252,9 +292,6 @@ export default {
|
|
|
{
|
|
|
type: 'value',
|
|
|
splitLine: { show: false },
|
|
|
- min: 380,
|
|
|
- interval: 10,
|
|
|
- max: 420,
|
|
|
axisLine: {
|
|
|
lineStyle: {
|
|
|
color: '#374672',
|
|
|
@@ -311,15 +348,16 @@ export default {
|
|
|
} = config || {}
|
|
|
this.timer[valueKey] = setInterval(() => {
|
|
|
const increment = Math.random() > 0.5
|
|
|
- const amount = (Math.random() * 0.04).toFixed(2) + 0.01
|
|
|
+ const amount = (Math.random() * 0.04 + 0.01).toFixed(2);
|
|
|
let newValue = null
|
|
|
if (increment) {
|
|
|
- newValue = (parseFloat(value) + parseFloat(amount)).toFixed(2)
|
|
|
+ newValue = (parseFloat(value) + parseFloat(amount)).toFixed(2);
|
|
|
} else {
|
|
|
- newValue = (parseFloat(value) - parseFloat(amount)).toFixed(2)
|
|
|
+ // 确保值不会变成负数
|
|
|
+ newValue = Math.max(0, (parseFloat(value) - parseFloat(amount))).toFixed(2);
|
|
|
}
|
|
|
if (callback && typeof callback === 'function') {
|
|
|
- callback(newValue, amount, increment)
|
|
|
+ callback(newValue, amount, increment);
|
|
|
}
|
|
|
}, 5000)
|
|
|
}else{
|
|
|
@@ -327,10 +365,20 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
stopTimer(valueKey) {
|
|
|
- if (this.timer[valueKey]) {
|
|
|
- // 确保定时器已启动
|
|
|
- clearInterval(this.timer[valueKey]) // 停止定时器
|
|
|
- this.timer = null // 清除定时器引用
|
|
|
+ if (valueKey) {
|
|
|
+ // 停止特定的定时器
|
|
|
+ if (this.timer[valueKey]) {
|
|
|
+ clearInterval(this.timer[valueKey])
|
|
|
+ this.timer[valueKey] = null
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 停止所有定时器
|
|
|
+ Object.keys(this.timer).forEach(key => {
|
|
|
+ if (this.timer[key]) {
|
|
|
+ clearInterval(this.timer[key])
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.timer = {}
|
|
|
}
|
|
|
},
|
|
|
getAroundAnalysisOwnList() {
|
|
|
@@ -369,7 +417,7 @@ export default {
|
|
|
this.artShow = false
|
|
|
this.flyToPoint(row)
|
|
|
getVideoRealtimeUrl({
|
|
|
- deviceCode: row.deviceCode,
|
|
|
+ deviceCode: row.deviceCode,
|
|
|
channelCode: row.channelCode,
|
|
|
netType: 2,
|
|
|
protocolType:9,
|