Showing
1 changed file
with
24 additions
and
2 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: 2022-06-29 21:36:59 | 4 | + * @LastEditTime: 2024-11-21 17:08:22 |
| 5 | - * @FilePath: /tswj/src/router.js | 5 | + * @FilePath: /data-table/src/router.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| 8 | import { createRouter, createWebHashHistory } from 'vue-router'; | 8 | import { createRouter, createWebHashHistory } from 'vue-router'; |
| 9 | import RootRoute from './route.js'; | 9 | import RootRoute from './route.js'; |
| 10 | import asyncRoutesArr from "./mock/routes" | 10 | import asyncRoutesArr from "./mock/routes" |
| 11 | import generateRoutes from './utils/generateRoute' | 11 | import generateRoutes from './utils/generateRoute' |
| 12 | +import { showConfirmDialog } from "vant"; | ||
| 13 | +import Cookies from 'js-cookie'; | ||
| 14 | +import { styleColor } from "@/constant.js"; | ||
| 12 | 15 | ||
| 13 | // TAG: 路由配置表 | 16 | // TAG: 路由配置表 |
| 14 | /** | 17 | /** |
| ... | @@ -48,8 +51,27 @@ router.beforeEach((to, from, next) => { | ... | @@ -48,8 +51,27 @@ router.beforeEach((to, from, next) => { |
| 48 | next({ ...to.redirectedFrom, replace: true }); | 51 | next({ ...to.redirectedFrom, replace: true }); |
| 49 | }, 1000); | 52 | }, 1000); |
| 50 | } else { | 53 | } else { |
| 54 | + if (to.query.page_type === 'add') { // 表单为新增状态, 检查是否有未完成的表单信息 | ||
| 55 | + const existingCookie = Cookies.get(to.query.code); | ||
| 56 | + if (existingCookie) { | ||
| 57 | + showConfirmDialog({ | ||
| 58 | + title: '温馨提示', | ||
| 59 | + message: '您还未完成的表单,是否继续?', | ||
| 60 | + confirmButtonColor: styleColor.baseColor, | ||
| 61 | + cancelButtonText: '删除' | ||
| 62 | + }) | ||
| 63 | + .then(() => { // 通过后把数据绑定上去 | ||
| 64 | + next(); | ||
| 65 | + }) | ||
| 66 | + .catch(() => { // 删除cookie | ||
| 67 | + Cookies.remove(to.query.code); | ||
| 68 | + next(); | ||
| 69 | + }); | ||
| 70 | + } | ||
| 71 | + } else { | ||
| 51 | next() | 72 | next() |
| 52 | } | 73 | } |
| 74 | + } | ||
| 53 | }) | 75 | }) |
| 54 | 76 | ||
| 55 | router.afterEach(() => { | 77 | router.afterEach(() => { | ... | ... |
-
Please register or login to post a comment