dataDashboard.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <div style="background-color: #0e122d">
  3. <div class="screenTitle">
  4. <img
  5. :src="topBg"
  6. alt=""
  7. >
  8. <span>龙弛智慧隧道系统</span>
  9. </div>
  10. <div class="screen">
  11. <div class="leftBox">
  12. <div class="deviceSummary">
  13. <div class="deviceSummary_title">
  14. <img
  15. alt=""
  16. :src="Device"
  17. style="padding-left: 15px"
  18. >
  19. <span style="padding-left: 10px;">设备汇总</span>
  20. </div>
  21. <div class="deviceOptionBox">
  22. <div
  23. v-for="item in deviceTypeList"
  24. :key="item.id"
  25. class="deviceOptionRow"
  26. >
  27. <div
  28. v-for="item2 in item"
  29. :key="item2.ID"
  30. class="deviceOption"
  31. >
  32. <div style="width: 35px;height: 35px">
  33. <img
  34. :src="item.url"
  35. style="width: 35px;height: 35px"
  36. alt=""
  37. >
  38. </div>
  39. <el-text
  40. style="padding-top: 8px;color: #ffffff"
  41. size="small"
  42. >
  43. 1/0
  44. </el-text>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. <div class="inductance">
  50. <div class="inductanceTitle">
  51. <img
  52. alt=""
  53. :src="Power"
  54. style="padding-left: 15px"
  55. >
  56. <span style="padding-left: 10px;">电感检测</span>
  57. </div>
  58. </div>
  59. <div class="warn">
  60. <div class="warnTitle">
  61. <img
  62. alt=""
  63. :src="Warn"
  64. style="padding-left: 15px"
  65. >
  66. <span style="padding-left: 10px;">警告列表</span>
  67. </div>
  68. </div>
  69. </div>
  70. <div class="centerBox">
  71. <div style="width: 1200px;height: 600px;border: 3px solid #1b92fd; padding: 2px">
  72. <Map />
  73. </div>
  74. <div class="centerBox_chart">
  75. <div class="centerBox_environment">
  76. <div class="centerBox_environment_title">
  77. <img
  78. :src="Setting"
  79. alt=""
  80. style="padding-left: 10px"
  81. >
  82. <span style="padding-left: 15px;">环境</span>
  83. </div>
  84. <div
  85. id="environment"
  86. class="centerBox_environment_chart"
  87. style="width: 500px"
  88. />
  89. </div>
  90. <div class="centerBox_environment">
  91. <div class="centerBox_environment_title">
  92. <img
  93. :src="Sunlight"
  94. alt=""
  95. style="padding-left: 10px"
  96. >
  97. <span style="padding-left: 15px;">光照度</span>
  98. </div>
  99. <div
  100. id="lamp"
  101. class="centerBox_environment_chart"
  102. style="width: 500px"
  103. />
  104. </div>
  105. </div>
  106. </div>
  107. <div class="rightBox" />
  108. </div>
  109. </div>
  110. </template>
  111. <script setup>
  112. import Device from '@/assets/icons/device.png'
  113. import { reactive, onMounted, watch } from 'vue'
  114. // import environments from '@/assets/icons/environment.png'
  115. // import fourWays from '@/assets/icons/fourWays.png'
  116. // import inductance from '@/assets/icons/inductance.png'
  117. // import singleLamp from '@/assets/icons/singleLamp.png'
  118. import Setting from '@/assets/icons/setting.png'
  119. import Sunlight from '@/assets/icons/sunlight.png'
  120. import topBg from '@/assets/icons/topbg.png'
  121. import Power from '@/assets/icons/power.png'
  122. import Warn from '@/assets/icons/warn.png'
  123. import Map from '@/view/screen/components/map.vue'
  124. import * as echarts from 'echarts'
  125. import { useScreenStore } from '@/pinia/modules/screen'
  126. import { queryTunnelList } from '@/api/tunnel'
  127. import { queryAllDeviceGenres } from '@/api/device'
  128. const useScreen = useScreenStore()
  129. // const deviceList = reactive([
  130. // { url: environments, label: '环境:', value: '1/0' },
  131. // { url: fourWays, label: '四路:', value: '1/0' },
  132. // { url: inductance, label: '电感:', value: '1/0' },
  133. // { url: singleLamp, label: '单灯:', value: '1/0' },
  134. // ])
  135. const deviceTypeList = reactive([])
  136. const condition = {
  137. pageInfo: {
  138. page: 1,
  139. pageSize: 1000
  140. },
  141. name: '',
  142. regionId: 0,
  143. userId: 1
  144. }
  145. const lampData = reactive({})
  146. onMounted(() => {
  147. queryTunnelList(condition).then(res => {
  148. if (res.code === 0) {
  149. useScreen.setTunnelList(res.data)
  150. Object.assign(lampData, res.data.list[0])
  151. loading(lampData.envData)
  152. loadingLamp(lampData.envData)
  153. }
  154. })
  155. queryAllDeviceGenres().then(res => {
  156. if (res.code === 0) {
  157. const result = []
  158. for (let i = 0; i < res.data.length; i += 4) {
  159. result.push(res.data.slice(i, i + 4))
  160. }
  161. deviceTypeList.push(...result)
  162. console.log('设备类型', deviceTypeList)
  163. }
  164. })
  165. })
  166. const loading = (list) => {
  167. const chartDom = document.getElementById('environment')
  168. const myChart = echarts.init(chartDom)
  169. const option = {
  170. tooltip: {
  171. trigger: 'axis',
  172. axisPointer: {
  173. type: 'cross',
  174. crossStyle: {
  175. color: '#ffffff'
  176. }
  177. },
  178. },
  179. legend: {
  180. data: [
  181. // '待下发','处置中','已完成'
  182. {
  183. name: '温度',
  184. textStyle: {
  185. color: '#0EFCFF' // 图例文字颜色
  186. }
  187. },
  188. {
  189. name: '湿度',
  190. textStyle: {
  191. color: '#1b92fd' // 图例文字颜色
  192. }
  193. }
  194. ],
  195. },
  196. xAxis: {
  197. type: 'time', // 使用时间类型的x轴
  198. boundaryGap: false,
  199. axisLine: {
  200. show: true,
  201. lineStyle: {
  202. color: '#ffffff',
  203. width: 1,
  204. type: 'solid'
  205. }
  206. }
  207. },
  208. yAxis: {
  209. axisLine: {
  210. show: true,
  211. lineStyle: {
  212. color: '#ffffff',
  213. width: 1,
  214. type: 'solid'
  215. }
  216. },
  217. splitLine: {
  218. lineStyle: {
  219. color: ['#ffffff']
  220. }
  221. }
  222. },
  223. series: [
  224. {
  225. name: '温度',
  226. type: 'line',
  227. data: list.map(item => [new Date(item.CreatedAt).getTime(), item.temperature])
  228. },
  229. {
  230. name: '湿度',
  231. type: 'line',
  232. data: list.map(item => [new Date(item.CreatedAt).getTime(), item.humidity])
  233. }
  234. ],
  235. }
  236. option && myChart.setOption(option)
  237. }
  238. const loadingLamp = (list) => {
  239. const chartDom = document.getElementById('lamp')
  240. const myChart = echarts.init(chartDom)
  241. const option = {
  242. tooltip: {
  243. trigger: 'axis',
  244. axisPointer: {
  245. type: 'cross',
  246. crossStyle: {
  247. color: '#ffffff'
  248. }
  249. },
  250. },
  251. legend: {
  252. data: [
  253. {
  254. name: '光照度',
  255. textStyle: {
  256. color: '#ffffff' // 图例文字颜色
  257. }
  258. },
  259. ]
  260. },
  261. xAxis: {
  262. type: 'time', // 使用时间类型的x轴
  263. boundaryGap: false,
  264. axisLine: {
  265. show: true,
  266. lineStyle: {
  267. color: '#ffffff',
  268. width: 1,
  269. type: 'solid'
  270. }
  271. }
  272. },
  273. yAxis: {
  274. axisLine: {
  275. show: true,
  276. lineStyle: {
  277. color: '#ffffff',
  278. width: 1,
  279. type: 'solid'
  280. }
  281. },
  282. splitLine: {
  283. lineStyle: {
  284. color: ['#ffffff']
  285. }
  286. }
  287. },
  288. series: [
  289. {
  290. name: '光照度',
  291. type: 'bar',
  292. data: list.map(item => [new Date(item.CreatedAt).getTime(), item.illuminance])
  293. },
  294. ]
  295. }
  296. option && myChart.setOption(option)
  297. }
  298. watch(() => useScreen.currentTunnel, (newValue) => {
  299. loading(newValue.envData)
  300. loadingLamp(newValue.envData)
  301. })
  302. </script>
  303. <style scoped lang="less">
  304. // 公共样式
  305. .title {
  306. display: flex;
  307. align-items: center;
  308. font-size: 20px;
  309. font-family: PingFang-SC-Medium,serif;
  310. color: rgba(27, 146, 253, 1);
  311. }
  312. .boxShape {
  313. width: 370px;
  314. border: 1px solid rgba(27,146,253,0.5);
  315. background: rgba(50, 72, 106, 0.2);
  316. margin-left: 20px;
  317. }
  318. //.....................
  319. .screenTitle{
  320. width: 100%;
  321. height: 100px;
  322. display: flex;
  323. justify-content: center;
  324. align-items: center;
  325. //background: linear-gradient(to bottom, #2583e0, #80aad8); /*设置渐变的方向从左到右 颜色从ff0000到ffff00*/
  326. //-webkit-background-clip: text;/*将设置的背景颜色限制在文字中*/
  327. //-webkit-text-fill-color: transparent;/*给文字设置成透明*/
  328. position: relative;
  329. span{
  330. position: absolute;
  331. top: 30px;
  332. left: 890px;
  333. font-size: 30px;
  334. color: #ffffff;
  335. padding-left: 20px;
  336. letter-spacing: 10px;
  337. }
  338. img{
  339. height: 80px;
  340. }
  341. }
  342. .screen{
  343. width: 100%;
  344. height: 1200px;
  345. background-color: #0e122d;
  346. display: flex;
  347. margin-top: 20px;
  348. .leftBox {
  349. width: 20%;
  350. height: 1200px;
  351. .deviceSummary {
  352. height: 240px;
  353. .boxShape;
  354. .deviceSummary_title {
  355. width: 370px;
  356. height: 50px;
  357. .title;
  358. img{
  359. width: 30px;
  360. height: 30px;
  361. }
  362. }
  363. .deviceOptionBox {
  364. width: 370px;
  365. height: 190px;
  366. margin-top: 20px;
  367. .deviceOptionRow {
  368. width: 100%;
  369. height: 60px;
  370. display: flex;
  371. margin-top: 20px;
  372. .deviceOption {
  373. width: 90px;
  374. height: 60px;
  375. display: flex;
  376. flex-direction: column;
  377. align-items: center;
  378. color: #ffffff;
  379. }
  380. }
  381. }
  382. }
  383. .inductance {
  384. height: 200px;
  385. margin-top: 20px;
  386. .boxShape;
  387. .inductanceTitle {
  388. width: 370px;
  389. height: 50px;
  390. .title;
  391. img{
  392. width: 30px;
  393. height: 30px;
  394. }
  395. }
  396. }
  397. .warn {
  398. height: 400px;
  399. margin-top: 20px;
  400. .boxShape;
  401. .warnTitle {
  402. width: 370px;
  403. height: 50px;
  404. .title;
  405. img{
  406. width: 30px;
  407. height: 30px;
  408. }
  409. }
  410. }
  411. }
  412. .centerBox {
  413. width: 60%;
  414. height: 1200px;
  415. display: flex;
  416. flex-direction: column;
  417. align-items: center;
  418. .centerBox_chart {
  419. width: 1200px;
  420. height: 220px;
  421. margin-top: 40px;
  422. display: flex;
  423. justify-content: space-between;
  424. border: 1px solid rgba(27,146,253,0.5);
  425. background: rgba(50, 72, 106, 0.2);
  426. }
  427. .centerBox_environment{
  428. width: 500px;
  429. height: 220px;
  430. position: relative;
  431. .centerBox_environment_title {
  432. width: 500px;
  433. height: 50px;
  434. .title;
  435. img {
  436. width: 30px;
  437. height: 30px;
  438. }
  439. }
  440. .centerBox_environment_chart {
  441. height: 250px;
  442. position: absolute;
  443. top: 5px;
  444. }
  445. }
  446. }
  447. .rightBox {
  448. width: 20%;
  449. height: 1200px;
  450. }
  451. }
  452. </style>