From 8efc5f52074e03a82f72448a2739ada9c5127b85 Mon Sep 17 00:00:00 2001 From: baiqi Date: Thu, 14 Nov 2024 17:28:18 +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=E6=8E=92=E5=BA=8F&=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/result/assertionTable.vue | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 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 b5f7fe75ce..d432c54c25 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 @@ -130,28 +130,37 @@ width: 300, }, ]; - const tableData = ref(props.requestResult?.responseResult.assertions); + + const tableData = ref(props.requestResult?.responseResult.assertions || []); + const isTableFiltered = ref(false); function handleFilterChange(dataIndex: string, value: string[] | (string | number | boolean)[] | undefined) { if (value && value.length > 0) { - tableData.value = props.requestResult?.responseResult.assertions.filter((item) => { - return (value as boolean[]).includes(item.pass); - }); + isTableFiltered.value = true; + tableData.value = + props.requestResult?.responseResult.assertions.filter((item) => { + return (value as boolean[]).includes(item.pass); + }) || []; } else { - tableData.value = props.requestResult?.responseResult.assertions; + isTableFiltered.value = false; + tableData.value = props.requestResult?.responseResult.assertions || []; } } function handleSortChange(sorter: { [key: string]: string }) { if (Object.keys(sorter).length > 0) { const dataIndex = Object.keys(sorter)[0] as keyof ResponseAssertionTableItem; - const copyArray = [...(props.requestResult?.responseResult.assertions || [])]; + const copyArray = isTableFiltered.value + ? [...tableData.value] + : [...(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; + tableData.value = isTableFiltered.value + ? [...tableData.value] + : props.requestResult?.responseResult.assertions || []; } }