Files
emsapp/pages/work/index.vue

134 lines
2.8 KiB
Vue
Raw Normal View History

2025-07-29 23:05:58 +08:00
<template>
<view class="work-container">
<!-- 站点选择列表 -->
<uni-section title="站点选择" type="line" titleFontSize='16px' class="uni-pa-5">
<uni-data-select :clear="false" v-model="siteId" :localdata="siteList"
@change="selectedSite"></uni-data-select>
</uni-section>
<!-- 菜单 -->
<!-- <uni-section title="工作台" type="line" titleFontSize='16px'></uni-section> -->
<view class="grid-body">
<uni-grid :column="4" :showBorder="false" @change="toDetail">
<uni-grid-item v-for="(item,index) in gridList" :index="index" :key="index+'work'">
<view class="grid-item-box">
<uni-icons :type="item.icon" size="30"></uni-icons>
<text class="text">{{item.text}}</text>
</view>
</uni-grid-item>
</uni-grid>
</view>
</view>
</template>
<script>
import {
getAllSites
} from '@/api/ems/site.js'
export default {
data() {
return {
siteList: [],
siteId: '', //选择的站点ID
gridList: [{
page: 'bmszl',
icon: 'map-filled',
text: 'BMS总览',
},
{
page: 'bmsdcc',
icon: 'map',
text: 'BMS电池簇',
},
{
page: 'pcs',
icon: 'flag-filled',
text: 'PCS',
},
{
page: 'db',
icon: 'smallcircle',
text: '电表',
},
{
page: 'dtdc',
icon: 'smallcircle-filled',
text: '单体电池',
}
]
}
},
methods: {
toDetail(e) {
const {
index
} = e.detail
this.$tab.navigateTo(`/pages/work/${this.gridList[index].page}/index?siteId=${this.siteId}`)
},
selectedSite(id) {
this.siteId = id
}
},
// 页面切换不会重新调用如果希望每次切换页面都重新调接口使用onShow
mounted() {
getAllSites().then(response => {
console.log('返回数据', response)
const data = response?.data || []
this.siteList = data.map(item => {
return {
text: item.siteName,
value: item.siteId,
id: item.id
}
})
// 设置默认展示的站点
data.length > 0 && (this.siteId = data[0].siteId)
})
}
}
</script>
<style lang="scss" scoped>
/* #ifndef APP-NVUE */
page {
display: flex;
flex-direction: column;
box-sizing: border-box;
background-color: #fff;
min-height: 100%;
height: auto;
}
view {
font-size: 14px;
line-height: inherit;
}
/* #endif */
.text {
text-align: center;
font-size: 26rpx;
margin-top: 10rpx;
}
.grid-item-box {
flex: 1;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
align-items: center;
justify-content: center;
padding: 15px 0;
}
.uni-margin-wrap {
width: 690rpx;
width: 100%;
;
}
@media screen and (min-width: 500px) {}
</style>