Commit a0425096 authored by yyh's avatar yyh

返回提示保存

parent 807c4062
...@@ -17,6 +17,7 @@ import { Component, Prop, Watch, Vue } from 'vue-property-decorator'; ...@@ -17,6 +17,7 @@ import { Component, Prop, Watch, Vue } from 'vue-property-decorator';
import { Button, Field } from 'vant'; import { Button, Field } from 'vant';
import TemplateDetail from '@/components/TemplateDetail.vue'; import TemplateDetail from '@/components/TemplateDetail.vue';
import { TemplateDataItem } from '@/const/interface'; import { TemplateDataItem } from '@/const/interface';
import { Route } from 'vue-router';
@Component({ @Component({
components: { components: {
[Button.name]: Button, [Button.name]: Button,
...@@ -32,6 +33,8 @@ export default class ProofDetail extends Vue { ...@@ -32,6 +33,8 @@ export default class ProofDetail extends Vue {
private detail2: string = '' ; private detail2: string = '' ;
private name2: string = ''; private name2: string = '';
private checkEdited: boolean = true;
@Prop({ @Prop({
}) })
private templateId!: number; private templateId!: number;
...@@ -61,7 +64,8 @@ export default class ProofDetail extends Vue { ...@@ -61,7 +64,8 @@ export default class ProofDetail extends Vue {
this.showBtn = true; this.showBtn = true;
} }
} }
private beforeRouteLeave(to: any, from: any, next: any) { private beforeRouteLeave(to: Route, from: Route, next: () => void) {
if(!this.checkEdited) return next();
if ( this.name !== this.name2 || JSON.stringify(this.detail) !== this.detail2 ) { if ( this.name !== this.name2 || JSON.stringify(this.detail) !== this.detail2 ) {
this.$dialog.confirm({ this.$dialog.confirm({
title: '提示', title: '提示',
...@@ -94,6 +98,7 @@ export default class ProofDetail extends Vue { ...@@ -94,6 +98,7 @@ export default class ProofDetail extends Vue {
} else { } else {
await this.$api.proof.add(this.name, this.detail); await this.$api.proof.add(this.name, this.detail);
} }
this.checkEdited = false;
this.$router.push({name: 'ProofList'}); this.$router.push({name: 'ProofList'});
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment