From c87ff4cb745329798f6172bb9566c91270db34f0 Mon Sep 17 00:00:00 2001 From: baiqi Date: Tue, 12 Nov 2024 18:39:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E6=96=AD=E8=A8=80=E8=A1=A8=E6=A0=BC=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/result/assertionTable.vue | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/frontend/src/views/api-test/components/requestComposition/response/result/assertionTable.vue b/frontend/src/views/api-test/components/requestComposition/response/result/assertionTable.vue index 8da335e635..b5f7fe75ce 100644 --- a/frontend/src/views/api-test/components/requestComposition/response/result/assertionTable.vue +++ b/frontend/src/views/api-test/components/requestComposition/response/result/assertionTable.vue @@ -143,11 +143,16 @@ } function handleSortChange(sorter: { [key: string]: string }) { - const dataIndex = Object.keys(sorter)[0] as keyof ResponseAssertionTableItem; - tableData.value = tableData.value?.sort((a, b) => { - const sortResult = a[dataIndex] > b[dataIndex] ? -1 : 1; - return sorter[dataIndex] === 'asc' ? sortResult : -sortResult; - }); + if (Object.keys(sorter).length > 0) { + const dataIndex = Object.keys(sorter)[0] as keyof ResponseAssertionTableItem; + const copyArray = [...(props.requestResult?.responseResult.assertions || [])]; + tableData.value = copyArray.sort((a, b) => { + const sortResult = a[dataIndex] > b[dataIndex] ? -1 : 1; + return sorter[dataIndex] === 'asc' ? sortResult : -sortResult; + }); + } else { + tableData.value = props.requestResult?.responseResult.assertions; + } }