wupengfei
2025-04-02 f5f5dc20f7fa2b59671abccf6c6513fabb39789a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import * as insuranceClaimServices from '@/services/api/InsuranceClaim';
import dayjs from 'dayjs';
import { useQuery } from '@tanstack/vue-query';
 
export function useInsuranceClaimCount() {
  const form = reactive({
    year: dayjs().year() + '',
    month: dayjs().month() + 1 + '',
    claimChannel: '',
  });
 
  const { data: claimCount } = useQuery({
    queryKey: ['insuranceClaimServices/getInsuranceClaimCount', form],
    queryFn: async () => {
      let res = await insuranceClaimServices.getInsuranceClaimCount(
        {
          year: form.year ? Number(form.year) : null,
          month: form.month ? Number(form.month) : null,
          claimChannel: form.claimChannel,
        },
        {
          showLoading: false,
        }
      );
      return res;
    },
    keepPreviousData: true,
  });
 
  function disabledYear(time: Date) {
    return dayjs(time).isAfter(dayjs(), 'year');
  }
 
  return {
    form,
    claimCount,
    disabledYear,
  };
}
 
type InsuranceClaimYearMonthCountCountOptions = {
  year: MaybeRef<number | string>;
};
 
export function useInsuranceClaimYearMonthCountCount({
  year,
}: InsuranceClaimYearMonthCountCountOptions) {
  const { data: claimYearMonthCountList, isLoading } = useQuery({
    queryKey: ['insuranceClaimServices/getInsuranceClaimYearMonthCountList', year],
    queryFn: async () => {
      let res = await insuranceClaimServices.getInsuranceClaimYearMonthCountList(
        {
          year: Number(unref(year)),
        },
        {
          showLoading: false,
        }
      );
      return res;
    },
    select(data) {
      return data.reverse();
    },
    placeholderData: () => [] as API.InsuranceClaimYearMonthCountListOutput[],
  });
 
  return {
    claimYearMonthCountList,
    isLoading,
  };
}