import { useQuery } from '@tanstack/vue-query';
|
import { useIntervalFn } from '@vueuse/core';
|
import * as dataBoardServices from '@/services/api/DataBoard';
|
import { StringUtils } from '@/utils';
|
|
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: StringUtils.maskString({ str: 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,
|
};
|
}
|
|
type UseDataBoardOverviewByParkV2 = {
|
industrialParkId: MaybeRef<string>;
|
onSuccess?: (data: API.GetDataBoardOverviewByParkV2Output) => void;
|
};
|
|
export function useGetDataBoardOverviewByParkV2(options: UseDataBoardOverviewByParkV2) {
|
const { industrialParkId, onSuccess } = options;
|
const {
|
data: detail,
|
isLoading,
|
refetch,
|
} = useQuery({
|
queryKey: ['dataBoardServices/getDataBoardOverviewByParkV2', industrialParkId],
|
queryFn: async () => {
|
let params: API.APIgetDataBoardOverviewByParkV2Params = {};
|
if (!!unref(industrialParkId)) {
|
params.industrialParkId = unref(industrialParkId);
|
}
|
return await dataBoardServices.getDataBoardOverviewByParkV2(params, {
|
showLoading: false,
|
});
|
},
|
placeholderData: () => ({} as API.GetDataBoardOverviewByParkV2Output),
|
onSuccess: (data) => {
|
onSuccess?.(data);
|
},
|
});
|
|
return {
|
detail,
|
refetch,
|
};
|
}
|
|
type UseWanUnitOptions = {
|
wanUnit: boolean;
|
};
|
|
export function useGetDataBoardLastQuarterOutputValueCount(options: UseWanUnitOptions) {
|
const { wanUnit } = options;
|
|
const { data: detail, isLoading } = useQuery({
|
queryKey: ['dataBoardServices/getDataBoardLastQuarterOutputValueCount', wanUnit],
|
queryFn: async () => {
|
return await dataBoardServices.getDataBoardLastQuarterOutputValueCount(
|
{ wanUnit: wanUnit },
|
{
|
showLoading: false,
|
}
|
);
|
},
|
placeholderData: () => ({} as API.GetDataBoardLastQuarterOutputValueCountOutput),
|
});
|
|
return {
|
detail,
|
};
|
}
|
|
export function useGetDataBoardLastQuarterEnterpriseClientUserCount() {
|
const { data: detail, isLoading } = useQuery({
|
queryKey: ['dataBoardServices/getDataBoardLastQuarterEnterpriseClientUserCount'],
|
queryFn: async () => {
|
return await dataBoardServices.getDataBoardLastQuarterEnterpriseClientUserCount(
|
{},
|
{
|
showLoading: false,
|
}
|
);
|
},
|
placeholderData: () => ({} as API.GetDataBoardLastQuarterEnterpriseClientUserCountOutput),
|
});
|
|
return {
|
detail,
|
};
|
}
|
|
export function useGetDataBoardOutputValueRank(options: UseGetDataBoardBountyUseAmountRankOptions) {
|
const { take } = options;
|
const { data: detail, isLoading } = useQuery({
|
queryKey: ['dataBoardServices/getDataBoardOutputValueRank', take],
|
queryFn: async () => {
|
return await dataBoardServices.getDataBoardOutputValueRank(
|
{ take: take },
|
{
|
showLoading: false,
|
}
|
);
|
},
|
placeholderData: () => ({} as API.GetDataBoardOutputValueRankOutput),
|
});
|
|
const dataBoardOutputValueRankList = computed(() =>
|
detail.value.items?.map((x) => ({
|
name: StringUtils.maskString({ str: x.enterpriseName }),
|
value: x.outputValue,
|
}))
|
);
|
|
return {
|
dataBoardOutputValueRankList,
|
};
|
}
|
|
export function useGetDataBoardEnterpriseClientUserRank(
|
options: UseGetDataBoardBountyUseAmountRankOptions
|
) {
|
const { take } = options;
|
const { data: detail, isLoading } = useQuery({
|
queryKey: ['dataBoardServices/getDataBoardEnterpriseClientUserRank', take],
|
queryFn: async () => {
|
return await dataBoardServices.getDataBoardEnterpriseClientUserRank(
|
{ take: take },
|
{
|
showLoading: false,
|
}
|
);
|
},
|
placeholderData: () => ({} as API.GetDataBoardEnterpriseClientUserRankOutput),
|
});
|
|
const enterpriseClientUserRankList = computed(() =>
|
detail.value.items?.map((x) => ({
|
name: StringUtils.maskString({ str: x.enterpriseName }),
|
value: x.count,
|
}))
|
);
|
|
return {
|
enterpriseClientUserRankList,
|
};
|
}
|