From ae91ceef96250c190ad0dfbeee5e11a3578ee5a6 Mon Sep 17 00:00:00 2001 From: RubyLiu Date: Tue, 27 Jun 2023 20:29:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E7=AC=AC=E4=B8=80=E6=AC=A1=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E6=8F=90=E7=A4=BA=E6=9C=AA=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/business/definition/ApiDefinition.vue | 2 ++ .../components/complete/ApiBaseInfo.vue | 27 +++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/api-test/frontend/src/business/definition/ApiDefinition.vue b/api-test/frontend/src/business/definition/ApiDefinition.vue index 2d293f7d66..e79e9555ac 100644 --- a/api-test/frontend/src/business/definition/ApiDefinition.vue +++ b/api-test/frontend/src/business/definition/ApiDefinition.vue @@ -783,6 +783,7 @@ export default { } else { if (id) { store.apiMap.delete(id); + store.saveMap.delete(id); } this.handleTabRemove(targetName); } @@ -1053,6 +1054,7 @@ export default { store.apiStatus.set('fromChange', false); store.apiStatus.set('requestChange', false); store.apiStatus.set('responseChange', false); + store.apiStatus.set('customFormChange', false); store.apiMap.set(data.id, store.apiStatus); // 保存后将保存状态置为true store.saveMap.set(data.id, true); diff --git a/api-test/frontend/src/business/definition/components/complete/ApiBaseInfo.vue b/api-test/frontend/src/business/definition/components/complete/ApiBaseInfo.vue index f58b7df100..b6ac12a5a9 100644 --- a/api-test/frontend/src/business/definition/components/complete/ApiBaseInfo.vue +++ b/api-test/frontend/src/business/definition/components/complete/ApiBaseInfo.vue @@ -95,7 +95,6 @@ import MsSelectTree from 'metersphere-frontend/src/components/select-tree/Select import MsInputTag from 'metersphere-frontend/src/components/MsInputTag'; import CustomFiledFormRow from 'metersphere-frontend/src/components/form/CustomFiledFormRow'; import { useApiStore } from '@/store'; -import { hasLicense } from 'metersphere-frontend/src/utils/permission'; import { API_STATUS, REQ_METHOD } from '../../model/JsonData'; const store = useApiStore(); @@ -217,7 +216,7 @@ export default { }, customFieldForm: { handler(v, v1) { - if (v && v1 && store.apiMap && this.basicForm.id) { + if (v && v1 ) { this.customApiMapStatus(); } }, @@ -231,12 +230,30 @@ export default { store.apiMap.set(this.basicForm.id, store.apiStatus); } }, + /** + * 自定义字段的状态 + * 有此方法是因为自定义字段点击保存按钮后会再次触发watch方法,导致customFromChange为true + */ customApiMapStatus() { - if(store.saveMap.get(this.basicForm.id)){ + if(store.saveMap.has(this.basicForm.id) === false){ + // 首次进入页面,若saveMap不存在,初始化saveMap, store.saveMap.set(this.basicForm.id, false); - store.apiStatus.set('customFormChange',false ); + if (this.basicForm.id && this.isFormAlive) { + // 初始化 customFromChange 为true + store.apiStatus.set('customFormChange', true); + store.apiMap.set(this.basicForm.id, store.apiStatus); + } } else { - store.apiStatus.set('customFormChange',true ); + // 不是首次进入页面,若 saveMap 为True,说明已经保存过 + if(store.saveMap.get(this.basicForm.id) === true){ + store.saveMap.set(this.basicForm.id,false); + return; + } + // 不是首次进入页面,若 saveMap 为False,说明未保存过 + if (this.basicForm.id && this.isFormAlive) { + store.apiStatus.set('customFormChange', true); + store.apiMap.set(this.basicForm.id, store.apiStatus); + } } },