From d89d432f70f406279f95cded713689c58dfea33b Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Fri, 22 Mar 2024 18:56:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=A0=E9=99=A4=E7=8E=AF=E5=A2=83=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E4=BA=8C=E6=AC=A1=E6=8F=90=E7=A4=BA=E7=9A=84=E7=BC=BA?= =?UTF-8?q?=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1037587 --user=王孝刚 【项目管理】环境管理-删除项目环境没有弹框提醒 https://www.tapd.cn/55049933/s/1479438 --- .../environmental/index.vue | 95 +++++++++++++------ .../environmental/locale/en-US.ts | 6 ++ .../environmental/locale/zh-CN.ts | 4 + 3 files changed, 76 insertions(+), 29 deletions(-) diff --git a/frontend/src/views/project-management/environmental/index.vue b/frontend/src/views/project-management/environmental/index.vue index 4f2439a6fe..2bf1d10588 100644 --- a/frontend/src/views/project-management/environmental/index.vue +++ b/frontend/src/views/project-management/environmental/index.vue @@ -263,7 +263,9 @@ groupListEnv, listEnv, } from '@/api/modules/project-management/envManagement'; + import { deleteModule } from '@/api/modules/project-management/fileManagement'; import { useI18n } from '@/hooks/useI18n'; + import useModal from '@/hooks/useModal'; import { useAppStore } from '@/store'; import useProjectEnvStore, { ALL_PARAM, @@ -509,43 +511,78 @@ function searchData() { initData(keyword.value); } - + const { openModal } = useModal(); // 处理删除环境 const handleDeleteEnv = async (id: string) => { - try { - if (store.currentId === NEW_ENV_PARAM) { - // 删除id为newEnvParam的环境 - envList.value = envList.value.filter((item) => item.id !== id); - store.setCurrentId(envList.value[0].id); - } - if (id === NEW_ENV_PARAM) { - envList.value = envList.value.filter((item) => item.id !== id); - store.setCurrentId(envList.value[0].id); - return; - } - await deleteEnv(id); - Message.success(t('common.deleteSuccess')); - initData(keyword.value, true); - } catch (error) { - // eslint-disable-next-line no-console - console.log(error); + if (store.currentId === NEW_ENV_PARAM) { + // 删除id为newEnvParam的环境 + envList.value = envList.value.filter((item) => item.id !== id); + store.setCurrentId(envList.value[0].id); } + if (id === NEW_ENV_PARAM) { + envList.value = envList.value.filter((item) => item.id !== id); + store.setCurrentId(envList.value[0].id); + return; + } + const matchingItem = envList.value.find((item) => item.id === id); + const itemName = matchingItem ? matchingItem.name : null; + openModal({ + type: 'error', + title: t('project.environmental.env.delete', { name: itemName }), + content: t('project.environmental.env.deleteTip'), + okText: t('project.fileManagement.deleteConfirm'), + okButtonProps: { + status: 'danger', + }, + maskClosable: false, + onBeforeOk: async () => { + try { + await deleteEnv(id); + Message.success(t('common.deleteSuccess')); + initData(keyword.value, true); + } catch (error) { + // eslint-disable-next-line no-console + console.log(error); + } + }, + hideCancel: false, + }); }; // 处理删除环境组 const handleDeleteEnvGroup = async (id: string) => { - try { - if (store.currentGroupId === NEW_ENV_GROUP) { - // 删除id为newEnvParam的环境 - evnGroupList.value = evnGroupList.value.filter((item) => item.id !== id); - } else { - await deleteEnvGroup(id); - } - await initGroupList(); - } catch (error) { - // eslint-disable-next-line no-console - console.log(error); + if (store.currentId === NEW_ENV_GROUP) { + evnGroupList.value = evnGroupList.value.filter((item) => item.id !== id); + store.setCurrentId(envList.value[0].id); } + if (id === NEW_ENV_GROUP) { + evnGroupList.value = evnGroupList.value.filter((item) => item.id !== id); + store.setCurrentId(envList.value[0].id); + return; + } + const matchingItem = envList.value.find((item) => item.id === id); + const itemName = matchingItem ? matchingItem.name : null; + openModal({ + type: 'error', + title: t('project.environmental.env.deleteGroup', { name: itemName }), + content: t('project.environmental.env.deleteGroupTip'), + okText: t('project.fileManagement.deleteConfirm'), + okButtonProps: { + status: 'danger', + }, + maskClosable: false, + onBeforeOk: async () => { + try { + await deleteEnvGroup(id); + Message.success(t('common.deleteSuccess')); + await initGroupList(); + } catch (error) { + // eslint-disable-next-line no-console + console.log(error); + } + }, + hideCancel: false, + }); }; function changeShowType(value: string | number | boolean) { diff --git a/frontend/src/views/project-management/environmental/locale/en-US.ts b/frontend/src/views/project-management/environmental/locale/en-US.ts index 353718c732..36eb5e625f 100644 --- a/frontend/src/views/project-management/environmental/locale/en-US.ts +++ b/frontend/src/views/project-management/environmental/locale/en-US.ts @@ -117,4 +117,10 @@ export default { 'project.environmental.env.systemTitle': 'environment', 'project.environmental.env.selectedTitle': 'Selected environment', 'project.environmental.env.constantBatchAddTip': 'Only supports batch adding const type', + 'project.environmental.env.delete': 'Whether to delete the environment `{name}`?', + 'project.environmental.env.deleteTip': + 'Deleting it will cause scenes that reference this environment to fail to execute properly!', + 'project.environmental.env.deleteGroup': 'Whether to delete the environment group `{name}`?', + 'project.environmental.env.deleteGroupTip': + 'Deleting it will cause scenes that reference this environment group to fail to execute properly!', }; diff --git a/frontend/src/views/project-management/environmental/locale/zh-CN.ts b/frontend/src/views/project-management/environmental/locale/zh-CN.ts index 903850fd86..dfd09f925e 100644 --- a/frontend/src/views/project-management/environmental/locale/zh-CN.ts +++ b/frontend/src/views/project-management/environmental/locale/zh-CN.ts @@ -123,4 +123,8 @@ export default { 'project.environmental.env.systemTitle': '环境', 'project.environmental.env.selectedTitle': '已选环境', 'project.environmental.env.constantBatchAddTip': '只支持常量类型批量添加', + 'project.environmental.env.delete': '是否删除环境 `{name}`?', + 'project.environmental.env.deleteTip': '删除后会导致引用此环境的场景无法正常执行', + 'project.environmental.env.deleteGroup': '是否删除环境组 `{name}`?', + 'project.environmental.env.deleteGroupTip': '删除后会导致引用此环境组的场景无法正常执行', };