lu-lowcode-package-form 0.10.58 → 0.10.60

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.58",
3
+ "version": "0.10.60",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^4.8.1",
6
6
  "@dnd-kit/core": "^6.1.0",
package/src/App.jsx CHANGED
@@ -322,6 +322,7 @@ function App() {
322
322
 
323
323
  let result = { code: 0, data: { list: pageData } };
324
324
  console.log("request result", result)
325
+ await new Promise(resolve => setTimeout(resolve, 200))
325
326
  return result
326
327
  }}
327
328
  option_label="label"
@@ -139,30 +139,32 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
139
139
  }
140
140
  return list
141
141
  }
142
+ const handleOptions = async (list) => {
143
+ if (Array.isArray(list)) {
144
+ for (let index = 0; index < list.length; index++) {
145
+ const item = list[index];
146
+ if (typeof subRequest == "function") {
147
+ let subList = []
148
+ const { data } = await subRequest(item)
149
+ if (data?.list && Array.isArray(data.list)) {
150
+ subList = data.list.map(subItem => ({ label: `${item[option_label]}-${subItem[sub_option_label]}`, value: `${item[option_value]}-${subItem[sub_option_value]}` }))
151
+ }
152
+ list[index] = { ...item, label: item[option_label], title: item[option_label], options: subList }
153
+ }
154
+ list[index] = { ...item, label: item[option_label], value: item[option_value] }
155
+ }
156
+ if (nOptions.length > 0 && !isEqual(nOptions, list)) {
157
+ typeof onChange === 'function' && onChange(undefined)
158
+ }
159
+ }
160
+ return list
161
+ }
142
162
 
143
163
  const fetchOptions = async (params, ruleParams) => {
144
164
  try {
145
165
  let list = await fetchList(params, ruleParams)
146
-
147
- if (Array.isArray(list)) {
148
- for (let index = 0; index < list.length; index++) {
149
- const item = list[index];
150
- if (typeof subRequest == "function") {
151
- let subList = []
152
- const { data } = await subRequest(item)
153
- if (data?.list && Array.isArray(data.list)) {
154
- subList = data.list.map(subItem => ({ label: `${item[option_label]}-${subItem[sub_option_label]}`, value: `${item[option_value]}-${subItem[sub_option_value]}` }))
155
- }
156
- list[index] = { ...item, label: item[option_label], title: item[option_label], options: subList }
157
- }
158
- list[index] = { ...item, label: item[option_label], value: item[option_value] }
159
- }
160
- if (nOptions.length > 0 && !isEqual(nOptions, list)) {
161
- typeof onChange === 'function' && onChange(undefined)
162
- }
163
- setNOptions(list)
164
- }
165
- else setNOptions([])
166
+ list = await handleOptions(list)
167
+ setNOptions(Array.isArray(list) ? list : [])
166
168
  return list
167
169
  } catch (error) {
168
170
  console.error("fetchOptions", error)
@@ -192,6 +194,7 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
192
194
  const loadMoreOptions = async () => {
193
195
  const nextPageParams = { ...requestParams, page: currentPageRef.current + 1, pageSize: currentPageSize };
194
196
  let newOptions = await fetchList(nextPageParams, null)
197
+ newOptions = await handleOptions(newOptions)
195
198
  if (Array.isArray(newOptions) && newOptions.length > 0) {
196
199
  setNOptions(prevOptions => [...prevOptions, ...newOptions]);
197
200
  currentPageRef.current = currentPageRef.current + 1;