fix(项目管理): 修复删除环境没有二次提示的缺陷
--bug=1037587 --user=王孝刚 【项目管理】环境管理-删除项目环境没有弹框提醒 https://www.tapd.cn/55049933/s/1479438
This commit is contained in:
parent
cef0f5895f
commit
d89d432f70
|
@ -263,7 +263,9 @@
|
||||||
groupListEnv,
|
groupListEnv,
|
||||||
listEnv,
|
listEnv,
|
||||||
} from '@/api/modules/project-management/envManagement';
|
} from '@/api/modules/project-management/envManagement';
|
||||||
|
import { deleteModule } from '@/api/modules/project-management/fileManagement';
|
||||||
import { useI18n } from '@/hooks/useI18n';
|
import { useI18n } from '@/hooks/useI18n';
|
||||||
|
import useModal from '@/hooks/useModal';
|
||||||
import { useAppStore } from '@/store';
|
import { useAppStore } from '@/store';
|
||||||
import useProjectEnvStore, {
|
import useProjectEnvStore, {
|
||||||
ALL_PARAM,
|
ALL_PARAM,
|
||||||
|
@ -509,10 +511,9 @@
|
||||||
function searchData() {
|
function searchData() {
|
||||||
initData(keyword.value);
|
initData(keyword.value);
|
||||||
}
|
}
|
||||||
|
const { openModal } = useModal();
|
||||||
// 处理删除环境
|
// 处理删除环境
|
||||||
const handleDeleteEnv = async (id: string) => {
|
const handleDeleteEnv = async (id: string) => {
|
||||||
try {
|
|
||||||
if (store.currentId === NEW_ENV_PARAM) {
|
if (store.currentId === NEW_ENV_PARAM) {
|
||||||
// 删除id为newEnvParam的环境
|
// 删除id为newEnvParam的环境
|
||||||
envList.value = envList.value.filter((item) => item.id !== id);
|
envList.value = envList.value.filter((item) => item.id !== id);
|
||||||
|
@ -523,6 +524,19 @@
|
||||||
store.setCurrentId(envList.value[0].id);
|
store.setCurrentId(envList.value[0].id);
|
||||||
return;
|
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);
|
await deleteEnv(id);
|
||||||
Message.success(t('common.deleteSuccess'));
|
Message.success(t('common.deleteSuccess'));
|
||||||
initData(keyword.value, true);
|
initData(keyword.value, true);
|
||||||
|
@ -530,22 +544,45 @@
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
hideCancel: false,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理删除环境组
|
// 处理删除环境组
|
||||||
const handleDeleteEnvGroup = async (id: string) => {
|
const handleDeleteEnvGroup = async (id: string) => {
|
||||||
try {
|
if (store.currentId === NEW_ENV_GROUP) {
|
||||||
if (store.currentGroupId === NEW_ENV_GROUP) {
|
|
||||||
// 删除id为newEnvParam的环境
|
|
||||||
evnGroupList.value = evnGroupList.value.filter((item) => item.id !== id);
|
evnGroupList.value = evnGroupList.value.filter((item) => item.id !== id);
|
||||||
} else {
|
store.setCurrentId(envList.value[0].id);
|
||||||
await deleteEnvGroup(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();
|
await initGroupList();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
hideCancel: false,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function changeShowType(value: string | number | boolean) {
|
function changeShowType(value: string | number | boolean) {
|
||||||
|
|
|
@ -117,4 +117,10 @@ export default {
|
||||||
'project.environmental.env.systemTitle': 'environment',
|
'project.environmental.env.systemTitle': 'environment',
|
||||||
'project.environmental.env.selectedTitle': 'Selected environment',
|
'project.environmental.env.selectedTitle': 'Selected environment',
|
||||||
'project.environmental.env.constantBatchAddTip': 'Only supports batch adding const type',
|
'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!',
|
||||||
};
|
};
|
||||||
|
|
|
@ -123,4 +123,8 @@ export default {
|
||||||
'project.environmental.env.systemTitle': '环境',
|
'project.environmental.env.systemTitle': '环境',
|
||||||
'project.environmental.env.selectedTitle': '已选环境',
|
'project.environmental.env.selectedTitle': '已选环境',
|
||||||
'project.environmental.env.constantBatchAddTip': '只支持常量类型批量添加',
|
'project.environmental.env.constantBatchAddTip': '只支持常量类型批量添加',
|
||||||
|
'project.environmental.env.delete': '是否删除环境 `{name}`?',
|
||||||
|
'project.environmental.env.deleteTip': '删除后会导致引用此环境的场景无法正常执行',
|
||||||
|
'project.environmental.env.deleteGroup': '是否删除环境组 `{name}`?',
|
||||||
|
'project.environmental.env.deleteGroupTip': '删除后会导致引用此环境组的场景无法正常执行',
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue