|  |  |  | 
|---|
|  |  |  | import Taro, { EventChannel } from '@tarojs/taro'; | 
|---|
|  |  |  | import { useDictionaryDataSelect } from './dic'; | 
|---|
|  |  |  | import axios from 'axios'; | 
|---|
|  |  |  | import * as dictionaryServices from '@12333/services/apiV2/dictionary'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export function useArea() { | 
|---|
|  |  |  | const queryClient = useQueryClient(); | 
|---|
|  |  |  | 
|---|
|  |  |  | export function useAreaTree(options = {} as UseAreaTreeOptions) { | 
|---|
|  |  |  | const { maxLayer = AreaType.Area } = options; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const { areaList } = useAllAreaList(); | 
|---|
|  |  |  | // const { areaList } = useAllAreaList(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const areaTree = computed(() => formatAreaListToTree(areaList.value, null, unref(maxLayer))); | 
|---|
|  |  |  | const { data: areaTree } = useQuery({ | 
|---|
|  |  |  | queryKey: ['dictionaryServices/getAreaSelect', maxLayer], | 
|---|
|  |  |  | queryFn: () => { | 
|---|
|  |  |  | return dictionaryServices.getAreaSelect( | 
|---|
|  |  |  | { | 
|---|
|  |  |  | maxDeep: unref(maxLayer), | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { showLoading: false } | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | placeholderData: () => [] as API.GetAreaSelectQueryResultOption[], | 
|---|
|  |  |  | staleTime: Infinity, | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // const areaTree = computed(() => formatAreaListToTree(areaList.value, null, unref(maxLayer))); | 
|---|
|  |  |  | console.log('areaTree: ', areaTree); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return { areaTree: areaTree }; | 
|---|
|  |  |  | } | 
|---|