139 lines
3.7 KiB
Vue
Raw Normal View History

2024-04-20 17:26:03 +08:00
<template>
<div class="projectContent">
<div class="left">
<leftTop :projectData="projectData" class="leftTop" ref="leftTopRef"></leftTop>
<leftCenter :statisticsCount="statisticsCount" class="leftCenter"></leftCenter>
<!-- <leftBottom :statisticsCount="statisticsCount" class="leftBottom"></leftBottom> -->
</div>
<div class="center">
<centerTop :projectData="projectData" class="centerTop" ref="centerTopRef"></centerTop>
<centerBottom :projectData="projectData" class="centerBottom" ref="centerBottomRef"></centerBottom>
</div>
<div class="right">
<rightTop class="rightTop" ref="rightTopRef"></rightTop>
<rightCenter class="rightCenter" ref="rightCenterRef"></rightCenter>
<rightBottom class="rightBottom" ref="rightBottomRef"></rightBottom>
</div>
</div>
</template>
<script setup lang="ts">
import leftTop from "@/views/commandScreen/commandCenter/leftTop.vue";
import leftCenter from "@/views/commandScreen/commandCenter/leftCenter.vue";
import leftBottom from "@/views/commandScreen/commandCenter/leftBottom.vue";
import centerTop from "@/views/commandScreen/commandCenter/centerTop.vue";
import centerBottom from "@/views/commandScreen/commandCenter/centerBottom.vue";
import rightTop from "@/views/commandScreen/commandCenter/rightTop.vue";
import rightCenter from "@/views/commandScreen/commandCenter/rightCenter.vue";
import rightBottom from "@/views/commandScreen/commandCenter/rightBottom.vue";
import { GlobalStore } from "@/stores";
const store = GlobalStore();
import { getWorkerStatisticsCountApi, getProjectDetail } from "@/api/modules/projectOverview";
import { ref, onMounted, onBeforeUnmount,nextTick } from "vue";
const statisticsCount = ref(null as any);
const projectData = ref(null as any);
//获取项目信息
const getProjectInfo = async () => {
const res = await getProjectDetail({ projectSn: store.sn });
// console.log("获取项目信息", res);
// console.log("获取工程类别", projectTypeEnum);
projectData.value = res.result;
};
//获取人员概览
const getPersonDetail = async () => {
const res = await getWorkerStatisticsCountApi({ sn: store.sn });
statisticsCount.value = res.result;
};
const leftTopRef = ref();
const centerTopRef = ref();
const centerBottomRef = ref();
const rightTopRef = ref();
const rightCenterRef = ref();
const rightBottomRef = ref();
const callChildFn = async () => {
nextTick( async ()=>{
leftTopRef.value.projectTypeEnum()
centerTopRef.value.getQueryBySnData()
centerBottomRef.value.getProgressOption()
rightTopRef.value.getSafeInfo()
rightCenterRef.value.qualityInfo()
rightBottomRef.value.getList()
})
}
//定时器
const interval = ref(null as any);
//定时调用
const startInterval = async () => {
interval.value= setInterval(() => {
getPersonDetail();
getProjectInfo();
callChildFn();
}, 30 * 1000);
}
// 在组件销毁时清除 interval
const destroyInterval = () => {
if (interval.value) {
clearInterval(interval.value);
}
}
// 在组件销毁时调用 destroyInterval 方法清除 interval
onBeforeUnmount(() => {
destroyInterval();
})
window.onbeforeunload = (e) => {
destroyInterval();
}
onMounted( async () => {
getPersonDetail();
getProjectInfo();
startInterval();
});
</script>
<style lang="scss" scoped>
.projectContent {
width: 100%;
height: 100%;
display: flex;
.left {
height: 100%;
width: 26%;
.leftTop {
height: 32%;
}
.leftCenter {
height: 68%;
margin: 3% 0 3% 0;
}
}
.center {
width: 46%;
margin: 0 1%;
.centerTop {
height: 50%;
margin-bottom: 3%;
}
.centerBottom {
height: 50%;
}
}
.right {
width: 26%;
.rightTop {
height: 32%;
}
.rightCenter {
height: 33%;
margin: 3% 0 3% 0;
}
.rightBottom {
height: 32%;
}
}
}
</style>