Răsfoiți Sursa

近三天报警趋势接口对接

like 6 luni în urmă
părinte
comite
9a373ffc5f

+ 12 - 0
snowy-admin-web/src/api/coldchain/alarmTrendApi.js

@@ -0,0 +1,12 @@
+import { baseRequest } from '@/utils/request'
+
+const request = (url, ...arg) => baseRequest(`/coldchain/monitornotice/` + url, ...arg)
+
+/**
+ * 首页近三天报警趋势Api接口
+ **/
+export default {
+	threeDays(data) {
+		return request('getNoticeByDate', data, 'get')
+	}
+}

+ 25 - 39
snowy-admin-web/src/components/HomeCard/SysTrendCard/index.vue

@@ -34,13 +34,26 @@
 
 <script setup name="SysTrendCard">
 	import * as echarts from 'echarts'
+	import alarmTrendApi from '@/api/coldchain/alarmTrendApi.js'
 
 	onMounted(() => {
-		getEcharts1()
-		getEcharts2()
-		getEcharts3()
+		init()
 	})
-	const getEcharts1 = () => {
+
+	const data = ref([])
+
+	const init = () => {
+		alarmTrendApi.threeDays().then((res) => {
+			if (res && res.length > 0) {
+				getEcharts1(res[2])
+				getEcharts2(res[1])
+				getEcharts3(res[0])
+				console.log(res, 'xxxxxxxxxxxxxxxxxxxxxxx')
+			}
+		})
+	}
+
+	const getEcharts1 = (val) => {
 		let Echarts = echarts.init(document.getElementById('echart1'))
 		const option = {
 			tooltip: {
@@ -61,16 +74,7 @@
 			},
 			xAxis: {
 				type: 'category',
-				data: [
-					'00:00-03:00',
-					'03:00-06:00',
-					'06:00-09:00',
-					'09:00-12:00',
-					'12:00-15:00',
-					'15:00-18:00',
-					'18:00-21:00',
-					'21:00-24:00'
-				],
+				data: val.timePeriodList,
 
 				axisPointer: {
 					type: 'shadow'
@@ -104,7 +108,7 @@
 			series: [
 				{
 					name: '报警次数',
-					data: [12, 34, 41, 5, 28, 19, 4, 36],
+					data: val.countList,
 					type: 'line',
 					smooth: true,
 					showSymbol: false,
@@ -139,7 +143,7 @@
 		}
 	}
 
-	const getEcharts2 = () => {
+	const getEcharts2 = (val) => {
 		let Echarts = echarts.init(document.getElementById('echart2'))
 		const option = {
 			tooltip: {
@@ -160,16 +164,7 @@
 			},
 			xAxis: {
 				type: 'category',
-				data: [
-					'00:00-03:00',
-					'03:00-06:00',
-					'06:00-09:00',
-					'09:00-12:00',
-					'12:00-15:00',
-					'15:00-18:00',
-					'18:00-21:00',
-					'21:00-24:00'
-				],
+				data: val.timePeriodList,
 				axisPointer: {
 					type: 'shadow'
 				},
@@ -202,7 +197,7 @@
 			series: [
 				{
 					name: '报警次数',
-					data: [6, 64, 34, 10, 30, 21, 49, 14],
+					data: val.countList,
 					type: 'line',
 					smooth: true,
 					showSymbol: false,
@@ -236,7 +231,7 @@
 			Echarts.resize()
 		}
 	}
-	const getEcharts3 = () => {
+	const getEcharts3 = (val) => {
 		let Echarts = echarts.init(document.getElementById('echart3'))
 		const option = {
 			tooltip: {
@@ -257,16 +252,7 @@
 			},
 			xAxis: {
 				type: 'category',
-				data: [
-					'00:00-03:00',
-					'03:00-06:00',
-					'06:00-09:00',
-					'09:00-12:00',
-					'12:00-15:00',
-					'15:00-18:00',
-					'18:00-21:00',
-					'21:00-24:00'
-				],
+				data: val.timePeriodList,
 				axisPointer: {
 					type: 'shadow'
 				},
@@ -299,7 +285,7 @@
 			series: [
 				{
 					name: '报警次数',
-					data: [10, 25, 51, 3, 4, 0, 0, 0],
+					data: val.countList,
 					type: 'line',
 					smooth: true,
 					showSymbol: false,