| | |
| | | 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 }: UseEnterpriseDetailOptions) { |
| | | 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) }, |
| | | { id: unref(id), supplierEnterpriseId: unref(supplierEnterpriseId) }, |
| | | { |
| | | showLoading: false, |
| | | } |
| | |
| | | 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 }; |
| | | } |