fix: add associatedKey support for drawerSelect component

This commit is contained in:
chenos 2021-02-05 19:43:46 +08:00
parent b050e4ce5d
commit 9bd79cf082

View File

@ -28,7 +28,7 @@ function transform({value, multiple, labelField, valueField = 'id'}) {
} }
function DrawerSelectComponent(props) { function DrawerSelectComponent(props) {
const { disabled, target, multiple, filter, associatedName, labelField, valueField = 'id', value, onChange } = props; const { disabled, target, multiple, filter, resourceName, associatedKey, labelField, valueField = 'id', value, onChange } = props;
const [selectedKeys, selectedValue] = transform({value, multiple, labelField, valueField }); const [selectedKeys, selectedValue] = transform({value, multiple, labelField, valueField });
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const [selectedRowKeys, setSelectedRowKeys] = useState(multiple ? selectedKeys : [selectedKeys]); const [selectedRowKeys, setSelectedRowKeys] = useState(multiple ? selectedKeys : [selectedKeys]);
@ -98,7 +98,9 @@ function DrawerSelectComponent(props) {
<ViewFactory <ViewFactory
defaultFilter={filter} defaultFilter={filter}
multiple={multiple} multiple={multiple}
resourceName={target} resourceTarget={target}
resourceName={associatedKey ? resourceName : target}
associatedKey={associatedKey}
isFieldComponent={true} isFieldComponent={true}
selectedRowKeys={selectedRowKeys} selectedRowKeys={selectedRowKeys}
onSelected={(values) => { onSelected={(values) => {