fix(接口测试): 断言排序&筛选
This commit is contained in:
parent
8914f05c93
commit
8efc5f5207
|
@ -130,28 +130,37 @@
|
||||||
width: 300,
|
width: 300,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const tableData = ref(props.requestResult?.responseResult.assertions);
|
|
||||||
|
const tableData = ref(props.requestResult?.responseResult.assertions || []);
|
||||||
|
const isTableFiltered = ref<boolean>(false);
|
||||||
|
|
||||||
function handleFilterChange(dataIndex: string, value: string[] | (string | number | boolean)[] | undefined) {
|
function handleFilterChange(dataIndex: string, value: string[] | (string | number | boolean)[] | undefined) {
|
||||||
if (value && value.length > 0) {
|
if (value && value.length > 0) {
|
||||||
tableData.value = props.requestResult?.responseResult.assertions.filter((item) => {
|
isTableFiltered.value = true;
|
||||||
return (value as boolean[]).includes(item.pass);
|
tableData.value =
|
||||||
});
|
props.requestResult?.responseResult.assertions.filter((item) => {
|
||||||
|
return (value as boolean[]).includes(item.pass);
|
||||||
|
}) || [];
|
||||||
} else {
|
} else {
|
||||||
tableData.value = props.requestResult?.responseResult.assertions;
|
isTableFiltered.value = false;
|
||||||
|
tableData.value = props.requestResult?.responseResult.assertions || [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSortChange(sorter: { [key: string]: string }) {
|
function handleSortChange(sorter: { [key: string]: string }) {
|
||||||
if (Object.keys(sorter).length > 0) {
|
if (Object.keys(sorter).length > 0) {
|
||||||
const dataIndex = Object.keys(sorter)[0] as keyof ResponseAssertionTableItem;
|
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) => {
|
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 {
|
} else {
|
||||||
tableData.value = props.requestResult?.responseResult.assertions;
|
tableData.value = isTableFiltered.value
|
||||||
|
? [...tableData.value]
|
||||||
|
: props.requestResult?.responseResult.assertions || [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue