chore: 兼容异常数据 (#8923)

This commit is contained in:
liaoxuezhi 2023-11-29 19:05:54 +08:00 committed by GitHub
parent abcf0ed0d6
commit 2c05f9c7fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 9 deletions

View File

@ -34,6 +34,7 @@ import {
import {CardProps, CardSchema} from './Card';
import {Card2Props, Card2Schema} from './Card2';
import type {IItem} from 'amis-core';
import find from 'lodash/find';
/**
* Cards
@ -496,11 +497,25 @@ export default class Cards extends React.Component<GridProps, object> {
store.reset();
}
bulkUpdate(value: object, items: Array<object>) {
const {store} = this.props;
bulkUpdate(value: any, items: Array<object>) {
// const {store} = this.props;
const items2 = store.items.filter(item => ~items.indexOf(item.pristine));
items2.forEach(item => item.change(value));
// const items2 = store.items.filter(item => ~items.indexOf(item.pristine));
// items2.forEach(item => item.change(value));
const {store, primaryField} = this.props;
if (primaryField && value.ids) {
const ids = value.ids.split(',');
const rows = store.items.filter(item =>
find(ids, (id: any) => id && id == item.data[primaryField])
);
const newValue = {...value, ids: undefined};
rows.forEach(item => item.change(newValue));
} else if (Array.isArray(items)) {
const rows = store.items.filter(item => ~items.indexOf(item.pristine));
rows.forEach(item => item.change(value));
}
}
getSelected() {

View File

@ -45,6 +45,7 @@ import {ActionSchema} from './Action';
import {SchemaRemark} from './Remark';
import type {IItem} from 'amis-core';
import type {OnEventProps} from 'amis-core';
import find from 'lodash/find';
/**
*
@ -560,11 +561,25 @@ export default class List extends React.Component<ListProps, object> {
store.reset();
}
bulkUpdate(value: object, items: Array<object>) {
const {store} = this.props;
bulkUpdate(value: any, items: Array<object>) {
// const {store} = this.props;
const items2 = store.items.filter(item => ~items.indexOf(item.pristine));
items2.forEach(item => item.change(value));
// const items2 = store.items.filter(item => ~items.indexOf(item.pristine));
// items2.forEach(item => item.change(value));
const {store, primaryField} = this.props;
if (primaryField && value.ids) {
const ids = value.ids.split(',');
const rows = store.items.filter(item =>
find(ids, (id: any) => id && id == item.data[primaryField])
);
const newValue = {...value, ids: undefined};
rows.forEach(item => item.change(newValue));
} else if (Array.isArray(items)) {
const rows = store.items.filter(item => ~items.indexOf(item.pristine));
rows.forEach(item => item.change(value));
}
}
getSelected() {

View File

@ -1251,7 +1251,7 @@ export default class Table extends React.Component<TableProps, object> {
);
const newValue = {...value, ids: undefined};
rows.forEach(row => row.change(newValue));
} else {
} else if (Array.isArray(items)) {
const rows = store.rows.filter(item => ~items.indexOf(item.pristine));
rows.forEach(row => row.change(value));
}