Files
emsapp/pages/work/index.vue

138 lines
2.9 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="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">
<view class="icon iconfont" :class="item.icon" size="30"></view>
<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: 'icon-BMS',
text: 'BMS总览',
},
{
page: 'bmsdcc',
icon: 'icon-a-dianchicunengliangkuai',
text: 'BMS电池簇',
},
{
page: 'pcs',
icon: 'icon-PCS',
text: 'PCS',
},
{
page: 'db',
icon: 'icon-dianbiao4',
text: '电表',
},
{
page: 'dtdc',
icon: 'icon-dantidianchi',
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%;
;
}
.icon {
font-size: 26px;
}
@media screen and (min-width: 500px) {}
</style>