Explorar o código

接口多请求修改

yf_wsy %!s(int64=3) %!d(string=hai) anos
pai
achega
4f02de3a84

+ 239 - 3
bigdata2/src/pages/cure/scd/scdDetail.vue

@@ -10,7 +10,7 @@
 				<span>设备名称:{{name || '无'}}</span>
 				<span>位置:{{address}}</span>
 			</div>
-			<DateSearch @dateChange="dateChange"></DateSearch>
+			<DateSearch @dateChange="dateChange" ref="setSelected"></DateSearch>
 		</div>
 		<div class="ctrl-check">
 			<el-button type="primary" size="mini" @click="refresh">刷新</el-button>
@@ -78,6 +78,10 @@ export default {
 	},
 	data() {
 		return {
+			isOne:true,
+			isSelect:true,
+			isSelectNian:true,
+			isSelectYear:true,
 			id: this.$route.query.id,
 			name: this.$route.query.name,
 			address: this.$route.query.address,
@@ -145,6 +149,233 @@ export default {
 	},
 	methods: {
 		//获取折线数据
+		initChartDataList() {
+			this.$axios({
+				method: 'POST',
+				url: '/scd_report_detail_chart',
+				data: this.qs.stringify({
+					req: 'filter',
+					id: this.queryInfo.e_id,
+					begin: this.queryInfo.begin,
+					end: this.queryInfo.end
+				})
+			}).then((res) => {
+				if (res.data.length > 0) {
+					this.isOne = false;
+					var ChartData = [
+						{
+							name: '温度(°C)',
+							dat: []
+						},
+						{
+							name: '湿度(%)',
+							dat: []
+						},
+						{
+							name: '击虫次数',
+							dat: []
+						}
+					]
+					var data = res.data
+					this.options = {}
+					this.options2 = {}
+					if (data.length > 0) {
+						for (let item of data) {
+							ChartData[0].dat.unshift([
+								this.returnTime(item.tim),
+								parseFloat(item.at)
+							])
+							ChartData[1].dat.unshift([
+								this.returnTime(item.tim),
+								parseFloat(item.ah)
+							])
+							ChartData[2].dat.unshift([
+								this.returnTime(item.tim),
+								item.ct
+							])
+						}
+						this.options = {
+							chart: {
+								zoomType: 'x'
+							},
+							title: {
+								text: '环境温湿度',
+								align: 'left'
+							},
+							subtitle: {
+								text: ''
+							},
+							xAxis: {
+								crosshair: true, //十字基准线
+								type: 'datetime',
+								dateTimeLabelFormats: {
+									//根据时间间距X轴自动显示哪种格式
+									millisecond: '%H:%M:%S.%L',
+									second: '%H:%M:%S',
+									minute: '%H:%M',
+									hour: '%H:%M',
+									day: '%m-%d',
+									week: '%m-%d',
+									month: '%Y-%m',
+									year: '%Y'
+								}
+							},
+							yAxis: {
+								title: {
+									text: ''
+								}
+							},
+							legend: {
+								// layout: 'vertical',
+								align: 'right',
+								verticalAlign: 'top'
+							},
+							plotOptions: {
+								series: {
+									label: {
+										connectorAllowed: false
+									},
+									pointStart: 2010
+								}
+							},
+							series: [
+								{
+									name: ChartData[0].name,
+									data: ChartData[0].dat
+								},
+								{
+									name: ChartData[1].name,
+									data: ChartData[1].dat
+								}
+							],
+							colors: ['#00e29d', '#6cbbff', '#ff3f3f'],
+							credits: {
+								//去掉默认的highcharts.com
+								enabled: false
+							},
+							tooltip: {
+								// crosshairs: true,
+								shared: true, //折线共享
+								headerFormat: '<b>{point.x:%Y-%m-%e %H:%M:%S}</b><br>'
+							},
+							responsive: {
+								rules: [
+									{
+										condition: {
+											maxWidth: 500
+										},
+										chartOptions: {
+											legend: {
+												layout: 'horizontal',
+												align: 'center',
+												verticalAlign: 'bottom'
+											}
+										}
+									}
+								]
+							}
+						}
+
+						this.options2 = {
+							chart: {
+								zoomType: 'x'
+							},
+							title: {
+								text: '击虫次数',
+								align: 'left'
+							},
+							subtitle: {
+								text: ''
+							},
+							xAxis: {
+								crosshair: true, //十字基准线
+								type: 'datetime',
+								dateTimeLabelFormats: {
+									//根据时间间距X轴自动显示哪种格式
+									millisecond: '%H:%M:%S.%L',
+									second: '%H:%M:%S',
+									minute: '%H:%M',
+									hour: '%H:%M',
+									day: '%m-%d',
+									week: '%m-%d',
+									month: '%Y-%m',
+									year: '%Y'
+								}
+							},
+							yAxis: {
+								title: {
+									text: ''
+								}
+							},
+							legend: {
+								// layout: 'vertical',
+								align: 'right',
+								verticalAlign: 'top'
+							},
+							plotOptions: {
+								series: {
+									label: {
+										connectorAllowed: false
+									},
+									pointStart: 2010
+								}
+							},
+							series: [
+								{
+									name: ChartData[2].name,
+									data: ChartData[2].dat
+								}
+							],
+							colors: ['#00e29d', '#6cbbff', '#ff3f3f'],
+							credits: {
+								//去掉默认的highcharts.com
+								enabled: false
+							},
+							tooltip: {
+								// crosshairs: true,
+								shared: true, //折线共享
+								headerFormat: '<b>{point.x:%Y-%m-%e %H:%M:%S}</b><br>'
+							},
+							responsive: {
+								rules: [
+									{
+										condition: {
+											maxWidth: 500
+										},
+										chartOptions: {
+											legend: {
+												layout: 'horizontal',
+												align: 'center',
+												verticalAlign: 'bottom'
+											}
+										}
+									}
+								]
+							}
+						}
+					}
+				}else{
+					this.options = {}
+					this.options2 = {}
+					if(this.isSelect){
+						this.$refs.setSelected.timeBtnClick(2);
+						this.isSelect = false
+						// this.getChartDataList()
+						// this.getHisDataList()
+					}else if(this.isSelectNian){
+						this.$refs.setSelected.timeBtnClick(3);
+						this.isSelectNian = false
+						// this.getChartDataList()
+						// this.getHisDataList()
+					}else if(this.isSelectYear){
+						this.$refs.setSelected.timeBtnClick(4);
+						this.isSelectYear = false
+						// this.getChartDataList()
+						// this.getHisDataList()
+					}
+				}
+			})
+		},
 		getChartDataList() {
 			this.$axios({
 				method: 'POST',
@@ -413,8 +644,13 @@ export default {
 			this.queryInfo.page = 1
 			this.queryInfo.begin = new Date(data.begin*1000).toLocaleDateString().replace(/\//g,'-'); 
 			this.queryInfo.end = new Date(data.end*1000).toLocaleDateString().replace(/\//g,'-'); 
-			this.getHisDataList()
-			this.getChartDataList()
+			if(this.isOne){
+				this.initChartDataList()
+				this.getHisDataList()
+			}else{
+				this.getChartDataList()
+				this.getHisDataList()
+			}
 		},
 		//改变page
 		changePage(val) {

+ 9 - 8
bigdata2/src/pages/forecasting/bzy/DataDetail.vue

@@ -131,6 +131,7 @@ export default {
 				})
 			}).then((res) => {
 				if (res.data.length) {
+					this.isOne = false;
 					var ChartData = [
 						{
 							name: '温度(°C)',
@@ -322,18 +323,18 @@ export default {
 					if(this.isSelect){
 						this.$refs.setSelected.timeBtnClick(2);
 						this.isSelect = false
-						this.getChartDataList()
-						this.getHisDataList()
+						// this.getChartDataList()
+						// this.getHisDataList()
 					}else if(this.isSelectNian){
 						this.$refs.setSelected.timeBtnClick(3);
 						this.isSelectNian = false
-						this.getChartDataList()
-						this.getHisDataList()
+						// this.getChartDataList()
+						// this.getHisDataList()
 					}else if(this.isSelectYear){
 						this.$refs.setSelected.timeBtnClick(4);
 						this.isSelectYear = false
-						this.getChartDataList()
-						this.getHisDataList()
+						// this.getChartDataList()
+						// this.getHisDataList()
 					}
 				}
 			})
@@ -606,13 +607,13 @@ export default {
 			this.queryInfo.page = 1
 			this.queryInfo.begin = new Date(data.begin*1000).toLocaleDateString().replace(/\//g,'-'); 
 			this.queryInfo.end = new Date(data.end*1000).toLocaleDateString().replace(/\//g,'-'); 
-			this.getHisDataList()
 			if(this.isOne){
 				this.initChartDataList()
+				this.getHisDataList()
 			}else{
 				this.getChartDataList()
+				this.getHisDataList()
 			}
-			this.isOne = false
 		},
 		changePage(val) {
 			this.queryInfo.page = val

+ 9 - 9
bigdata2/src/pages/forecasting/cbd/DataDetails.vue

@@ -386,6 +386,7 @@ export default {
 				})
 			}).then((res) => {
 				if(res.data.length>0){
+					this.isOne = false;
 					var at = [],ah = [];
 					for(var i = 0;i<res.data.length;i++){
 						at.push([this.returnTime(res.data[i].tim),res.data[i].at/10])
@@ -481,20 +482,20 @@ export default {
 					console.log(res.data.length);
 						this.$refs.setSelected.timeBtnClick(2);
 						this.isSelect = false
-						this.getChartLine();
-						this.getHisDataList()
+						// this.getChartLine();
+						// this.getHisDataList()
 					}else if(this.isSelectNian){
 					console.log(res.data.length);
 						this.$refs.setSelected.timeBtnClick(3);
 						this.isSelectNian = false
-						this.getChartLine()
-						this.getHisDataList()
+						// this.getChartLine()
+						// this.getHisDataList()
 					}else if(this.isSelectYear){
 					console.log(res.data.length);
 						this.$refs.setSelected.timeBtnClick(4);
 						this.isSelectYear = false
-						this.getChartLine()
-						this.getHisDataList()
+						// this.getChartLine()
+						// this.getHisDataList()
 					}
 				}
 			})
@@ -640,14 +641,13 @@ export default {
 			this.queryInfo.page = 1
 			this.queryInfo.begin = new Date(data.begin*1000).toLocaleDateString().replace(/\//g,'-'); 
 			this.queryInfo.end = new Date(data.end*1000).toLocaleDateString().replace(/\//g,'-'); 
-			this.getChartLine()
-			this.getHisDataList()
 			if(this.isOne){
 				this.initChartLine()
+				this.getHisDataList()
 			}else{
 				this.getChartLine()
+				this.getHisDataList()
 			}
-			this.isOne = false
 		},
 		//获取表格数据
 		getHisDataList() {

+ 242 - 221
bigdata2/src/pages/forecasting/xycb/xycbDataDetail.vue

@@ -166,222 +166,226 @@ export default {
 			return timestamp;
 		},
 		//获取折线数据
-		initChartDataList() {
-			this.$axios({
-				method: 'POST',
-				url: '/sex_at_ah',
-				data: this.qs.stringify({
-					begin:  this.queryInfo.begin,
-					end: this.queryInfo.end,
-					e_id: this.queryInfo.e_id,
-				})
-			}).then((res) => {
-				if (res.data.length > 0) {
-					var ChartData = [
-						{
-							name: '温度(°C)',
-							dat: []
-						},
-						{
-							name: '湿度(%)',
-							dat: []
-						},
-						{
-							name: '红外计数值',
-							dat: []
-						},
-						{
-							name: '高压计数值',
-							dat: []
-						},
-						{
-							name: 'cpu温度(°C)',
-							dat: []
-						}
-					]
-					var data = res.data
-					for (let item of data) {
-						ChartData[0].dat.unshift([
-							this.returnTime(item.tim),
-							Number(item.at)
-						])
-						ChartData[1].dat.unshift([
-							this.returnTime(item.tim),
-							Number(item.ah)
-						])
-						ChartData[2].dat.unshift([
-							this.returnTime(item.tim),
-							Number(item.infr_ct)
-						])
-					}
-					this.options = {
-						chart: {
-							zoomType: 'x'
-						},
-						title: {
-							text: '环境温湿度',
-							align: 'left'
-						},
-						subtitle: {
-							text: ''
-						},
-						xAxis: {
-							crosshair: true, //十字基准线
-							type: 'datetime',
-							dateTimeLabelFormats: {
-								//根据时间间距X轴自动显示哪种格式
-								millisecond: '%H:%M:%S.%L',
-								second: '%H:%M:%S',
-								minute: '%H:%M',
-								hour: '%H:%M',
-								day: '%m-%d',
-								week: '%m-%d',
-								month: '%Y-%m',
-								year: '%Y'
-							}
-						},
-						yAxis: {
-							title: {
-								text: ''
-							}
-						},
-						legend: {
-							// layout: 'vertical',
-							align: 'right',
-							verticalAlign: 'top'
-						},
-						plotOptions: {
-							series: {
-								label: {
-									connectorAllowed: false
-								},
-								pointStart: 2010
-							}
-						},
-						series: [
-							{
-								type: 'spline',
-								name: ChartData[0].name,
-								data: ChartData[0].dat
-							},
-							{
-								type: 'spline',
-								name: ChartData[1].name,
-								data: ChartData[1].dat
-							},
-						],
-						colors: ['#6cbbff', '#ff3f3f','#00e29d', ],
-						credits: {
-							//去掉默认的highcharts.com
-							enabled: false
-						},
-						tooltip: {
-							// crosshairs: true,
-							shared: true, //折线共享
-							headerFormat: '<b>{point.x:%Y-%m-%e %H:%M:%S}</b><br>'
-						}
-					}
-					this.options2 = {
-						chart: {
-							zoomType: 'x'
-						},
-						title: {
-							text: '红外计数值',
-							align: 'left'
-						},
-						subtitle: {
-							text: ''
-						},
-						xAxis: {
-							crosshair: true, //十字基准线
-							type: 'datetime',
-							dateTimeLabelFormats: {
-								//根据时间间距X轴自动显示哪种格式
-								millisecond: '%H:%M:%S.%L',
-								second: '%H:%M:%S',
-								minute: '%H:%M',
-								hour: '%H:%M',
-								day: '%m-%d',
-								week: '%m-%d',
-								month: '%Y-%m',
-								year: '%Y'
-							}
-						},
-						yAxis: {
-							title: {
-								text: ''
-							}
-						},
-						legend: {
-							// layout: 'vertical',
-							align: 'right',
-							verticalAlign: 'top'
-						},
-						plotOptions: {
-							series: {
-								label: {
-									connectorAllowed: false
-								},
-								pointStart: 2010
-							}
-						},
-						series: [
-							{
-								type: 'spline',
-								name: ChartData[2].name,
-								data: ChartData[2].dat
-							}
-						],
-						colors: ['#00e29d', '#6cbbff', '#ff3f3f'],
-						credits: {
-							//去掉默认的highcharts.com
-							enabled: false
-						},
-						tooltip: {
-							// crosshairs: true,
-							shared: true, //折线共享
-							headerFormat: '<b>{point.x:%Y-%m-%e %H:%M:%S}</b><br>'
-						},
-						responsive: {
-							rules: [
-								{
-									condition: {
-										maxWidth: 500
-									},
-									chartOptions: {
-										legend: {
-											layout: 'horizontal',
-											align: 'center',
-											verticalAlign: 'bottom'
-										}
-									}
-								}
-							]
-						}
-					}
+		// initChartDataList() {
+		// 	this.$axios({
+		// 		method: 'POST',
+		// 		url: '/sex_at_ah',
+		// 		data: this.qs.stringify({
+		// 			begin:  this.queryInfo.begin,
+		// 			end: this.queryInfo.end,
+		// 			e_id: this.queryInfo.e_id,
+		// 		})
+		// 	}).then((res) => {
+		// 		if (res.data.length > 0) {
+		// 			this.isOne = false;
+		// 			var ChartData = [
+		// 				{
+		// 					name: '温度(°C)',
+		// 					dat: []
+		// 				},
+		// 				{
+		// 					name: '湿度(%)',
+		// 					dat: []
+		// 				},
+		// 				{
+		// 					name: '红外计数值',
+		// 					dat: []
+		// 				},
+		// 				{
+		// 					name: '高压计数值',
+		// 					dat: []
+		// 				},
+		// 				{
+		// 					name: 'cpu温度(°C)',
+		// 					dat: []
+		// 				}
+		// 			]
+		// 			var data = res.data
+		// 			for (let item of data) {
+		// 				ChartData[0].dat.unshift([
+		// 					this.returnTime(item.tim),
+		// 					Number(item.at)
+		// 				])
+		// 				ChartData[1].dat.unshift([
+		// 					this.returnTime(item.tim),
+		// 					Number(item.ah)
+		// 				])
+		// 				ChartData[2].dat.unshift([
+		// 					this.returnTime(item.tim),
+		// 					Number(item.infr_ct)
+		// 				])
+		// 			}
+		// 			this.options = {
+		// 				chart: {
+		// 					zoomType: 'x'
+		// 				},
+		// 				title: {
+		// 					text: '环境温湿度',
+		// 					align: 'left'
+		// 				},
+		// 				subtitle: {
+		// 					text: ''
+		// 				},
+		// 				xAxis: {
+		// 					crosshair: true, //十字基准线
+		// 					type: 'datetime',
+		// 					dateTimeLabelFormats: {
+		// 						//根据时间间距X轴自动显示哪种格式
+		// 						millisecond: '%H:%M:%S.%L',
+		// 						second: '%H:%M:%S',
+		// 						minute: '%H:%M',
+		// 						hour: '%H:%M',
+		// 						day: '%m-%d',
+		// 						week: '%m-%d',
+		// 						month: '%Y-%m',
+		// 						year: '%Y'
+		// 					}
+		// 				},
+		// 				yAxis: {
+		// 					title: {
+		// 						text: ''
+		// 					}
+		// 				},
+		// 				legend: {
+		// 					// layout: 'vertical',
+		// 					align: 'right',
+		// 					verticalAlign: 'top'
+		// 				},
+		// 				plotOptions: {
+		// 					series: {
+		// 						label: {
+		// 							connectorAllowed: false
+		// 						},
+		// 						pointStart: 2010
+		// 					}
+		// 				},
+		// 				series: [
+		// 					{
+		// 						type: 'spline',
+		// 						name: ChartData[0].name,
+		// 						data: ChartData[0].dat
+		// 					},
+		// 					{
+		// 						type: 'spline',
+		// 						name: ChartData[1].name,
+		// 						data: ChartData[1].dat
+		// 					},
+		// 				],
+		// 				colors: ['#6cbbff', '#ff3f3f','#00e29d', ],
+		// 				credits: {
+		// 					//去掉默认的highcharts.com
+		// 					enabled: false
+		// 				},
+		// 				tooltip: {
+		// 					// crosshairs: true,
+		// 					shared: true, //折线共享
+		// 					headerFormat: '<b>{point.x:%Y-%m-%e %H:%M:%S}</b><br>'
+		// 				}
+		// 			}
+		// 			this.options2 = {
+		// 				chart: {
+		// 					zoomType: 'x'
+		// 				},
+		// 				title: {
+		// 					text: '红外计数值',
+		// 					align: 'left'
+		// 				},
+		// 				subtitle: {
+		// 					text: ''
+		// 				},
+		// 				xAxis: {
+		// 					crosshair: true, //十字基准线
+		// 					type: 'datetime',
+		// 					dateTimeLabelFormats: {
+		// 						//根据时间间距X轴自动显示哪种格式
+		// 						millisecond: '%H:%M:%S.%L',
+		// 						second: '%H:%M:%S',
+		// 						minute: '%H:%M',
+		// 						hour: '%H:%M',
+		// 						day: '%m-%d',
+		// 						week: '%m-%d',
+		// 						month: '%Y-%m',
+		// 						year: '%Y'
+		// 					}
+		// 				},
+		// 				yAxis: {
+		// 					title: {
+		// 						text: ''
+		// 					}
+		// 				},
+		// 				legend: {
+		// 					// layout: 'vertical',
+		// 					align: 'right',
+		// 					verticalAlign: 'top'
+		// 				},
+		// 				plotOptions: {
+		// 					series: {
+		// 						label: {
+		// 							connectorAllowed: false
+		// 						},
+		// 						pointStart: 2010
+		// 					}
+		// 				},
+		// 				series: [
+		// 					{
+		// 						type: 'spline',
+		// 						name: ChartData[2].name,
+		// 						data: ChartData[2].dat
+		// 					}
+		// 				],
+		// 				colors: ['#00e29d', '#6cbbff', '#ff3f3f'],
+		// 				credits: {
+		// 					//去掉默认的highcharts.com
+		// 					enabled: false
+		// 				},
+		// 				tooltip: {
+		// 					// crosshairs: true,
+		// 					shared: true, //折线共享
+		// 					headerFormat: '<b>{point.x:%Y-%m-%e %H:%M:%S}</b><br>'
+		// 				},
+		// 				responsive: {
+		// 					rules: [
+		// 						{
+		// 							condition: {
+		// 								maxWidth: 500
+		// 							},
+		// 							chartOptions: {
+		// 								legend: {
+		// 									layout: 'horizontal',
+		// 									align: 'center',
+		// 									verticalAlign: 'bottom'
+		// 								}
+		// 							}
+		// 						}
+		// 					]
+		// 				}
+		// 			}
 					
-				}else{
-					this.options = {};
-					this.options2 = {};
-					if(this.isSelect){
-						this.$refs.setSelected.timeBtnClick(2);
-						this.isSelect = false
-						this.getChartDataList()
-						this.getHisDataList()
-					}else if(this.isSelectNian){
-						this.$refs.setSelected.timeBtnClick(3);
-						this.isSelectNian = false
-						this.getChartDataList()
-						this.getHisDataList()
-					}else if(this.isSelectYear){
-						this.$refs.setSelected.timeBtnClick(4);
-						this.isSelectYear = false
-						this.getChartDataList()
-						this.getHisDataList()
-					}
-				}
-			})
-		},
+		// 		}else{
+		// 			this.options = {};
+		// 			this.options2 = {};
+		// 			if(this.isSelect){
+		// 				console.log("月月");
+		// 				this.$refs.setSelected.timeBtnClick(2);
+		// 				this.isSelect = false
+		// 				this.getChartDataList()
+		// 				this.getHisDataList()
+		// 			}else if(this.isSelectNian){
+		// 				console.log("半半半");
+		// 				this.$refs.setSelected.timeBtnClick(3);
+		// 				this.isSelectNian = false
+		// 				this.getChartDataList()
+		// 				this.getHisDataList()
+		// 			}else if(this.isSelectYear){
+		// 				console.log("年年年");
+		// 				this.$refs.setSelected.timeBtnClick(4);
+		// 				this.isSelectYear = false
+		// 				this.getChartDataList()
+		// 				this.getHisDataList()
+		// 			}
+		// 		}
+		// 	})
+		// },
 		//获取折线数据
 		getChartDataList() {
 			this.$axios({
@@ -393,7 +397,9 @@ export default {
 					e_id: this.queryInfo.e_id,
 				})
 			}).then((res) => {
+				console.log(res.data.length)
 				if (res.data.length > 0) {
+					this.isOne = false;
 					var ChartData = [
 						{
 							name: '温度(°C)',
@@ -576,11 +582,27 @@ export default {
 							]
 						}
 					}
-					
 				}else{
 					this.options = {};
 					this.options2 = {};
-					
+					if(this.isOne){
+						if(this.isSelect){
+							this.$refs.setSelected.timeBtnClick(2);
+							this.isSelect = false
+							// this.getChartDataList()
+							// this.getHisDataList()
+						}else if(this.isSelectNian){
+							this.$refs.setSelected.timeBtnClick(3);
+							this.isSelectNian = false
+							// this.getChartDataList()
+							// this.getHisDataList()
+						}else if(this.isSelectYear){
+							this.$refs.setSelected.timeBtnClick(4);
+							this.isSelectYear = false
+							// this.getChartDataList()
+							// this.getHisDataList()
+					}
+					}
 				}
 			})
 		},
@@ -645,20 +667,19 @@ export default {
 		//改变page
 		changePage(val) {
 			this.queryInfo.page = val
+			console.log("改变page表格");
 			this.getHisDataList()
 		},
 		dateChange(data) {
-			console.log(data.begin);
 			this.queryInfo.page = 1
 			this.queryInfo.begin = data.begin?new Date(data.begin*1000).toLocaleDateString().replace(/\//g,'-'):''; 
 			this.queryInfo.end = data.end?new Date(data.end*1000).toLocaleDateString().replace(/\//g,'-'):''; 
 			this.getHisDataList()
 			if(this.isOne){
-				this.initChartDataList()
-			}else{
 				this.getChartDataList()
 			}
-			this.isOne = false
+			
+			
 		},
 		setWidth(item) {
 			if (item[1] == 'addtime') {