wupengfei
4 天以前 7af4ab328e56300f7dca75de6c532d16464d2f10
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
import { useInfiniteLoading } from '@12333/hooks';
import { EnumPagedListOrder } from '@12333/constants';
import _ from 'lodash';
import { MaybeRef, unref } from 'vue';
import * as taskUserServices from '@12333/services/apiV2/taskUser';
 
type UseTaskListOptions = {
  id?: MaybeRef<string>;
};
 
export function useTaskUserList(options: UseTaskListOptions = {}) {
  const { id } = options;
 
  const { infiniteLoadingProps, invalidateQueries } = useInfiniteLoading(
    ({ pageParam }) => {
      let params: API.GetTaskUsersQuery = {
        pageModel: {
          rows: 20,
          page: pageParam,
          orderInput: [{ property: 'id', order: EnumPagedListOrder.Desc }],
        },
        id: unref(id),
      };
 
      return taskUserServices.getTaskUsers(params, {
        showLoading: false,
      });
    },
    {
      queryKey: ['taskUserServices/getTaskUsers', id],
      enabled: !!unref(id),
    }
  );
 
  return {
    infiniteLoadingProps,
    invalidateQueries,
  };
}