hookehuyr

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

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