| New file |
| | |
| | | import { useQuery } from '@tanstack/vue-query'; |
| | | import { useIntervalFn } from '@vueuse/core'; |
| | | import * as dataBoardServices from '@/services/api/DataBoard'; |
| | | |
| | | export function useIntervalValue<T>(initValue: T) { |
| | | const value = ref(initValue); |
| | | const preValue = ref(initValue); |
| | | |
| | | useIntervalFn(() => { |
| | | value.value = 0; |
| | | setTimeout(() => { |
| | | value.value = preValue.value; |
| | | }, 500); |
| | | }, 30000); |
| | | |
| | | function changeValue(_value: T) { |
| | | value.value = _value; |
| | | preValue.value = _value; |
| | | } |
| | | |
| | | return { value, changeValue }; |
| | | } |
| | | |
| | | export function useGetDataBoardOverview() { |
| | | const { data: detail, isLoading } = useQuery({ |
| | | queryKey: ['dataBoardServices/getDataBoardOverview'], |
| | | queryFn: async () => { |
| | | return await dataBoardServices.getDataBoardOverview( |
| | | {}, |
| | | { |
| | | showLoading: false, |
| | | } |
| | | ); |
| | | }, |
| | | placeholderData: () => ({} as API.GetDataBoardOverviewOutput), |
| | | }); |
| | | |
| | | return { |
| | | detail, |
| | | }; |
| | | } |
| | | |
| | | export function useGetDataBoardNewCustomerCount() { |
| | | const { data: detail, isLoading } = useQuery({ |
| | | queryKey: ['dataBoardServices/getDataBoardNewCustomerCount'], |
| | | queryFn: async () => { |
| | | return await dataBoardServices.getDataBoardNewCustomerCount( |
| | | {}, |
| | | { |
| | | showLoading: false, |
| | | } |
| | | ); |
| | | }, |
| | | placeholderData: () => ({} as API.GetDataBoardNewCustomerCountOutput), |
| | | }); |
| | | |
| | | return { |
| | | detail, |
| | | }; |
| | | } |
| | | |
| | | export function useGetDataBoardNewBountyApplyCount() { |
| | | const { data: detail, isLoading } = useQuery({ |
| | | queryKey: ['dataBoardServices/getDataBoardNewBountyApplyCount'], |
| | | queryFn: async () => { |
| | | return await dataBoardServices.getDataBoardNewBountyApplyCount( |
| | | {}, |
| | | { |
| | | showLoading: false, |
| | | } |
| | | ); |
| | | }, |
| | | placeholderData: () => ({} as API.GetDataBoardNewBountyApplyCountOutput), |
| | | }); |
| | | |
| | | return { |
| | | detail, |
| | | }; |
| | | } |
| | | export function useGetDataBoardNewBountyReleaseAmountCount() { |
| | | const { data: detail, isLoading } = useQuery({ |
| | | queryKey: ['dataBoardServices/getDataBoardNewBountyReleaseAmountCount'], |
| | | queryFn: async () => { |
| | | return await dataBoardServices.getDataBoardNewBountyReleaseAmountCount( |
| | | {}, |
| | | { |
| | | showLoading: false, |
| | | } |
| | | ); |
| | | }, |
| | | placeholderData: () => ({} as API.GetDataBoardNewBountyReleaseAmountCountOutput), |
| | | }); |
| | | |
| | | return { |
| | | detail, |
| | | }; |
| | | } |
| | | |
| | | export function useGetDataBoardNewBountyUseAmountCount() { |
| | | const { data: detail, isLoading } = useQuery({ |
| | | queryKey: ['dataBoardServices/getDataBoardNewBountyUseAmountCount'], |
| | | queryFn: async () => { |
| | | return await dataBoardServices.getDataBoardNewBountyUseAmountCount( |
| | | {}, |
| | | { |
| | | showLoading: false, |
| | | } |
| | | ); |
| | | }, |
| | | placeholderData: () => ({} as API.GetDataBoardNewBountyUseAmountCountOutput), |
| | | }); |
| | | |
| | | return { |
| | | detail, |
| | | }; |
| | | } |
| | | |
| | | export function useGetDataBoardNewInsurePeopleCount() { |
| | | const { data: detail, isLoading } = useQuery({ |
| | | queryKey: ['dataBoardServices/getDataBoardNewInsurePeopleCount'], |
| | | queryFn: async () => { |
| | | return await dataBoardServices.getDataBoardNewInsurePeopleCount( |
| | | {}, |
| | | { |
| | | showLoading: false, |
| | | } |
| | | ); |
| | | }, |
| | | placeholderData: () => ({} as API.GetDataBoardNewInsurePeopleCountOutput), |
| | | }); |
| | | |
| | | return { |
| | | detail, |
| | | }; |
| | | } |
| | | |
| | | type UseGetDataBoardBountyUseAmountRankOptions = { |
| | | take: number; |
| | | }; |
| | | |
| | | export function useGetDataBoardBountyUseAmountRank( |
| | | options: UseGetDataBoardBountyUseAmountRankOptions |
| | | ) { |
| | | const { take } = options; |
| | | const { data: detail, isLoading } = useQuery({ |
| | | queryKey: ['dataBoardServices/getDataBoardBountyUseAmountRank', take], |
| | | queryFn: async () => { |
| | | return await dataBoardServices.getDataBoardBountyUseAmountRank( |
| | | { take: take }, |
| | | { |
| | | showLoading: false, |
| | | } |
| | | ); |
| | | }, |
| | | placeholderData: () => ({} as API.GetDataBoardBountyUseAmountRankOutput), |
| | | }); |
| | | |
| | | const bountyUseAmountRankList = computed(() => |
| | | detail.value.items?.map((x) => ({ |
| | | name: x.enterpriseName, |
| | | value: x.amount, |
| | | })) |
| | | ); |
| | | |
| | | return { |
| | | bountyUseAmountRankList, |
| | | }; |
| | | } |
| | | |
| | | export function useGetDataBoardInsurePeopleCountRank( |
| | | options: UseGetDataBoardBountyUseAmountRankOptions |
| | | ) { |
| | | const { take } = options; |
| | | const { data: detail, isLoading } = useQuery({ |
| | | queryKey: ['dataBoardServices/getDataBoardInsurePeopleCountRank', take], |
| | | queryFn: async () => { |
| | | return await dataBoardServices.getDataBoardInsurePeopleCountRank( |
| | | { take: take }, |
| | | { |
| | | showLoading: false, |
| | | } |
| | | ); |
| | | }, |
| | | placeholderData: () => ({} as API.GetDataBoardInsurePeopleCountRankOutput), |
| | | }); |
| | | |
| | | const insurePeopleCountRankList = computed(() => |
| | | detail.value.items?.map((x) => ({ |
| | | name: x.enterpriseName, |
| | | value: x.count, |
| | | })) |
| | | ); |
| | | |
| | | return { |
| | | insurePeopleCountRankList, |
| | | }; |
| | | } |