修复crud 在开启保留条目选择或者 primaryField 没值时导致的勾选混乱问题

Change-Id: I6e3fd0cdbdc996f8856e39922c21f2157704d3bc
This commit is contained in:
2betop 2020-11-11 11:59:36 +08:00
parent f99ddf7232
commit 9fbb4971a6
2 changed files with 22 additions and 6 deletions

View File

@ -1254,8 +1254,9 @@ export default class CRUD extends React.Component<CRUDProps, any> {
const idx = findIndex(
oldItems,
a =>
a[primaryField || 'id'] &&
a[primaryField || 'id'] == item[primaryField || 'id']
a === item ||
(a[primaryField || 'id'] &&
a[primaryField || 'id'] == item[primaryField || 'id'])
);
if (~idx) {
@ -1263,21 +1264,35 @@ export default class CRUD extends React.Component<CRUDProps, any> {
} else {
oldItems.push(item);
}
const idx2 = findIndex(
oldUnselectedItems,
a =>
a === item ||
(a[primaryField || 'id'] &&
a[primaryField || 'id'] == item[primaryField || 'id'])
);
if (~idx2) {
oldUnselectedItems.splice(idx2, 1);
}
});
unSelectedItems.forEach(item => {
const idx = findIndex(
oldUnselectedItems,
a =>
a[primaryField || 'id'] &&
a[primaryField || 'id'] == item[primaryField || 'id']
a === item ||
(a[primaryField || 'id'] &&
a[primaryField || 'id'] == item[primaryField || 'id'])
);
const idx2 = findIndex(
oldItems,
a =>
a[primaryField || 'id'] &&
a[primaryField || 'id'] == item[primaryField || 'id']
a === item ||
(a[primaryField || 'id'] &&
a[primaryField || 'id'] == item[primaryField || 'id'])
);
if (~idx) {

View File

@ -780,6 +780,7 @@ export const TableStore = iRendererStore
find(
selected,
a =>
a[valueField || 'value'] &&
a[valueField || 'value'] == item.pristine[valueField || 'value']
)
) {