import { useQuery, useQueryClient } from '@tanstack/vue-query';
|
import * as taskServices from '@12333/services/apiV2/task';
|
import * as enterpriseServices from '@12333/services/apiV2/enterprise';
|
import { MaybeRef, unref } from 'vue';
|
|
type UseEnterpriseDetailOptions = {
|
id: MaybeRef<string>;
|
supplierEnterpriseId?: MaybeRef<string>;
|
};
|
|
export function useEnterpriseDetail({ id, supplierEnterpriseId }: UseEnterpriseDetailOptions) {
|
const { data, refetch, isLoading, isError } = useQuery({
|
queryKey: ['taskServices/getTaskEnterprise', id],
|
queryFn: async () => {
|
return await taskServices.getTaskEnterprise(
|
{ id: unref(id), supplierEnterpriseId: unref(supplierEnterpriseId) },
|
{
|
showLoading: false,
|
}
|
);
|
},
|
placeholderData: () => ({} as API.GetTaskEnterpriseQueryResult),
|
});
|
|
return {
|
enterpriseDetail: data,
|
refetch,
|
isLoading,
|
isError,
|
};
|
}
|
|
export function useGetSupplierEnterpriseSelect() {
|
const queryClient = useQueryClient();
|
|
const { data: supplierEnterpriseSelect } = useQuery({
|
queryKey: ['enterpriseServices/getSupplierEnterpriseSelect'],
|
queryFn: () => {
|
return enterpriseServices.getSupplierEnterpriseSelect(
|
{},
|
{
|
showLoading: false,
|
}
|
);
|
},
|
placeholderData: () => [] as API.SelectOptionGuidGetSupplierEnterpriseSelectQueryOption[],
|
});
|
|
return { supplierEnterpriseSelect };
|
}
|