From 3d9ce28ae9d7e74cbe6128c726a4ab53eabeb698 Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Wed, 18 Aug 2021 01:31:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20InputTable=20index?= =?UTF-8?q?=20=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderers/Form/InputTable.tsx | 36 +++++++++++++++++++++++++------ src/store/table.ts | 1 - 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/renderers/Form/InputTable.tsx b/src/renderers/Form/InputTable.tsx index a01564259..f64513888 100644 --- a/src/renderers/Form/InputTable.tsx +++ b/src/renderers/Form/InputTable.tsx @@ -548,8 +548,15 @@ export default class FormTable extends React.Component { return null; } + const perPage = this.props.perPage; + const page = this.state.page || 1; + let offset = 0; + if (typeof perPage === 'number' && perPage) { + offset = (page - 1) * perPage; + } + return { - quickEditEnabled: this.state.editIndex === index + quickEditEnabled: this.state.editIndex === index + offset }; } @@ -670,8 +677,16 @@ export default class FormTable extends React.Component { }); btns.push({ - children: ({key, rowIndex}: {key: any; rowIndex: number}) => - this.state.editIndex === rowIndex ? ( + children: ({ + key, + rowIndex, + offset + }: { + key: any; + rowIndex: number; + offset: number; + }) => + this.state.editIndex === rowIndex + offset ? (