fix: picker选中项不显示label问题修复

This commit is contained in:
wanglinfang 2023-08-18 15:04:23 +08:00
parent 5e2d90d8b1
commit 244d4a935b
2 changed files with 5 additions and 12 deletions

View File

@ -1182,7 +1182,7 @@ export const FormItemStore = StoreNode.named('FormItemStore')
selected.forEach((item, index) => {
const value = getOptionValue(item, valueField);
if (flattenedMap.get(value)) {
selectedOptions.push(item);
selectedOptions.push(flattenedMap.get(value));
return;
}

View File

@ -579,23 +579,16 @@ export default class CRUD extends React.Component<CRUDProps, any> {
this.renderHeaderToolbar = this.renderHeaderToolbar.bind(this);
this.renderFooterToolbar = this.renderFooterToolbar.bind(this);
}
// picker的数据如果是异步加载那么初始的value其实是{id: ' 7', engine: ' 7', __unmatched: true}这种样子的
// 拿到数据后又会变成真实数据,类似这种{browser: "Firefox 1.0", engine: "Gecko - syo6k7", grade: "A", group: "train", id: 7, platform: "Win 98+ / OSX.2+", version: "1.7"}
// 因此比较value是否更改只比较关键字段即可否则会执行多次setSelectedItems
// 显隐切换时,也会导致需要二次点击才能选中的问题
let val: any;
const valueField = props.valueField || props.primaryField;
if (
this.props.pickerMode &&
isArrayChildrenModified(
(val = getPropValue(this.props))?.map((item: any) => item[valueField]),
getPropValue(prevProps)?.map((item: any) => item[valueField])
(val = getPropValue(this.props)),
getPropValue(prevProps)
) &&
!isEqual(
val?.map((item: any) => item[valueField]),
store.selectedItems.concat().map((item: any) => item[valueField])
)
!isEqual(val, store.selectedItems.concat())
) {
/**
* Table -> CRUD -> Picker -> Form