Explorar el Código

列表页面部分字段数据展示bug修改

bobo04052021@163.com hace 4 días
padre
commit
4b5a9d37e3
Se han modificado 1 ficheros con 58 adiciones y 32 borrados
  1. 58 32
      pages/home/home.vue

+ 58 - 32
pages/home/home.vue

@@ -2,11 +2,11 @@
   <view class="container">
     <view v-if="!menushow" class="main">
       <view class="u-page">
-        <u-list :class="{ empty: curlist.length === 0 }">
-          <template v-if="curlist.length > 0">
+        <u-list :class="{ empty: showList.length === 0 }">
+          <template v-if="showList.length > 0">
             <u-list-item
               class="itemback"
-              v-for="(item, index) in curlist"
+              v-for="(item, index) in showList"
               :key="index"
             >
               <div>
@@ -108,6 +108,10 @@
                               ? "行人"
                               : item[showitem.monitorcode] == "1"
                               ? "行车"
+                              : item[showitem.monitorcode] == "3"
+                              ? "短路"
+                              : item[showitem.monitorcode] == "3"
+                              ? "行车/短路"
                               : "-"
                           }}
                         </view>
@@ -121,10 +125,10 @@
                           "
                         >
                           {{
-                            item.readData[showitem.monitorcode] == null ||
-                            item.readData[showitem.monitorcode] == ""
+                            item[showitem.monitorcode] == null ||
+                            item[showitem.monitorcode] == ""
                               ? "-"
-                              : item.readData[showitem.monitorcode]
+                              : item[showitem.monitorcode]
                           }}
                         </view>
                         <view
@@ -170,7 +174,6 @@
                         "
                       >
                         <view
-                          v-if="showitem.datatype == 1"
                           class="demo-layout bg-purple-light"
                           style="
                             margin-top: 10rpx;
@@ -181,17 +184,26 @@
                         >
                           {{
                             item[
-                              showitem.monitorcode.startsWith("Fan")
+                              showitem.monitorcode.startsWith("fan")
+                                ? showitem.monitorcode.replace(/^fan/, "fan1")
+                                : showitem.monitorcode.startsWith("Fan")
                                 ? showitem.monitorcode.replace(/^Fan/, "Fan1")
                                 : showitem.monitorcode
                             ] !== undefined &&
                             item[
-                              showitem.monitorcode.startsWith("Fan")
+                              showitem.monitorcode.startsWith("fan")
+                                ? showitem.monitorcode.replace(/^fan/, "fan1")
+                                : showitem.monitorcode.startsWith("Fan")
                                 ? showitem.monitorcode.replace(/^Fan/, "Fan1")
                                 : showitem.monitorcode
                             ] !== null
                               ? item[
-                                  showitem.monitorcode.startsWith("Fan")
+                                  showitem.monitorcode.startsWith("fan")
+                                    ? showitem.monitorcode.replace(
+                                        /^fan/,
+                                        "fan1"
+                                      )
+                                    : showitem.monitorcode.startsWith("Fan")
                                     ? showitem.monitorcode.replace(
                                         /^Fan/,
                                         "Fan1"
@@ -201,7 +213,7 @@
                               : "-"
                           }}
                         </view>
-                        <view
+                        <!-- <view
                           v-else-if="showitem.datatype == 2"
                           class="demo-layout bg-purple-light"
                           style="
@@ -231,7 +243,7 @@
                                 ]
                               : "-"
                           }}
-                        </view>
+                        </view> -->
 
                         <view
                           class="demo-layout bg-purple-light"
@@ -273,7 +285,6 @@
                         "
                       >
                         <view
-                          v-if="showitem.datatype == 1"
                           class="demo-layout bg-purple-light"
                           style="
                             margin-top: 10rpx;
@@ -284,17 +295,26 @@
                         >
                           {{
                             item[
-                              showitem.monitorcode.startsWith("Fan")
+                              showitem.monitorcode.startsWith("fan")
+                                ? showitem.monitorcode.replace(/^fan/, "fan2")
+                                : showitem.monitorcode.startsWith("Fan")
                                 ? showitem.monitorcode.replace(/^Fan/, "Fan2")
                                 : showitem.monitorcode
                             ] !== undefined &&
                             item[
-                              showitem.monitorcode.startsWith("Fan")
+                              showitem.monitorcode.startsWith("fan")
+                                ? showitem.monitorcode.replace(/^fan/, "fan2")
+                                : showitem.monitorcode.startsWith("Fan")
                                 ? showitem.monitorcode.replace(/^Fan/, "Fan2")
                                 : showitem.monitorcode
                             ] !== null
                               ? item[
-                                  showitem.monitorcode.startsWith("Fan")
+                                  showitem.monitorcode.startsWith("fan")
+                                    ? showitem.monitorcode.replace(
+                                        /^fan/,
+                                        "fan2"
+                                      )
+                                    : showitem.monitorcode.startsWith("Fan")
                                     ? showitem.monitorcode.replace(
                                         /^Fan/,
                                         "Fan2"
@@ -304,7 +324,7 @@
                               : "-"
                           }}
                         </view>
-                        <view
+                        <!-- <view
                           v-else-if="showitem.datatype == 2"
                           class="demo-layout bg-purple-light"
                           style="
@@ -334,7 +354,7 @@
                                 ]
                               : "-"
                           }}
-                        </view>
+                        </view> -->
 
                         <view
                           class="demo-layout bg-purple-light"
@@ -380,6 +400,7 @@ export default {
       isWarnVisible: false,
       deviceType1: "",
       devices1: [],
+      showList: [],
     };
   },
   props: ["showColum", "deviceType"],
@@ -448,26 +469,31 @@ export default {
             if (response.data.code == 200) {
               this.deviceList[type] = response.data.result.msgTxt[0].datalist;
               this.curlist = this.deviceList[type];
-              this.curlist.forEach((item) => {
-                if (item.readData.frontGateOpen == 1) {
-                  item.readData.frontGateOpen = "打开";
+              const processedList = this.curlist.map((item) => {
+                const { readData, ...baseFields } = item;
+                return { ...baseFields, ...readData };
+              });
+              this.showList = processedList;
+              this.showList.forEach((item) => {
+                if (item.frontGateOpen == 1) {
+                  item.frontGateOpen = "打开";
                 } else {
-                  item.readData.frontGateOpen = "关闭";
+                  item.frontGateOpen = "关闭";
                 }
-                if (item.readData.midGateOpen == 1) {
-                  item.readData.midGateOpen = "打开";
+                if (item.midGateOpen == 1) {
+                  item.midGateOpen = "打开";
                 } else {
-                  item.readData.midGateOpen = "关闭";
+                  item.midGateOpen = "关闭";
                 }
-                if (item.readData.rearGateOpen == 1) {
-                  item.readData.rearGateOpen = "打开";
+                if (item.rearGateOpen == 1) {
+                  item.rearGateOpen = "打开";
                 } else {
-                  item.readData.rearGateOpen = "关闭";
+                  item.rearGateOpen = "关闭";
                 }
-                if (item.readData.midGateOpen == 1) {
-                  item.readData.midGateOpen = "打开";
+                if (item.midGateOpen == 1) {
+                  item.midGateOpen = "打开";
                 } else {
-                  item.readData.midGateOpen = "关闭";
+                  item.midGateOpen = "关闭";
                 }
                 this.deviceType1 = item.deviceType;
                 let original = this.TabCur;
@@ -490,7 +516,7 @@ export default {
             }
           })
           .catch((error) => {
-            console.log("catch===>response", response);
+            // console.log("catch===>response", response);
             reject(error);
           });
       });