| | |
| | | import { useInfiniteLoading } from '@12333/hooks'; |
| | | import { useQuery, useQueryClient } from '@tanstack/vue-query'; |
| | | import { |
| | | EnumEnterpriseWalletAccessTextForSettle, |
| | | EnumPagedListOrder, |
| | | EnumSettlementCycle, |
| | | EnumTaskCheckReceiveStatus, |
| | |
| | | EnumTaskReleaseStatus, |
| | | EnumTaskStatus, |
| | | EnumUserGender, |
| | | EnumTaskUserApplyStatus, |
| | | } from '@12333/constants'; |
| | | import _ from 'lodash'; |
| | | import { trim } from '@12333/utils'; |
| | | import { MaybeRef, reactive, ref, unref } from 'vue'; |
| | | import { OrderUtils, trim } from '@12333/utils'; |
| | | import { computed, MaybeRef, reactive, Ref, ref, unref } from 'vue'; |
| | | import * as taskServices from '@12333/services/apiV2/task'; |
| | | import * as enterpriseWalletServices from '@12333/services/apiV2/enterpriseWallet'; |
| | | import dayjs from 'dayjs'; |
| | | import * as taskCheckReceiveServices from '@12333/services/apiV2/taskCheckReceive'; |
| | | |
| | |
| | | enterpriseId?: string; |
| | | time?: Date; |
| | | }; |
| | | |
| | | beforeRequest?: (params: API.GetTaskInfosQuery) => API.GetTaskInfosQuery; |
| | | }; |
| | | |
| | | /** |
| | | * @description 仅C端使用 |
| | | */ |
| | | export function useTaskList(options: UseTaskListOptions = {}) { |
| | | const { cityCode = '', enabled = true, defaultQueryMenuState = {} } = options; |
| | | const { cityCode = '', enabled = true, defaultQueryMenuState = {}, beforeRequest } = options; |
| | | |
| | | const searchValue = ref(''); |
| | | |
| | |
| | | checkReceiveStatus: '' as any as EnumTaskCheckReceiveStatus, |
| | | enterpriseId: '', |
| | | time: '' as any as Date, |
| | | applyStatus: '' as any as EnumTaskUserApplyStatus, |
| | | ...defaultQueryMenuState, |
| | | }); |
| | | |
| | |
| | | rows: 20, |
| | | page: pageParam, |
| | | orderInput: [ |
| | | queryState.orderType === HomeOrderType.Recommend |
| | | ? { property: 'recommendStatus', order: EnumPagedListOrder.Desc } |
| | | : { property: 'createdTime', order: EnumPagedListOrder.Desc }, |
| | | ], |
| | | { property: 'releaseStatus', order: EnumPagedListOrder.Asc }, |
| | | queryState.orderType === HomeOrderType.Recommend && { |
| | | property: 'recommendTime', |
| | | order: EnumPagedListOrder.Desc, |
| | | }, |
| | | { property: 'createdTime', order: EnumPagedListOrder.Desc }, |
| | | ].filter(Boolean), |
| | | }, |
| | | keywords: queryState.searchValueTrim, |
| | | cityCode: unref(cityCode), |
| | |
| | | endTime: queryMenuState.time |
| | | ? dayjs(queryMenuState.time).format('YYYY-MM-DD 23:59:59') |
| | | : '', |
| | | applyStatus: queryMenuState.applyStatus, |
| | | }; |
| | | |
| | | if (beforeRequest) { |
| | | params = beforeRequest(params); |
| | | } |
| | | |
| | | return taskServices.getOpenTaskInfos(params, { |
| | | showLoading: false, |
| | |
| | | infiniteLoadingProps, |
| | | }; |
| | | } |
| | | |
| | | type EnterpriseWalletAccessSelectOptions = { |
| | | supplierEnterpriseId: MaybeRef<string>; |
| | | }; |
| | | |
| | | export function useEnterpriseWalletAccessSelect(options: EnterpriseWalletAccessSelectOptions) { |
| | | const { supplierEnterpriseId } = options; |
| | | const { data } = useQuery({ |
| | | queryKey: ['enterpriseWalletServices/getEnterpriseWalletAccessSelect', supplierEnterpriseId], |
| | | queryFn: () => { |
| | | return enterpriseWalletServices.getEnterpriseWalletAccessSelect( |
| | | { supplierEnterpriseId: unref(supplierEnterpriseId) }, |
| | | { |
| | | showLoading: false, |
| | | } |
| | | ); |
| | | }, |
| | | placeholderData: () => [] as API.SelectOptionGuidGetEnterpriseWalletAccessSelectQueryOption[], |
| | | }); |
| | | |
| | | const enterpriseWalletAccessSelect = computed(() => data.value?.map((x) => x.data)); |
| | | |
| | | const settlementAccessList = computed(() => { |
| | | return enterpriseWalletAccessSelect.value?.length > 0 |
| | | ? enterpriseWalletAccessSelect.value.map((x) => ({ |
| | | label: EnumEnterpriseWalletAccessTextForSettle[x.access], |
| | | value: x.access, |
| | | })) |
| | | : []; |
| | | }); |
| | | |
| | | return { settlementAccessList }; |
| | | } |
| | | |
| | | type UseTaskInfoOptions = { |
| | | id: MaybeRef<string>; |
| | | onSuccess?: (data: API.GetTaskInfoQueryResult) => any; |
| | | }; |
| | | |
| | | export function useTaskInfo({ id, onSuccess }: UseTaskInfoOptions) { |
| | | const { |
| | | isLoading, |
| | | isError, |
| | | data: detail, |
| | | refetch, |
| | | } = useQuery({ |
| | | queryKey: ['taskServices/getTaskInfo', id], |
| | | queryFn: async () => { |
| | | return await taskServices.getTaskInfo( |
| | | { id: unref(id) }, |
| | | { |
| | | showLoading: false, |
| | | } |
| | | ); |
| | | }, |
| | | placeholderData: () => ({} as API.GetTaskInfoQueryResult), |
| | | onSuccess(data) { |
| | | onSuccess?.(data); |
| | | }, |
| | | }); |
| | | |
| | | const isContainCheckIn = computed(() => |
| | | OrderUtils.isContainCheckIn(detail.value?.checkReceiveMethods) |
| | | ); |
| | | |
| | | return { detail, isLoading, isError, refetch, isContainCheckIn }; |
| | | } |
| | | |
| | | type UseCheckReceiveTaskUserSubmitOptions = { |
| | | params: MaybeRef<API.APIgetCheckReceiveTaskUserSubmitParams>; |
| | | onSuccess?: (data: API.GetCheckReceiveTaskUserSubmitQueryResult) => any; |
| | | }; |
| | | |
| | | export function useCheckReceiveTaskUserSubmit({ |
| | | params, |
| | | onSuccess, |
| | | }: UseCheckReceiveTaskUserSubmitOptions) { |
| | | const { |
| | | isLoading, |
| | | isError, |
| | | data: detail, |
| | | refetch, |
| | | } = useQuery({ |
| | | queryKey: ['taskCheckReceiveServices/getCheckReceiveTaskUserSubmit', params], |
| | | queryFn: async () => { |
| | | const _params = unref(params); |
| | | return await taskCheckReceiveServices.getCheckReceiveTaskUserSubmit( |
| | | // { ..._params, date: dayjs(_params.date).format('YYYY-MM-DD') }, |
| | | _params, |
| | | { |
| | | showLoading: false, |
| | | } |
| | | ); |
| | | }, |
| | | placeholderData: () => ({} as API.GetCheckReceiveTaskUserSubmitQueryResult), |
| | | onSuccess(data) { |
| | | onSuccess?.(data); |
| | | }, |
| | | }); |
| | | |
| | | const isContainCheckIn = computed(() => |
| | | OrderUtils.isContainCheckIn(detail.value?.checkReceiveMethods) |
| | | ); |
| | | |
| | | return { detail, isLoading, isError, refetch, isContainCheckIn }; |
| | | } |