lu-lowcode-package-form 0.10.5 → 0.10.6
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 +260 -260
- package/dist/index.es.js +18446 -18437
- package/package.json +1 -1
- package/src/App.jsx +6 -1
- package/src/components/field/select/search-select.jsx +16 -0
package/package.json
CHANGED
package/src/App.jsx
CHANGED
@@ -547,8 +547,13 @@ function App() {
|
|
547
547
|
|
548
548
|
]
|
549
549
|
}} />
|
550
|
-
|
550
|
+
|
551
|
+
<Field.SingleSelect mode="single" option_value={"id"} label="测试单选" __id="select1" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]}></Field.SingleSelect>
|
551
552
|
<Field.MultipleSelect mode="multiple" label="测多选" __id="select2" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]}></Field.MultipleSelect>
|
553
|
+
<Field.MultipleSelect mode="multiple" option_label={"label"} option_value={"value"} label="测多选2" __id="select2222" request={async (params) => {
|
554
|
+
console.log("MultipleSelect params", params)
|
555
|
+
return { code: 0, data: { list: [{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }] } }
|
556
|
+
}}></Field.MultipleSelect>
|
552
557
|
<Field.TreeSelect label="分组名" __id="title11"></Field.TreeSelect>
|
553
558
|
<Field.Switch label="开关" __id="switch"></Field.Switch>
|
554
559
|
<Layout.FormGroupTitle title={"嘟嘟嘟嘟嘟"} />
|
@@ -18,6 +18,9 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
|
|
18
18
|
console.log("new value /////",item)
|
19
19
|
typeof onChange === 'function' && onChange(item)
|
20
20
|
}
|
21
|
+
|
22
|
+
// 没有找到与value相等的选项,说明该项数据可能尚未加载,此时需要重新加载数据
|
23
|
+
if (!item) loadSelectOptions()
|
21
24
|
}
|
22
25
|
},[value])
|
23
26
|
useEffect(() => {
|
@@ -32,6 +35,19 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
|
|
32
35
|
// onChange(undefined)
|
33
36
|
// }
|
34
37
|
// },[fieldsValue])
|
38
|
+
|
39
|
+
const loadSelectOptions = async () => {
|
40
|
+
if (request && option_search){
|
41
|
+
const selectOptions = await fetchOptions({...requestParams, [option_search]: value?.label})
|
42
|
+
if (selectOptions && selectOptions.length > 0) {
|
43
|
+
let item = selectOptions.find(item => item.value == value?.value || item.value == value)
|
44
|
+
if (item && !isEqual(item, value)){
|
45
|
+
console.log("new value /////",item)
|
46
|
+
typeof onChange === 'function' && onChange(item)
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
35
51
|
const initData = async (params) => {
|
36
52
|
let item = null
|
37
53
|
const ruleParams = {}
|