@fairys/taro-tools-react 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,7 +13,7 @@ export interface PageDataInstanceState extends Object {
|
|
|
13
13
|
/**是否最后一页*/
|
|
14
14
|
hasLastPage?: boolean;
|
|
15
15
|
/**查询条件*/
|
|
16
|
-
search?:
|
|
16
|
+
search?: Record<string, any>;
|
|
17
17
|
/**表格数据*/
|
|
18
18
|
dataList?: any[];
|
|
19
19
|
/**选择行数据*/
|
|
@@ -97,7 +97,7 @@ export declare class PageDataInstance<T extends PageDataInstanceState = PageData
|
|
|
97
97
|
/**内置——查询方法*/
|
|
98
98
|
main_onSearch: () => void;
|
|
99
99
|
/**加载更多*/
|
|
100
|
-
main_onLoadMore: () => void
|
|
100
|
+
main_onLoadMore: () => Promise<void>;
|
|
101
101
|
}
|
|
102
102
|
export interface PageDataOptions<T extends PageDataInstanceState = PageDataInstanceState> {
|
|
103
103
|
/**初始值*/
|
|
@@ -210,7 +210,7 @@ class page_data_instance_PageDataInstance extends ProxyInstanceObjectBase {
|
|
|
210
210
|
this.main_onPageChange(1);
|
|
211
211
|
this.store.expandSearch = false;
|
|
212
212
|
};
|
|
213
|
-
main_onLoadMore = ()=>{
|
|
213
|
+
main_onLoadMore = async ()=>{
|
|
214
214
|
if (this.store.loading?.pageLoading) return;
|
|
215
215
|
const isTabs = this.store.isTabs;
|
|
216
216
|
if (isTabs) {
|
|
@@ -233,10 +233,12 @@ class page_data_instance_PageDataInstance extends ProxyInstanceObjectBase {
|
|
|
233
233
|
[`${tabKey}LoadMore`]: true
|
|
234
234
|
});
|
|
235
235
|
this._setValues({
|
|
236
|
-
[`${tabKey}Page`]: nextPage
|
|
236
|
+
[`${tabKey}Page`]: nextPage
|
|
237
|
+
});
|
|
238
|
+
await this.main_getList();
|
|
239
|
+
this._setValues({
|
|
237
240
|
[`${tabKey}HasLastPage`]: hasLastPage
|
|
238
241
|
});
|
|
239
|
-
this.main_getList();
|
|
240
242
|
return;
|
|
241
243
|
}
|
|
242
244
|
const total = this.store.total || 0;
|
|
@@ -255,10 +257,12 @@ class page_data_instance_PageDataInstance extends ProxyInstanceObjectBase {
|
|
|
255
257
|
if (nextPage >= count && total) hasLastPage = true;
|
|
256
258
|
this.store.loading.loadMore = true;
|
|
257
259
|
this._setValues({
|
|
258
|
-
page: nextPage
|
|
260
|
+
page: nextPage
|
|
261
|
+
});
|
|
262
|
+
await this.main_getList();
|
|
263
|
+
this._setValues({
|
|
259
264
|
hasLastPage
|
|
260
265
|
});
|
|
261
|
-
this.main_getList();
|
|
262
266
|
};
|
|
263
267
|
}
|
|
264
268
|
function usePageDataInstance(instance) {
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@ export interface PageDataInstanceState extends Object {
|
|
|
18
18
|
/**是否最后一页*/
|
|
19
19
|
hasLastPage?: boolean;
|
|
20
20
|
/**查询条件*/
|
|
21
|
-
search?:
|
|
21
|
+
search?: Record<string, any>;
|
|
22
22
|
/**表格数据*/
|
|
23
23
|
dataList?: any[];
|
|
24
24
|
/**选择行数据*/
|
|
@@ -301,7 +301,7 @@ export class PageDataInstance<
|
|
|
301
301
|
this.store.expandSearch = false;
|
|
302
302
|
};
|
|
303
303
|
/**加载更多*/
|
|
304
|
-
main_onLoadMore = () => {
|
|
304
|
+
main_onLoadMore = async () => {
|
|
305
305
|
if (this.store.loading?.pageLoading) {
|
|
306
306
|
// 加载中,不进行请求
|
|
307
307
|
return;
|
|
@@ -329,9 +329,9 @@ export class PageDataInstance<
|
|
|
329
329
|
// 判断是否最后一页数据
|
|
330
330
|
this._setValues({
|
|
331
331
|
[`${tabKey}Page`]: nextPage,
|
|
332
|
-
[`${tabKey}HasLastPage`]: hasLastPage,
|
|
333
332
|
});
|
|
334
|
-
this.main_getList();
|
|
333
|
+
await this.main_getList();
|
|
334
|
+
this._setValues({ [`${tabKey}HasLastPage`]: hasLastPage });
|
|
335
335
|
return;
|
|
336
336
|
}
|
|
337
337
|
const total = this.store.total || 0;
|
|
@@ -352,8 +352,9 @@ export class PageDataInstance<
|
|
|
352
352
|
}
|
|
353
353
|
this.store.loading.loadMore = true;
|
|
354
354
|
// 判断是否最后一页数据
|
|
355
|
-
this._setValues({ page: nextPage
|
|
356
|
-
this.main_getList();
|
|
355
|
+
this._setValues({ page: nextPage });
|
|
356
|
+
await this.main_getList();
|
|
357
|
+
this._setValues({ hasLastPage });
|
|
357
358
|
};
|
|
358
359
|
}
|
|
359
360
|
|
|
@@ -442,6 +443,7 @@ export function PageDataInstanceContextProvider<T extends PageDataInstanceState
|
|
|
442
443
|
isMountLoad,
|
|
443
444
|
title,
|
|
444
445
|
} = props;
|
|
446
|
+
|
|
445
447
|
const pageInstance = usePageDataInstance(instance);
|
|
446
448
|
|
|
447
449
|
instance.onBefore = onBefore;
|