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 };
|
}
|