lu-lowcode-package-form 0.10.60 → 0.10.62

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lu-lowcode-package-form",
3
- "version": "0.10.60",
3
+ "version": "0.10.62",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^4.8.1",
6
6
  "@dnd-kit/core": "^6.1.0",
@@ -12,7 +12,9 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
12
12
 
13
13
  const currentPageRef = useRef(1);
14
14
  const currentPageSize = 10
15
- const [isAllLoaded, setIsAllLoaded] = useState(false)
15
+ const isAllLoadedRef = useRef(false)
16
+ const isLoadingRef = useRef(false);
17
+
16
18
  useEffect(() => {
17
19
  // console.log("SearchSelect useEffect props", props)
18
20
  if (value) {
@@ -79,6 +81,7 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
79
81
  let item = null
80
82
  const ruleParams = {}
81
83
  currentPageRef.current = 1
84
+ isAllLoadedRef.current = false
82
85
  if (request && typeof request === 'function') {
83
86
  debounceFetchOptions(params, ruleParams)
84
87
  }
@@ -191,13 +194,26 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
191
194
  }
192
195
  };
193
196
 
197
+
194
198
  const loadMoreOptions = async () => {
195
- const nextPageParams = { ...requestParams, page: currentPageRef.current + 1, pageSize: currentPageSize };
196
- let newOptions = await fetchList(nextPageParams, null)
197
- newOptions = await handleOptions(newOptions)
198
- if (Array.isArray(newOptions) && newOptions.length > 0) {
199
- setNOptions(prevOptions => [...prevOptions, ...newOptions]);
200
- currentPageRef.current = currentPageRef.current + 1;
199
+ if (isAllLoadedRef.current || isLoadingRef.current) return; // 检查是否已加载完毕或正在加载
200
+
201
+ isLoadingRef.current = true; // 设置加载状态为 true
202
+
203
+ try {
204
+ const nextPageParams = { ...requestParams, page: currentPageRef.current + 1, pageSize: currentPageSize };
205
+ let newOptions = await fetchList(nextPageParams, null);
206
+ newOptions = await handleOptions(newOptions);
207
+ if (Array.isArray(newOptions) && newOptions.length > 0) {
208
+ setNOptions(prevOptions => [...prevOptions, ...newOptions]);
209
+ } else {
210
+ isAllLoadedRef.current = true;
211
+ }
212
+ currentPageRef.current += 1;
213
+ } catch (error) {
214
+ console.error("加载更多选项时出错", error);
215
+ } finally {
216
+ isLoadingRef.current = false; // 重置加载状态
201
217
  }
202
218
  };
203
219
  return addWrapper ? (