ScreenView.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <script setup>
  2. import { ref, onBeforeUnmount, onMounted } from "vue";
  3. import autofit from 'autofit.js'
  4. import { userTop } from '@/components';
  5. import WaterYield from "./components/WaterYield";
  6. import WaterQuality from "./components/WaterQuality";
  7. import ContinueData from "./components/ContinueData";
  8. import shuizhi from "./components/shuizhi";
  9. import dataBox from "./components/dataBox";
  10. import liuliang from "./components/liuliang";
  11. import gongyi from "./components/gongyi";
  12. import middleBox from "./components/middleBox";
  13. import EchartBar from "./components/EchartBar";
  14. import ControlHelper from "./components/ControlHelper";
  15. import { screenApi } from "@/api/screen"
  16. import dayjs from 'dayjs';
  17. import 'dayjs/locale/zh-cn';
  18. dayjs.locale('zh-cn'); // 设置day.js使用中文/ 导入中文语言包
  19. const gongyiData = ref([])
  20. const reportData = ref({})
  21. const screenData = ref({})
  22. const time = ref('')
  23. let timer = null
  24. let timeHour = null
  25. const dataTime = ref("");
  26. // 获取工艺管控 助手
  27. const getWarningList = () => {
  28. screenApi.warningList().then(res => {
  29. gongyiData.value = res.data || []
  30. })
  31. }
  32. // 获取数据费助手
  33. const getLeastShortReport = () => {
  34. screenApi.getLeastShortReport().then(res => {
  35. reportData.value = res.data
  36. })
  37. }
  38. // 获取大屏分析数据
  39. const getRealTimeData = () => {
  40. screenApi.realTimeData().then(res => {
  41. screenData.value = res.data
  42. dataTime.value = `更新时间:${res.data.testHour}`
  43. time.value = dayjs(res.data.timestamp).format('HH:mm:ss')
  44. timeHour = setInterval(() => {
  45. time.value = updateCurrentTime(res.data.timestamp)
  46. }, 1000)
  47. })
  48. }
  49. const updateCurrentTime = (timestamp) => {
  50. // 计算从初始时间戳到现在经过的时间
  51. const now = dayjs();
  52. const initialTime = dayjs(timestamp);
  53. const elapsedTime = now.diff(initialTime);
  54. // 使用初始时间戳加上经过的时间来更新当前时间
  55. const currentTime = initialTime.add(elapsedTime, 'millisecond');
  56. return currentTime.format('HH:mm:ss');
  57. }
  58. const init = () => {
  59. getRealTimeData()
  60. getWarningList()
  61. getLeastShortReport()
  62. }
  63. function changeSize () {
  64. // 基于设计稿 1920px 宽度的计算
  65. document.documentElement.style.fontSize = (document.documentElement.clientWidth * 10) / 1920 + 'px';
  66. }
  67. changeSize();
  68. init()
  69. onMounted(() => {
  70. autofit.init({
  71. dw: 1920,
  72. dh: 1080,
  73. el:"#screen-view",
  74. resize: true,
  75. })
  76. window.addEventListener('resize', changeSize, false);
  77. //每5s刷新数据
  78. timer = setInterval(() => {
  79. init()
  80. }, 1000 * 60 * 60)
  81. })
  82. onBeforeUnmount(() => {
  83. document.documentElement.style.fontSize = '';
  84. clearInterval(timer)
  85. clearInterval(timeHour)
  86. timer = null;
  87. timeHour = null
  88. })
  89. </script>
  90. <template>
  91. <div class="screen-view" id="screen-view">
  92. <div class="screen-view-top">
  93. <div class="left">
  94. <span class="time">{{ time }}</span>
  95. <span class="line"></span>
  96. <div class="date">
  97. <div>{{ dayjs(screenData.timestamp).format("dddd") }}</div>
  98. <div class="text-[12px]">{{ dayjs(screenData.timestamp).format('YYYY-MM-DD') }}</div>
  99. </div>
  100. </div>
  101. <div class="chat-header flex items-center justify-end pr-[18px] space-x-[16px]">
  102. <userTop></userTop>
  103. </div>
  104. </div>
  105. <div class="menu">
  106. <RouterLink to="/" class="item item1">智慧总控</RouterLink>
  107. <RouterLink to="/answer" class="item item2">专家问答</RouterLink>
  108. <RouterLink to="/water-warn" class="item item3">工艺管控</RouterLink>
  109. <RouterLink to="/work" class="item item4">智能办公</RouterLink>
  110. </div>
  111. <div class="screen-container">
  112. <div class="screen-container-main">
  113. <div class="left">
  114. <WaterYield :screenData="screenData"></WaterYield>
  115. <WaterQuality :screenData="screenData"></WaterQuality>
  116. </div>
  117. <div class="middle">
  118. <middleBox :dataTime="dataTime"></middleBox>
  119. </div>
  120. <div class="right">
  121. <ContinueData :screenData="screenData"></ContinueData>
  122. <dataBox :reportData="reportData"></dataBox>
  123. <gongyi :gongyiData="gongyiData"></gongyi>
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. </template>
  129. <style lang="scss" scoped>
  130. .screen-view {
  131. position: relative;
  132. display: flex;
  133. // justify-content: space-around;
  134. flex-flow: column;
  135. width: 100vw;
  136. height: 100vh;
  137. min-width: 1200px;
  138. min-height: 700px;
  139. background: url(@/assets/images/home/home_bg.png) center center no-repeat;
  140. background-size: 100% 100%;
  141. overflow: hidden;
  142. .screen-view-top {
  143. flex-shrink: 0;
  144. display: flex;
  145. align-items: end;
  146. justify-content: space-between;
  147. height: 90px;
  148. padding: 0 50px;
  149. .left {
  150. display: flex;
  151. align-items: center;
  152. font-size: 16px;
  153. }
  154. .time {
  155. width: 150px;
  156. font-size: 36px;
  157. font-weight: bold;
  158. text-align: left;
  159. color: #333;
  160. }
  161. .line {
  162. margin: 0 10px 0 10px;
  163. display: inline-block;
  164. background: #767C82;
  165. height: 28px;
  166. width: 2px;
  167. }
  168. .date {
  169. text-align: center;
  170. color: #415B73;
  171. }
  172. }
  173. .menu {
  174. display: flex;
  175. align-items: center;
  176. justify-content: center;
  177. flex-shrink: 0;
  178. height: 68px;
  179. .item {
  180. width: 218px;
  181. height: 52px;
  182. display: inline-block;
  183. font-size: 0;
  184. }
  185. .item1 {
  186. background: url('@/assets/images/home/menu_1_hover.png') no-repeat;
  187. background-size: 100% 100%;
  188. }
  189. .item2 {
  190. background: url('@/assets/images/home/menu_2.png') no-repeat;
  191. background-size: 100% 100%;
  192. margin-right: 20rem;
  193. &:hover {
  194. background: url('@/assets/images/home/menu_2_hover.png') no-repeat;
  195. background-size: 100% 100%;
  196. }
  197. }
  198. .item3 {
  199. background: url('@/assets/images/home/menu_3.png') no-repeat;
  200. background-size: 100% 100%;
  201. &:hover {
  202. background: url('@/assets/images/home/menu_3_hover.png') no-repeat;
  203. background-size: 100% 100%;
  204. }
  205. }
  206. .item4 {
  207. background: url('@/assets/images/home/menu_4.png') no-repeat;
  208. background-size: 100% 100%;
  209. &:hover {
  210. background: url('@/assets/images/home/menu_4_hover.png') no-repeat;
  211. background-size: 100% 100%;
  212. }
  213. }
  214. }
  215. .screen-container {
  216. position: relative;
  217. display: flex;
  218. flex-flow: column;
  219. padding: 0 60px;
  220. z-index: 2;
  221. &-main {
  222. position: relative;
  223. height: 100%;
  224. display: flex;
  225. justify-content: space-between;
  226. .left {
  227. display: flex;
  228. flex-flow: column;
  229. }
  230. .middle {
  231. position: relative;
  232. flex: 1;
  233. }
  234. }
  235. }
  236. .img-card {
  237. position: absolute;
  238. top: 50%;
  239. left: 50%;
  240. transform: translate(-50%, -50%);
  241. width: 79rem;
  242. height: 59rem;
  243. }
  244. }
  245. @media screen and (max-width: 1440px) {
  246. .screen-view {
  247. justify-content: center;
  248. }
  249. }
  250. </style>
  251. <style lang="scss">
  252. .home-box {
  253. width: 54rem;
  254. border-radius: 0.8rem;
  255. &-top {
  256. padding: 0.7rem 2.4rem 0.7rem 1.2rem;
  257. display: flex;
  258. justify-content: space-between;
  259. position: relative;
  260. align-items: center;
  261. &::after {
  262. content: '';
  263. height: 0.2rem;
  264. background: url('@/assets/images/home/line.png') no-repeat;
  265. background-size: 100% 100%;
  266. width: 100%;
  267. position: absolute;
  268. left: 1.2rem;
  269. bottom: 0;
  270. }
  271. .title {
  272. font-size: 1.8rem;
  273. font-weight: bold;
  274. display: flex;
  275. align-items: center;
  276. &::before {
  277. content: '';
  278. width: 2rem;
  279. height: 2rem;
  280. background: url('@/assets/images/home/mark.png') no-repeat;
  281. background-size: cover;
  282. margin-right: 0.8rem;
  283. display: inline-block;
  284. }
  285. }
  286. }
  287. }
  288. </style>