Просмотр исходного кода

task6454设施环境总览:顺序调整(金山)

CHINAMI-P698360\Administrator 7 часов назад
Родитель
Сommit
cead29bc71
1 измененных файлов с 29 добавлено и 5 удалено
  1. 29 5
      src/views/system/fasc/index.vue

+ 29 - 5
src/views/system/fasc/index.vue

@@ -112,11 +112,35 @@ export default {
         }
       })
       // 对类型进行排序
-      result.sort((a, b) => {
-        return a.facs_type.localeCompare(b.facs_type, 'zh')
-      })
-      console.log('格式化数据', result)
-      this.cardInfos = result
+      const { setting = {} } = this.$store.getters
+      const yiLanPaixu = setting.facilityEnv?.yiLanPaixu
+      if (yiLanPaixu && yiLanPaixu.length > 0) {
+        const orderMap = new Map()
+        yiLanPaixu.forEach((facs_type, index) => {
+          orderMap.set(facs_type, index)
+        })
+        const sortedArr = [...result].sort((a, b) => {
+          const idxA = orderMap.has(a.facs_type)
+            ? orderMap.get(a.facs_type)
+            : Infinity
+          const idxB = orderMap.has(b.facs_type)
+            ? orderMap.get(b.facs_type)
+            : Infinity
+          // 权重不同先比权重
+          if (idxA !== idxB) return idxA - idxB
+          // 权重相同(都是不在排序队列),再按facs_type字母排序
+          console.log(a.b)
+
+          return a.facs_type.localeCompare(b.facs_type, 'zh')
+        })
+        this.cardInfos = sortedArr
+        console.log(cardInfos)
+      } else {
+        result.sort((a, b) => {
+          return a.facs_type.localeCompare(b.facs_type, 'zh')
+        })
+        this.cardInfos = result
+      }
     })
   },
   methods: {