zhengyiming
20 小时以前 6fc60fcdccd4c99e43be482ecf3757108e833c34
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { EnumParkRewardStatisticsDetailScene } from '@/constants';
import { useTable } from '@bole-core/components';
import * as parkBountyApplyServices from '@/services/api/ParkBountyApply';
import { OrderInputType } from '@bole-core/core';
import { useQuery } from '@tanstack/vue-query';
import dayjs from 'dayjs';
 
type UseRewardStatisticsDetailOptions = {
  scene?: Ref<EnumParkRewardStatisticsDetailScene>;
  enterpriseId?: Ref<string>;
  month?: Ref<string>;
};
export function useRewardStatisticsDetail(options: UseRewardStatisticsDetailOptions = {}) {
  const { scene = '' as any as EnumParkRewardStatisticsDetailScene, enterpriseId, month } = options;
 
  const {
    getDataSource: getRewardStatisticsDetail,
    proTableProps,
    paginationState,
    extraParamState,
    reset,
  } = useTable(
    async ({ pageIndex, pageSize }, extraParamState) => {
      try {
        let params: API.GetRewardStatisticsDetailInput = {
          pageModel: {
            rows: pageSize,
            page: pageIndex,
            orderInput: extraParamState.orderInput,
          },
          enterpriseId: unref(enterpriseId),
          scene: unref(scene),
          month: unref(month),
        };
        let res = await parkBountyApplyServices.getRewardStatisticsDetail(params);
        return res;
      } catch (error) {}
    },
    {
      defaultExtraParams: {
        orderInput: [{ property: 'creationTime', order: OrderInputType.Desc }],
      },
      columnsRenderProps: {
        creationTime: { type: 'date', format: 'YYYY-MM-DD HH:mm:ss' },
        auditTime: { type: 'date', format: 'YYYY-MM-DD HH:mm:ss' },
        amount: { type: 'money' },
      },
    }
  );
 
  return {
    getRewardStatisticsDetail,
    proTableProps,
    paginationState,
    extraParamState,
    reset,
  };
}
 
type UseRewardStatisticsMonthsOptions = {
  industrialParkId?: MaybeRef<string>;
  enabled?: MaybeRef<boolean>;
};
 
export function useRewardStatisticsMonths(options: UseRewardStatisticsMonthsOptions = {}) {
  const { industrialParkId, enabled } = options;
 
  const { data: rewardStatisticsMonths } = useQuery({
    queryKey: ['parkBountyApplyServices/getRewardStatisticsMonths', industrialParkId],
    queryFn: async () => {
      let params: API.APIgetRewardStatisticsMonthsParams = {
        industrialParkId: unref(industrialParkId),
      };
      let res = await parkBountyApplyServices.getRewardStatisticsMonths(params, {
        showLoading: false,
      });
      return res;
    },
    placeholderData: [] as string[],
    enabled: enabled,
  });
 
  const disabledDate = computed(() => {
    return (time: Date) => {
      return rewardStatisticsMonths.value.every((x) => !dayjs(x).isSame(dayjs(time), 'month'));
    };
  });
 
  return { rewardStatisticsMonths, disabledDate };
}