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 @@
>
@@ -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