IOTRight.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <template>
  2. <div class="iot-data-left">
  3. <div class="left-box">
  4. <titleBgBox class="left-title-bg-box" title="在线趋势">
  5. <div class="device-info" ref="onLineRef"></div>
  6. </titleBgBox>
  7. <titleBgBox class="left-title-bg-box" title="设备消息趋势">
  8. <div class="device-info" ref="deviceInfoRef"></div>
  9. </titleBgBox>
  10. <titleBgBox class="left-title-bg-box" title="高频感知事件">
  11. <div class="pie-position-box">
  12. <IOTPie class="pie-item" />
  13. <div class="pie-info-data">
  14. <div class="pie-info-item">
  15. <div class="icon-label" style="border-color: #bcbf5c"></div>
  16. <span class="name">设备离线</span>
  17. <span class="num">20%</span>
  18. </div>
  19. <div class="pie-info-item">
  20. <div class="icon-label" style="border-color: #bcbf5c"></div>
  21. <span class="name">雨水液位异常</span>
  22. <span class="num">20%</span>
  23. </div>
  24. <div class="pie-info-item">
  25. <div class="icon-label" style="border-color: #bcbf5c"></div>
  26. <span class="name">污水液位异常</span>
  27. <span class="num">20%</span>
  28. </div>
  29. <div class="pie-info-item">
  30. <div class="icon-label" style="border-color: #bcbf5c"></div>
  31. <span class="name">设备离线</span>
  32. <span class="num">20%</span>
  33. </div>
  34. <div class="pie-info-item">
  35. <div class="icon-label" style="border-color: #bcbf5c"></div>
  36. <span class="name">水务供应压力异常</span>
  37. <span class="num">20%</span>
  38. </div>
  39. <div class="pie-info-item">
  40. <div class="icon-label" style="border-color: #bcbf5c"></div>
  41. <span class="name">其他</span>
  42. <span class="num">20%</span>
  43. </div>
  44. </div>
  45. </div>
  46. </titleBgBox>
  47. </div>
  48. </div>
  49. </template>
  50. <script setup>
  51. import { onMounted, ref } from "vue";
  52. import IOTPie from "./IOTPie.vue";
  53. import titleBgBox from "./titleBgBox.vue";
  54. import * as echarts from "echarts";
  55. import { QueryTrendsmsg, QueryTrendsOnline } from "../../../service/iotService";
  56. const deviceInfoRef = ref(null);
  57. const onLineRef = ref(null);
  58. //设备消息趋势折线图options
  59. const deviceInfoOption = (xData, yData) => {
  60. return {
  61. tooltip: {
  62. trigger: "axis",
  63. axisPointer: {
  64. type: "cross",
  65. },
  66. },
  67. grid: {
  68. left: "5%",
  69. right: "5%",
  70. bottom: "3%",
  71. top: "3%",
  72. containLabel: true,
  73. },
  74. xAxis: [
  75. {
  76. type: "category",
  77. boundaryGap: false,
  78. axisLabel: {
  79. show: true,
  80. textStyle: {
  81. color: "#BFC8D7",
  82. },
  83. },
  84. axisTick: {
  85. show: false,
  86. },
  87. axisLine: {
  88. show: true, //是否显示轴线
  89. lineStyle: {
  90. color: "#fff", //刻度线的颜色
  91. opacity: 0.12,
  92. },
  93. },
  94. data: xData,
  95. },
  96. ],
  97. yAxis: [
  98. {
  99. type: "value",
  100. splitLine: {
  101. show: true,
  102. lineStyle: {
  103. type: "dashed",
  104. color: "#fff", //刻度线的颜色
  105. opacity: 0.12,
  106. },
  107. },
  108. axisLabel: {
  109. show: true,
  110. textStyle: {
  111. color: "#BFC8D7",
  112. },
  113. },
  114. },
  115. ],
  116. series: [
  117. {
  118. name: "Email",
  119. type: "line",
  120. stack: "Total",
  121. // emphasis: {
  122. // focus: "series",
  123. // },
  124. areaStyle: {
  125. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  126. {
  127. offset: 0,
  128. color: "rgba(45, 144, 255, 0.86)",
  129. },
  130. {
  131. offset: 0.2,
  132. color: "rgba(45, 144, 255, 0.4)",
  133. },
  134. {
  135. offset: 1,
  136. color: "rgba(45, 144, 255, 0)",
  137. },
  138. ]),
  139. },
  140. data: yData,
  141. },
  142. ],
  143. };
  144. };
  145. const barWidth = 20;
  146. const onLineOptions = (xData, yData) => {
  147. return {
  148. xAxis: {
  149. data: xData,
  150. axisTick: {
  151. show: false,
  152. },
  153. axisLine: { lineStyle: { color: "#ffffff", opacity: 0.52, width: 1 } },
  154. },
  155. yAxis: {
  156. splitLine: {
  157. show: true,
  158. lineStyle: {
  159. type: "dashed",
  160. color: "#ffffff",
  161. opacity: 0.18,
  162. },
  163. },
  164. axisLabel: {
  165. show: true,
  166. textStyle: {
  167. color: "#BFC8D7",
  168. },
  169. },
  170. },
  171. dataGroupId: "",
  172. grid: {
  173. left: "5%",
  174. right: "5%",
  175. bottom: "3%",
  176. top: "3%",
  177. containLabel: true,
  178. },
  179. series: [
  180. {
  181. type: "pictorialBar", // 象型柱状
  182. symbol: "diamond",
  183. symbolSize: [barWidth, 5], // 调整大小
  184. // symbolOffset: [-13, -3], // 图形相对于原本位置的偏移
  185. symbolOffset: ["0%", -3], // 图形相对于原本位置的偏移
  186. symbolPosition: "end",
  187. z: 12,
  188. color: "#E1EEFF",
  189. data: yData, //Y轴上的高度
  190. },
  191. {
  192. name: "",
  193. type: "bar",
  194. barWidth: barWidth,
  195. barGap: "10%",
  196. // zlevel: 2,
  197. stack: "1",
  198. itemStyle: {
  199. opacity: 0.7,
  200. color: new echarts.graphic.LinearGradient(0, 1, 1, 1, [
  201. {
  202. offset: 0.5,
  203. color: "rgba(199,217,243,0.99)",
  204. },
  205. {
  206. offset: 0.5,
  207. color: "rgba(199,217,243,0.5)",
  208. },
  209. {
  210. offset: 0.5,
  211. color: "#6C86C4",
  212. },
  213. {
  214. offset: 1,
  215. color: "#6C86C4",
  216. },
  217. ]),
  218. // barBorderRadius: 0,
  219. borderRadius: 0,
  220. },
  221. // 是否在每个柱子显示 相应的值
  222. label: {
  223. show: false,
  224. position: ["0", "-25"],
  225. color: "#005dd9",
  226. fontSize: 14,
  227. fontWeight: "bold",
  228. },
  229. data: yData,
  230. }
  231. ],
  232. };
  233. };
  234. const initCharts = (domRefValue, options) => {
  235. const myChart = echarts.init(domRefValue);
  236. options && myChart.setOption(options);
  237. };
  238. //获取消息趋势
  239. const getDeviceInfo = () => {
  240. QueryTrendsmsg().then(res => {
  241. if(res.data.code == '200'){
  242. const xData = res.data.data.map(item => item.date.slice(5))
  243. const yData = res.data.data.map(item => item.reportCount)
  244. initCharts(deviceInfoRef.value, deviceInfoOption(xData, yData));
  245. }
  246. })
  247. };
  248. //获取在线趋势数据
  249. const getOnlineInfo = () => {
  250. QueryTrendsOnline().then(res => {
  251. if(res.data.code == '200'){
  252. const xData = res.data.data.map(item => item.date.slice(5))
  253. const yData = res.data.data.map(item => item.onlineCount)
  254. initCharts(onLineRef.value, onLineOptions(xData, yData));
  255. }
  256. })
  257. }
  258. onMounted(() => {
  259. getDeviceInfo()
  260. getOnlineInfo()
  261. });
  262. </script>
  263. <style scoped lang="scss">
  264. .iot-data-left {
  265. box-sizing: border-box;
  266. position: fixed;
  267. top: 0;
  268. right: 0;
  269. width: 450px;
  270. height: 100vh;
  271. font-size: 18px;
  272. z-index: 99;
  273. padding: 58px 25px 44px 0;
  274. background: linear-gradient(
  275. 90deg,
  276. rgba(0, 17, 51, 0),
  277. rgba(0, 17, 50, 0.5),
  278. rgba(0, 17, 50, 0.75)
  279. );
  280. .left-box {
  281. box-sizing: border-box;
  282. width: 100%;
  283. height: 100%;
  284. padding: 15px 25px 15px 25px;
  285. background-image: url("@/assets/imgs/IOTImage/right-bg.png");
  286. background-repeat: no-repeat;
  287. background-size: 100% 100%;
  288. .online-info {
  289. width: 100%;
  290. height: 220px;
  291. margin: 10px 0;
  292. margin-bottom: 20px;
  293. }
  294. .device-info {
  295. width: 100%;
  296. height: 220px;
  297. margin: 10px 0;
  298. margin-bottom: 20px;
  299. }
  300. .pie-position-box {
  301. position: relative;
  302. .pie-item {
  303. margin-top: 20px;
  304. }
  305. .pie-info-data {
  306. display: flex;
  307. justify-content: space-between;
  308. flex-wrap: wrap;
  309. position: absolute;
  310. top: 200px;
  311. left: 0px;
  312. z-index: 101;
  313. .pie-info-item {
  314. display: flex;
  315. width: calc(30% - 18px);
  316. flex-direction: column;
  317. text-align: left;
  318. position: relative;
  319. color: #ffffff;
  320. padding-top: 5px;
  321. padding-left: 18px;
  322. .icon-label {
  323. position: absolute;
  324. width: 9px;
  325. height: 9px;
  326. border: 1px solid;
  327. border-radius: 50%;
  328. top: 25%;
  329. left: 2px;
  330. &::before {
  331. position: absolute;
  332. top: 50%;
  333. left: 50%;
  334. transform: translate(-50%, -50%);
  335. content: "";
  336. border: 3px solid;
  337. border-color: inherit;
  338. border-radius: 5px;
  339. }
  340. }
  341. .name {
  342. font-size: 14px;
  343. color: #9bb9dd;
  344. white-space: nowrap;
  345. }
  346. .num {
  347. color: #dfecfb;
  348. font-size: 14px;
  349. font-family: "heitao";
  350. }
  351. }
  352. }
  353. }
  354. }
  355. }
  356. </style>