feat(性能测试): 编辑性能测试时选择文件保留前一页的选项

--bug=1019307 --user=郭雨琦
https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001019307
This commit is contained in:
guoyuqi 2023-01-04 18:32:02 +08:00 committed by f2c-ci-robot[bot]
parent 48e52d6d3a
commit aad051a956
3 changed files with 45 additions and 8 deletions

View File

@ -374,10 +374,20 @@
#{id} #{id}
</foreach> </foreach>
AND project_id = #{projectId,jdbcType=VARCHAR} AND project_id = #{projectId,jdbcType=VARCHAR}
<if test="request.name!=null"> <if test="request.name != null">
AND file_metadata.name LIKE CONCAT('%', #{request.name}, '%') AND file_metadata.name LIKE CONCAT('%', #{request.name}, '%')
</if> </if>
order by update_time DESC <if test="request.ids != null and request.ids.size() > 0">
AND file_metadata.id NOT IN (
SELECT file_id
FROM load_test_file t
WHERE t.test_id IN
<foreach collection="request.ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
)
</if>
ORDER BY update_time DESC
</select> </select>
<select id="selectProjectIds" resultType="java.lang.String"> <select id="selectProjectIds" resultType="java.lang.String">

View File

@ -102,11 +102,19 @@
import MsDialogFooter from "metersphere-frontend/src/components/MsDialogFooter"; import MsDialogFooter from "metersphere-frontend/src/components/MsDialogFooter";
import MsTablePagination from "metersphere-frontend/src/components/pagination/TablePagination"; import MsTablePagination from "metersphere-frontend/src/components/pagination/TablePagination";
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token"; import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
import {findThreadGroup} from "../../../business/test/model/ThreadGroup"; import {findThreadGroup} from "@/business/test/model/ThreadGroup";
import MsTableButton from "metersphere-frontend/src/components/MsTableButton"; import MsTableButton from "metersphere-frontend/src/components/MsTableButton";
import MsTableHeader from "metersphere-frontend/src/components/MsTableHeader"; import MsTableHeader from "metersphere-frontend/src/components/MsTableHeader";
import MsTableOperatorButton from "metersphere-frontend/src/components/MsTableOperatorButton"; import MsTableOperatorButton from "metersphere-frontend/src/components/MsTableOperatorButton";
import {checkFileIsRelated, deleteFile, getJmxContents, getProjectFileByName, getProjectFiles, updateFile, uploadFiles} from "../../../api/performance"; import {
checkFileIsRelated,
deleteFile,
getJmxContents,
getProjectFileByName,
getProjectFiles,
updateFile,
uploadFiles
} from "@/api/performance";
export default { export default {
name: "ExistFiles", name: "ExistFiles",
@ -117,6 +125,7 @@ export default {
uploadList: Array, uploadList: Array,
scenarios: Array, scenarios: Array,
isReadOnly: Boolean, isReadOnly: Boolean,
testId: String
}, },
inject: [ inject: [
'reload' 'reload'
@ -131,6 +140,7 @@ export default {
loadType: 'jmx', loadType: 'jmx',
existFiles: [], existFiles: [],
selectIds: new Set, selectIds: new Set,
selectFiles: [],
condition: {}, condition: {},
projectId: getCurrentProjectID() projectId: getCurrentProjectID()
}; };
@ -144,16 +154,23 @@ export default {
close() { close() {
this.loadFileVisible = false; this.loadFileVisible = false;
this.selectIds.clear(); this.selectIds.clear();
this.selectFiles = [];
}, },
handleSelectAll(selection) { handleSelectAll(selection) {
if (selection.length > 0) { if (selection.length > 0) {
this.existFiles.forEach(item => { this.existFiles.forEach(item => {
this.selectIds.add(item.id); this.selectIds.add(item.id);
this.selectFiles.push(item);
}); });
} else { } else {
this.existFiles.forEach(item => { this.existFiles.forEach(item => {
if (this.selectIds.has(item.id)) { if (this.selectIds.has(item.id)) {
this.selectIds.delete(item.id); this.selectIds.delete(item.id);
for (let i = 0; i < this.selectFiles.length - 1; i++) {
if (this.selectFiles[i].id === item.id) {
this.selectFiles.splice(i, 1);
}
}
} }
}); });
} }
@ -161,11 +178,21 @@ export default {
handleSelectionChange(selection, row) { handleSelectionChange(selection, row) {
if (this.selectIds.has(row.id)) { if (this.selectIds.has(row.id)) {
this.selectIds.delete(row.id); this.selectIds.delete(row.id);
for (let i = 0; i < this.selectFiles.length - 1; i++) {
if (this.selectFiles[i].id === row.id) {
this.selectFiles.splice(i, 1);
}
}
} else { } else {
this.selectIds.add(row.id); this.selectIds.add(row.id);
this.selectFiles.push(row);
} }
}, },
getProjectFiles() { getProjectFiles() {
if (this.testId) {
this.condition.ids = [];
this.condition.ids.push(this.testId);
}
this.loading = getProjectFiles(this.loadType, this.projectId, this.currentPage, this.pageSize, this.condition) this.loading = getProjectFiles(this.loadType, this.projectId, this.currentPage, this.pageSize, this.condition)
.then(res => { .then(res => {
let data = res.data; let data = res.data;
@ -176,6 +203,7 @@ export default {
handleImport(file) { handleImport(file) {
if (file) { // if (file) { //
this.selectIds.add(file.id); this.selectIds.add(file.id);
this.selectFiles.push(file)
this.getJmxContents(); this.getJmxContents();
return; return;
} }
@ -183,11 +211,9 @@ export default {
this.loadFileVisible = false; this.loadFileVisible = false;
return; return;
} }
let rows = this.existFiles.filter(f => this.selectIds.has(f.id));
let jmxIds = []; let jmxIds = [];
for (let i = 0; i < rows.length; i++) { for (let i = 0; i < this.selectFiles.length; i++) {
let row = rows[i]; let row = this.selectFiles[i];
if (this.tableData.filter(f => f.name === row.name).length > 0) { if (this.tableData.filter(f => f.name === row.name).length > 0) {
setTimeout(() => { setTimeout(() => {
this.$warning(this.$t('load_test.delete_file') + 'name: ' + row.name); this.$warning(this.$t('load_test.delete_file') + 'name: ' + row.name);

View File

@ -110,6 +110,7 @@
<exist-files ref="existFiles" <exist-files ref="existFiles"
@fileChange="fileChange" @fileChange="fileChange"
:test-id="test.id"
:file-list="fileList" :file-list="fileList"
:table-data="tableData" :table-data="tableData"
:upload-list="uploadList" :upload-list="uploadList"