ScreenView.vue 6.4 KB

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