hookehuyr

fix 检查是否有未完成的表单逻辑修改

/*
* @Date: 2022-05-26 13:57:28
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-11-25 15:01:10
* @LastEditTime: 2024-12-23 18:00:57
* @FilePath: /data-table/src/router.js
* @Description: 文件描述
*/
......@@ -51,30 +51,8 @@ router.beforeEach((to, from, next) => {
next({ ...to.redirectedFrom, replace: true });
}, 1000);
} else {
if (to.query.page_type === 'add' || to.query.page_type === undefined) { // 表单为新增状态, 检查是否有未完成的表单信息
const existingCookie = Cookies.get(to.query.code);
if (existingCookie && to.query.force_back !== '1') {
showConfirmDialog({
title: '温馨提示',
message: '您还未完成的表单,是否继续?',
confirmButtonColor: styleColor.baseColor,
cancelButtonText: '删除',
closeOnPopstate: false,
})
.then(() => { // 通过后把数据绑定上去
next();
})
.catch(() => { // 删除cookie
Cookies.remove(to.query.code);
next();
});
} else {
next();
}
} else {
next()
}
}
})
router.afterEach(() => {
......
......@@ -514,7 +514,15 @@ onMounted(async () => {
// TAG:不同类型提交表单处理
if (page_type === 'add' || page_type === undefined) { // 表单为新增状态, 检查是否有未完成的表单信息
const existingCookie = Cookies.get($route.query.code);
if (existingCookie) {
if (existingCookie && !force_back) {
showConfirmDialog({
title: '温馨提示',
message: '您还未完成的表单,是否继续?',
confirmButtonColor: styleColor.baseColor,
cancelButtonText: '删除',
closeOnPopstate: false,
})
.then(() => { // 通过后把数据绑定上去
// 如果Cookie存在,更新它
let object = JSON.parse(existingCookie);
// 默认值
......@@ -526,6 +534,10 @@ onMounted(async () => {
item.component_props.default = value;
}
});
})
.catch(() => { // 删除cookie
Cookies.remove(to.query.code);
});
}
}
if (page_type === 'add' && !force_back) { // 表单为新增状态, 非后台打开状态
......