feat(router): 添加编辑申报数据后的刷新功能
- 在编辑申报数据页面添加 beforeRouteLeave 钩子,设置需要刷新的标志- 在申报数据页面添加 beforeRouteEnter 钩子,根据标志决定是否刷新数据 - 优化用户体验,确保编辑后能正确刷新展示最新的申报数据
Showing
2 changed files
with
17 additions
and
0 deletions
| ... | @@ -808,6 +808,13 @@ | ... | @@ -808,6 +808,13 @@ |
| 808 | this.back(); | 808 | this.back(); |
| 809 | } | 809 | } |
| 810 | }, | 810 | }, |
| 811 | + beforeRouteLeave(to, from, next) { | ||
| 812 | + if (to.name === 'ReportingData') { | ||
| 813 | + // 设置一个标志表示需要刷新数据 | ||
| 814 | + to.meta.needsRefresh = true; | ||
| 815 | + } | ||
| 816 | + next(); | ||
| 817 | + }, | ||
| 811 | methods: { | 818 | methods: { |
| 812 | mapDicDatas(dicArr, code){ | 819 | mapDicDatas(dicArr, code){ |
| 813 | if (code != "") { | 820 | if (code != "") { | ... | ... |
| ... | @@ -585,6 +585,16 @@ export default { | ... | @@ -585,6 +585,16 @@ export default { |
| 585 | this.popoverClose(); | 585 | this.popoverClose(); |
| 586 | }, | 586 | }, |
| 587 | }, | 587 | }, |
| 588 | + beforeRouteEnter(to, from, next) { | ||
| 589 | + next(vm => { | ||
| 590 | + // 检查标志是否需要刷新数据 | ||
| 591 | + if (to.meta.needsRefresh) { | ||
| 592 | + vm.search(0); | ||
| 593 | + // 重置标志 | ||
| 594 | + to.meta.needsRefresh = false; | ||
| 595 | + } | ||
| 596 | + }); | ||
| 597 | + }, | ||
| 588 | methods: { | 598 | methods: { |
| 589 | //查询申报数据 | 599 | //查询申报数据 |
| 590 | search(val) { | 600 | search(val) { | ... | ... |
-
Please register or login to post a comment