Jelajahi Sumber

fix: 修复设备历史数据展示和图表逻辑问题

1. 修正equipList2页面中pur_id的赋值错误
2. 重构gshistory.vue的表格列和数据处理逻辑,移除冗余的空气温湿度字段,新增电导率展示
3. 简化表头数据初始化和图表数据组装代码,优化遍历逻辑
4. 调整控制台日志输出内容
allen 3 hari lalu
induk
melakukan
7522134297
2 mengubah file dengan 32 tambahan dan 54 penghapusan
  1. 31 53
      pages/environment/gshistory.vue
  2. 1 1
      pages/equipList2/index.vue

+ 31 - 53
pages/environment/gshistory.vue

@@ -42,11 +42,9 @@
 						</tr>
 						<tr class="tr" v-for="(items,indexs) in historylistdata" :key="'b'+indexs" v-if="!forbidden">
 							<td class="td">{{items.upl_time|timeFormat()}}</td>
-							<td class="td">{{items.ats}}</td>
-							<td class="td">{{items.at}}</td>
 							<td class="td" v-for="(item,index) in items.temp" :key="'c'+index">{{item}}</td>
 							<td class="td" v-for="(item,index) in items.swc" :key="'d'+index">{{item}}</td>
-							<td class="td">{{items.atm}}</td>
+							<td class="td" v-for="(item,index) in items.ecs" :key="'e'+index">{{item}}</td>
 						</tr>
 						<tr class="tr" v-if="forbidden">
 							<td class="td" v-for="item in 13">暂无数据</td>
@@ -80,9 +78,7 @@
 				dataloadingtf: true,
 				canvastishiTF: false,
 				device_id: '', //设备ID
-				thdata: ["上传时间", "空气湿度(%RH)", "空气温度(℃)", "10cm土壤温度(%RH)", "20cm土壤温度(%RH)", "30cm土壤温度(%RH)", "10cm土壤湿度(%RH)", "20cm土壤湿度(%RH)", "30cm土壤湿度(%RH)",
-					"大气压强(Pa)"
-				], //表格抬头
+				thdata: ["上传时间"], //表格抬头
 				forbidden: false,
 				historylistdata: [], //历史数据
 				pagesum: 1,
@@ -129,59 +125,41 @@
 				var arr1 = []
 				var arr2 = []
 				var xtitle = []
-				var obj = [{
-					name: '空气温度',
-					data: [],
-					color: '#00E29D'
-				}, {
-					name: '空气湿度',
-					data: [],
-					color: '#6CBBFF'
-				}]
-				var arr3 = []
+				var obj = []
 				var k = 0
 				for (var i = 0; i < res.dat_char.length; i++) {
 					var times = new Date(res.dat_char[i].upl_time * 1000)
 					xtitle.unshift(times.getMonth() + 1 + "/" + times.getDate() + "-" + times.getHours() + ":" + times
 						.getMinutes())
-					arr1.unshift(res.dat_char[i].at == "" ? "0" : res.dat_char[i].at) //空气温度
-					arr2.unshift(res.dat_char[i].ats == "" ? "0" : res.dat_char[i].ats) //空气湿度
-					res.dat_char[i].temp = res.dat_char[i].temp.split(",")
-					res.dat_char[i].swc = res.dat_char[i].swc.split(",")
-					res.dat_char[i].ecs = res.dat_char[i].ecs.split(",")
-					for (var j = 0; j < res.dat_char[i].temp.length; j++) {
-						arr3.unshift(res.dat_char[i].temp[j] == "" ? "0" : res.dat_char[i].temp[j]) //10cm土壤温度
-					}
+					const temp = res.dat_char[i].temp.split(",")
+					const swc = res.dat_char[i].swc.split(",")
+					const ecs = res.dat_char[i].ecs.split(",")
 					this.thdata.length = 1;
 					res.depth.split(',').forEach((dep, index) => {
 						this.thdata.push(`${dep}cm土壤温度(℃)`)
-						res.dat_char[i].temp.forEach((items, indexs) => {
-							var tempdata = [];
-							var tempdatas = [];
-							var ecsarr = [];
-							tempdata.push(Number(items));
-							tempdatas.push(Number(res.dat_char[i].swc[indexs]));
-							if((res.dat_char[i]).ecs[indexs]) {
-								ecsarr.push(Number(res.dat_char[i].ecs[indexs]));
-							}
-							var temparrs = {
-								name: dep + "cm土壤温度(℃)",
-								data: tempdata,
-							};
-							var temparr = {
-								name: dep + "cm土壤湿度(%RH)",
-								data: tempdatas,
-							};
-							var ecsparr = {
-								name: dep + "cm电导率(ms/cm)",
-								data: ecsarr,
-							};
-							obj.push(temparr);
-							obj.push(temparrs);
-							if(ecsarr.length > 0) {
-								obj.push(ecsparr);
-							}
-						});
+						var tempdata = [];
+						var tempdatas = [];
+						var ecsarr = [];
+						tempdata.push(Number(temp[index]));
+						tempdatas.push(Number(swc[index]));
+						ecsarr.push(Number(ecs[index]));
+						var temparrs = {
+							name: dep + "cm土壤温度(℃)",
+							data: tempdata,
+						};
+						var temparr = {
+							name: dep + "cm土壤湿度(%RH)",
+							data: tempdatas,
+						};
+						var ecsparr = {
+							name: dep + "cm电导率(ms/cm)",
+							data: ecsarr,
+						};
+						obj.push(temparr);
+						obj.push(temparrs);
+						if(ecsarr.length > 0) {
+							obj.push(ecsparr);
+						}
 					})
 					res.depth.split(',').forEach((dep, index) => {
 						this.thdata.push(`${dep}cm土壤湿度(%RH)`)
@@ -207,8 +185,8 @@
 						data: el.data,
 					});
 				});
-				console.log(listArr)
-				if(listArr.length==0){
+				console.log(listArr,'listArrlistArrlistArr')
+				if(listArr.length == 0){
 					this.canvastishiTF = false
 				}else{
 					this.canvastishiTF = true

+ 1 - 1
pages/equipList2/index.vue

@@ -288,7 +288,7 @@
       },
 			historys(item) {
 				const type_id = item.type_id;
-				item.pur_id = this.currentPur_id;
+				item.pur_id = this.pur_id;
 				switch (type_id) {
 					// 水肥新设备
 					case 22: