useProduct.ts
712 Bytes
import type { ConfigurationContentType } from '@/api/content/model'
import { getProductsDetailWithThingsModel } from '@/api/device'
import { useProductsStoreWithOut } from '@/store/modules/products'
export function useProduct() {
const getAllDeviceProfileIds = async (contentData: ConfigurationContentType) => {
const deviceProfileIds = contentData.productAndDevice?.map(item => item.profileId) || []
const result = await getProductsDetailWithThingsModel({ deviceProfileIds, functionTypeEnum: 'all' })
const productsStore = useProductsStoreWithOut()
productsStore.setProducts(result.reduce((prev, next) => ({ ...prev, [next.id]: next }), {}))
}
return {
getAllDeviceProfileIds,
}
}