2026-03-10 16:19:47 +08:00

43 lines
976 B
TypeScript

import { defineStore } from 'pinia'
import type { Equipment } from '@/types'
import { getEquipmentList } from '@/api/equipment'
interface EquipmentState {
equipmentList: Equipment[]
total: number
loading: boolean
}
export const useEquipmentStore = defineStore('equipment', {
state: (): EquipmentState => ({
equipmentList: [],
total: 0,
loading: false
}),
actions: {
async fetchEquipmentList(params?: {
page?: number
pageSize?: number
equipmentType?: string
status?: string
keyword?: string
storageLocationId?: number
}) {
this.loading = true
try {
const response = await getEquipmentList(params || {})
if (response.data) {
this.equipmentList = response.data.list
this.total = response.data.total
}
} catch (error) {
console.error('获取设备列表失败:', error)
} finally {
this.loading = false
}
}
}
})