Showing
2 changed files
with
14 additions
and
24 deletions
| 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: 2024-11-25 15:01:10 | 4 | + * @LastEditTime: 2024-12-23 18:00:57 |
| 5 | * @FilePath: /data-table/src/router.js | 5 | * @FilePath: /data-table/src/router.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| ... | @@ -51,30 +51,8 @@ router.beforeEach((to, from, next) => { | ... | @@ -51,30 +51,8 @@ router.beforeEach((to, from, next) => { |
| 51 | next({ ...to.redirectedFrom, replace: true }); | 51 | next({ ...to.redirectedFrom, replace: true }); |
| 52 | }, 1000); | 52 | }, 1000); |
| 53 | } else { | 53 | } else { |
| 54 | - if (to.query.page_type === 'add' || to.query.page_type === undefined) { // 表单为新增状态, 检查是否有未完成的表单信息 | ||
| 55 | - const existingCookie = Cookies.get(to.query.code); | ||
| 56 | - if (existingCookie && to.query.force_back !== '1') { | ||
| 57 | - showConfirmDialog({ | ||
| 58 | - title: '温馨提示', | ||
| 59 | - message: '您还未完成的表单,是否继续?', | ||
| 60 | - confirmButtonColor: styleColor.baseColor, | ||
| 61 | - cancelButtonText: '删除', | ||
| 62 | - closeOnPopstate: false, | ||
| 63 | - }) | ||
| 64 | - .then(() => { // 通过后把数据绑定上去 | ||
| 65 | - next(); | ||
| 66 | - }) | ||
| 67 | - .catch(() => { // 删除cookie | ||
| 68 | - Cookies.remove(to.query.code); | ||
| 69 | - next(); | ||
| 70 | - }); | ||
| 71 | - } else { | ||
| 72 | - next(); | ||
| 73 | - } | ||
| 74 | - } else { | ||
| 75 | next() | 54 | next() |
| 76 | } | 55 | } |
| 77 | - } | ||
| 78 | }) | 56 | }) |
| 79 | 57 | ||
| 80 | router.afterEach(() => { | 58 | router.afterEach(() => { | ... | ... |
| ... | @@ -514,7 +514,15 @@ onMounted(async () => { | ... | @@ -514,7 +514,15 @@ onMounted(async () => { |
| 514 | // TAG:不同类型提交表单处理 | 514 | // TAG:不同类型提交表单处理 |
| 515 | if (page_type === 'add' || page_type === undefined) { // 表单为新增状态, 检查是否有未完成的表单信息 | 515 | if (page_type === 'add' || page_type === undefined) { // 表单为新增状态, 检查是否有未完成的表单信息 |
| 516 | const existingCookie = Cookies.get($route.query.code); | 516 | const existingCookie = Cookies.get($route.query.code); |
| 517 | - if (existingCookie) { | 517 | + if (existingCookie && !force_back) { |
| 518 | + showConfirmDialog({ | ||
| 519 | + title: '温馨提示', | ||
| 520 | + message: '您还未完成的表单,是否继续?', | ||
| 521 | + confirmButtonColor: styleColor.baseColor, | ||
| 522 | + cancelButtonText: '删除', | ||
| 523 | + closeOnPopstate: false, | ||
| 524 | + }) | ||
| 525 | + .then(() => { // 通过后把数据绑定上去 | ||
| 518 | // 如果Cookie存在,更新它 | 526 | // 如果Cookie存在,更新它 |
| 519 | let object = JSON.parse(existingCookie); | 527 | let object = JSON.parse(existingCookie); |
| 520 | // 默认值 | 528 | // 默认值 |
| ... | @@ -526,6 +534,10 @@ onMounted(async () => { | ... | @@ -526,6 +534,10 @@ onMounted(async () => { |
| 526 | item.component_props.default = value; | 534 | item.component_props.default = value; |
| 527 | } | 535 | } |
| 528 | }); | 536 | }); |
| 537 | + }) | ||
| 538 | + .catch(() => { // 删除cookie | ||
| 539 | + Cookies.remove(to.query.code); | ||
| 540 | + }); | ||
| 529 | } | 541 | } |
| 530 | } | 542 | } |
| 531 | if (page_type === 'add' && !force_back) { // 表单为新增状态, 非后台打开状态 | 543 | if (page_type === 'add' && !force_back) { // 表单为新增状态, 非后台打开状态 | ... | ... |
-
Please register or login to post a comment