123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- <script setup>
- import { ref, onBeforeUnmount, onMounted } from "vue";
- import { userTop } from '@/components';
- import shuizhi from "./components/shuizhi";
- import dataBox from "./components/dataBox";
- import liuliang from "./components/liuliang";
- import gongyi from "./components/gongyi";
- import middleBox from "./components/middleBox";
- import EchartBar from "./components/EchartBar";
- import ControlHelper from "./components/ControlHelper";
- import { screenApi } from "@/api/screen"
- import dayjs from 'dayjs';
- import 'dayjs/locale/zh-cn';
- dayjs.locale('zh-cn'); // 设置day.js使用中文/ 导入中文语言包
- const gongyiData = ref([])
- const reportData = ref({})
- const screenData = ref({})
- const time = ref('')
- let timer = null
- let timeHour = null
- const dataTime = ref("");
- // 获取工艺管控 助手
- const getWarningList = () => {
- screenApi.warningList().then(res => {
- gongyiData.value = res.data || []
- })
- }
- // 获取数据费助手
- const getLeastShortReport = () => {
- screenApi.getLeastShortReport().then(res => {
- reportData.value = res.data
- })
- }
- // 获取大屏分析数据
- const getRealTimeData = () => {
- screenApi.realTimeData().then(res => {
- screenData.value = res.data
- dataTime.value = `更新时间:${res.data.testHour}`
- time.value = dayjs(res.data.timestamp).format('HH:mm:ss')
- timeHour = setInterval(() => {
- time.value = updateCurrentTime(res.data.timestamp)
- }, 1000)
- })
- }
- const updateCurrentTime = (timestamp) => {
- // 计算从初始时间戳到现在经过的时间
- const now = dayjs();
- const initialTime = dayjs(timestamp);
- const elapsedTime = now.diff(initialTime);
- // 使用初始时间戳加上经过的时间来更新当前时间
- const currentTime = initialTime.add(elapsedTime, 'millisecond');
- return currentTime.format('HH:mm:ss');
- }
- const init = () => {
- getRealTimeData()
- getWarningList()
- getLeastShortReport()
- }
- init()
- function changeSize () {
- // 基于设计稿 1920px 宽度的计算
- document.documentElement.style.fontSize = (document.documentElement.clientWidth * 10) / 1920 + 'px';
- }
- changeSize();
- onMounted(() => {
- window.addEventListener('resize', changeSize, false);
- //每5s刷新数据
- timer = setInterval(() => {
- init()
- }, 1000 * 60 * 60)
- })
- onBeforeUnmount(() => {
- document.documentElement.style.fontSize = '';
- clearInterval(timer)
- clearInterval(timeHour)
- timer = null;
- timeHour = null
- })
- </script>
- <template>
- <div class="screen-view" id="screen-view">
- <div class="screen-view-top">
- <div class="left space-x-[1rem]">
- <span class="time">{{ time }}</span>
- <span class="line"></span>
- <div class="data">
- <div>{{ dayjs(screenData.timestamp).format("dddd") }}</div>
- <div class="text-[12px]">{{ dayjs(screenData.timestamp).format('YYYY-MM-DD') }}</div>
- </div>
- </div>
- <div class="chat-header flex items-center justify-end pr-[18px] space-x-[16px]">
- <userTop></userTop>
- </div>
- </div>
- <div class="menu">
- <RouterLink to="/" class="item item1">智慧总控</RouterLink>
- <RouterLink to="/answer" class="item item2">专家问答</RouterLink>
- <RouterLink to="/water-warn" class="item item3">工艺管控</RouterLink>
- <RouterLink to="/work" class="item item4">智能办公</RouterLink>
- </div>
- <div class="screen-container">
- <div class="screen-container-main">
- <div class="left">
- <shuizhi :screenData="screenData"></shuizhi>
- <EchartBar :screenData="screenData"></EchartBar>
- <liuliang :screenData="screenData"></liuliang>
- </div>
- <div class="middle">
- <middleBox :dataTime="dataTime"></middleBox>
- </div>
- <div class="right">
- <ControlHelper></ControlHelper>
- <dataBox :reportData="reportData"></dataBox>
- <gongyi :gongyiData="gongyiData"></gongyi>
- </div>
- </div>
- </div>
- </div>
- </template>
- <style lang="scss" scoped>
- .screen-view {
- position: relative;
- display: flex;
- justify-content: space-around;
- flex-flow: column;
- width: 100vw;
- height: 100vh;
- background: url(@/assets/images/home/home_bg.png) center center no-repeat;
- background-size: 100% 100%;
- overflow: hidden;
- &-top {
- display: flex;
- align-items: end;
- justify-content: space-between;
- padding: 0 5rem;
- height: 9rem;
- .left {
- display: flex;
- align-items: center;
- font-size: 1.6rem;
- }
- .time {
- font-size: 3.6rem;
- font-weight: bold;
- color: #333;
- }
- .line {
- margin: 0 1rem 0 1.5rem;
- display: inline-block;
- background: #767C82;
- height: 2.8rem;
- width: 0.2rem;
- }
- .data {
- color: #415B73;
- }
- }
- .menu {
- display: flex;
- align-content: center;
- justify-content: center;
- flex-shrink: 0;
- .item {
- width: 21.8rem;
- height: 5.2rem;
- display: inline-block;
- font-size: 0;
- }
- .item1 {
- background: url('@/assets/images/home/menu_1_hover.png') no-repeat;
- background-size: 100% 100%;
- }
- .item2 {
- background: url('@/assets/images/home/menu_2.png') no-repeat;
- background-size: 100% 100%;
- margin-right: 20rem;
- &:hover {
- background: url('@/assets/images/home/menu_2_hover.png') no-repeat;
- background-size: 100% 100%;
- }
- }
- .item3 {
- background: url('@/assets/images/home/menu_3.png') no-repeat;
- background-size: 100% 100%;
- &:hover {
- background: url('@/assets/images/home/menu_3_hover.png') no-repeat;
- background-size: 100% 100%;
- }
- }
- .item4 {
- background: url('@/assets/images/home/menu_4.png') no-repeat;
- background-size: 100% 100%;
- &:hover {
- background: url('@/assets/images/home/menu_4_hover.png') no-repeat;
- background-size: 100% 100%;
- }
- }
- }
- .water-work-inner {
- position: absolute;
- left: 50%;
- top: 50%;
- transform: translate(-50%, -50%);
- width: 150rem;
- height: 80rem;
- // background: url("@assets/images/home/water-work.png") no-repeat;
- background: red;
- }
- .screen-container {
- position: relative;
- display: flex;
- flex-flow: column;
- height: 80rem;
- padding: 0 6rem;
- z-index: 2;
- &-main {
- position: relative;
- height: 100%;
- display: flex;
- justify-content: space-between;
- .left {
- display: flex;
- flex-flow: column;
- }
- .middle {
- position: relative;
- flex: 1;
- }
- }
- }
- .img-card {
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- width: 79rem;
- height: 59rem;
- }
- }
- @media screen and (max-width: 1440px) {
- .screen-view {
- justify-content: flex-start;
- // background: url(@/assets/images/home/home_bg.png) center top no-repeat;
- // background-size: contain;
- }
- }
- </style>
- <style lang="scss">
- .home-box {
- width: 54rem;
- // width: 540px;
- border-radius: 0.8rem;
- // border: 1px solid #fff;
- // margin-bottom: 2rem;
- &-top {
- padding: 0.7rem 2.4rem 0.7rem 1.2rem;
- display: flex;
- justify-content: space-between;
- position: relative;
- align-items: center;
- &::after {
- content: '';
- height: 0.2rem;
- background: url('@/assets/images/home/line.png') no-repeat;
- background-size: 100% 100%;
- width: 100%;
- position: absolute;
- left: 1.2rem;
- bottom: 0;
- }
- .title {
- font-size: 1.8rem;
- font-weight: bold;
- display: flex;
- align-items: center;
- &::before {
- content: '';
- width: 2rem;
- height: 2rem;
- background: url('@/assets/images/home/mark.png') no-repeat;
- background-size: cover;
- margin-right: 0.8rem;
- display: inline-block;
- }
- }
- }
- }
- </style>
|