fix(接口测试): 编辑接口自定义字段第一次保存关闭提示未保存

This commit is contained in:
RubyLiu 2023-06-27 20:29:25 +08:00 committed by fit2-zhao
parent f1b188316e
commit ae91ceef96
2 changed files with 24 additions and 5 deletions

View File

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

View File

@ -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){
// saveMapsaveMap,
store.saveMap.set(this.basicForm.id, false);
store.apiStatus.set('customFormChange',false );
} else {
if (this.basicForm.id && this.isFormAlive) {
// customFromChange true
store.apiStatus.set('customFormChange', true);
store.apiMap.set(this.basicForm.id, store.apiStatus);
}
} else {
// 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);
}
}
},