lu-lowcode-package-form 0.10.61 → 0.10.63
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/dist/index.cjs.js +89 -89
- package/dist/index.es.js +2276 -2265
- package/package.json +1 -1
- package/src/components/field/select/search-select.jsx +25 -9
package/package.json
CHANGED
@@ -13,6 +13,8 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
|
|
13
13
|
const currentPageRef = useRef(1);
|
14
14
|
const currentPageSize = 10
|
15
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) {
|
@@ -192,17 +194,31 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
|
|
192
194
|
}
|
193
195
|
};
|
194
196
|
|
197
|
+
|
195
198
|
const loadMoreOptions = async () => {
|
196
|
-
if (isAllLoadedRef.current) return
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
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 => {
|
209
|
+
const existingValues = new Set(prevOptions.map(option => option.value));
|
210
|
+
const filteredNewOptions = newOptions.filter(option => !existingValues.has(option.value));
|
211
|
+
return [...prevOptions, ...filteredNewOptions];
|
212
|
+
});
|
213
|
+
} else {
|
214
|
+
isAllLoadedRef.current = true;
|
215
|
+
}
|
216
|
+
currentPageRef.current += 1;
|
217
|
+
} catch (error) {
|
218
|
+
console.error("加载更多选项时出错", error);
|
219
|
+
} finally {
|
220
|
+
isLoadingRef.current = false; // 重置加载状态
|
204
221
|
}
|
205
|
-
currentPageRef.current = currentPageRef.current + 1;
|
206
222
|
};
|
207
223
|
return addWrapper ? (
|
208
224
|
<BaseWrapper {...props}>
|