From ad7bcaa7cf148cc34ba3bf6217bea70d2f8a2557 Mon Sep 17 00:00:00 2001 From: "xinxin.wu" Date: Mon, 11 Mar 2024 10:01:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E7=AE=A1=E7=90=86=E6=96=AD=E8=A8=80=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E8=B0=83=E6=95=B4&=E9=83=A8=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=AE=A1=E7=90=86bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ms-assertion/comp/ResponseBodyTab.vue | 234 ++++++++++-------- .../business/ms-assertion/index.vue | 223 ++++++++++------- .../components/pure/ms-code-editor/types.ts | 4 + .../pure/ms-form-create/form-create.ts | 12 +- frontend/src/config/pathMap.ts | 2 +- frontend/src/enums/apiEnum.ts | 1 + .../components/caseTemplateDetail.vue | 27 +- .../components/addFieldToTemplateDrawer.vue | 6 +- .../template/components/addTemplate.vue | 1 + 9 files changed, 310 insertions(+), 200 deletions(-) diff --git a/frontend/src/components/business/ms-assertion/comp/ResponseBodyTab.vue b/frontend/src/components/business/ms-assertion/comp/ResponseBodyTab.vue index 056529fdfc..51468289ef 100644 --- a/frontend/src/components/business/ms-assertion/comp/ResponseBodyTab.vue +++ b/frontend/src/components/business/ms-assertion/comp/ResponseBodyTab.vue @@ -7,14 +7,16 @@ -
+ +
-
+ + +
{{ t('ms.assertion.responseContentType') }}
- - XML - HTML + + XML + HTML
-
+ + +
{{ t('ms.assertion.responseContentType') }}
- + JSON XML
- + {{ t('ms.assertion.followApi') }}
diff --git a/frontend/src/components/business/ms-assertion/index.vue b/frontend/src/components/business/ms-assertion/index.vue index ff6f2df4d3..af595bf28e 100644 --- a/frontend/src/components/business/ms-assertion/index.vue +++ b/frontend/src/components/business/ms-assertion/index.vue @@ -11,86 +11,101 @@ {{ item.label }} -
- -
-
- {{ index + 1 }} - {{ item.name }} -
-
-
- - - - - - -
- +
+ + +
+
+ {{ index + 1 }} + {{ item.name }} +
+
+
+ + + + + + +
+ + +
-
- + +
- - - - - - - - - - - - + + + + + + + + + + + + + +
@@ -133,11 +148,50 @@ const valueKey = computed(() => { return activeKey.value && assertions.value.find((item) => item.id === activeKey.value)?.assertionType; }); + const defaultResBodyItem = { + jsonPathAssertion: { + assertions: [], + }, + xpathAssertion: { responseFormat: 'XML', assertions: [] }, + assertionBodyType: '', + regexAssertion: { + assertions: [], + }, + // TODO文档暂时不做 + // documentAssertion: { + // jsonAssertion: [ + // { + // id: rootId, + // paramsName: 'root', + // mustInclude: false, + // typeChecking: false, + // paramType: 'object', + // matchCondition: '', + // matchValue: '', + // }, + // ], + // responseFormat: 'JSON', + // followApi: false, + // }, + }; // 计算当前页面的存储的状态 const getCurrentItemState = computed({ get: () => { - return assertions.value.find((item) => item.id === activeKey.value); + const currentResItem = + assertions.value.find((item: any) => item.id === activeKey.value) || assertions.value[0] || {}; + if (currentResItem && currentResItem?.assertionType === ResponseAssertionType.RESPONSE_BODY) { + const { jsonPathAssertion, xpathAssertion, regexAssertion } = currentResItem; + return { + ...currentResItem, + jsonPathAssertion: jsonPathAssertion || defaultResBodyItem.jsonPathAssertion, + xpathAssertion: xpathAssertion || defaultResBodyItem.xpathAssertion, + assertionBodyType: '', + regexAssertion: regexAssertion || defaultResBodyItem.regexAssertion, + bodyAssertionDataByType: {}, + }; + } + return currentResItem; }, set: (val: ExecuteAssertion) => { const currentIndex = assertions.value.findIndex((item) => item.id === activeKey.value); @@ -223,11 +277,12 @@ assertions: [], }, xpathAssertion: { + responseFormat: 'XML', assertions: [], }, - regexAssertion: { - assertions: [], - }, + // regexAssertion: { + // assertions: [], + // }, bodyAssertionDataByType: {}, }); break; @@ -284,6 +339,7 @@ getCurrentItemState.value = { ...val }; break; case ResponseAssertionType.RESPONSE_BODY: + getCurrentItemState.value = { ...val }; break; case ResponseAssertionType.RESPONSE_TIME: getCurrentItemState.value = { ...val }; @@ -300,7 +356,9 @@ }; watchEffect(() => { - console.log(getCurrentItemState.value); + getCurrentItemState.value = + assertions.value.find((item: any) => item.id === activeKey.value) || assertions.value[0] || {}; + activeKey.value = getCurrentItemState.value.id; }); @@ -317,7 +375,6 @@ padding: 12px; width: 216px; min-width: 216px; - height: calc(100vh - 394px); background-color: var(--color-text-n9); flex-direction: column; gap: 4px; diff --git a/frontend/src/components/pure/ms-code-editor/types.ts b/frontend/src/components/pure/ms-code-editor/types.ts index de69624e48..cbc07de905 100644 --- a/frontend/src/components/pure/ms-code-editor/types.ts +++ b/frontend/src/components/pure/ms-code-editor/types.ts @@ -119,4 +119,8 @@ export const editorProps = { type: Boolean as PropType, default: false, }, + widthClass: { + type: String as PropType, + default: '', + }, }; diff --git a/frontend/src/components/pure/ms-form-create/form-create.ts b/frontend/src/components/pure/ms-form-create/form-create.ts index b7aaaf0fa6..c75f8dc987 100644 --- a/frontend/src/components/pure/ms-form-create/form-create.ts +++ b/frontend/src/components/pure/ms-form-create/form-create.ts @@ -68,10 +68,9 @@ export const MEMBER = { value: '', options: [], props: { - 'multiple': false, + multiple: false, // 'placeholder': t('formCreate.PleaseSelect'), - 'modelValue': '', - 'allow-clear': true, + modelValue: '', }, }; @@ -82,11 +81,10 @@ export const MULTIPLE_MEMBER = { value: [], options: [], props: { - 'multiple': true, + multiple: true, // 'placeholder': t('formCreate.PleaseSelect'), - 'options': [], - 'modelValue': [], - 'allow-clear': true, + options: [], + modelValue: [], }, }; diff --git a/frontend/src/config/pathMap.ts b/frontend/src/config/pathMap.ts index d4151a1ee4..31f22128fb 100644 --- a/frontend/src/config/pathMap.ts +++ b/frontend/src/config/pathMap.ts @@ -657,7 +657,7 @@ export const pathMap: PathMapItem[] = [ level: MENU_LEVEL[2], }, { - key: 'PROJECT_MANAGEMENT_COMMON_SCRIPT', // 项目管理-公共脚本 + key: ' PROJECT_CUSTOM_FUNCTION', // 项目管理-公共脚本 locale: 'menu.projectManagement.commonScript', route: RouteEnum.PROJECT_MANAGEMENT_COMMON_SCRIPT, permission: [], diff --git a/frontend/src/enums/apiEnum.ts b/frontend/src/enums/apiEnum.ts index 82878f86c0..9755be3f06 100644 --- a/frontend/src/enums/apiEnum.ts +++ b/frontend/src/enums/apiEnum.ts @@ -113,6 +113,7 @@ export enum ResponseBodyAssertionType { JSON_PATH = 'JSON_PATH', REGEX = 'REGEX', // 正则表达式 XPATH = 'XPATH', + SCRIPT = 'SCRIPT', } // 接口断言-响应体断言-文档类型 export enum ResponseBodyAssertionDocumentType { diff --git a/frontend/src/views/case-management/caseManagementFeature/components/caseTemplateDetail.vue b/frontend/src/views/case-management/caseManagementFeature/components/caseTemplateDetail.vue index 0f39866f94..7776e19168 100644 --- a/frontend/src/views/case-management/caseManagementFeature/components/caseTemplateDetail.vue +++ b/frontend/src/views/case-management/caseManagementFeature/components/caseTemplateDetail.vue @@ -270,6 +270,7 @@ import { useI18n } from '@/hooks/useI18n'; import useAppStore from '@/store/modules/app'; import useFeatureCaseStore from '@/store/modules/case/featureCase'; + import useUserStore from '@/store/modules/user'; import { downloadByteFile, getGenerateId } from '@/utils'; import { hasAnyPermission } from '@/utils/permission'; @@ -279,12 +280,15 @@ CreateOrUpdateCase, CustomAttributes, DetailCase, + OptionsFieldId, StepList, } from '@/models/caseManagement/featureCase'; import type { ModuleTreeNode, TableQueryParams } from '@/models/common'; import { convertToFile, initFormCreate } from './utils'; + const userStore = useUserStore(); + const { t } = useI18n(); const route = useRoute(); const appStore = useAppStore(); @@ -382,16 +386,33 @@ const { customFields, id } = res; form.value.templateId = id; const result = customFields.map((item: any) => { + const memberType = ['MEMBER', 'MULTIPLE_MEMBER']; + let initValue = item.defaultValue; + let optionsValue: OptionsFieldId[] = item.options; + if (memberType.includes(item.type)) { + optionsValue = [ + { + fieldId: item.fieldId, + internal: item.internal, + text: userStore.name || '', + value: userStore.id || '', + }, + ]; + if (item.defaultValue === 'CREATE_USER') { + initValue = item.type === 'MEMBER' ? userStore.id : [userStore.id]; + } + } + return { type: item.type, name: item.fieldId, label: item.fieldName, - value: item.defaultValue, + value: initValue, required: item.required, options: item.options || [], props: { - modelValue: item.defaultValue, - options: item.options || [], + modelValue: initValue, + options: optionsValue || [], }, }; }); diff --git a/frontend/src/views/setting/organization/template/components/addFieldToTemplateDrawer.vue b/frontend/src/views/setting/organization/template/components/addFieldToTemplateDrawer.vue index 25fd6768bb..9dba15f997 100644 --- a/frontend/src/views/setting/organization/template/components/addFieldToTemplateDrawer.vue +++ b/frontend/src/views/setting/organization/template/components/addFieldToTemplateDrawer.vue @@ -119,7 +119,7 @@ tableSelectData: DefinedFieldItem[]; // 表格选择字段 }>(); - const emit = defineEmits(['confirm', 'update:visible', 'update-data']); + const emit = defineEmits(['confirm', 'update:visible', 'update-data', 'brash']); const totalList = ref([]); @@ -229,9 +229,9 @@ showAddDrawer.value = false; }; - const okHandler = () => { + const okHandler = (editFlag: boolean, fieldId: string) => { // eslint-disable-next-line vue/custom-event-name-casing - emit('update-data'); + emit('update-data', editFlag, fieldId); }; watch( diff --git a/frontend/src/views/setting/organization/template/components/addTemplate.vue b/frontend/src/views/setting/organization/template/components/addTemplate.vue index 4961a881ba..8893af859a 100644 --- a/frontend/src/views/setting/organization/template/components/addTemplate.vue +++ b/frontend/src/views/setting/organization/template/components/addTemplate.vue @@ -182,6 +182,7 @@ :table-select-data="(selectData as DefinedFieldItem[])" :mode="props.mode" @confirm="confirmHandler" + @update-data="updateFieldHandler" />