| | |
| | | fieldNamesMap: x.data.fieldNames ? JSON.parse(x.data.fieldNames) : {}, |
| | | })); |
| | | }, |
| | | placeholderData: () => |
| | | [] as API.SelectQueryResultOptionGuidGetDictionaryCategorySelectQueryOption[], |
| | | placeholderData: () => [] as API.SelectOptionGuidGetDictionaryCategorySelectQueryOption[], |
| | | }); |
| | | |
| | | const queryClient = useQueryClient(); |
| | | |
| | | function ensureQueryData() { |
| | | return queryClient.ensureQueryData< |
| | | API.SelectQueryResultOptionGuidGetDictionaryCategorySelectQueryOption[] |
| | | API.SelectOptionGuidGetDictionaryCategorySelectQueryOption[] |
| | | >({ |
| | | queryKey: ['dictionaryServices/getDictionaryCategorySelect'], |
| | | }); |
| | | } |
| | | |
| | | function updateDictionaryCategorySelect() { |
| | | queryClient.invalidateQueries({ |
| | | queryKey: ['dictionaryServices/getDictionaryCategorySelect'], |
| | | }); |
| | | } |
| | |
| | | getDictionaryCategoryById, |
| | | getDictionaryCategoryNameByCode, |
| | | getDictionaryCategoryByCode, |
| | | updateDictionaryCategorySelect, |
| | | }; |
| | | } |
| | | |
| | | type UseDictionaryDataSelectOptions = { |
| | | categoryId?: MaybeRef<string>; |
| | | categoryCode?: MaybeRef<string>; |
| | | categoryCode?: MaybeRef<CategoryCode>; |
| | | }; |
| | | |
| | | export function useDictionaryDataSelect({ |
| | |
| | | categoryCode, |
| | | }: UseDictionaryDataSelectOptions) { |
| | | const { data: dictionaryDataList, refetch } = useQuery({ |
| | | queryKey: ['dictionaryServices/getDictionaryDataSelect'], |
| | | queryKey: ['dictionaryServices/getDictionaryDataSelect', categoryId, categoryCode], |
| | | queryFn: async () => { |
| | | let res = await dictionaryServices.getDictionaryDataSelect( |
| | | { |
| | |
| | | code: x.data?.code ?? '', |
| | | })); |
| | | }, |
| | | placeholderData: () => |
| | | [] as API.SelectQueryResultOptionGuidGetDictionaryDataSelectQueryResultOption[], |
| | | |
| | | enabled: !!unref(categoryId) || !!unref(categoryCode), |
| | | placeholderData: () => [] as API.SelectOptionGuidGetDictionaryDataSelectQueryResultOption[], |
| | | }); |
| | | |
| | | function getDictionaryDataNameById(id: string) { |
| | |
| | | |
| | | function ensureQueryData() { |
| | | return queryClient.ensureQueryData< |
| | | API.SelectQueryResultOptionGuidGetDictionaryDataSelectQueryResultOption[] |
| | | API.SelectOptionGuidGetDictionaryDataSelectQueryResultOption[] |
| | | >({ |
| | | queryKey: ['dictionaryServices/getDictionaryDataSelect'], |
| | | }); |
| | | } |
| | | |
| | | function updateDictionaryDataSelect(categoryId?: string) { |
| | | queryClient.invalidateQueries({ |
| | | queryKey: ['dictionaryServices/getDictionaryDataSelect', categoryId], |
| | | }); |
| | | } |
| | | |
| | |
| | | getDictionaryDataNameById, |
| | | getDictionaryDataNameByCode, |
| | | getDictionaryDataByCode, |
| | | updateDictionaryDataSelect, |
| | | }; |
| | | } |