From 92921431668181fb6d3387368c751ccc40aba8cf Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期五, 28 十一月 2025 17:14:32 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev-dataBoard'

---
 src/views/DataBoard/hooks/index.ts |  197 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 197 insertions(+), 0 deletions(-)

diff --git a/src/views/DataBoard/hooks/index.ts b/src/views/DataBoard/hooks/index.ts
new file mode 100644
index 0000000..0ead499
--- /dev/null
+++ b/src/views/DataBoard/hooks/index.ts
@@ -0,0 +1,197 @@
+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,
+  };
+}

--
Gitblit v1.9.1