Merge pull request 'fix: 修改多选下拉框数据问题' (#392) from fix_multipleSelect into @hera/dev
Reviewed-on: daoyoucloud/tachycode#392 Reviewed-by: sealday <zhanglin@daoyoucloud.com>
This commit is contained in:
		
						commit
						759f51dae8
					
				| @ -21,25 +21,13 @@ type Props = SelectProps<any, any> & { | ||||
| const isEmptyObject = (val: any) => !isValid(val) || (typeof val === 'object' && Object.keys(val).length === 0); | ||||
| 
 | ||||
| const ObjectSelect = (props: Props) => { | ||||
|   const { | ||||
|     value, | ||||
|     options: defultValue, | ||||
|     onChange, | ||||
|     fieldNames, | ||||
|     mode, | ||||
|     loading, | ||||
|     rawOptions, | ||||
|     defaultValue, | ||||
|     ...others | ||||
|   } = props; | ||||
|   const [options, setOptions] = useState([]); | ||||
|   const [defult, setDefult] = useState(false); | ||||
|   const { value, options, onChange, fieldNames, mode, loading, rawOptions, defaultValue, ...others } = props; | ||||
|   const [defoptions, setDefOptions] = useState(); | ||||
|   const fieldSchema = useFieldSchema(); | ||||
|   const collectionName = fieldSchema['collectionName']; | ||||
|   const filterField = fieldSchema['x-component-props']['params']; | ||||
|   const filter = filterField ? JSON.stringify(filterField.filter) : {}; | ||||
|   const api = useAPIClient(); | ||||
| 
 | ||||
|   useAsyncEffect(async () => { | ||||
|     if (collectionName) { | ||||
|       const defValue = await api.request({ | ||||
| @ -49,10 +37,9 @@ const ObjectSelect = (props: Props) => { | ||||
|           filter: filterField ? { ...filterField.filter } : {}, | ||||
|         }, | ||||
|       }); | ||||
|       setOptions(defValue?.data?.data); | ||||
|       setDefOptions(defValue?.data?.data); | ||||
|     } | ||||
|   }, [filter]); | ||||
| 
 | ||||
|   const toValue = (v: any) => { | ||||
|     if (isEmptyObject(v)) { | ||||
|       return; | ||||
| @ -89,7 +76,7 @@ const ObjectSelect = (props: Props) => { | ||||
|       }} | ||||
|       labelInValue | ||||
|       notFoundContent={loading ? <Spin /> : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />} | ||||
|       options={options} | ||||
|       options={defoptions || options} | ||||
|       fieldNames={fieldNames} | ||||
|       showSearch | ||||
|       popupMatchSelectWidth={false} | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user