mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 20:18:03 +08:00
解决 labelField valueField 不是 label value 的问题
This commit is contained in:
parent
9d4b983d9e
commit
70d034460c
@ -528,7 +528,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className={`${ns}Select-value`} key={index}>
|
<div className={`${ns}Select-value`} key={index}>
|
||||||
{item.label}
|
{item[labelField || 'label']}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -50,6 +50,7 @@ export default class SelectControl extends React.Component<SelectProps, any> {
|
|||||||
delimiter,
|
delimiter,
|
||||||
multiple,
|
multiple,
|
||||||
type,
|
type,
|
||||||
|
valueField,
|
||||||
onChange,
|
onChange,
|
||||||
setOptions,
|
setOptions,
|
||||||
options,
|
options,
|
||||||
@ -62,7 +63,11 @@ export default class SelectControl extends React.Component<SelectProps, any> {
|
|||||||
|
|
||||||
(Array.isArray(value) ? value : value ? [value] : []).forEach(
|
(Array.isArray(value) ? value : value ? [value] : []).forEach(
|
||||||
(option: any) => {
|
(option: any) => {
|
||||||
let resolved = find(options, (item: any) => item.value == option.value);
|
let resolved = find(
|
||||||
|
options,
|
||||||
|
(item: any) =>
|
||||||
|
item[valueField || 'value'] == option[valueField || 'value']
|
||||||
|
);
|
||||||
resolved || additonalOptions.push(option);
|
resolved || additonalOptions.push(option);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -70,22 +75,24 @@ export default class SelectControl extends React.Component<SelectProps, any> {
|
|||||||
if (joinValues) {
|
if (joinValues) {
|
||||||
if (multiple) {
|
if (multiple) {
|
||||||
newValue = Array.isArray(value)
|
newValue = Array.isArray(value)
|
||||||
? (value.map(item => item.value).join(delimiter) as string)
|
? (value
|
||||||
|
.map(item => item[valueField || 'value'])
|
||||||
|
.join(delimiter) as string)
|
||||||
: value
|
: value
|
||||||
? (value as Option).value
|
? (value as Option)[valueField || 'value']
|
||||||
: '';
|
: '';
|
||||||
} else {
|
} else {
|
||||||
newValue = newValue ? (newValue as Option).value : '';
|
newValue = newValue ? (newValue as Option)[valueField || 'value'] : '';
|
||||||
}
|
}
|
||||||
} else if (extractValue) {
|
} else if (extractValue) {
|
||||||
if (multiple) {
|
if (multiple) {
|
||||||
newValue = Array.isArray(value)
|
newValue = Array.isArray(value)
|
||||||
? value.map(item => item.value)
|
? value.map(item => item[valueField || 'value'])
|
||||||
: value
|
: value
|
||||||
? [(value as Option).value]
|
? [(value as Option)[valueField || 'value']]
|
||||||
: [''];
|
: [''];
|
||||||
} else {
|
} else {
|
||||||
newValue = newValue ? (newValue as Option).value : '';
|
newValue = newValue ? (newValue as Option)[valueField || 'value'] : '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user