first commit
This commit is contained in:
22
src/hooks/app/productName.ts
Normal file
22
src/hooks/app/productName.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { ref } from 'vue'
|
||||
import { getProductNameList } from '@/apis/equipment/product'
|
||||
import type { LabelValueState } from '@/types/global'
|
||||
|
||||
/** 设备名称列表 */
|
||||
export function productName(options?: { onSuccess?: () => void }) {
|
||||
const loading = ref(false)
|
||||
const productNameList = ref<LabelValueState[]>([])
|
||||
|
||||
const getProductName = async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
const res = await getProductNameList()
|
||||
productNameList.value = res.data
|
||||
// eslint-disable-next-line ts/no-unused-expressions
|
||||
options?.onSuccess && options.onSuccess()
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
return { productNameList, getProductName, loading }
|
||||
}
|
||||
Reference in New Issue
Block a user