Merge pull request #303 from 2betop/master

CRUD 的 quickSave 发送原始值
This commit is contained in:
liaoxuezhi 2019-10-24 10:26:13 +08:00 committed by GitHub
commit 49253234fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 14 deletions

View File

@ -84,7 +84,7 @@
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
display: inline-block; display: inline-block;
line-height: 1; vertical-align: middle;
} }
&-clear { &-clear {

View File

@ -639,7 +639,8 @@ export default class CRUD extends React.Component<CRUDProps, any> {
rows: Array<object> | object, rows: Array<object> | object,
diff: Array<object> | object, diff: Array<object> | object,
indexes: Array<number>, indexes: Array<number>,
unModifiedItems?: Array<any> unModifiedItems?: Array<any>,
rowsOrigin?: Array<object> | object
) { ) {
const {store, quickSaveApi, quickSaveItemApi, primaryField, env, messages, reload} = this.props; const {store, quickSaveApi, quickSaveItemApi, primaryField, env, messages, reload} = this.props;
@ -652,7 +653,8 @@ export default class CRUD extends React.Component<CRUDProps, any> {
const data: any = createObject(store.data, { const data: any = createObject(store.data, {
rows, rows,
rowsDiff: diff, rowsDiff: diff,
indexes: indexes indexes: indexes,
rowsOrigin
}); });
if (rows.length && rows[0].hasOwnProperty(primaryField || 'id')) { if (rows.length && rows[0].hasOwnProperty(primaryField || 'id')) {
@ -681,7 +683,8 @@ export default class CRUD extends React.Component<CRUDProps, any> {
const data = createObject(store.data, { const data = createObject(store.data, {
item: rows, item: rows,
modified: diff modified: diff,
origin: rowsOrigin
}); });
const sendData = createObject(data, rows); const sendData = createObject(data, rows);

View File

@ -40,7 +40,8 @@ export interface GridProps extends RendererProps {
items: Array<object> | object, items: Array<object> | object,
diff: Array<object> | object, diff: Array<object> | object,
rowIndexes: Array<number> | number, rowIndexes: Array<number> | number,
unModifiedItems?: Array<object> unModifiedItems?: Array<object>,
rowOrigins?: Array<object> | object
) => void; ) => void;
onSaveOrder?: (moved: Array<object>, items: Array<object>) => void; onSaveOrder?: (moved: Array<object>, items: Array<object>) => void;
onQuery: (values: object) => void; onQuery: (values: object) => void;
@ -324,7 +325,7 @@ export default class Cards extends React.Component<GridProps, object> {
return; return;
} }
onSave(item.data, difference(item.data, item.pristine), item.index); onSave(item.data, difference(item.data, item.pristine), item.index, undefined, item.pristine);
} }
handleSave() { handleSave() {
@ -338,7 +339,7 @@ export default class Cards extends React.Component<GridProps, object> {
const itemIndexes = store.modifiedItems.map(item => item.index); const itemIndexes = store.modifiedItems.map(item => item.index);
const diff = store.modifiedItems.map(item => difference(item.data, item.pristine)); const diff = store.modifiedItems.map(item => difference(item.data, item.pristine));
const unModifiedItems = store.items.filter(item => !item.modified).map(item => item.data); const unModifiedItems = store.items.filter(item => !item.modified).map(item => item.data);
onSave(items, diff, itemIndexes, unModifiedItems); onSave(items, diff, itemIndexes, unModifiedItems, store.modifiedItems.map(item => item.pristine));
} }
handleSaveOrder() { handleSaveOrder() {

View File

@ -908,7 +908,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
level="default" level="default"
disabled={!hasPending} disabled={!hasPending}
className={cx('FileControl-uploadBtn')} className={cx('FileControl-uploadBtn')}
onClick={this.handleSelect} onClick={this.toggleUpload}
> >
{uploading ? '暂停上传' : '开始上传'} {uploading ? '暂停上传' : '开始上传'}
</Button> </Button>

View File

@ -41,7 +41,8 @@ export interface ListProps extends RendererProps {
items: Array<object> | object, items: Array<object> | object,
diff: Array<object> | object, diff: Array<object> | object,
rowIndexes: Array<number> | number, rowIndexes: Array<number> | number,
unModifiedItems?: Array<object> unModifiedItems?: Array<object>,
rowOrigins?: Array<object> | object
) => void; ) => void;
onSaveOrder?: (moved: Array<object>, items: Array<object>) => void; onSaveOrder?: (moved: Array<object>, items: Array<object>) => void;
onQuery: (values: object) => void; onQuery: (values: object) => void;
@ -295,7 +296,7 @@ export default class List extends React.Component<ListProps, object> {
return; return;
} }
onSave(item.data, difference(item.data, item.pristine), item.index); onSave(item.data, difference(item.data, item.pristine), item.index, undefined, item.pristine);
} }
handleSave() { handleSave() {
@ -309,7 +310,7 @@ export default class List extends React.Component<ListProps, object> {
const itemIndexes = store.modifiedItems.map(item => item.index); const itemIndexes = store.modifiedItems.map(item => item.index);
const diff = store.modifiedItems.map(item => difference(item.data, item.pristine)); const diff = store.modifiedItems.map(item => difference(item.data, item.pristine));
const unModifiedItems = store.items.filter(item => !item.modified).map(item => item.data); const unModifiedItems = store.items.filter(item => !item.modified).map(item => item.data);
onSave(items, diff, itemIndexes, unModifiedItems); onSave(items, diff, itemIndexes, unModifiedItems, store.modifiedItems.map(item => item.pristine));
} }
handleSaveOrder() { handleSaveOrder() {

View File

@ -69,7 +69,8 @@ export interface TableProps extends RendererProps {
items: Array<object> | object, items: Array<object> | object,
diff: Array<object> | object, diff: Array<object> | object,
rowIndexes: Array<number> | number, rowIndexes: Array<number> | number,
unModifiedItems?: Array<object> unModifiedItems?: Array<object>,
rowOrigins?: Array<object> | object
) => void; ) => void;
onSaveOrder?: (moved: Array<object>, items: Array<object>) => void; onSaveOrder?: (moved: Array<object>, items: Array<object>) => void;
onQuery: (values: object) => void; onQuery: (values: object) => void;
@ -384,7 +385,7 @@ export default class Table extends React.Component<TableProps, object> {
return; return;
} }
onSave(item.data, difference(item.data, item.pristine), item.index); onSave(item.data, difference(item.data, item.pristine), item.index, undefined, item.pristine);
} }
async handleSave() { async handleSave() {
@ -408,7 +409,7 @@ export default class Table extends React.Component<TableProps, object> {
const rowIndexes = store.modifiedRows.map(item => item.index); const rowIndexes = store.modifiedRows.map(item => item.index);
const diff = store.modifiedRows.map(item => difference(item.data, item.pristine)); const diff = store.modifiedRows.map(item => difference(item.data, item.pristine));
const unModifiedRows = store.rows.filter(item => !item.modified).map(item => item.data); const unModifiedRows = store.rows.filter(item => !item.modified).map(item => item.data);
onSave(rows, diff, rowIndexes, unModifiedRows); onSave(rows, diff, rowIndexes, unModifiedRows, store.modifiedRows.map(item => item.pristine));
} }
handleSaveOrder() { handleSaveOrder() {