| | |
| | | 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; |
| | | }); |
| | | }); |
| | |
| | | }); |
| | | } |
| | | |
| | | return { deviceList, loading, fetchDevice, deleteDevice }; |
| | | return { deviceList, loading, getDevice, fetchDevice, deleteDevice }; |
| | | }); |