| import * as dictionaryServices from '@/services/api/Dictionary'; | 
| import { useQuery, useQueryClient } from '@tanstack/vue-query'; | 
|   | 
| export function useInsureProductSettingAllList() { | 
|   const { data: allInsureProductSettingList, refetch } = useQuery({ | 
|     queryKey: ['dictionaryServices/getInsureProductSettingAllList'], | 
|     queryFn: async () => { | 
|       let res = await dictionaryServices.getInsureProductSettingAllList({}, { showLoading: false }); | 
|       return res; | 
|     }, | 
|     placeholderData: () => [] as API.InsureProductSettingDto[], | 
|   }); | 
|   | 
|   return { | 
|     allInsureProductSettingList, | 
|     refetch, | 
|   }; | 
| } | 
|   | 
| export function useUserInsureProductSetting() { | 
|   const { data: allUserInsureProductSettingList, refetch } = useQuery({ | 
|     queryKey: ['dictionaryServices/getUserInsureProductSetting'], | 
|     queryFn: async () => { | 
|       let res = await dictionaryServices.getUserInsureProductSetting({ showLoading: false }); | 
|       return res; | 
|     }, | 
|     placeholderData: () => [] as API.InsureProductSettingDto[], | 
|   }); | 
|   | 
|   function getInsureProductByIdNumber(productIdNumber: string) { | 
|     return allUserInsureProductSettingList.value.find((x) => x.productIdNumber === productIdNumber); | 
|   } | 
|   | 
|   function getInsureProductIdByIdNumber(productIdNumber: string) { | 
|     const insureProduct = getInsureProductByIdNumber(productIdNumber); | 
|     return insureProduct?.id ?? ''; | 
|   } | 
|   | 
|   const queryClient = useQueryClient(); | 
|   | 
|   function ensureUserInsureProductSetting() { | 
|     return queryClient.ensureQueryData<API.InsureProductSettingDto[]>({ | 
|       queryKey: ['dictionaryServices/getUserInsureProductSetting'], | 
|     }); | 
|   } | 
|   | 
|   /**是否是生煎保账号 */ | 
|   const isSjbAccount = computed(() => allUserInsureProductSettingList.value.length > 0); | 
|   | 
|   return { | 
|     allUserInsureProductSettingList, | 
|     getInsureProductByIdNumber, | 
|     getInsureProductIdByIdNumber, | 
|     refetch, | 
|     ensureUserInsureProductSetting, | 
|     isSjbAccount, | 
|   }; | 
| } | 
|   | 
| type UseInsureProductSchemeAllListOptions = { | 
|   insureProductId?: MaybeRef<string>; | 
| }; | 
|   | 
| export function useInsureProductSchemeAllList(options: UseInsureProductSchemeAllListOptions = {}) { | 
|   const { insureProductId } = options; | 
|   | 
|   const { data: allInsureProductSchemeList, refetch } = useQuery({ | 
|     queryKey: ['dictionaryServices/getInsureProductSchemeAllList', insureProductId], | 
|     queryFn: async () => { | 
|       let res = await dictionaryServices.getInsureProductSchemeAllList( | 
|         { | 
|           insureProductId: unref(insureProductId), | 
|         }, | 
|         { showLoading: false } | 
|       ); | 
|       return res; | 
|     }, | 
|     placeholderData: () => [] as API.InsureProductSchemeDto[], | 
|     enabled: computed(() => !!unref(insureProductId)), | 
|     staleTime: Infinity, | 
|   }); | 
|   | 
|   function getInsureProductSchemeByCode(code: string) { | 
|     return allInsureProductSchemeList.value.find((x) => x.code === code); | 
|   } | 
|   function getInsureProductSchemeByIdNumber(idNumber: string) { | 
|     return allInsureProductSchemeList.value.find((x) => x.idNumber === idNumber); | 
|   } | 
|   | 
|   return { | 
|     allInsureProductSchemeList, | 
|     refetch, | 
|     getInsureProductSchemeByCode, | 
|     getInsureProductSchemeByIdNumber, | 
|   }; | 
| } |