diff --git a/frontend/src/business/components/api/definition/ApiDefinition.vue b/frontend/src/business/components/api/definition/ApiDefinition.vue index 5ce39997d1..7ab55ca43c 100644 --- a/frontend/src/business/components/api/definition/ApiDefinition.vue +++ b/frontend/src/business/components/api/definition/ApiDefinition.vue @@ -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) { diff --git a/frontend/src/business/components/track/case/TestCase.vue b/frontend/src/business/components/track/case/TestCase.vue index b585e5e5f0..e236795bb3 100644 --- a/frontend/src/business/components/track/case/TestCase.vue +++ b/frontend/src/business/components/track/case/TestCase.vue @@ -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'), diff --git a/frontend/src/business/components/track/case/components/TestCaseEdit.vue b/frontend/src/business/components/track/case/components/TestCaseEdit.vue index 6d9bca16cd..44435fcea9 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEdit.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEdit.vue @@ -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 = {};