From 5f44d21b3921abc88506a7ec46b3fe6f078664aa Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期五, 14 三月 2025 15:33:24 +0800
Subject: [PATCH] 新增走航融合功能(初版)

---
 src/stores/device.js |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/stores/device.js b/src/stores/device.js
index c75f474..82adade 100644
--- a/src/stores/device.js
+++ b/src/stores/device.js
@@ -3,17 +3,27 @@
 import deviceApi from '@/api/deviceApi';
 import { useFetchData } from '@/composables/fetchData';
 
-// 璧拌埅浠诲姟
+// 璧拌埅璁惧
 export const useDeviceStore = defineStore('device', () => {
   const deviceList = ref([]);
   const { loading, fetchData } = useFetchData();
+
+  function getDevice(deviceType) {
+    if (deviceType) {
+      return deviceList.value.filter((v) => v.deviceType == deviceType);
+    } else {
+      return deviceList.value;
+    }
+  }
 
   function fetchDevice(type) {
     return fetchData((page, pageSize) => {
       return deviceApi
         .fethchDevice({ type: type, page, pageSize })
         .then((res) => {
-          deviceList.value = res.data;
+          deviceList.value = res.data.sort((a, b) => {
+            return a.deviceCode < b.deviceCode ? -1 : 1;
+          });
           return res;
         });
     });
@@ -38,5 +48,5 @@
     });
   }
 
-  return { deviceList, loading, fetchDevice, deleteDevice };
+  return { deviceList, loading, getDevice, fetchDevice, deleteDevice };
 });

--
Gitblit v1.9.3