24 lines
808 B
TypeScript
24 lines
808 B
TypeScript
import { ref } from 'vue'
|
|
import type { EquipmentQuery } from '@/apis/equipment/equipment'
|
|
import { getEquipmentNameList } from '@/apis/equipment/equipment'
|
|
import type { LabelValueState } from '@/types/global'
|
|
|
|
/** 设备名称列表 */
|
|
export function equipmentName(query: EquipmentQuery, options?: { onSuccess?: () => void }) {
|
|
const loading = ref(false)
|
|
const equipmentNameList = ref<LabelValueState[]>([])
|
|
|
|
const getEquipmentName = async () => {
|
|
try {
|
|
loading.value = true
|
|
const res = await getEquipmentNameList(query)
|
|
equipmentNameList.value = res.data
|
|
// eslint-disable-next-line ts/no-unused-expressions
|
|
options?.onSuccess && options.onSuccess()
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
return { equipmentNameList, getEquipmentName, loading }
|
|
}
|