From 24f53c5cd69900de4d601bc13973bfc16717e25a Mon Sep 17 00:00:00 2001 From: liaoxuezhi Date: Thu, 24 Oct 2019 10:24:52 +0800 Subject: [PATCH] =?UTF-8?q?CRUD=20=E7=9A=84=20quickSave=20=E5=8F=91?= =?UTF-8?q?=E9=80=81=E5=8E=9F=E5=A7=8B=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scss/components/form/_file.scss | 2 +- src/renderers/CRUD.tsx | 9 ++++++--- src/renderers/Cards.tsx | 7 ++++--- src/renderers/Form/File.tsx | 2 +- src/renderers/List.tsx | 7 ++++--- src/renderers/Table.tsx | 7 ++++--- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/scss/components/form/_file.scss b/scss/components/form/_file.scss index da817f3a1..5046b8141 100644 --- a/scss/components/form/_file.scss +++ b/scss/components/form/_file.scss @@ -84,7 +84,7 @@ overflow: hidden; text-overflow: ellipsis; display: inline-block; - line-height: 1; + vertical-align: middle; } &-clear { diff --git a/src/renderers/CRUD.tsx b/src/renderers/CRUD.tsx index 8109f1b00..b104baa06 100644 --- a/src/renderers/CRUD.tsx +++ b/src/renderers/CRUD.tsx @@ -639,7 +639,8 @@ export default class CRUD extends React.Component { rows: Array | object, diff: Array | object, indexes: Array, - unModifiedItems?: Array + unModifiedItems?: Array, + rowsOrigin?: Array | object ) { const {store, quickSaveApi, quickSaveItemApi, primaryField, env, messages, reload} = this.props; @@ -652,7 +653,8 @@ export default class CRUD extends React.Component { const data: any = createObject(store.data, { rows, rowsDiff: diff, - indexes: indexes + indexes: indexes, + rowsOrigin }); if (rows.length && rows[0].hasOwnProperty(primaryField || 'id')) { @@ -681,7 +683,8 @@ export default class CRUD extends React.Component { const data = createObject(store.data, { item: rows, - modified: diff + modified: diff, + origin: rowsOrigin }); const sendData = createObject(data, rows); diff --git a/src/renderers/Cards.tsx b/src/renderers/Cards.tsx index cf3ad6219..f94102410 100644 --- a/src/renderers/Cards.tsx +++ b/src/renderers/Cards.tsx @@ -40,7 +40,8 @@ export interface GridProps extends RendererProps { items: Array | object, diff: Array | object, rowIndexes: Array | number, - unModifiedItems?: Array + unModifiedItems?: Array, + rowOrigins?: Array | object ) => void; onSaveOrder?: (moved: Array, items: Array) => void; onQuery: (values: object) => void; @@ -324,7 +325,7 @@ export default class Cards extends React.Component { 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() { @@ -338,7 +339,7 @@ export default class Cards extends React.Component { const itemIndexes = store.modifiedItems.map(item => item.index); const diff = store.modifiedItems.map(item => difference(item.data, item.pristine)); 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() { diff --git a/src/renderers/Form/File.tsx b/src/renderers/Form/File.tsx index c9772d572..064fd07d8 100644 --- a/src/renderers/Form/File.tsx +++ b/src/renderers/Form/File.tsx @@ -908,7 +908,7 @@ export default class FileControl extends React.Component { level="default" disabled={!hasPending} className={cx('FileControl-uploadBtn')} - onClick={this.handleSelect} + onClick={this.toggleUpload} > {uploading ? '暂停上传' : '开始上传'} diff --git a/src/renderers/List.tsx b/src/renderers/List.tsx index ed8f7a163..8a22907de 100644 --- a/src/renderers/List.tsx +++ b/src/renderers/List.tsx @@ -41,7 +41,8 @@ export interface ListProps extends RendererProps { items: Array | object, diff: Array | object, rowIndexes: Array | number, - unModifiedItems?: Array + unModifiedItems?: Array, + rowOrigins?: Array | object ) => void; onSaveOrder?: (moved: Array, items: Array) => void; onQuery: (values: object) => void; @@ -295,7 +296,7 @@ export default class List extends React.Component { 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() { @@ -309,7 +310,7 @@ export default class List extends React.Component { const itemIndexes = store.modifiedItems.map(item => item.index); const diff = store.modifiedItems.map(item => difference(item.data, item.pristine)); 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() { diff --git a/src/renderers/Table.tsx b/src/renderers/Table.tsx index 98cbb739c..739b40fa0 100644 --- a/src/renderers/Table.tsx +++ b/src/renderers/Table.tsx @@ -69,7 +69,8 @@ export interface TableProps extends RendererProps { items: Array | object, diff: Array | object, rowIndexes: Array | number, - unModifiedItems?: Array + unModifiedItems?: Array, + rowOrigins?: Array | object ) => void; onSaveOrder?: (moved: Array, items: Array) => void; onQuery: (values: object) => void; @@ -384,7 +385,7 @@ export default class Table extends React.Component { 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() { @@ -408,7 +409,7 @@ export default class Table extends React.Component { const rowIndexes = store.modifiedRows.map(item => item.index); const diff = store.modifiedRows.map(item => difference(item.data, item.pristine)); 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() {