fix(接口测试): 接口定义页面提醒未保存优化

This commit is contained in:
wxg0103 2021-11-25 17:41:06 +08:00 committed by 刘瑞斌
parent 198c272a6d
commit ec90829542
3 changed files with 28 additions and 24 deletions

View File

@ -555,27 +555,29 @@ export default {
}
},
closeConfirm(targetName) {
let tabs = this.apiTabs;
if(!tabs[1].api) {
this.handleTabRemove(targetName);
}
if (tabs[1].api && this.$store.state.apiMap.size > 0) {
if (this.$store.state.apiMap.get(tabs[1].api.id).get("responseChange") === true || this.$store.state.apiMap.get(tabs[1].api.id).get("requestChange") === true ||
this.$store.state.apiMap.get(tabs[1].api.id).get("fromChange") === true) {
this.$alert("接口[ " + tabs[1].api.name + " ]未保存,是否确认关闭?", '', {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
callback: (action) => {
if (action === 'confirm') {
this.$store.state.apiMap.delete(tabs[1].api.id);
this.handleTabRemove(targetName);
}
let tab = this.apiTabs;
tab.forEach(t => {
if (t.name === targetName) {
if (t.api && this.$store.state.apiMap.size > 0 && this.$store.state.apiMap.has(t.api.id)) {
if (this.$store.state.apiMap.get(t.api.id).get("responseChange") === true || this.$store.state.apiMap.get(t.api.id).get("requestChange") === true ||
this.$store.state.apiMap.get(t.api.id).get("fromChange") === true) {
this.$alert("接口[ " + t.api.name + " ]未保存,是否确认关闭?", '', {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
callback: (action) => {
if (action === 'confirm') {
this.$store.state.apiMap.delete(t.api.id);
this.handleTabRemove(targetName);
}
}
});
}
});
} else {
this.handleTabRemove(targetName);
}
}
} else{
this.handleTabRemove(targetName);
}
})
},
handleTabRemove(targetName) {

View File

@ -295,7 +295,7 @@ export default {
handleTabClose() {
let message = "";
this.tabs.forEach(t => {
if (t && this.$store.state.testCaseMap.has(t.testCaseInfo.id) && this.$store.state.testCaseMap.get(t.testCaseInfo.id) > 2) {
if (t && this.$store.state.testCaseMap.has(t.testCaseInfo.id) && this.$store.state.testCaseMap.get(t.testCaseInfo.id) > 1) {
message += t.testCaseInfo.name + "";
}
})
@ -320,7 +320,7 @@ export default {
},
closeConfirm(targetName) {
let t = this.tabs.filter(tab => tab.name === targetName);
if (t && this.$store.state.testCaseMap.has(t[0].testCaseInfo.id) && this.$store.state.testCaseMap.get(t[0].testCaseInfo.id) > 2) {
if (t && this.$store.state.testCaseMap.has(t[0].testCaseInfo.id) && this.$store.state.testCaseMap.get(t[0].testCaseInfo.id) > 1) {
this.$alert("用例[ " + t[0].testCaseInfo.name + " ]未保存,是否确认关闭?", '', {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),

View File

@ -457,6 +457,7 @@ export default {
if (!this.form.remark) {
this.form.remark = "";
}
this.$store.state.testCaseMap.set(this.form.id, 0);
},
handleCommand(e) {
if (e === "ADD_AND_CREATE") {
@ -498,7 +499,10 @@ export default {
},
reload() {
this.isStepTableAlive = false;
this.$nextTick(() => (this.isStepTableAlive = true));
this.$nextTick(() => {
this.isStepTableAlive = true;
this.$store.state.testCaseMap.set(this.form.id, 0);
});
},
reloadForm() {
this.isFormAlive = false;
@ -606,7 +610,6 @@ export default {
this.showInputTag = true;
});
});
this.$store.state.testCaseMap.set(this.form.id, 0);
},
async setFormData(testCase) {
try {
@ -635,7 +638,6 @@ export default {
this.setDefaultValue();
//
this.reloadForm();
this.$store.state.testCaseMap.set(this.form.id, 0);
},
setTestCaseExtInfo(testCase) {
this.testCase = {};