You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
821 B
32 lines
821 B
import { ref } from 'vue' |
|
import { defineStore } from 'pinia' |
|
import { getEngineeringList } from '@/api/module/engineering' |
|
import type { IEngineeringOV } from '@/api/module/engineering/index.d' |
|
|
|
export const useEngineeringStore = defineStore('engineering', () => { |
|
// State |
|
const engineeringList = ref<IEngineeringOV[]>([]) |
|
const loading = ref(false) |
|
|
|
// Actions |
|
const fetchEngineeringList = async () => { |
|
loading.value = true |
|
try { |
|
const res = await getEngineeringList() |
|
engineeringList.value = Array.isArray(res.data?.list) ? res.data.list : [] |
|
} catch (error) { |
|
console.error(error) |
|
engineeringList.value = [] |
|
} finally { |
|
loading.value = false |
|
} |
|
} |
|
|
|
return { |
|
// State |
|
engineeringList, |
|
loading, |
|
// Actions |
|
fetchEngineeringList, |
|
} |
|
})
|
|
|