| | |
| | | import { useInfiniteLoading } from '@12333/hooks'; |
| | | import { OrderInputType, Gender } from '@12333/constants'; |
| | | import * as orderServices from '@12333/services/api/Order'; |
| | | import * as flexWorkerServices from '@12333/services/api/FlexWorker'; |
| | | import _ from 'lodash'; |
| | | import { trim } from '@12333/utils'; |
| | | import { MaybeRef } from 'vue'; |
| | | |
| | | export enum HomeOrderType { |
| | | Recommend = 'Recommend', |
| | | LastShelfTime = 'LastShelfTime', |
| | | } |
| | | |
| | | export function useTaskList() { |
| | | type UseTaskListOptions = { |
| | | cityName?: MaybeRef<string>; |
| | | }; |
| | | |
| | | export function useTaskList(options: UseTaskListOptions = {}) { |
| | | const { cityName = '' } = options; |
| | | |
| | | const searchValue = ref(''); |
| | | |
| | | const DefaultQueryState = { |
| | | const queryMenuState = reactive({ |
| | | gender: '' as any as Gender, |
| | | }; |
| | | }); |
| | | |
| | | const queryState = reactive({ |
| | | searchValueTrim: '', |
| | | orderType: HomeOrderType.Recommend, |
| | | companyId: '', |
| | | ...DefaultQueryState, |
| | | }); |
| | | |
| | | const handleSearch = _.debounce(function () { |
| | |
| | | |
| | | const { infiniteLoadingProps } = useInfiniteLoading( |
| | | ({ pageParam }) => { |
| | | let params: API.FrontOrderListInput = { |
| | | let params: API.GetFlexTaskListInput = { |
| | | pageModel: { |
| | | rows: 20, |
| | | page: pageParam, |
| | |
| | | }, |
| | | }; |
| | | |
| | | return orderServices.getFrontOrderList(params, { |
| | | return flexWorkerServices.getFlexTaskByArrange(params, { |
| | | showLoading: false, |
| | | }); |
| | | }, |
| | | { |
| | | queryKey: ['orderServices/getFrontOrderList', queryState], |
| | | queryKey: ['flexWorkerServices/getFlexTaskByArrange', queryState, queryMenuState, cityName], |
| | | } |
| | | ); |
| | | |
| | | return { |
| | | searchValue, |
| | | queryState, |
| | | DefaultQueryState, |
| | | queryMenuState, |
| | | handleSearch, |
| | | infiniteLoadingProps, |
| | | }; |