<template>
|
<b-card no-body class="p10">
|
<div class="pl10 pr10 pt10 overflow-y">
|
<h5 class="mb-0">
|
食堂管理
|
</h5>
|
<div class="flex-center" style="height:10vh">
|
<div class="col text-center">
|
<h1 class="fw900">{{peopleCount}}</h1>
|
<p class="mb-0">就餐人数</p>
|
</div>
|
<div class="col text-center">
|
<h1 :class="`text-${densityJson.description} fw900`">{{densityJson.lable}}</h1>
|
<p class="mb-0">密集等级</p>
|
</div>
|
</div>
|
<!-- <div class="py-5 text-center" v-else>
|
<small class="text-muted">暂无数据</small>
|
</div> -->
|
</div>
|
</b-card>
|
</template>
|
<!-- Page -->
|
<script>
|
import CommonModel from '@/server/models/CommonModel'
|
import { getDensityDicts } from '@/server/common.js'
|
export default {
|
name: 'HomeDataCanteen',
|
data() {
|
return {
|
userInfo: this.$store.getters.basicUserInfo,
|
densityDictsList: [],
|
/* webSocket声明 */
|
CanteenStateWS: new CommonModel(),
|
infoDataCountWsClient: null,
|
peopleCount: 0
|
}
|
},
|
computed: {
|
densityJson() {
|
let titleJson = { lable: '正常', description: 'info' }
|
if (this.densityDictsList.length === 0) {
|
return titleJson
|
}
|
if (
|
this.peopleCount >=
|
this.densityDictsList[this.densityDictsList.length - 1].value
|
) {
|
return { lable: '非常挤', description: 'danger' }
|
}
|
let minCount = 0
|
for (let i = 0; i < this.densityDictsList.length + 1; i++) {
|
const iteam = this.densityDictsList[i] ? this.densityDictsList[i] : null
|
if (
|
iteam &&
|
iteam.value &&
|
iteam.lable &&
|
this.peopleCount >= minCount &&
|
this.peopleCount < iteam.value
|
) {
|
titleJson.lable = iteam.lable
|
titleJson.description = iteam.description
|
? iteam.description
|
: 'primary'
|
return titleJson
|
}
|
minCount = iteam.value
|
}
|
return titleJson
|
}
|
},
|
methods: {
|
async getDensityDicts() {
|
let res = await getDensityDicts({
|
orgId: this.userInfo.orgId,
|
type: 'SCHOOL_DENSITY',
|
module: this.$store.state.menuName ? this.$store.state.menuName : ''
|
})
|
if (res && res.code === '0') {
|
this.densityDictsList = res.data
|
}
|
},
|
/* ws获取食堂人数 start */
|
getCanteenPersonnelNum() {
|
try {
|
this.CanteenStateWS.getCanteenPersonnelNum(
|
{
|
orgId: this.userInfo.orgId
|
},
|
this.infoDataCountMsg,
|
err => {
|
console.log(err, '获取食堂人数--出错')
|
},
|
close => {
|
console.log(close, '获取食堂人数--关闭')
|
},
|
e => {
|
this.infoDataCountWsClient = e
|
}
|
)
|
} catch (ex) {
|
console.log('获取食堂人数--异常', ex)
|
}
|
},
|
infoDataCountMsg(res) {
|
if (res && res.result) {
|
this.peopleCount = res.result
|
}
|
// console.log(res, '获取地图警报数量--接收数据')
|
}
|
},
|
created() {
|
/* 查询密集度字典 */
|
this.getDensityDicts()
|
/* 查询列表 */
|
this.infoDataCountWsClient && this.infoDataCountWsClient.close()
|
this.getCanteenPersonnelNum()
|
}
|
}
|
</script>
|
<style>
|
.fw900 {
|
font-weight: 900;
|
}
|
</style>
|