From a2551c2b534dda270480f6f87333af0c1988ffd8 Mon Sep 17 00:00:00 2001 From: lizhensheng Date: Tue, 7 Nov 2023 17:17:50 +0800 Subject: [PATCH 1/2] [chore]: Optimize order and SQL review form --- src/page/Order/AuditResult/index.tsx | 2 +- src/page/Order/Create/index.tsx | 8 ++++++-- src/page/SqlAuditRecord/Create/index.tsx | 13 +++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/page/Order/AuditResult/index.tsx b/src/page/Order/AuditResult/index.tsx index f6832bba..8b673baf 100644 --- a/src/page/Order/AuditResult/index.tsx +++ b/src/page/Order/AuditResult/index.tsx @@ -159,7 +159,7 @@ const AuditResult: React.FC = (props) => { }, [pagination, filterInfo, duplicate, props.taskId, getAuditTaskSql]); return ( - + { currentTabKey: string ) => { if (values.isSameSqlOrder) { - auditOrderWithSameSql(values); + return auditOrderWithSameSql(values); } else { - auditOrderWthDifferenceSql(values, currentTabIndex, currentTabKey); + return auditOrderWthDifferenceSql( + values, + currentTabIndex, + currentTabKey + ); } }, [auditOrderWithSameSql, auditOrderWthDifferenceSql] diff --git a/src/page/SqlAuditRecord/Create/index.tsx b/src/page/SqlAuditRecord/Create/index.tsx index 521fcbe1..50744977 100644 --- a/src/page/SqlAuditRecord/Create/index.tsx +++ b/src/page/SqlAuditRecord/Create/index.tsx @@ -33,6 +33,16 @@ const SQLAuditCreate: React.FC = () => { const baseRef = useRef(null); const sqlInfoRef = useRef(null); + const scrollToAuditResult = () => { + const auditResultCardElement = document.getElementById( + 'audit-result-task-card' + ); + auditResultCardElement?.scrollIntoView({ + behavior: 'smooth', + block: 'end', + }); + }; + const auditSQL: SQLInfoFormProps['submit'] = async (values) => { const baseValues = await baseForm.validateFields(); const params: ICreateSQLAuditRecordV1Params = { @@ -56,6 +66,7 @@ const SQLAuditCreate: React.FC = () => { } else { setTask(res.data.data.task); message.success(t('sqlAudit.create.SQLInfo.successTips')); + scrollToAuditResult(); } } }); @@ -75,6 +86,7 @@ const SQLAuditCreate: React.FC = () => { if (res.data.code === ResponseCode.SUCCESS) { setTask(record.task); message.success(t('sqlAudit.create.SQLInfo.successTips')); + scrollToAuditResult(); } }); }; @@ -82,6 +94,7 @@ const SQLAuditCreate: React.FC = () => { const resetForm = () => { baseRef.current?.reset(); sqlInfoRef.current?.reset(); + setTask(undefined); }; return ( From c2cb6b9d2353aafccf646c847f0d58303aecf604 Mon Sep 17 00:00:00 2001 From: lizhensheng Date: Tue, 7 Nov 2023 17:37:23 +0800 Subject: [PATCH 2/2] [test]: Update test snapshot --- .../__test__/__snapshots__/AuditResultCollection.test.tsx.snap | 3 +++ .../AuditResult/__test__/__snapshots__/index.test.tsx.snap | 2 ++ src/page/Order/Create/__snapshots__/index.test.tsx.snap | 2 ++ src/page/Order/Create/index.test.tsx | 2 ++ src/page/Order/Detail/__snapshots__/index.test.tsx.snap | 2 ++ 5 files changed, 11 insertions(+) diff --git a/src/page/Order/AuditResult/__test__/__snapshots__/AuditResultCollection.test.tsx.snap b/src/page/Order/AuditResult/__test__/__snapshots__/AuditResultCollection.test.tsx.snap index cfbd2c0b..ef72b657 100644 --- a/src/page/Order/AuditResult/__test__/__snapshots__/AuditResultCollection.test.tsx.snap +++ b/src/page/Order/AuditResult/__test__/__snapshots__/AuditResultCollection.test.tsx.snap @@ -125,6 +125,7 @@ exports[`test AuditResultCollection should be show overview tab when showOvervie >
{ await act(async () => jest.advanceTimersByTime(3000)); + await act(async () => jest.advanceTimersByTime(3000)); + fireEvent.input(screen.getByLabelText('order.sqlInfo.sql'), { target: { value: 'select * from table3' }, }); diff --git a/src/page/Order/Detail/__snapshots__/index.test.tsx.snap b/src/page/Order/Detail/__snapshots__/index.test.tsx.snap index dc55cec0..4dab19ff 100644 --- a/src/page/Order/Detail/__snapshots__/index.test.tsx.snap +++ b/src/page/Order/Detail/__snapshots__/index.test.tsx.snap @@ -992,6 +992,7 @@ exports[`Order/Detail should get new sql audit result when update audit sql 1`] >