Files
smart_storage_app/pages/tabbar/components/environmentalControl/position.vue

186 lines
3.7 KiB
Vue
Raw Normal View History

2025-06-30 10:21:25 +08:00
<template>
<view class="warp padding-top-30 padding-bottom-30">
<zero-loading v-if="loading" position="absolute"></zero-loading>
<template v-if="airData.length && !loading">
<view v-for="(item, index) in airData" :key="index" class="group-item" >
<view class="item-title">
<view class="section"></view>
<view class="title">{{ item.name }}</view>
</view>
<view class="item-num">{{ toFix(item.value) }}
</view>
</view>
</template>
<template v-else-if="!airData.length && !loading">
<view class="empty">{{ this.$t('homePage.home.noData') }}</view>
</template>
<historyModal :is-show.sync="histroyShow" :title="chartTitle" :params="hisParams"/>
</view>
</template>
<script>
import historyModal from '@/components/history-modal/index.vue'
export default {
components: { historyModal },
data() {
return {
airData: [],
stationId: null,
histroyShow: false,
chartTitle:'',
hisParams:{},
loading:false
}
},
computed: {
currentStation() {
return this.vuex_currentStation;
},
},
watch: {
currentStation: {
handler(val) {
if (val && val.id) {
this.stationId = val.id
this.getAirData()
}
},
deep: true,
immediate: true
},
},
methods: {
showHistory(item){
this.histroyShow = true
this.hisParams = item
this.chartTitle = item.name
},
toFix(val) {
if (val) {
const result = Number(val).toFixed(2);
return result;
} else if (val === 0) {
return 0;
} else {
return "";
}
},
async getAirData() {
this.loading = true
let self = this;
return new Promise((resolve, reject) => {
self.$u.api.homePageData
.GetDynamicConfig({
stationId: this.stationId,
permissionId: 928,
pageLocation:'airData'
})
.then((res) => {
this.loading = false
this.airData = res.data
resolve();
})
.catch((err) => {
reject("错误");
});
});
},
},
}
</script>
<style lang="scss" scoped>
.warp {
width: 100%;
display: flex;
flex-wrap: wrap;
// justify-content: center;
position: relative;
.group-item {
display: flex;
flex-direction: column;
align-items: center;
width: 199rpx;
height: 110rpx;
justify-content: center;
padding: 10rpx;
2025-07-01 16:59:10 +08:00
background: rgba(254, 131, 15, 0.05);
2025-06-30 10:21:25 +08:00
border-radius: 10rpx;
margin: 10rpx 10rpx;
position: relative;
.item-num {
font-size: 36rpx;
color: #282828;
font-weight: bold;
width: 100%;
padding-left: 15rpx;
white-space: nowrap;
overflow: hidden; //文本超出隐藏
text-overflow: ellipsis; //文本超出省略号替
// text-align: center;
}
.item-title {
display: flex;
width: 100%;
align-items: center;
font-size: 24rpx;
padding-top: 10rpx;
.section {
height: 30rpx;
width: 6rpx;
2025-07-01 16:59:10 +08:00
background-color: #07976E;
2025-06-30 10:21:25 +08:00
border-radius: 8rpx;
}
.title {
padding-left: 10rpx;
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis; //文本超出省略号替
color: #2a2a2a;
}
}
}
.empty {
width: 100%;
height: 100rpx;
text-align: center;
line-height: 100rpx;
color: #2a2a2a;
font-size: 24rpx;
}
.padding-top-30 {
padding-top: 30rpx;
}
.padding-bottom-30 {
padding-bottom: 30rpx;
}
.history-icon {
position: absolute;
right: 0rpx;
top: 0rpx;
image {
width: 30rpx;
height: 30rpx;
}
}
}
</style>