瀏覽代碼

常规BUG修复

Koishi 2 天之前
父節點
當前提交
9488fc49dd
共有 1 個文件被更改,包括 116 次插入94 次删除
  1. 116 94
      src/views/IntegratedAlarm/reliability/historyAnalyse/index.vue

+ 116 - 94
src/views/IntegratedAlarm/reliability/historyAnalyse/index.vue

@@ -177,11 +177,16 @@
           min-width="170"
           header-align="center"
           show-overflow-tooltip
-          sortable="customSort"
+          sortable="custom"
         >
+          <!-- :sort-method="
+            (a, b) => {
+              return a[`${item.code}_count`] - b[`${item.code}_count`];
+            }
+          " -->
           <template #default="scope">
             <div class="bar">
-                <!-- :style="{
+              <!-- :style="{
                   width:
                     row[`${item.code}_count`] || row[`${item.code}_time`]
                       ? (row[`${item.code}_count`] /
@@ -193,14 +198,23 @@
                 }" -->
               <div
                 class="bar-percent"
-                :style="{width: scope.row[`${item.code}_count`] > 0 ? (Math.ceil(scope.row[`${item.code}_count`]) / 
-                Math.ceil(scope.column.realWidth))*100 + 'px' : '0px'}"
+                :style="{
+                  width:
+                    scope.row[`${item.code}_count`] > 0
+                      ? (Math.ceil(scope.row[`${item.code}_count`]) /
+                          Math.ceil(scope.column.realWidth)) *
+                          100 +
+                        'px'
+                      : '0px',
+                }"
               ></div>
               <!-- <span class="value">{{ row[`${item.code}_count`] }} 次</span> -->
-              <span class="value">{{ getCalcValue(scope.row[`${item.code}_count`]) }} 次</span>
+              <span class="value"
+                >{{ getCalcValue(scope.row[`${item.code}_count`]) }} 次</span
+              >
             </div>
             <div class="bar">
-                <!-- :style="{
+              <!-- :style="{
                   width:
                     row[`${item.code}_count`] || row[`${item.code}_time`]
                       ? (row[`${item.code}_time`] /
@@ -212,11 +226,20 @@
                 }" -->
               <div
                 class="bar-percent"
-                :style="{width: scope.row[`${item.code}_time`] > 0 ? (Math.ceil(scope.row[`${item.code}_time`]) / 
-                Math.ceil(scope.column.realWidth))*100 + 'px' : '0px'}"
+                :style="{
+                  width:
+                    scope.row[`${item.code}_time`] > 0
+                      ? (Math.ceil(scope.row[`${item.code}_time`]) /
+                          Math.ceil(scope.column.realWidth)) *
+                          100 +
+                        'px'
+                      : '0px',
+                }"
               ></div>
               <!-- <span class="value">{{ row[`${item.code}_time`] }} 分钟</span> -->
-              <span class="value">{{ getCalcValue(scope.row[`${item.code}_time`]) }} 分钟</span>
+              <span class="value"
+                >{{ getCalcValue(scope.row[`${item.code}_time`]) }} 分钟</span
+              >
             </div>
           </template>
         </el-table-column>
