hookehuyr

fix(路由): 处理leader来源的表单未完成提示问题

在路由跳转和周期选择时,对leader来源的特殊情况进行处理
当页面类型为新增或未指定且来源为leader时,清除未完成表单的cookie
避免显示不必要的未完成表单提示弹框
1 /* 1 /*
2 * @Date: 2022-05-26 13:57:28 2 * @Date: 2022-05-26 13:57:28
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-09-25 18:29:36 4 + * @LastEditTime: 2025-11-06 10:45:17
5 * @FilePath: /data-table/src/router.js 5 * @FilePath: /data-table/src/router.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -91,6 +91,15 @@ router.beforeEach((to, from, next) => { ...@@ -91,6 +91,15 @@ router.beforeEach((to, from, next) => {
91 resetDialogState(); 91 resetDialogState();
92 } 92 }
93 93
94 + // 新增:在显示未完成表单弹框之前,对 leader 来源进行特殊处理
95 + // 如果是新增页面或未指定类型,并且来源为 leader,则提前清理未完成表单的 Cookie,避免弹框
96 + // 这样可以确保不会触发 showUnfinishedFormDialog 或包含“您还未完成的表单,是否继续?”的提示
97 + if ((to.query.page_type === 'add' || to.query.page_type === undefined) && (to.query.volunteer_source === 'leader')) {
98 + if (to.query.code) {
99 + Cookies.remove(to.query.code);
100 + }
101 + }
102 +
94 // 使用404为中转页面,避免动态路由没有渲染出来,控制台报警告问题 103 // 使用404为中转页面,避免动态路由没有渲染出来,控制台报警告问题
95 if (to.path == '/404' && to.redirectedFrom != undefined) { 104 if (to.path == '/404' && to.redirectedFrom != undefined) {
96 // 模拟异步操作 105 // 模拟异步操作
......
...@@ -168,6 +168,13 @@ const confirmCycleSelection = () => { ...@@ -168,6 +168,13 @@ const confirmCycleSelection = () => {
168 * @param {Object} route 目标路由对象 168 * @param {Object} route 目标路由对象
169 */ 169 */
170 const checkUnfinishedForm = (route) => { 170 const checkUnfinishedForm = (route) => {
171 + // 新增:在显示未完成表单弹框之前,对 leader 来源进行特殊处理
172 + // 如果是新增页面或未指定类型,并且来源为 leader,则提前清理未完成表单的 Cookie,避免弹框
173 + if ((route.query.page_type === 'add' || route.query.page_type === undefined) && (route.query.volunteer_source === 'leader')) {
174 + if (route.query.code) {
175 + Cookies.remove(route.query.code);
176 + }
177 + }
171 // 只在新增状态时检查 178 // 只在新增状态时检查
172 if (route.query.page_type === 'add' || route.query.page_type === undefined) { 179 if (route.query.page_type === 'add' || route.query.page_type === undefined) {
173 const existingCookie = Cookies.get(route.query.code); 180 const existingCookie = Cookies.get(route.query.code);
......