| | |
| | | import { useInfiniteLoading } from '@12333/hooks'; |
| | | import { OrderInputType, Gender } from '@12333/constants'; |
| | | import * as flexWorkerServices from '@12333/services/api/FlexWorker'; |
| | | import { |
| | | EnumPagedListOrder, |
| | | EnumSettlementCycle, |
| | | EnumTaskRecommendStatus, |
| | | EnumTaskReleaseStatus, |
| | | EnumTaskStatus, |
| | | EnumUserGender, |
| | | } from '@12333/constants'; |
| | | import _ from 'lodash'; |
| | | import { trim } from '@12333/utils'; |
| | | import { MaybeRef } from 'vue'; |
| | | import * as taskServices from '@12333/services/apiV2/task'; |
| | | |
| | | export enum HomeOrderType { |
| | | Recommend = 'Recommend', |
| | |
| | | const searchValue = ref(''); |
| | | |
| | | const queryMenuState = reactive({ |
| | | gender: '' as any as Gender, |
| | | genderLimit: '' as any as EnumUserGender, |
| | | settlementCycle: '' as any as EnumSettlementCycle, |
| | | benefitCodes: '', |
| | | status: '' as any as EnumTaskStatus, |
| | | }); |
| | | |
| | | const queryState = reactive({ |
| | | searchValueTrim: '', |
| | | orderType: HomeOrderType.Recommend, |
| | | companyId: '', |
| | | }); |
| | | |
| | | const handleSearch = _.debounce(function () { |
| | |
| | | |
| | | const { infiniteLoadingProps } = useInfiniteLoading( |
| | | ({ pageParam }) => { |
| | | let params: API.GetFlexTaskListInput = { |
| | | let params: API.GetTaskInfosQuery = { |
| | | pageModel: { |
| | | rows: 20, |
| | | page: pageParam, |
| | | orderInput: [ |
| | | queryState.orderType === HomeOrderType.Recommend |
| | | ? { property: 'creationTime', order: OrderInputType.Desc } |
| | | : { property: 'lastShelfTime', order: OrderInputType.Desc }, |
| | | ? { property: 'createdTime', order: EnumPagedListOrder.Desc } |
| | | : {}, |
| | | ], |
| | | }, |
| | | keywords: queryState.searchValueTrim, |
| | | // cityCode: 'string', |
| | | settlementCycle: queryMenuState.settlementCycle, |
| | | benefitCodes: [queryMenuState.benefitCodes].filter(Boolean), |
| | | genderLimit: queryMenuState.genderLimit, |
| | | status: queryMenuState.status, |
| | | releaseStatus: EnumTaskReleaseStatus.InProcess, |
| | | }; |
| | | |
| | | return flexWorkerServices.getFlexTaskByArrange(params, { |
| | | if (queryState.orderType === HomeOrderType.Recommend) { |
| | | params.recommendStatus = EnumTaskRecommendStatus.Yes; |
| | | } |
| | | |
| | | return taskServices.getTaskInfos(params, { |
| | | showLoading: false, |
| | | }); |
| | | }, |
| | | { |
| | | queryKey: ['flexWorkerServices/getFlexTaskByArrange', queryState, queryMenuState, cityName], |
| | | queryKey: ['taskServices/getTaskInfos', queryState, queryMenuState, cityName], |
| | | } |
| | | ); |
| | | |