lu-lowcode-package-form 0.10.55 → 0.10.57
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 +222 -222
- package/dist/index.es.js +11467 -11454
- package/package.json +1 -1
- package/src/components/field/select/search-select.jsx +26 -2
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
|
3
3
|
import { Input, Select as OriginalSelect, Spin } from 'antd';
|
4
|
-
import React, { useEffect, useState, forwardRef, useCallback } from 'react';
|
4
|
+
import React, { useEffect, useState, forwardRef, useCallback ,useRef} from 'react';
|
5
5
|
import { BaseWrapper } from "../base"
|
6
6
|
import { debounce, isEqual } from 'lodash';
|
7
7
|
|
@@ -9,6 +9,9 @@ import { debounce, isEqual } from 'lodash';
|
|
9
9
|
const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsValue, shouldUpdateKey,value, type, defaultValue, onChange, option_label, option_value, option_search, options, request, requestParams, callError, subRequest, sub_option_label = "label", mode = "single", sub_option_value = "id", rightIconRender, rightIcon, rightIconClick,recordFieldsChange, ...props }, ref) => {
|
10
10
|
const [nOptions, setNOptions] = React.useState([])
|
11
11
|
const [fetching, setFetching] = useState(false);
|
12
|
+
|
13
|
+
const currentPageRef = useRef(1);
|
14
|
+
const [isAllLoaded, setIsAllLoaded] = useState(false)
|
12
15
|
useEffect(() => {
|
13
16
|
// console.log("SearchSelect useEffect props", props)
|
14
17
|
if (value) {
|
@@ -74,6 +77,7 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
|
|
74
77
|
|
75
78
|
let item = null
|
76
79
|
const ruleParams = {}
|
80
|
+
currentPageRef.current = 1
|
77
81
|
if (request && typeof request === 'function') {
|
78
82
|
debounceFetchOptions(params, ruleParams)
|
79
83
|
}
|
@@ -171,7 +175,25 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
|
|
171
175
|
}
|
172
176
|
}
|
173
177
|
|
174
|
-
|
178
|
+
const handleScroll = (event) => {
|
179
|
+
const { target } = event;
|
180
|
+
if (target.scrollTop + target.clientHeight >= target.scrollHeight) {
|
181
|
+
// 滚动到底部,加载更多数据
|
182
|
+
loadMoreOptions();
|
183
|
+
}
|
184
|
+
};
|
185
|
+
|
186
|
+
const loadMoreOptions = async () => {
|
187
|
+
if (request && option_value) {
|
188
|
+
const nextPageParams = { ...requestParams, page: currentPageRef.current + 1, pageSize: currentPageSize };
|
189
|
+
debounceFetchOptions(nextPageParams, null, (newOptions) => {
|
190
|
+
if (newOptions && newOptions.length > 0) {
|
191
|
+
setNOptions(prevOptions => [...prevOptions, ...newOptions]);
|
192
|
+
currentPageRef.current = currentPageRef.current + 1;
|
193
|
+
}
|
194
|
+
});
|
195
|
+
}
|
196
|
+
};
|
175
197
|
return addWrapper ? (
|
176
198
|
<BaseWrapper {...props}>
|
177
199
|
<OriginalSelect
|
@@ -185,6 +207,7 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
|
|
185
207
|
onChange={handleChange}
|
186
208
|
style={{ width: '100%', flex: 1 }}
|
187
209
|
options={nOptions}
|
210
|
+
onPopupScroll={typeof request === 'function' ? handleScroll : null}
|
188
211
|
mode={mode} >
|
189
212
|
|
190
213
|
</OriginalSelect>
|
@@ -203,6 +226,7 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
|
|
203
226
|
onChange={handleChange}
|
204
227
|
style={{ width: '100%' }}
|
205
228
|
options={nOptions}
|
229
|
+
onPopupScroll={typeof request === 'function' ? handleScroll : null}
|
206
230
|
mode={mode} >
|
207
231
|
|
208
232
|
</OriginalSelect>
|