fix: 路由父级的记录改为全局 修复点击选项卡X无法跳转到正确来源的bug
This commit is contained in:
@ -21,6 +21,9 @@ import { Modal } from 'ant-design-vue';
|
|||||||
import 'ant-design-vue/dist/antd.less';
|
import 'ant-design-vue/dist/antd.less';
|
||||||
//如果需要使用葡萄城报表 放开代码注释
|
//如果需要使用葡萄城报表 放开代码注释
|
||||||
// import { Core } from '@grapecity/activereports';
|
// import { Core } from '@grapecity/activereports';
|
||||||
|
window.fcd = {
|
||||||
|
routeBackMapping: {}
|
||||||
|
};
|
||||||
|
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
|
|||||||
@ -38,9 +38,12 @@ function createPageGuard(router: Router) {
|
|||||||
// Notify routing changes
|
// Notify routing changes
|
||||||
setRouteChange(to);
|
setRouteChange(to);
|
||||||
const toPath = to.path;
|
const toPath = to.path;
|
||||||
if (toPath.indexOf('views/secondDev') >= 0 || toPath.indexOf('/viewForm') >= 0) {
|
if (/createFlow|approveFlow|createForm|viewForm/.test(toPath)) {
|
||||||
// 记录从哪里来的 关闭页面的时候好跳回去
|
// 记录从哪里来的 关闭页面的时候好跳回去
|
||||||
localStorage.setItem('parentRoutePath', from.path);
|
if(!window.fcd.routeBackMapping[to.path]){
|
||||||
|
// tab切换也会触发路由守卫 所以只记录第一次的状态
|
||||||
|
window.fcd.routeBackMapping[to.path] = from.path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -184,7 +184,7 @@ export const useMultipleTabStore = defineStore({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async closeTab(tab: RouteLocationNormalized, router: Router, backTo: String) {
|
async closeTab(tab: RouteLocationNormalized, router: Router) {
|
||||||
const close = (route: RouteLocationNormalized) => {
|
const close = (route: RouteLocationNormalized) => {
|
||||||
const { fullPath, meta: { affix } = {} } = route;
|
const { fullPath, meta: { affix } = {} } = route;
|
||||||
if (affix) {
|
if (affix) {
|
||||||
@ -207,6 +207,8 @@ export const useMultipleTabStore = defineStore({
|
|||||||
let toTarget: RouteLocationRaw = {};
|
let toTarget: RouteLocationRaw = {};
|
||||||
|
|
||||||
const index = this.tabList.findIndex((item) => item.path === path);
|
const index = this.tabList.findIndex((item) => item.path === path);
|
||||||
|
const backTo = window.fcd.routeBackMapping[tab.path];
|
||||||
|
delete window.fcd.routeBackMapping[tab.path];
|
||||||
const backToIndex = backTo ? this.tabList.findIndex((item) => item.path === backTo) : -1;
|
const backToIndex = backTo ? this.tabList.findIndex((item) => item.path === backTo) : -1;
|
||||||
|
|
||||||
// If the current is the leftmost tab
|
// If the current is the leftmost tab
|
||||||
|
|||||||
@ -82,8 +82,6 @@
|
|||||||
const tabStore = useMultipleTabStore();
|
const tabStore = useMultipleTabStore();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const currentRoute = router.currentRoute.value;
|
const currentRoute = router.currentRoute.value;
|
||||||
const parentRoutePath = localStorage.getItem('parentRoutePath');
|
|
||||||
localStorage.removeItem('parentRoutePath');
|
|
||||||
const fullPath = currentRoute.fullPath;
|
const fullPath = currentRoute.fullPath;
|
||||||
const rQuery = currentRoute.query;
|
const rQuery = currentRoute.query;
|
||||||
const rParams = currentRoute.params;
|
const rParams = currentRoute.params;
|
||||||
@ -137,7 +135,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
tabStore.closeTab(currentRoute, router, parentRoutePath);
|
tabStore.closeTab(currentRoute, router);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onApproveClick() {
|
async function onApproveClick() {
|
||||||
|
|||||||
@ -79,9 +79,7 @@ const { t } = useI18n();
|
|||||||
const { data, approveUserData, initProcessData, notificationSuccess, notificationError } = userTaskItem();
|
const { data, approveUserData, initProcessData, notificationSuccess, notificationError } = userTaskItem();
|
||||||
const currentRoute = router.currentRoute.value;
|
const currentRoute = router.currentRoute.value;
|
||||||
const rParams = currentRoute.params;
|
const rParams = currentRoute.params;
|
||||||
const fullPath = currentRoute.fullPath;
|
const fullPath = currentRoute.fullPath;;
|
||||||
const parentRoutePath = localStorage.getItem('parentRoutePath');
|
|
||||||
localStorage.removeItem('parentRoutePath');
|
|
||||||
const rSchemaId = rParams.arg1;
|
const rSchemaId = rParams.arg1;
|
||||||
const rDraftsId = rParams.arg2;
|
const rDraftsId = rParams.arg2;
|
||||||
const taskId = ref();
|
const taskId = ref();
|
||||||
@ -125,7 +123,7 @@ function openFlowChart() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
tabStore.closeTab(currentRoute, router, parentRoutePath);
|
tabStore.closeTab(currentRoute, router);
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
|||||||
@ -47,8 +47,6 @@ const { currentRoute } = router;
|
|||||||
|
|
||||||
const { formPath } = currentRoute.value.query;
|
const { formPath } = currentRoute.value.query;
|
||||||
const pathArr = formPath.split('/');
|
const pathArr = formPath.split('/');
|
||||||
const parentRoutePath = localStorage.getItem('parentRoutePath');
|
|
||||||
localStorage.removeItem('parentRoutePath');
|
|
||||||
|
|
||||||
const tabStore = useMultipleTabStore();
|
const tabStore = useMultipleTabStore();
|
||||||
const formProps = ref(null);
|
const formProps = ref(null);
|
||||||
@ -93,7 +91,7 @@ async function setFormType() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
tabStore.closeTab(currentRoute.value, router, parentRoutePath);
|
tabStore.closeTab(currentRoute.value, router);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
|
|||||||
Reference in New Issue
Block a user