ScreenView.vue 7.4 KB

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