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
| import { BaseData, useInfiniteLoading } from '@12333/hooks';
| import Taro from '@tarojs/taro';
| import * as enterpriseServices from '@12333/services/apiV2/enterprise';
| import { InfiniteData } from '@tanstack/vue-query';
|
| type UseEnterpriseAddressesOptions = {
| rows?: number;
| onSuccess?: (data: InfiniteData<BaseData<API.GetEnterpriseAddressesQueryResultItem>>) => any;
| };
|
| export function useEnterpriseAddresses(options: UseEnterpriseAddressesOptions = {}) {
| const { rows = 20, onSuccess } = options;
|
| const { infiniteLoadingProps, invalidateQueries } = useInfiniteLoading(
| ({ pageParam }) => {
| let params: API.GetEnterpriseAddressesQuery = {
| pageModel: {
| rows: rows,
| page: pageParam,
| },
| };
|
| return enterpriseServices.getEnterpriseAddresses(params, {
| showLoading: false,
| });
| },
| {
| queryKey: ['enterpriseServices/getEnterpriseAddresses', rows],
| onSuccess(data) {
| onSuccess?.(data);
| },
| }
| );
|
| return { infiniteLoadingProps, invalidateQueries };
| }
|
|