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
| import { useInfiniteLoading } from '@12333/hooks';
| import { OrderInputType, Gender } from '@12333/constants';
| import * as orderServices from '@12333/services/api/Order';
| import _ from 'lodash';
| import { trim } from '@12333/utils';
|
| export enum HomeOrderType {
| Recommend = 'Recommend',
| LastShelfTime = 'LastShelfTime',
| }
|
| export function useTaskList() {
| const searchValue = ref('');
|
| const DefaultQueryState = {
| gender: '' as any as Gender,
| };
|
| const queryState = reactive({
| searchValueTrim: '',
| orderType: HomeOrderType.Recommend,
| companyId: '',
| ...DefaultQueryState,
| });
|
| const handleSearch = _.debounce(function () {
| queryState.searchValueTrim = trim(searchValue.value);
| }, 300);
|
| const { infiniteLoadingProps } = useInfiniteLoading(
| ({ pageParam }) => {
| let params: API.FrontOrderListInput = {
| pageModel: {
| rows: 20,
| page: pageParam,
| orderInput: [
| queryState.orderType === HomeOrderType.Recommend
| ? { property: 'isRecommend', order: OrderInputType.Desc }
| : { property: 'lastShelfTime', order: OrderInputType.Desc },
| ],
| },
| };
|
| return orderServices.getFrontOrderList(params, {
| showLoading: false,
| });
| },
| {
| queryKey: ['orderServices/getFrontOrderList', queryState],
| }
| );
|
| return {
| searchValue,
| queryState,
| DefaultQueryState,
| handleSearch,
| infiniteLoadingProps,
| };
| }
|
|