From 6934478aec3351bb29e6628b3dca4b868aeca2f4 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Mon, 8 Apr 2024 16:20:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E5=89=8D=E5=90=8E=E7=BD=AE=E6=9D=A1=E4=BB=B6=E5=8F=8A=E6=96=AD?= =?UTF-8?q?=E8=A8=80=E6=B7=BB=E5=8A=A0=E6=B2=A1=E6=9C=89=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E4=BA=8C=E6=AC=A1=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1037910 --user=宋昌昌 【接口测试】定义-调试-断言-脚本重命名输入一个超长的名称 https://www.tapd.cn/55049933/s/1490281 --bug=1037488 --user=宋昌昌 【接口测试】定义-调试-后置-脚本操作-删除存在内容的脚本没有二次确认 https://www.tapd.cn/55049933/s/1490326 --- .../business/ms-assertion/comp/ScriptTab.vue | 12 ++++- .../business/ms-assertion/index.vue | 48 ++++++++++++++++--- .../components/business/ms-assertion/type.ts | 1 + .../api-test/components/condition/content.vue | 25 ++++++++-- .../api-test/components/condition/list.vue | 24 +++++++++- .../components/bug-detail-drawer.vue | 6 +++ .../environmental/locale/en-US.ts | 1 + .../environmental/locale/zh-CN.ts | 1 + 8 files changed, 104 insertions(+), 14 deletions(-) diff --git a/frontend/src/components/business/ms-assertion/comp/ScriptTab.vue b/frontend/src/components/business/ms-assertion/comp/ScriptTab.vue index 9437539b46..c415f25abc 100644 --- a/frontend/src/components/business/ms-assertion/comp/ScriptTab.vue +++ b/frontend/src/components/business/ms-assertion/comp/ScriptTab.vue @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/frontend/src/components/business/ms-assertion/index.vue b/frontend/src/components/business/ms-assertion/index.vue index f682302002..0154347237 100644 --- a/frontend/src/components/business/ms-assertion/index.vue +++ b/frontend/src/components/business/ms-assertion/index.vue @@ -40,9 +40,13 @@ >
{{ index + 1 }} -
{{ - item.name - }}
+ +
{{ item.name }}
+
@@ -128,6 +132,7 @@ v-model:data="getCurrentItemState" :disabled="props.disabled" @change="handleChange" + @deleteScriptItem="deleteScriptItem" />
@@ -152,14 +157,17 @@ import ScriptTab from './comp/ScriptTab.vue'; import StatusCodeTab from './comp/StatusCodeTab.vue'; import VariableTab from './comp/VariableTab.vue'; - import { useI18n } from '@/hooks/useI18n'; + import useModal from '@/hooks/useModal'; + import { characterLimit } from '@/utils'; import { ExecuteAssertionConfig } from '@/models/apiTest/common'; import { ResponseAssertionType, ResponseBodyAssertionType } from '@/enums/apiEnum'; import { MsAssertionItem } from './type'; + const { openModal } = useModal(); + defineOptions({ name: 'MsAssertion', }); @@ -358,8 +366,25 @@ const handleMoreActionSelect = (event: ActionsItem, item: MsAssertionItem) => { const currentIndex = assertions.value.findIndex((tmpItem) => tmpItem.id === item.id); if (event.eventTag === 'delete') { - assertions.value.splice(currentIndex, 1); - activeKey.value = currentIndex > 0 ? assertions.value[currentIndex - 1].id : ''; + openModal({ + type: 'error', + title: t('system.orgTemplate.deleteTemplateTitle', { name: characterLimit(item.name) }), + content: t('script.delete.confirm'), + okText: t('system.userGroup.confirmDelete'), + cancelText: t('system.userGroup.cancel'), + okButtonProps: { + status: 'danger', + }, + onBeforeOk: async () => { + try { + assertions.value.splice(currentIndex, 1); + activeKey.value = currentIndex > 0 ? assertions.value[currentIndex - 1].id : ''; + } catch (error) { + console.log(error); + } + }, + hideCancel: false, + }); } else { // copy 当前item const tmpObj = { ...cloneDeep(assertions.value[currentIndex]), id: new Date().getTime().valueOf().toString() }; @@ -370,6 +395,15 @@ } }; + /** + * 删除脚本项 + */ + const deleteScriptItem = (id: string | number) => { + const currentIndex = assertions.value.findIndex((tmpItem) => tmpItem.id === id); + assertions.value.splice(currentIndex, 1); + activeKey.value = currentIndex > 0 ? assertions.value[currentIndex - 1].id : ''; + }; + // item点击 const handleItemClick = (item: MsAssertionItem) => { activeKey.value = item.id; @@ -522,4 +556,4 @@ opacity: 1; } } - + \ No newline at end of file diff --git a/frontend/src/components/business/ms-assertion/type.ts b/frontend/src/components/business/ms-assertion/type.ts index bc1a4ad19a..7940546905 100644 --- a/frontend/src/components/business/ms-assertion/type.ts +++ b/frontend/src/components/business/ms-assertion/type.ts @@ -8,6 +8,7 @@ export interface MsAssertionItem { id: string; label: string; value: string; + name: string; valueObj: ValueObject; } diff --git a/frontend/src/views/api-test/components/condition/content.vue b/frontend/src/views/api-test/components/condition/content.vue index f878eddde1..78934ebfec 100644 --- a/frontend/src/views/api-test/components/condition/content.vue +++ b/frontend/src/views/api-test/components/condition/content.vue @@ -457,9 +457,7 @@ import MsCodeEditor from '@/components/pure/ms-code-editor/index.vue'; import { LanguageEnum } from '@/components/pure/ms-code-editor/types'; import MsIcon from '@/components/pure/ms-icon-font/index.vue'; - import MsBaseTable from '@/components/pure/ms-table/base-table.vue'; import type { MsTableColumn } from '@/components/pure/ms-table/type'; - import useTable from '@/components/pure/ms-table/useTable'; import { ActionsItem } from '@/components/pure/ms-table-more-action/types'; import InsertCommonScript from '@/components/business/ms-common-script/insertCommonScript.vue'; import AddScriptDrawer from '@/components/business/ms-common-script/ms-addScriptDrawer.vue'; @@ -472,7 +470,9 @@ import { getProtocolList } from '@/api/modules/api-test/common'; import { useI18n } from '@/hooks/useI18n'; + import useModal from '@/hooks/useModal'; import useAppStore from '@/store/modules/app'; + import { characterLimit } from '@/utils'; import { hasAnyPermission } from '@/utils/permission'; import { @@ -497,6 +497,8 @@ import { defaultKeyValueParamItem } from '@/views/api-test/components/config'; + const { openModal } = useModal(); + export type ExpressionConfig = (RegexExtract | JSONPathExtract | XPathExtract) & Record; const appStore = useAppStore(); const props = withDefaults( @@ -604,7 +606,24 @@ if (!result){ * 删除条件 */ function deleteCondition() { - emit('delete', condition.value.id); + openModal({ + type: 'error', + title: t('system.orgTemplate.deleteTemplateTitle', { name: characterLimit(condition.value.name) }), + content: t('script.delete.confirm'), + okText: t('system.userGroup.confirmDelete'), + cancelText: t('system.userGroup.cancel'), + okButtonProps: { + status: 'danger', + }, + onBeforeOk: async () => { + try { + emit('delete', condition.value.id); + } catch (error) { + console.log(error); + } + }, + hideCancel: false, + }); } const commonScriptShowType = ref<'parameters' | 'scriptContent'>('parameters'); diff --git a/frontend/src/views/api-test/components/condition/list.vue b/frontend/src/views/api-test/components/condition/list.vue index d05d5f877b..77848b4848 100644 --- a/frontend/src/views/api-test/components/condition/list.vue +++ b/frontend/src/views/api-test/components/condition/list.vue @@ -67,6 +67,8 @@ import { conditionTypeNameMap } from '@/config/apiTest'; import { useI18n } from '@/hooks/useI18n'; + import useModal from '@/hooks/useModal'; + import { characterLimit } from '@/utils'; import { ExecuteConditionProcessor } from '@/models/apiTest/common'; import { RequestConditionProcessor } from '@/enums/apiEnum'; @@ -86,6 +88,7 @@ const { t } = useI18n(); const data = useVModel(props, 'list', emit); + const { openModal } = useModal(); // 当前聚焦的列表项 const focusItemKey = ref(''); @@ -206,7 +209,24 @@ if (event.eventTag === 'copy') { copyListItem(item); } else if (event.eventTag === 'delete') { - deleteListItem(item); + openModal({ + type: 'error', + title: t('system.orgTemplate.deleteTemplateTitle', { name: characterLimit(item.name) }), + content: t('script.delete.confirm'), + okText: t('system.userGroup.confirmDelete'), + cancelText: t('system.userGroup.cancel'), + okButtonProps: { + status: 'danger', + }, + onBeforeOk: async () => { + try { + deleteListItem(item); + } catch (error) { + console.log(error); + } + }, + hideCancel: false, + }); } } @@ -218,4 +238,4 @@ background: white !important; box-shadow: 0 0 0 1px var(--color-text-n8); } - + \ No newline at end of file diff --git a/frontend/src/views/bug-management/components/bug-detail-drawer.vue b/frontend/src/views/bug-management/components/bug-detail-drawer.vue index c47212223b..4cd5baa036 100644 --- a/frontend/src/views/bug-management/components/bug-detail-drawer.vue +++ b/frontend/src/views/bug-management/components/bug-detail-drawer.vue @@ -632,6 +632,12 @@ (val) => { if (val) { activeTab.value = 'detail'; + } else { + const query = { ...route.query }; + delete query.id; + router.replace({ + query, + }); } } ); 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 f3859d555a..7681e939cb 100644 --- a/frontend/src/views/project-management/environmental/locale/en-US.ts +++ b/frontend/src/views/project-management/environmental/locale/en-US.ts @@ -128,4 +128,5 @@ export default { 'project.environmental.database.nameIsExist': 'Database name already exists', 'project.environmental.http.noneDataExist': 'There is already a domain name with an enabled range of none!', 'project.environmental.http.selectModule': 'Please select module', + 'script.delete.confirm': 'After deletion, it cannot be restored. Please exercise caution.', }; 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 e506e2a25b..d44c8f5eec 100644 --- a/frontend/src/views/project-management/environmental/locale/zh-CN.ts +++ b/frontend/src/views/project-management/environmental/locale/zh-CN.ts @@ -132,4 +132,5 @@ export default { 'project.environmental.database.nameIsExist': '数据源名称已存在', 'project.environmental.http.noneDataExist': '已存在启用范围为无的域名!', 'project.environmental.http.selectModule': '请选择模块', + 'script.delete.confirm': '删除后无法恢复, 请谨慎操作!', };