diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index 0d04fa8af5..3d5ddfe5fb 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -130,35 +130,41 @@ public class PerformanceTestService { } public void delete(DeleteTestPlanRequest request) { - String testId = request.getId(); - if (!request.isForceDelete()) { - testCaseService.checkIsRelateTest(testId); - } - // 删除时保存jmx内容 - List fileMetadataList = getFileMetadataByTestId(testId); - List jmxFiles = fileMetadataList.stream().filter(f -> StringUtils.equalsIgnoreCase(f.getType(), FileType.JMX.name())).collect(Collectors.toList()); - byte[] bytes = EngineFactory.mergeJmx(jmxFiles); - LoadTestReportExample loadTestReportExample = new LoadTestReportExample(); - loadTestReportExample.createCriteria().andTestIdEqualTo(testId); - List loadTestReports = loadTestReportMapper.selectByExample(loadTestReportExample); - loadTestReports.forEach(loadTestReport -> { - LoadTestReportWithBLOBs record = new LoadTestReportWithBLOBs(); - record.setId(loadTestReport.getId()); - record.setJmxContent(new String(bytes, StandardCharsets.UTF_8)); - extLoadTestReportMapper.updateJmxContentIfAbsent(record); + LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(request.getId()); + LoadTestExample example = new LoadTestExample(); + example.createCriteria().andRefIdEqualTo(loadTest.getRefId()); + List loadTests = loadTestMapper.selectByExample(example); + + loadTests.forEach(test -> { + if (!request.isForceDelete()) { + testCaseService.checkIsRelateTest(test.getId()); + } + // 删除时保存jmx内容 + List fileMetadataList = getFileMetadataByTestId(test.getId()); + List jmxFiles = fileMetadataList.stream().filter(f -> StringUtils.equalsIgnoreCase(f.getType(), FileType.JMX.name())).collect(Collectors.toList()); + byte[] bytes = EngineFactory.mergeJmx(jmxFiles); + LoadTestReportExample loadTestReportExample = new LoadTestReportExample(); + loadTestReportExample.createCriteria().andTestIdEqualTo(test.getId()); + List loadTestReports = loadTestReportMapper.selectByExample(loadTestReportExample); + loadTestReports.forEach(loadTestReport -> { + LoadTestReportWithBLOBs record = new LoadTestReportWithBLOBs(); + record.setId(loadTestReport.getId()); + record.setJmxContent(new String(bytes, StandardCharsets.UTF_8)); + extLoadTestReportMapper.updateJmxContentIfAbsent(record); + }); + //delete scheduleFunctionalCases + scheduleService.deleteByResourceId(test.getId(), ScheduleGroup.PERFORMANCE_TEST.name()); + + // delete load_test + loadTestMapper.deleteByPrimaryKey(test.getId()); + + testPlanLoadCaseService.deleteByTestId(test.getId()); + + detachFileByTestId(test.getId()); + + deleteFollows(test.getId()); }); - //delete scheduleFunctionalCases - scheduleService.deleteByResourceId(testId, ScheduleGroup.PERFORMANCE_TEST.name()); - - // delete load_test - loadTestMapper.deleteByPrimaryKey(request.getId()); - - testPlanLoadCaseService.deleteByTestId(testId); - - detachFileByTestId(request.getId()); - - deleteFollows(request.getId()); } private void deleteFollows(String testId) { diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue index 255f24c0de..b0af8b82fe 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue @@ -290,7 +290,7 @@ - + @@ -316,7 +316,7 @@ import axios from "axios"; import {getGraphByCondition} from "@/network/graph"; import MsTableSearchBar from "@/business/components/common/components/MsTableSearchBar"; import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar"; -import ApiDeleteConfirm from "@/business/components/api/definition/components/list/ApiDeleteConfirm"; +import ListItemDeleteConfirm from "@/business/components/common/components/ListItemDeleteConfirm"; const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/); const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComponent("./graph/RelationshipGraphDrawer.vue") : {}; @@ -324,7 +324,7 @@ const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComp export default { name: "MsApiScenarioList", components: { - ApiDeleteConfirm, + ListItemDeleteConfirm, MsTableAdvSearchBar, MsTableSearchBar, MsTable, diff --git a/frontend/src/business/components/api/definition/components/list/ApiList.vue b/frontend/src/business/components/api/definition/components/list/ApiList.vue index b800d3f5b7..b26f89b83d 100644 --- a/frontend/src/business/components/api/definition/components/list/ApiList.vue +++ b/frontend/src/business/components/api/definition/components/list/ApiList.vue @@ -207,7 +207,7 @@ - + @@ -227,7 +227,7 @@ import MsTableColumn from "@/business/components/common/components/table/MsTable import MsBottomContainer from "../BottomContainer"; import MsBatchEdit from "../basis/BatchEdit"; import {API_METHOD_COLOUR, API_STATUS, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData"; -import {downloadFile, getCurrentProjectID, getUUID, hasLicense} from "@/common/js/utils"; +import {downloadFile, getCurrentProjectID, hasLicense} from "@/common/js/utils"; import {API_LIST} from '@/common/js/constants'; import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover"; import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus"; @@ -247,7 +247,7 @@ import {Body} from "@/business/components/api/definition/model/ApiTestModel"; import {editApiDefinitionOrder} from "@/network/api"; import {getProtocolFilter} from "@/business/components/api/definition/api-definition"; import {getGraphByCondition} from "@/network/graph"; -import ApiDeleteConfirm from "@/business/components/api/definition/components/list/ApiDeleteConfirm"; +import ListItemDeleteConfirm from "@/business/components/common/components/ListItemDeleteConfirm"; const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/); const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComponent("./graph/RelationshipGraphDrawer.vue") : {}; @@ -256,7 +256,7 @@ const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComp export default { name: "ApiList", components: { - ApiDeleteConfirm, + ListItemDeleteConfirm, HeaderLabelOperate, CaseBatchMove, ApiStatus, diff --git a/frontend/src/business/components/api/definition/components/list/ApiDeleteConfirm.vue b/frontend/src/business/components/common/components/ListItemDeleteConfirm.vue similarity index 97% rename from frontend/src/business/components/api/definition/components/list/ApiDeleteConfirm.vue rename to frontend/src/business/components/common/components/ListItemDeleteConfirm.vue index 57073d5739..d044811200 100644 --- a/frontend/src/business/components/api/definition/components/list/ApiDeleteConfirm.vue +++ b/frontend/src/business/components/common/components/ListItemDeleteConfirm.vue @@ -23,7 +23,7 @@ import MsDialogFooter from "@/business/components/common/components/MsDialogFooter"; export default { - name: "ApiDeleteConfirm", + name: "ListItemDeleteConfirm", components: {MsDialogFooter}, data() { return { diff --git a/frontend/src/business/components/performance/test/EditPerformanceTest.vue b/frontend/src/business/components/performance/test/EditPerformanceTest.vue index 52ac6cd639..4d4573b3a8 100644 --- a/frontend/src/business/components/performance/test/EditPerformanceTest.vue +++ b/frontend/src/business/components/performance/test/EditPerformanceTest.vue @@ -22,7 +22,7 @@ - + {{ $t('operating_log.change_history') }} + + @@ -122,9 +124,11 @@ import {TEST_CONFIGS} from "../../common/components/search/search-components"; import {getLastTableSortField} from "@/common/js/tableUtils"; import MsTable from "@/business/components/common/components/table/MsTable"; import {editLoadTestCaseOrder} from "@/network/load-test"; +import ListItemDeleteConfirm from "@/business/components/common/components/ListItemDeleteConfirm"; export default { components: { + ListItemDeleteConfirm, MsTable, MsTableHeader, MsPerformanceTestStatus, @@ -252,24 +256,24 @@ export default { }); }, handleDelete(test) { - this.$alert(this.$t('load_test.delete_confirm') + test.name + "?", '', { - confirmButtonText: this.$t('commons.confirm'), - callback: (action) => { - if (action === 'confirm') { - this._handleDelete(test); - } - } - }); + // 删除提供列表删除和全部版本删除 + this.$refs.apiDeleteConfirm.open(test, this.$t('load_test.delete_confirm')); }, - _handleDelete(test) { - let data = { - id: test.id - }; - - this.result = this.$post(this.deletePath, data, () => { - this.$success(this.$t('commons.delete_success')); - this.initTableData(); - }); + _handleDelete(test, deleteCurrentVersion) { + if (deleteCurrentVersion) { + this.$get('performance/delete/' + test.id + '/' + test.refId, () => { + this.$success(this.$t('commons.delete_success')); + this.getVersionHistory(); + }); + } else { + let data = { + id: test.id + }; + this.result = this.$post(this.deletePath, data, () => { + this.$success(this.$t('commons.delete_success')); + this.initTableData(); + }); + } }, link(row) { this.$router.push({ diff --git a/frontend/src/business/components/track/case/components/TestCaseList.vue b/frontend/src/business/components/track/case/components/TestCaseList.vue index f88b70ca0b..4420fbfbbc 100644 --- a/frontend/src/business/components/track/case/components/TestCaseList.vue +++ b/frontend/src/business/components/track/case/components/TestCaseList.vue @@ -227,7 +227,7 @@ - + @@ -259,14 +259,15 @@ import { deepClone, getCustomFieldBatchEditOption, getCustomFieldValue, - getCustomTableWidth, getLastTableSortField, + getCustomTableWidth, + getLastTableSortField, getPageInfo, getTableHeaderWithCustomFields, initCondition, } from "@/common/js/tableUtils"; import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate"; import PlanStatusTableItem from "@/business/components/track/common/tableItems/plan/PlanStatusTableItem"; -import {getCurrentProjectID, getCurrentUserId, getCurrentWorkspaceId, hasLicense} from "@/common/js/utils"; +import {getCurrentProjectID, getCurrentUserId, getCurrentWorkspaceId, getUUID, hasLicense} from "@/common/js/utils"; import {getTestTemplate} from "@/network/custom-field-template"; import {getProjectMember} from "@/network/user"; import MsTable from "@/business/components/common/components/table/MsTable"; @@ -277,14 +278,15 @@ import TestCasePreview from "@/business/components/track/case/components/TestCas import {editTestCaseOrder} from "@/network/testCase"; import {getGraphByCondition} from "@/network/graph"; import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar"; -import {getUUID} from "@/common/js/utils"; -import ApiDeleteConfirm from "@/business/components/api/definition/components/list/ApiDeleteConfirm"; +import ListItemDeleteConfirm from "@/business/components/common/components/ListItemDeleteConfirm"; + const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/); const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComponent("./graph/RelationshipGraphDrawer.vue") : {}; export default { name: "TestCaseList", components: { + ListItemDeleteConfirm, MsTableAdvSearchBar, TestCasePreview, BatchMove, @@ -310,7 +312,6 @@ export default { ReviewStatus, MsTag, ApiStatus, "relationshipGraphDrawer": relationshipGraphDrawer.default, - ApiDeleteConfirm }, data() { return {