mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:48:13 +08:00
fix: 修复 picker 点选时无法区分 false 和 数字 0 的问题 (#9193)
This commit is contained in:
parent
b14c3ab7cb
commit
0dcfb1d637
@ -210,20 +210,28 @@ export const ListStore = iRendererStore
|
|||||||
|
|
||||||
function updateSelected(selected: Array<any>, valueField?: string) {
|
function updateSelected(selected: Array<any>, valueField?: string) {
|
||||||
self.selectedItems.clear();
|
self.selectedItems.clear();
|
||||||
self.items.forEach(item => {
|
selected.forEach(item => {
|
||||||
if (~selected.indexOf(item.pristine)) {
|
let resolved = self.items.find(a => a.pristine === item);
|
||||||
self.selectedItems.push(item);
|
|
||||||
} else if (
|
// 先严格比较,
|
||||||
find(selected, a => {
|
if (!resolved) {
|
||||||
const selectValue = a[valueField || 'value'];
|
resolved = self.items.find(a => {
|
||||||
const itemValue = item.pristine[valueField || 'value'];
|
const selectValue = item[valueField || 'value'];
|
||||||
return self.strictMode
|
const itemValue = a.pristine[valueField || 'value'];
|
||||||
? selectValue === itemValue
|
return selectValue === itemValue;
|
||||||
: selectValue == itemValue;
|
});
|
||||||
})
|
|
||||||
) {
|
|
||||||
self.selectedItems.push(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 再宽松比较
|
||||||
|
if (!resolved) {
|
||||||
|
resolved = self.items.find(a => {
|
||||||
|
const selectValue = item[valueField || 'value'];
|
||||||
|
const itemValue = a.pristine[valueField || 'value'];
|
||||||
|
return selectValue == itemValue;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
resolved && self.selectedItems.push(resolved);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1528,19 +1528,28 @@ export const TableStore = iRendererStore
|
|||||||
function updateSelected(selected: Array<any>, valueField?: string) {
|
function updateSelected(selected: Array<any>, valueField?: string) {
|
||||||
self.selectedRows.clear();
|
self.selectedRows.clear();
|
||||||
|
|
||||||
eachTree(self.rows, item => {
|
selected.forEach(item => {
|
||||||
if (~selected.indexOf(item.pristine)) {
|
let resolved = self.rows.find(a => a.pristine === item);
|
||||||
self.selectedRows.push(item.id);
|
|
||||||
} else if (
|
// 先严格比较,
|
||||||
find(
|
if (!resolved) {
|
||||||
selected,
|
resolved = self.rows.find(a => {
|
||||||
a =>
|
const selectValue = item[valueField || 'value'];
|
||||||
a[valueField || 'value'] &&
|
const itemValue = a.pristine[valueField || 'value'];
|
||||||
a[valueField || 'value'] == item.pristine[valueField || 'value']
|
return selectValue === itemValue;
|
||||||
)
|
});
|
||||||
) {
|
|
||||||
self.selectedRows.push(item.id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 再宽松比较
|
||||||
|
if (!resolved) {
|
||||||
|
resolved = self.rows.find(a => {
|
||||||
|
const selectValue = item[valueField || 'value'];
|
||||||
|
const itemValue = a.pristine[valueField || 'value'];
|
||||||
|
return selectValue == itemValue;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
resolved && self.selectedRows.push(resolved);
|
||||||
});
|
});
|
||||||
|
|
||||||
updateCheckDisable();
|
updateCheckDisable();
|
||||||
|
Loading…
Reference in New Issue
Block a user