@@ -334,10 +357,10 @@ const state = reactive({
     //   value: "inverter",
     // },
   ],
-//   tableData: dataJson2.data.data.data,
-//   tHeard: dataJson2.data.data.title,
-tableData: [],
-tHeard: [],
+  //   tableData: dataJson2.data.data.data,
+  //   tHeard: dataJson2.data.data.title,
+  tableData: [],
+  tHeard: [],
   changZhan: "",
   components: ["FDJ", "CLX"], //部件
   modelId: "", //型号
@@ -367,9 +390,8 @@ const getWpArray = async () => {
   const { data } = await getWpList(state.typeVal);
   changZhanArray.value = data;
   if (state.typeVal != "booststation") {
-    state.changZhan = data[0]?.id
+    state.changZhan = data[0]?.id;
     getTableList();
-
   } else {
     state.changZhan = "";
     state.modelId = "";
@@ -387,21 +409,21 @@ const getfetchRelatePart = async () => {
 };
 //型号列表
 const modelList = [
-    {
-        id: "WT2000D121H85",
-        name: "WT2000D121H85"
-    },
-    {
-        id: "UP2000-130",
-        name: "UP2000-130"
-    }
-]
+  {
+    id: "WT2000D121H85",
+    name: "WT2000D121H85",
+  },
+  {
+    id: "UP2000-130",
+    name: "UP2000-130",
+  },
+];
 // const modelList = computed(() => {
-  //   if (state.changZhan == "") {
-  //     return [];
-  //   } else {
-  //     return state.modelListAll[state.changZhan];
-  //   }
+//   if (state.changZhan == "") {
+//     return [];
+//   } else {
+//     return state.modelListAll[state.changZhan];
+//   }
 //   return [
 //     {
 //       id: "SEC-W02B-1250kW",
@@ -666,10 +688,9 @@ const handlePageChange = (val) => {
 // 获取列表数据 调用接口
 function getTableList() {
   if (state.components?.length) {
-
     getAlarmCountList({
-        pageNum: query.page,
-        pageSize: query.limit,
+      pageNum: query.page,
+      pageSize: query.limit,
       stationid: state.changZhan || "",
       begin: state.starttime,
       end: state.endtime,
@@ -678,17 +699,19 @@ function getTableList() {
       modelId: state.modelId,
       alarmIds: state.alarmIds,
       alarmType: state.typeVal,
-    }).then((res) => {
-        if (res && res.result.length>0) {
-            changeTableData(res.result)
-            query.pageTotal = res.total
+    })
+      .then((res) => {
+        if (res && res.result.length > 0) {
+          changeTableData(res.result);
+          query.pageTotal = res.total;
         } else {
-            state.tHeard = [];
-            state.tableData = [];
+          state.tHeard = [];
+          state.tableData = [];
         }
-    }).catch(() =>{
-    //   changeTableData(dataJson)
-    });
+      })
+      .catch(() => {
+        //   changeTableData(dataJson)
+      });
   } else {
     BASE.showMsg({
       msg: "部件至少选择一项才可查询",
@@ -697,65 +720,64 @@ function getTableList() {
 }
 
 const changeTableData = (res) => {
-    if (res.length) {
-        if (query.page === 1) {
-            windName.value = []
-        }
-        let tableData = [];
-        let tHeard = [];
-        let data = res;
-        data.forEach((pEle, index) => {
-          for (let wtId in pEle) {
-            let wtItem = data.find((tableItem) => {
-              return wtId === tableItem.windturbineId;
+  if (res.length) {
+    if (query.page === 1) {
+      windName.value = [];
+    }
+    let tableData = [];
+    let tHeard = [];
+    let data = res;
+    data.forEach((pEle, index) => {
+      for (let wtId in pEle) {
+        let wtItem = data.find((tableItem) => {
+          return wtId === tableItem.windturbineId;
+        });
+        !wtItem && (wtItem = { wtId });
+        if (pEle[wtId].length > 0) {
+          pEle[wtId].forEach((cEle) => {
+            let someRes = tHeard.some((findEle) => {
+              return findEle.label == cEle.alertText;
             });
-            !wtItem && (wtItem = { wtId });
-            if (pEle[wtId].length>0) {
-                pEle[wtId].forEach((cEle) => {
-                    let someRes = tHeard.some((findEle) => {
-                        return findEle.label == cEle.alertText;
-                    });
 
-                    if (!someRes) {
-                        tHeard.push({
-                        label: cEle.alertText,
-                        code: cEle.alarmid,
-                        });
-                    }
-                    wtItem[`${cEle.alarmid}_count`] = cEle.count;
-                    wtItem[`${cEle.alarmid}_time`] = cEle.time;
-                    wtItem["wtname"] = cEle.windturbineCode
-                });
-            } else {
-                wtItem["wtname"] = windName.value[index]
+            if (!someRes) {
+              tHeard.push({
+                label: cEle.alertText,
+                code: cEle.alarmid,
+              });
             }
-            if (query.page === 1) {
-                windName.value.push(wtItem["wtname"])
-            }
-            tableData.push(wtItem);
-          }
-        });
-        state.tHeard = tHeard;
-        state.tableData = tableData;
-      } else {
-        state.tHeard = [];
-        state.tableData = [];
-      }
-}
-
-const handleSortChange = ({ column, prop, order }) => {
-    let code = prop.code+'_count';
-    state.tableData = state.tableData.slice().sort((a, b) => {
-        if (order === 'ascending') {
-        return a[code] - b[code];
-        } else if (order === 'descending') {
-        return b[code] - a[code];
+            wtItem[`${cEle.alarmid}_count`] = cEle.count || 0;
+            wtItem[`${cEle.alarmid}_time`] = cEle.time || 0;
+            wtItem["wtname"] = cEle.windturbineCode;
+          });
         } else {
-        // return 0;
+          wtItem["wtname"] = windName.value[index];
+        }
+        if (query.page === 1) {
+          windName.value.push(wtItem["wtname"]);
         }
+        tableData.push(wtItem);
+      }
     });
-}
+    state.tHeard = tHeard;
+    state.tableData = tableData;
+  } else {
+    state.tHeard = [];
+    state.tableData = [];
+  }
+};
 
+const handleSortChange = ({ column, prop, order }) => {
+  let code = prop.code + "_count";
+  state.tableData = state.tableData.slice().sort((a, b) => {
+    if (order === "ascending") {
+      return (a[code] || 0) - (b[code] || 0);
+    } else if (order === "descending") {
+      return (b[code] || 0) - (a[code] || 0);
+    } else {
+      return 0;
+    }
+  });
+};
 
 const handleSort = function (val) {
   let item = val.prop;
@@ -893,7 +915,7 @@ const compare = function (property) {
       }
     }
     .pagination-wrapper :deep {
-        height: 30px;
+      height: 30px;
       text-align: right;
       margin-top: 10px;
     }