Bladeren bron

fix(equip&device): 修复设备详情跳转和数据展示问题

1.  恢复 equipList2 页面到气象站1的正确跳转链接
2.  优化 weatherStation1 页面参数布局,新增容器统一管理左右参数栏
3.  修复 eleDetail 表格数据展示错误:替换上报时间字段、适配u-charts数字数组格式要求
4.  新增通过名称获取表格key的方法,优化表格数据匹配逻辑
allen 5 dagen geleden
bovenliggende
commit
980b1fe5eb

+ 30 - 9
pages/deviceDetails/weatherStation1/eleDetail.vue

@@ -109,7 +109,7 @@
         <view class="fixed-column">
           <view class="table-cell header">上报时间</view>
           <view class="table-cell" v-for="(item, idx) in tableList" :key="idx">
-            {{ item.uptime }}
+            {{ item.time }}
           </view>
         </view>
         <view class="table-bg"></view>
@@ -121,7 +121,7 @@
               }}</view>
             </view>
             <view class="table-row" v-for="(item, idx) in tableList" :key="idx">
-              <view class="table-cell">{{ item[activeChartInfo.title] }}</view>
+              <view class="table-cell">{{ item[activeChartInfo.key] }}</view>
             </view>
           </view>
         </scroll-view>
@@ -177,6 +177,7 @@ export default {
       eleActive: 0,
       hasData: true,
       tableList: [],
+      titles: [],
       currentPage: 1,
       pageSize: 9,
       total: 0,
@@ -219,15 +220,20 @@ export default {
       const ctx = uni.createCanvasContext("temperatureChart", this);
       const currentEle = this.eleTabs[this.eleActive];
       console.log(currentEle, "currentEle");
-      currentEle.data.forEach((item) => {
-        if (item.value === "/" || item.value === "NA") {
-          item.value = "0";
+      // u-charts 的 series.data 必须是数字数组;原数据 value 为字符串(含 "/"、"NA"),
+      // 直接传对象数组会导致 Y 轴 min/max 计算异常,刻度全部相同
+      const seriesData = currentEle.data.map((item) => {
+        const val = item.value;
+        if (val === "/" || val === "NA" || val === null || val === undefined || val === "") {
+          return 0;
         }
+        const num = Number(val);
+        return isNaN(num) ? 0 : num;
       });
       const series = [
         {
           name: currentEle.name,
-          data: currentEle.data,
+          data: seriesData,
           lineWidth: 3,
           pointShape: "circle",
           pointSize: 12,
@@ -271,7 +277,7 @@ export default {
           scrollShow: true,
         },
         yAxis: {
-          splitNumber: 4,
+          tofix: 2,
           axisLineColor: "#E4E7ED",
           fontColor: "#656565",
           gridColor: "#E4E7ED",
@@ -380,12 +386,24 @@ export default {
       if (this.eleTabs.length === 0) return;
       this.eleActive = index;
       this.activeChartInfo = this.eleTabs[index];
+      const key = this.activeChartInfo.unit ? this.activeChartInfo.name + '(' + this.activeChartInfo.unit + ')' : this.activeChartInfo.name
+      const keyValue = this.getKeyByName(key)
+      this.activeChartInfo.key = keyValue
       this.isFolded = true; // 关闭展开面板
       this.$nextTick(() => {
         this.initChart();
       });
     },
-
+    getKeyByName(key){
+      const titles = [...this.titles]
+      let k
+      titles.forEach(title => {
+        if(title.name === key){
+          k = title.key
+        }
+      })
+      return k
+    },
     // 切换要素展开/收起状态
     toggleFold() {
       this.isFolded = !this.isFolded;
@@ -428,7 +446,9 @@ export default {
             this.eleTabs.find((item) => item.name === this.eleKey) ||
             this.eleTabs[0];
           this.eleActive = this.eleTabs.indexOf(this.activeChartInfo);
-          console.log(this.activeChartInfo, "activeChartInfo");
+          const key = this.activeChartInfo.unit ? this.activeChartInfo.name + '(' + this.activeChartInfo.unit + ')' : this.activeChartInfo.name
+          const keyValue = this.getKeyByName(key)
+          this.activeChartInfo.key = keyValue
           this.$nextTick(() => {
             this.initChart();
           });
@@ -464,6 +484,7 @@ export default {
           Array.isArray(val) ? `${val[1]}${val[3] || ""}` : val,
         );
         this.columns = resCol;
+        this.titles = res?.title || [];
         this.tableList = newData;
         this.total = res.total;
         console.log("tableList:", this.columns);

+ 28 - 21
pages/deviceDetails/weatherStation1/index.vue

@@ -121,29 +121,31 @@
             </view>
           </view>
           <view class="params-board">
-            <view class="params-left">
-              <view
-                v-for="(item, index) in statusList.slice(0, 4)"
-                :key="index"
-                class="params-item"
-              >
-                <view class="params-val">
-                  {{ item.value }}
-                  <span class="unit">{{ item.unit }}</span>
+            <view class="params-left-container">
+              <view class="params-left">
+                <view
+                  v-for="(item, index) in statusList.slice(0, 4)"
+                  :key="index"
+                  class="params-item"
+                >
+                  <view class="params-val">
+                    {{ item.value }}
+                    <span class="unit">{{ item.unit }}</span>
+                  </view>
+                  <view class="params-label">{{ item.name }}</view>
                 </view>
-                <view class="params-label">{{ item.name }}</view>
-              </view>
-            </view><view class="params-left">
-              <view
-                v-for="(item, index) in statusList.slice(4, 8)"
-                :key="index"
-                class="params-item"
-              >
-                <view class="params-val">
-                  {{ item.value }}
-                  <span class="unit">{{ item.unit }}</span>
+              </view><view class="params-left">
+                <view
+                  v-for="(item, index) in statusList.slice(4, 8)"
+                  :key="index"
+                  class="params-item"
+                >
+                  <view class="params-val">
+                    {{ item.value }}
+                    <span class="unit">{{ item.unit }}</span>
+                  </view>
+                  <view class="params-label">{{ item.name }}</view>
                 </view>
-                <view class="params-label">{{ item.name }}</view>
               </view>
             </view>
             <view class="params-right">
@@ -815,7 +817,12 @@ export default {
       justify-content: space-between;
       align-items: center;
       position: relative;
+      .params-left-container{
+        display: flex;
+        justify-content: space-between;
+      }
       .params-left {
+        flex:1;
         display: flex;
         flex-wrap: wrap;
         .params-item {

+ 14 - 14
pages/equipList2/index.vue

@@ -358,23 +358,23 @@
 						}
 						break;
 					case 38:
-						// uni.navigateTo({
-						// 	url: `../deviceDetails/weatherStation1/index?devBid=${item.id}&devName=${item.name}&devStatus=${item.status}&address=${item.address}&uptime=${item.uptime}&d_id=${item.d_id}&deviceType=46`,
-						// });
-						// break;
-						
-						var obj = {};
-						obj.d_id = item.d_id;
-						obj.equip_id = item.id;
-						obj.is_online = item.status;
-						obj.lat = item.lat;
-						obj.lng = item.lng;
-						obj.equip_name = item.name;
-						obj.uptime = item.uptime;
 						uni.navigateTo({
-							url: '../environment/equipment-new?shebei=' + JSON.stringify(obj),
+							url: `../deviceDetails/weatherStation1/index?devBid=${item.id}&devName=${item.name}&devStatus=${item.status}&address=${item.address}&uptime=${item.uptime}&d_id=${item.d_id}&deviceType=46`,
 						});
 						break;
+						
+						// var obj = {};
+						// obj.d_id = item.d_id;
+						// obj.equip_id = item.id;
+						// obj.is_online = item.status;
+						// obj.lat = item.lat;
+						// obj.lng = item.lng;
+						// obj.equip_name = item.name;
+						// obj.uptime = item.uptime;
+						// uni.navigateTo({
+						// 	url: '../environment/equipment-new?shebei=' + JSON.stringify(obj),
+						// });
+						break;
 					case 5:
 						var obj = {};
 						obj.d_id = item.d_id;