fix(接口测试): 断言表格排序

This commit is contained in:
baiqi 2024-11-12 18:39:53 +08:00 committed by Craftsman
parent 3eaeb27630
commit c87ff4cb74
1 changed files with 10 additions and 5 deletions

View File

@ -143,11 +143,16 @@
} }
function handleSortChange(sorter: { [key: string]: string }) { function handleSortChange(sorter: { [key: string]: string }) {
if (Object.keys(sorter).length > 0) {
const dataIndex = Object.keys(sorter)[0] as keyof ResponseAssertionTableItem; const dataIndex = Object.keys(sorter)[0] as keyof ResponseAssertionTableItem;
tableData.value = tableData.value?.sort((a, b) => { const copyArray = [...(props.requestResult?.responseResult.assertions || [])];
tableData.value = copyArray.sort((a, b) => {
const sortResult = a[dataIndex] > b[dataIndex] ? -1 : 1; const sortResult = a[dataIndex] > b[dataIndex] ? -1 : 1;
return sorter[dataIndex] === 'asc' ? sortResult : -sortResult; return sorter[dataIndex] === 'asc' ? sortResult : -sortResult;
}); });
} else {
tableData.value = props.requestResult?.responseResult.assertions;
}
} }
</script> </script>