refactor: 路由跳转时提示脑图保存
--bug=1008131 --user=陈建星 【github#7831】进入【测试跟踪】-【测试计划】,标记用例执行结果,点击其他窗口,未提示保存,导致用例执行结果记录丢失。 https://www.tapd.cn/55049933/s/1074851
This commit is contained in:
parent
8dc638b8fe
commit
8b2ad7a60c
|
@ -166,7 +166,8 @@ export default {
|
|||
type: '',
|
||||
activeDom: 'left',
|
||||
tmpActiveDom: null,
|
||||
total: 0
|
||||
total: 0,
|
||||
tmpPath: null
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
|
@ -178,6 +179,14 @@ export default {
|
|||
this.init(this.$route);
|
||||
}
|
||||
},
|
||||
beforeRouteLeave(to, from, next) {
|
||||
if (this.$store.state.isTestCaseMinderChanged) {
|
||||
this.$refs.isChangeConfirm.open();
|
||||
this.tmpPath = to.path;
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
redirectID() {
|
||||
this.renderComponent = false;
|
||||
|
|
|
@ -58,7 +58,9 @@ export default {
|
|||
open() {
|
||||
this.init();
|
||||
this.$refs.baseRelevance.open();
|
||||
this.$refs.apiCaseList.clear();
|
||||
if (this.$refs.apiCaseList) {
|
||||
this.$refs.apiCaseList.clear();
|
||||
}
|
||||
},
|
||||
init() {
|
||||
if (this.$refs.apiCaseList) {
|
||||
|
|
|
@ -567,10 +567,18 @@ export function openMinderConfirm(vueObj, activeDom) {
|
|||
export function saveMinderConfirm(vueObj, isSave) {
|
||||
if (isSave) {
|
||||
vueObj.$refs.minder.save(window.minder.exportJson());
|
||||
} else {
|
||||
vueObj.$store.commit('setIsTestCaseMinderChanged', false);
|
||||
}
|
||||
vueObj.$store.commit('setIsTestCaseMinderChanged', false);
|
||||
vueObj.$nextTick(() => {
|
||||
vueObj.activeDom = vueObj.tmpActiveDom;
|
||||
if (vueObj.tmpActiveDom) {
|
||||
vueObj.activeDom = vueObj.tmpActiveDom;
|
||||
vueObj.tmpActiveDom = null;
|
||||
}
|
||||
if (vueObj.tmpPath) {
|
||||
vueObj.$router.push({
|
||||
path: vueObj.tmpPath
|
||||
});
|
||||
vueObj.tmpPath = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
</template>
|
||||
</ms-test-plan-header-bar>
|
||||
<test-plan-functional v-if="activeIndex === 'functional'" :redirectCharType="redirectCharType"
|
||||
:clickType="clickType" :plan-id="planId"/>
|
||||
:clickType="clickType" :plan-id="planId" ref="testPlanFunctional"/>
|
||||
<test-plan-api v-if="activeIndex === 'api'" :redirectCharType="redirectCharType" :clickType="clickType"
|
||||
:plan-id="planId"/>
|
||||
<test-plan-load v-if="activeIndex === 'load'" :redirectCharType="redirectCharType" :clickType="clickType"
|
||||
|
@ -82,6 +82,13 @@ export default {
|
|||
this.getTestPlans();
|
||||
}
|
||||
},
|
||||
beforeRouteLeave(to, from, next) {
|
||||
if (!this.$refs.testPlanFunctional) {
|
||||
next();
|
||||
} else if (this.$refs.testPlanFunctional.handleBeforeRouteLeave(to)) {
|
||||
next();
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$EventBus.$on('projectChange', () => {
|
||||
if (this.$route.name === 'planView') {
|
||||
|
|
|
@ -450,7 +450,7 @@ export default {
|
|||
this.testCaseTemplate = template;
|
||||
this.fields = getTableHeaderWithCustomFields(this.tableHeaderKey, this.testCaseTemplate.customFields);
|
||||
this.result.loading = false;
|
||||
this.$refs.table.reloadTable();
|
||||
if (this.$refs.table) this.$refs.table.reloadTable();
|
||||
});
|
||||
},
|
||||
getCustomFieldValue(row, field) {
|
||||
|
|
|
@ -83,7 +83,8 @@ export default {
|
|||
activeDom: 'left',
|
||||
selectNode: {},
|
||||
condition: {},
|
||||
tmpActiveDom: null
|
||||
tmpActiveDom: null,
|
||||
tmpPath: null
|
||||
};
|
||||
},
|
||||
props: [
|
||||
|
@ -164,7 +165,16 @@ export default {
|
|||
},
|
||||
changeConfirm(isSave) {
|
||||
saveMinderConfirm(this, isSave);
|
||||
}
|
||||
},
|
||||
handleBeforeRouteLeave(to) {
|
||||
if (this.$store.state.isTestCaseMinderChanged) {
|
||||
this.$refs.isChangeConfirm.open();
|
||||
this.tmpPath = to.path;
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
</template>
|
||||
</ms-test-plan-header-bar>
|
||||
<test-review-function v-if="activeIndex === 'functional'" :redirectCharType="redirectCharType"
|
||||
:clickType="clickType" :review-id="reviewId"></test-review-function>
|
||||
:clickType="clickType" :review-id="reviewId" ref="testReviewFunction"/>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
@ -86,6 +86,13 @@ export default {
|
|||
this.initData();
|
||||
this.openTestCaseEdit(this.$route.path);
|
||||
},
|
||||
beforeRouteLeave(to, from, next) {
|
||||
if (!this.$refs.testReviewFunction) {
|
||||
next();
|
||||
} else if (this.$refs.testReviewFunction.handleBeforeRouteLeave(to)) {
|
||||
next();
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'$route'(to, from) {
|
||||
this.openTestCaseEdit(to.path);
|
||||
|
|
|
@ -82,7 +82,8 @@ export default {
|
|||
isMenuShow: true,
|
||||
activeDom: 'left',
|
||||
condition: {},
|
||||
tmpActiveDom: null
|
||||
tmpActiveDom: null,
|
||||
tmpPath: null
|
||||
}
|
||||
},
|
||||
props: [
|
||||
|
@ -130,7 +131,16 @@ export default {
|
|||
},
|
||||
changeConfirm(isSave) {
|
||||
saveMinderConfirm(this, isSave);
|
||||
}
|
||||
},
|
||||
handleBeforeRouteLeave(to) {
|
||||
if (this.$store.state.isTestCaseMinderChanged) {
|
||||
this.$refs.isChangeConfirm.open();
|
||||
this.tmpPath = to.path;
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue