diff --git a/backend/src/main/java/io/metersphere/performance/controller/request/DeleteReportRequest.java b/backend/src/main/java/io/metersphere/performance/controller/request/DeleteReportRequest.java index 5e1b2b2132..27581363f9 100644 --- a/backend/src/main/java/io/metersphere/performance/controller/request/DeleteReportRequest.java +++ b/backend/src/main/java/io/metersphere/performance/controller/request/DeleteReportRequest.java @@ -1,13 +1,13 @@ package io.metersphere.performance.controller.request; -import lombok.Getter; -import lombok.Setter; +import io.metersphere.track.request.testplancase.TestPlanFuncCaseConditions; +import lombok.Data; import java.util.List; -@Getter -@Setter +@Data public class DeleteReportRequest { - private List ids; + private String projectId; + private TestPlanFuncCaseConditions condition; } diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java index c68cb28bcd..a48b8915ca 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java @@ -347,11 +347,20 @@ public class PerformanceReportService { loadTestReportMapper.updateByPrimaryKeySelective(report); } - public void deleteReportBatch(DeleteReportRequest reportRequest) { - List ids = reportRequest.getIds(); + public void deleteReportBatch(DeleteReportRequest request) { + ServiceUtils.getSelectAllIds(request, request.getCondition(), + (query) -> getLoadTestReportIds(request.getProjectId())); + + List ids = request.getIds(); ids.forEach(this::deleteReport); } + private List getLoadTestReportIds(String projectId) { + ReportRequest request = new ReportRequest(); + request.setProjectId(projectId); + return this.getReportList(request).stream().map(LoadTestReport::getId).collect(Collectors.toList()); + } + public List getErrorChartData(String id) { if (isReportError(id)) { return Collections.emptyList(); diff --git a/frontend/src/business/components/performance/report/PerformanceTestReportList.vue b/frontend/src/business/components/performance/report/PerformanceTestReportList.vue index 85894c3885..036805bd64 100644 --- a/frontend/src/business/components/performance/report/PerformanceTestReportList.vue +++ b/frontend/src/business/components/performance/report/PerformanceTestReportList.vue @@ -6,22 +6,24 @@ - - - - - - + - - - - + @@ -150,15 +137,17 @@ import ReportTriggerModeItem from "../../common/tableItem/ReportTriggerModeItem" import {REPORT_CONFIGS} from "../../common/components/search/search-components"; import MsTableHeader from "../../common/components/MsTableHeader"; import ShowMoreBtn from "../../track/case/components/ShowMoreBtn"; -import {_filter, _sort, getLastTableSortField, saveLastTableSortField} from "@/common/js/tableUtils"; +import {_filter, _sort, buildBatchParam, getLastTableSortField, saveLastTableSortField} from "@/common/js/tableUtils"; import MsDialogFooter from "@/business/components/common/components/MsDialogFooter"; import SameTestReports from "@/business/components/performance/report/components/SameTestReports"; import MsRenameReportDialog from "@/business/components/common/components/report/MsRenameReportDialog"; import MsTableColumn from "@/business/components/common/components/table/MsTableColumn"; +import MsTable from "@/business/components/common/components/table/MsTable"; export default { name: "PerformanceTestReportList", components: { + MsTable, SameTestReports, MsDialogFooter, MsTableHeader, @@ -188,7 +177,6 @@ export default { }, projectId: null, tableData: [], - multipleSelection: [], currentPage: 1, pageSize: 10, total: 0, @@ -216,6 +204,28 @@ export default { name: this.$t('report.batch_delete'), handleClick: this.handleBatchDelete } ], + operators: [ + { + tip: this.$t('api_report.detail'), + icon: "el-icon-s-data", + exec: this.handleView, + type: 'primary', + permissions: ['PROJECT_PERFORMANCE_REPORT:READ'] + }, + { + tip: this.$t('load_test.report.diff'), + icon: "el-icon-s-operation", + type: "warning", + exec: this.handleDiff, + permissions: ['PROJECT_PERFORMANCE_REPORT:READ+COMPARE'] + }, { + tip: this.$t('commons.delete'), + icon: "el-icon-delete", + type: "danger", + exec: this.handleDelete, + permissions: ['PROJECT_PERFORMANCE_REPORT:READ+DELETE'] + } + ], selectRows: new Set(), versionFilters: [], versionOptions: [], @@ -303,9 +313,6 @@ export default { buildPagePath(path) { return path + "/" + this.currentPage + "/" + this.pageSize; }, - handleSelectionChange(val) { - this.multipleSelection = val; - }, handleRename(report) { this.$prompt(this.$t('commons.input_name'), '', { confirmButtonText: this.$t('commons.confirm'), @@ -366,45 +373,19 @@ export default { _filter(filters, this.condition); this.initTableData(); }, - handleSelect(selection, row) { - if (this.selectRows.has(row)) { - this.$set(row, "showMore", false); - this.selectRows.delete(row); - } else { - this.$set(row, "showMore", true); - this.selectRows.add(row); - } - }, saveSortField(key, orders) { saveLastTableSortField(key, JSON.stringify(orders)); }, - handleSelectAll(selection) { - if (selection.length > 0) { - this.tableData.forEach(item => { - this.$set(item, "showMore", true); - this.selectRows.add(item); - }); - } else { - this.selectRows.clear(); - this.tableData.forEach(row => { - this.$set(row, "showMore", false); - }); - } - }, handleBatchDelete() { this.$alert(this.$t('report.delete_batch_confirm') + "?", '', { confirmButtonText: this.$t('commons.confirm'), callback: (action) => { if (action === 'confirm') { - let ids = []; - this.selectRows.forEach(row => { - ids.push(row.id); - }); - this.result = this.$post("/performance/report/batch/delete", {ids: ids}, () => { + let param = buildBatchParam(this, this.$refs.table.selectIds); + this.result = this.$post("/performance/report/batch/delete", param, () => { + this.$success(this.$t('commons.delete_success')); this.initTableData(); }); - - this.$success(this.$t('commons.delete_success')); } }, });