Преглед на файлове

后台告警页面 默认查全部

fanxiaoyu преди 7 месеца
родител
ревизия
5a659d12dd
променени са 1 файла, в които са добавени 16 реда и са изтрити 1 реда
  1. 16 1
      cpp-ui/src/views/abnormalAlarm/index.vue

+ 16 - 1
cpp-ui/src/views/abnormalAlarm/index.vue

@@ -217,8 +217,23 @@ export default {
     async getStationCode() {
       await this.$axios({url: '/electricfield/all', method: 'get'}).then(response => {
         this.stationList = response.data
-        this.stationList.push({value: 'all', label: '全部'})
         if (this.stationList.length > 0) {
+          // 默认查全部
+          this.stationList.push({value: 'all', label: '全部'})
+          const sortItems = (arr, sortValue) => {
+            return arr.sort((a, b) => {
+              if (a.value === sortValue) {
+                return -1;
+              }
+              if (b.value === sortValue) {
+                return 1;
+              }
+              return a.value - b.value; // 示例:按id升序排序
+            });
+          };
+          const sortValue = 'all';
+          const sortedItems = sortItems(this.stationList, sortValue);
+          this.stationList = sortedItems
           this.stationCode = this.stationList[0].value
           this.dataQuery()
         }