From aa6dd0961bf7eab107b657996379ec54466ec460 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Wed, 19 Jan 2022 11:49:22 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=8E=A5=E5=8F=A3=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=92=8C=E5=9C=BA=E6=99=AF=E5=88=A0=E9=99=A4=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E9=80=89=E6=8B=A9=E5=85=A8=E9=83=A8=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=92=8C=E9=80=89=E4=B8=AD=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1009731 --user=刘瑞斌 【接口定义】列表里删除一个低版本的接口,新版本的同时被删掉了 https://www.tapd.cn/55049933/s/1094080 --- .../automation/scenario/ApiScenarioList.vue | 50 +++++++++++------ .../components/list/ApiDeleteConfirm.vue | 55 +++++++++++++++++++ .../definition/components/list/ApiList.vue | 42 +++++++++----- frontend/src/i18n/en-US.js | 2 + frontend/src/i18n/zh-CN.js | 2 + frontend/src/i18n/zh-TW.js | 2 + 6 files changed, 121 insertions(+), 32 deletions(-) create mode 100644 frontend/src/business/components/api/definition/components/list/ApiDeleteConfirm.vue diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue index 5a0f44d6f4..255f24c0de 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue @@ -283,12 +283,14 @@ :dialog-title="$t('test_track.case.batch_edit_case')"/> - - + + @@ -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(); }); } }, diff --git a/frontend/src/business/components/api/definition/components/list/ApiDeleteConfirm.vue b/frontend/src/business/components/api/definition/components/list/ApiDeleteConfirm.vue new file mode 100644 index 0000000000..57073d5739 --- /dev/null +++ b/frontend/src/business/components/api/definition/components/list/ApiDeleteConfirm.vue @@ -0,0 +1,55 @@ + + + + + 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 4e98645846..ba648d0af5 100644 --- a/frontend/src/business/components/api/definition/components/list/ApiList.vue +++ b/frontend/src/business/components/api/definition/components/list/ApiList.vue @@ -206,7 +206,8 @@ - + + @@ -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) { diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index b4474bef6f..4dd9145a6b 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -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", diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index 3e1e9809aa..411d11cb91 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -425,6 +425,8 @@ export default { form_config: "表单配置", form_content: "表单内容", sync_other_info: "同步以下信息到新版本", + delete_current_version: '列表版本', + delete_all_version: '全部版本', }, login: { normal_Login: "普通登录", diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index 1a00f6de52..6f397d55d4 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -425,6 +425,8 @@ export default { form_config: "表單配置", form_content: "表單內容", sync_other_info: "同步以下信息到新版本", + delete_current_version: '列表版本', + delete_all_version: '全部版本', }, login: { normal_Login: "普通登錄",