feat: 接口测试报告批量删除
This commit is contained in:
parent
98194ab778
commit
4203707ef5
|
@ -62,5 +62,10 @@ public class APIReportController {
|
|||
return apiReportService.dashboardTests(SessionUtils.getCurrentWorkspaceId());
|
||||
}
|
||||
|
||||
@PostMapping("/batch/delete")
|
||||
public void deleteAPIReportBatch(@RequestBody DeleteAPIReportRequest reportRequest) {
|
||||
apiReportService.deleteAPIReportBatch(reportRequest);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,9 +3,12 @@ package io.metersphere.api.dto;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class DeleteAPIReportRequest {
|
||||
|
||||
private String id;
|
||||
private List<String> ids;
|
||||
}
|
||||
|
|
|
@ -147,4 +147,13 @@ public class APIReportService {
|
|||
}
|
||||
|
||||
|
||||
public void deleteAPIReportBatch(DeleteAPIReportRequest reportRequest) {
|
||||
ApiTestReportDetailExample apiTestReportDetailExample = new ApiTestReportDetailExample();
|
||||
apiTestReportDetailExample.createCriteria().andReportIdIn(reportRequest.getIds());
|
||||
apiTestReportDetailMapper.deleteByExample(apiTestReportDetailExample);
|
||||
|
||||
ApiTestReportExample apiTestReportExample = new ApiTestReportExample();
|
||||
apiTestReportExample.createCriteria().andIdIn(reportRequest.getIds());
|
||||
apiTestReportMapper.deleteByExample(apiTestReportExample);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,16 @@
|
|||
:show-create="false"/>
|
||||
</template>
|
||||
<el-table border :data="tableData" class="adjust-table table-content" @sort-change="sort"
|
||||
@select-all="handleSelectAll"
|
||||
@select="handleSelect"
|
||||
@filter-change="filter" @row-click="handleView">
|
||||
<el-table-column
|
||||
type="selection"/>
|
||||
<el-table-column width="40" :resizable="false" align="center">
|
||||
<template v-slot:default="scope">
|
||||
<show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectRows.size"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('commons.name')" width="200" show-overflow-tooltip prop="name">
|
||||
</el-table-column>
|
||||
<el-table-column prop="testName" :label="$t('api_report.test_name')" width="200" show-overflow-tooltip/>
|
||||
|
@ -59,12 +68,13 @@ import MsTableOperatorButton from "../../common/components/MsTableOperatorButton
|
|||
import ReportTriggerModeItem from "../../common/tableItem/ReportTriggerModeItem";
|
||||
import {REPORT_CONFIGS} from "../../common/components/search/search-components";
|
||||
import {ApiEvent, LIST_CHANGE} from "@/business/components/common/head/ListEvent";
|
||||
import ShowMoreBtn from "../../track/case/components/ShowMoreBtn";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
ReportTriggerModeItem,
|
||||
MsTableOperatorButton,
|
||||
MsApiReportStatus, MsMainContainer, MsContainer, MsTableHeader, MsTablePagination
|
||||
MsApiReportStatus, MsMainContainer, MsContainer, MsTableHeader, MsTablePagination, ShowMoreBtn
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@ -92,6 +102,12 @@ export default {
|
|||
{text: this.$t('commons.trigger_mode.schedule'), value: 'SCHEDULE'},
|
||||
{text: this.$t('commons.trigger_mode.api'), value: 'API'}
|
||||
],
|
||||
buttons: [
|
||||
{
|
||||
name: this.$t('api_report.batch_delete'), handleClick: this.handleBatchDelete
|
||||
}
|
||||
],
|
||||
selectRows: new Set(),
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -147,6 +163,60 @@ export default {
|
|||
_filter(filters, this.condition);
|
||||
this.init();
|
||||
},
|
||||
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);
|
||||
}
|
||||
|
||||
let arr = Array.from(this.selectRows);
|
||||
|
||||
// 选中1个以上的用例时显示更多操作
|
||||
if (this.selectRows.size === 1) {
|
||||
this.$set(arr[0], "showMore", false);
|
||||
} else if (this.selectRows.size === 2) {
|
||||
arr.forEach(row => {
|
||||
this.$set(row, "showMore", true);
|
||||
})
|
||||
}
|
||||
},
|
||||
handleSelectAll(selection) {
|
||||
if (selection.length > 0) {
|
||||
if (selection.length === 1) {
|
||||
this.selectRows.add(selection[0]);
|
||||
} else {
|
||||
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('api_report.delete_batch_confirm') + "?", '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
let ids = Array.from(this.selectRows).map(row => row.id);
|
||||
this.$post('/api/report/batch/delete', {ids: ids}, () => {
|
||||
this.selectRows.clear();
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
this.search();
|
||||
// 发送广播,刷新 head 上的最新列表
|
||||
ApiEvent.$emit(LIST_CHANGE);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
|
|
@ -520,6 +520,7 @@ export default {
|
|||
request_cookie: "Cookie",
|
||||
response: "Response",
|
||||
delete_confirm: 'Confirm delete : ',
|
||||
delete_batch_confirm: 'Confirm batch delete report',
|
||||
scenario_name: "Scenario name",
|
||||
response_time: "Response time(ms)",
|
||||
latency: "Latency",
|
||||
|
@ -542,6 +543,7 @@ export default {
|
|||
sub_result: "Sub Result",
|
||||
detail: "Report detail",
|
||||
delete: "Delete report",
|
||||
batch_delete: "Delete reports in bulk",
|
||||
running: "The test is running",
|
||||
not_exist: "Test report does not exist",
|
||||
},
|
||||
|
|
|
@ -522,6 +522,7 @@ export default {
|
|||
request_cookie: "Cookie",
|
||||
response: "响应",
|
||||
delete_confirm: '确认删除报告: ',
|
||||
delete_batch_confirm: '确认批量删除报告',
|
||||
scenario_name: "场景名称",
|
||||
response_time: "响应时间(ms)",
|
||||
latency: "网络延迟",
|
||||
|
@ -544,6 +545,7 @@ export default {
|
|||
sub_result: "子请求",
|
||||
detail: "报告详情",
|
||||
delete: "删除报告",
|
||||
batch_delete: "批量删除报告",
|
||||
running: "测试执行中",
|
||||
not_exist: "测试报告不存在",
|
||||
},
|
||||
|
|
|
@ -520,6 +520,7 @@ export default {
|
|||
request_cookie: "Cookie",
|
||||
response: "響應",
|
||||
delete_confirm: '確認删除報告:',
|
||||
delete_batch_confirm: '確認批量刪除報告',
|
||||
scenario_name: "場景名稱",
|
||||
response_time: "回應時間(ms)",
|
||||
latency: "網路延遲",
|
||||
|
@ -542,6 +543,7 @@ export default {
|
|||
sub_result: "子請求",
|
||||
detail: "報告詳情",
|
||||
delete: "刪除報告",
|
||||
batch_delete: "批量刪除報告",
|
||||
running: "測試執行中",
|
||||
not_exist: "測試報告不存在",
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue