refactor: 接口定义和场景删除支持选择全部版本和选中版本

--bug=1009731 --user=刘瑞斌 【接口定义】列表里删除一个低版本的接口,新版本的同时被删掉了 https://www.tapd.cn/55049933/s/1094080
This commit is contained in:
CaptainB 2022-01-19 11:49:22 +08:00 committed by 刘瑞斌
parent 9443960c61
commit aa6dd0961b
6 changed files with 121 additions and 32 deletions

View File

@ -283,12 +283,14 @@
:dialog-title="$t('test_track.case.batch_edit_case')"/>
<batch-move @refresh="search" @moveSave="moveSave" ref="testBatchMove"/>
<ms-run-mode @handleRunBatch="handleRunBatch" :request="runRequest" ref="runMode"/>
<ms-run :debug="true" :environment="projectEnvMap" @runRefresh="runRefresh" :reportId="reportId" :saved="true" :executeType="'Saved'"
<ms-run :debug="true" :environment="projectEnvMap" @runRefresh="runRefresh" :reportId="reportId" :saved="true"
:executeType="'Saved'"
:environment-type="environmentType" :environment-group-id="envGroupId"
:run-data="debugData" ref="runTest"/>
<ms-task-center ref="taskCenter" :show-menu="false"/>
<relationship-graph-drawer :graph-data="graphData" ref="relationshipGraph"/>
<!-- 删除接口提示 -->
<api-delete-confirm ref="apiDeleteConfirm" @handleDelete="_handleDelete"/>
</div>
</template>
@ -314,6 +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";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComponent("./graph/RelationshipGraphDrawer.vue") : {};
@ -321,6 +324,7 @@ const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComp
export default {
name: "MsApiScenarioList",
components: {
ApiDeleteConfirm,
MsTableAdvSearchBar,
MsTableSearchBar,
MsTable,
@ -1126,30 +1130,42 @@ export default {
param.ids = [row.id];
this.$post('/api/automation/checkBeforeDelete/', param, response => {
let checkResult = response.data;
let alertMsg = this.$t('load_test.delete_threadgroup_confirm') + " ";
let alertMsg = this.$t('load_test.delete_threadgroup_confirm');
if (!checkResult.deleteFlag) {
alertMsg = "";
checkResult.checkMsg.forEach(item => {
alertMsg += item;
});
if (alertMsg === "") {
alertMsg = this.$t('load_test.delete_threadgroup_confirm') + " ";
alertMsg = this.$t('load_test.delete_threadgroup_confirm');
} else {
alertMsg += this.$t('api_test.is_continue') + " ";
alertMsg += this.$t('api_test.is_continue');
}
}
this.$alert(alertMsg, '', {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
callback: (action) => {
if (action === 'confirm') {
this.$post('/api/automation/removeToGcByBatch/', param, () => {
this.$success(this.$t('commons.delete_success'));
this.search();
});
}
}
});
//
//
this.$refs.apiDeleteConfirm.open(row, alertMsg);
});
}
},
_handleDelete(api, deleteCurrentVersion) {
//
if (deleteCurrentVersion) {
this.$get('/api/automation/delete/' + api.versionId + '/' + api.refId, () => {
this.$success(this.$t('commons.delete_success'));
this.$refs.apiDeleteConfirm.close();
this.search();
});
}
//
else {
let param = {};
this.buildBatchParam(param);
param.ids = [api.id];
this.$post('/api/automation/removeToGcByBatch/', param, () => {
this.$success(this.$t('commons.delete_success'));
this.$refs.apiDeleteConfirm.close();
this.search();
});
}
},

View File

@ -0,0 +1,55 @@
<template>
<el-dialog
:title="title"
:visible.sync="deleteApiVisible"
:show-close="false"
width="30%"
>
<el-radio-group v-model="deleteCurrentVersion">
<el-radio :label="true">{{ $t('commons.delete_current_version') }}</el-radio>
<el-radio :label="false">{{ $t('commons.delete_all_version') }}</el-radio>
</el-radio-group>
<template v-slot:footer>
<ms-dialog-footer
@cancel="close"
@confirm="handleDelete">
</ms-dialog-footer>
</template>
</el-dialog>
</template>
<script>
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
export default {
name: "ApiDeleteConfirm",
components: {MsDialogFooter},
data() {
return {
deleteApiVisible: false,
title: null,
deleteCurrentVersion: true,
api: {}
};
},
methods: {
open(api, title) {
this.api = api;
this.deleteCurrentVersion = true;
this.title = title + ' ' + api.name + '?';
this.deleteApiVisible = true;
},
close() {
this.deleteApiVisible = false;
},
handleDelete() {
this.$emit('handleDelete', this.api, this.deleteCurrentVersion);
},
}
};
</script>
<style scoped>
</style>

View File

@ -206,7 +206,8 @@
<case-batch-move @refresh="initTable" @moveSave="moveSave" ref="testCaseBatchMove"/>
<relationship-graph-drawer :graph-data="graphData" ref="relationshipGraph"/>
<!-- 删除接口提示 -->
<api-delete-confirm ref="apiDeleteConfirm" @handleDelete="_handleDelete"/>
</span>
</template>
@ -246,6 +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";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComponent("./graph/RelationshipGraphDrawer.vue") : {};
@ -254,6 +256,7 @@ const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComp
export default {
name: "ApiList",
components: {
ApiDeleteConfirm,
HeaderLabelOperate,
CaseBatchMove,
ApiStatus,
@ -812,20 +815,29 @@ export default {
});
return;
}
this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + api.name + " ", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
let ids = [api.id];
this.$post('/api/definition/removeToGc/', ids, () => {
this.$success(this.$t('commons.delete_success'));
// this.initTable();
this.$emit("refreshTable");
this.$refs.caseList.apiCaseClose();
});
}
}
});
//
this.$refs.apiDeleteConfirm.open(api, this.$t('api_test.definition.request.delete_confirm'));
},
_handleDelete(api, deleteCurrentVersion) {
//
if (deleteCurrentVersion) {
this.$get('/api/definition/delete/' + api.versionId + '/' + api.refId, () => {
this.$success(this.$t('commons.delete_success'));
this.$refs.apiDeleteConfirm.close();
this.$emit("refreshTable");
});
}
//
else {
let ids = [api.id];
this.$post('/api/definition/removeToGc/', ids, () => {
this.$success(this.$t('commons.delete_success'));
// this.initTable();
this.$refs.apiDeleteConfirm.close();
this.$emit("refreshTable");
this.$refs.caseList.apiCaseClose();
});
}
},
getColor(enable, method) {

View File

@ -423,6 +423,8 @@ export default {
form_config: "Form config",
form_content: "Form content",
sync_other_info: "Sync other config",
delete_current_version: 'Current version',
delete_all_version: 'All versions',
},
login: {
normal_Login: "Normal Login",

View File

@ -425,6 +425,8 @@ export default {
form_config: "表单配置",
form_content: "表单内容",
sync_other_info: "同步以下信息到新版本",
delete_current_version: '列表版本',
delete_all_version: '全部版本',
},
login: {
normal_Login: "普通登录",

View File

@ -425,6 +425,8 @@ export default {
form_config: "表單配置",
form_content: "表單內容",
sync_other_info: "同步以下信息到新版本",
delete_current_version: '列表版本',
delete_all_version: '全部版本',
},
login: {
normal_Login: "普通登錄",