v3.8.0 新增tab对象简化页签操作

This commit is contained in:
YunaiV 2022-02-17 15:21:46 +08:00
parent 5036971f55
commit 8e0415a8fe
12 changed files with 83 additions and 17 deletions

View File

@ -1,3 +1,4 @@
import tab from './tab'
import auth from './auth' import auth from './auth'
import cache from './cache' import cache from './cache'
import modal from './modal' import modal from './modal'
@ -5,6 +6,8 @@ import download from './download'
export default { export default {
install(Vue) { install(Vue) {
// 页签操作
Vue.prototype.$tab = tab
// 认证对象 // 认证对象
Vue.prototype.$auth = auth Vue.prototype.$auth = auth
// 缓存对象 // 缓存对象

View File

@ -0,0 +1,67 @@
import store from '@/store'
import router from '@/router';
export default {
// 刷新当前tab页签
refreshPage(obj) {
const { path, query, matched } = router.currentRoute;
if (obj === undefined) {
matched.forEach((m) => {
if (m.components && m.components.default && m.components.default.name) {
if (!['Layout', 'ParentView'].includes(m.components.default.name)) {
obj = { name: m.components.default.name, path: path, query: query };
}
}
});
}
return store.dispatch('tagsView/delCachedView', obj).then(() => {
const { path, query } = obj
router.replace({
path: '/redirect' + path,
query: query
})
})
},
// 关闭当前tab页签打开新页签
closeOpenPage(obj) {
store.dispatch("tagsView/delView", router.currentRoute);
if (obj !== undefined) {
return router.push(obj);
}
},
// 关闭指定tab页签
closePage(obj) {
if (obj === undefined) {
return store.dispatch('tagsView/delView', router.currentRoute).then(({ lastPath }) => {
return router.push(lastPath || '/');
});
}
return store.dispatch('tagsView/delView', obj);
},
// 关闭所有tab页签
closeAllPage() {
return store.dispatch('tagsView/delAllViews');
},
// 关闭左侧tab页签
closeLeftPage(obj) {
return store.dispatch('tagsView/delLeftTags', obj || router.currentRoute);
},
// 关闭右侧tab页签
closeRightPage(obj) {
return store.dispatch('tagsView/delRightTags', obj || router.currentRoute);
},
// 关闭其他tab页签
closeOtherPage(obj) {
return store.dispatch('tagsView/delOthersViews', obj || router.currentRoute);
},
// 添加tab页签
openPage(title, url) {
var obj = { path: url, meta: { title: title } }
store.dispatch('tagsView/addView', obj);
return router.push(url);
},
// 修改tab页签
updatePage(obj) {
return store.dispatch('tagsView/updateVisitedView', obj);
}
}

View File

@ -14,7 +14,7 @@ const mutations = {
}, },
ADD_CACHED_VIEW: (state, view) => { ADD_CACHED_VIEW: (state, view) => {
if (state.cachedViews.includes(view.name)) return if (state.cachedViews.includes(view.name)) return
if (!view.meta.noCache) { if (view.meta && !view.meta.noCache) {
state.cachedViews.push(view.name) state.cachedViews.push(view.name)
} }
}, },

View File

@ -449,8 +449,7 @@ export default {
}, },
/** 关闭按钮 */ /** 关闭按钮 */
close() { close() {
this.$store.dispatch("tagsView/delView", this.$route); this.$tab.closeOpenPage({ path: "/bpm/manager/form" });
this.$router.push({ path: "/bpm/manager/form", query: { t: Date.now()}})
}, },
encodeFields() { encodeFields() {
const fields = [] const fields = []

View File

@ -111,8 +111,7 @@ export default {
}, },
/** 关闭按钮 */ /** 关闭按钮 */
close() { close() {
this.$store.dispatch("tagsView/delView", this.$route); this.$tab.closeOpenPage({ path: "/bpm/manager/model" });
this.$router.push({ path: "/bpm/manager/model", query: { t: Date.now()}})
}, },
} }
}; };

View File

@ -66,8 +66,7 @@ export default {
// //
createLeave(this.form).then(response => { createLeave(this.form).then(response => {
this.$modal.msgSuccess("发起成功"); this.$modal.msgSuccess("发起成功");
this.$store.dispatch("tagsView/delView", this.$route); this.$tab.closeOpenPage({ path: "/bpm/oa/leave" });
this.$router.push({ path: "/bpm/oa/leave"});
}); });
}); });
} }

View File

@ -146,7 +146,7 @@ export default {
}).then(response => { }).then(response => {
this.$modal.msgSuccess("发起流程成功"); this.$modal.msgSuccess("发起流程成功");
// //
this.$store.dispatch("tagsView/delView", this.$route); this.$tab.closeOpenPage();
this.$router.go(-1); this.$router.go(-1);
}).catch(() => { }).catch(() => {
conf.disabled = false; // conf.disabled = false; //

View File

@ -302,7 +302,7 @@ export default {
}).then(response => { }).then(response => {
this.$modal.msgSuccess("发起流程成功"); this.$modal.msgSuccess("发起流程成功");
// //
this.$store.dispatch("tagsView/delView", this.$route); this.$tab.closeOpenPage();
this.$router.go(-1); this.$router.go(-1);
}).catch(() => { }).catch(() => {
conf.disabled = false; // conf.disabled = false; //

View File

@ -64,8 +64,7 @@ export default {
}); });
}, },
close() { close() {
this.$store.dispatch("tagsView/delView", this.$route); this.$tab.closePage();
this.$router.push({ path: "/index" });
} }
} }
}; };

View File

@ -68,8 +68,7 @@ export default {
}); });
}, },
close() { close() {
this.$store.dispatch("tagsView/delView", this.$route); this.$tab.closePage();
this.$router.push({ path: "/index" });
} }
} }
}; };

View File

@ -92,8 +92,7 @@ export default {
}); });
}, },
close() { close() {
this.$store.dispatch("tagsView/delView", this.$route); this.$tab.closePage();
this.$router.push({ path: "/index" });
} }
} }
}; };

View File

@ -211,8 +211,10 @@ export default {
}, },
/** 关闭按钮 */ /** 关闭按钮 */
close() { close() {
this.$store.dispatch("tagsView/delView", this.$route); this.$tab.closeOpenPage({
this.$router.push({ path: "/tool/codegen", query: { t: Date.now()}}) path: "/tool/codegen",
query: { t: Date.now(), pageNum: this.$route.query.pageNum } }
);
} }
}, },
mounted() { mounted() {