From 5ee33e21826dd1748cf9f745e8d82df5a8ee82a6 Mon Sep 17 00:00:00 2001 From: xinbinyan <404928130@qq.com> Date: Mon, 20 Nov 2023 19:05:10 +0800 Subject: [PATCH] update code --- src/page/SqlAuditRecord/Create/index.tsx | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/page/SqlAuditRecord/Create/index.tsx b/src/page/SqlAuditRecord/Create/index.tsx index e0d9bb5f..c6ed60f2 100644 --- a/src/page/SqlAuditRecord/Create/index.tsx +++ b/src/page/SqlAuditRecord/Create/index.tsx @@ -16,7 +16,7 @@ import { useCurrentProjectName } from '../../ProjectManage/ProjectDetail'; import AuditResult from '../../Order/AuditResult'; import sql_audit_record from '../../../api/sql_audit_record'; import { ICreateSQLAuditRecordV1Params } from '../../../api/sql_audit_record/index.d'; -import { useRef, useState, useEffect } from "react"; +import { useRef, useState } from "react"; import { IAuditTaskResV1, ISQLAuditRecordResData } from '../../../api/common'; import { ResponseCode } from '../../../data/common'; import EmptyBox from '../../../components/EmptyBox'; @@ -30,7 +30,6 @@ const SQLAuditCreate: React.FC = () => { const [sqlInfoForm] = useForm(); const { projectName } = useCurrentProjectName(); const [task, setTask] = useState(); - const [finishGetResult, setFinishGetResult] = useState(false); const baseRef = useRef(null); const sqlInfoRef = useRef(null); @@ -46,7 +45,6 @@ const SQLAuditCreate: React.FC = () => { const auditSQL: SQLInfoFormProps['submit'] = async (values) => { const baseValues = await baseForm.validateFields(); - setFinishGetResult(false); const params: ICreateSQLAuditRecordV1Params = { project_name: projectName, sqls: values.sql, @@ -66,6 +64,7 @@ const SQLAuditCreate: React.FC = () => { if ((baseValues.tags?.length ?? 0) > 0) { return updateTags(res.data.data, baseValues); } else { + message.success(t("sqlAudit.create.SQLInfo.successTips")); setTask(res.data.data.task); } } @@ -84,6 +83,7 @@ const SQLAuditCreate: React.FC = () => { }) .then((res) => { if (res.data.code === ResponseCode.SUCCESS) { + message.success(t("sqlAudit.create.SQLInfo.successTips")); setTask(record.task); } }); @@ -93,18 +93,8 @@ const SQLAuditCreate: React.FC = () => { baseRef.current?.reset(); sqlInfoRef.current?.reset(); setTask(undefined); - setFinishGetResult(false); }; - useEffect(() => { - if ((typeof task?.task_id === "number" && finishGetResult)) { - message.success(t("sqlAudit.create.SQLInfo.successTips")); - setTimeout(() => { - scrollToAuditResult(); - }, 500); - } - }, [task, t, finishGetResult]); - return ( <> @@ -141,7 +131,7 @@ const SQLAuditCreate: React.FC = () => { auditScore={task?.score} passRate={task?.pass_rate} getResultCallBack={() => { - setFinishGetResult(true); + scrollToAuditResult(); }} />