mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
v3.8.0 新增tab对象简化页签操作
This commit is contained in:
parent
5036971f55
commit
8e0415a8fe
@ -1,3 +1,4 @@
|
||||
import tab from './tab'
|
||||
import auth from './auth'
|
||||
import cache from './cache'
|
||||
import modal from './modal'
|
||||
@ -5,6 +6,8 @@ import download from './download'
|
||||
|
||||
export default {
|
||||
install(Vue) {
|
||||
// 页签操作
|
||||
Vue.prototype.$tab = tab
|
||||
// 认证对象
|
||||
Vue.prototype.$auth = auth
|
||||
// 缓存对象
|
||||
|
67
yudao-ui-admin/src/plugins/tab.js
Normal file
67
yudao-ui-admin/src/plugins/tab.js
Normal 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);
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ const mutations = {
|
||||
},
|
||||
ADD_CACHED_VIEW: (state, view) => {
|
||||
if (state.cachedViews.includes(view.name)) return
|
||||
if (!view.meta.noCache) {
|
||||
if (view.meta && !view.meta.noCache) {
|
||||
state.cachedViews.push(view.name)
|
||||
}
|
||||
},
|
||||
|
@ -449,8 +449,7 @@ export default {
|
||||
},
|
||||
/** 关闭按钮 */
|
||||
close() {
|
||||
this.$store.dispatch("tagsView/delView", this.$route);
|
||||
this.$router.push({ path: "/bpm/manager/form", query: { t: Date.now()}})
|
||||
this.$tab.closeOpenPage({ path: "/bpm/manager/form" });
|
||||
},
|
||||
encodeFields() {
|
||||
const fields = []
|
||||
|
@ -111,8 +111,7 @@ export default {
|
||||
},
|
||||
/** 关闭按钮 */
|
||||
close() {
|
||||
this.$store.dispatch("tagsView/delView", this.$route);
|
||||
this.$router.push({ path: "/bpm/manager/model", query: { t: Date.now()}})
|
||||
this.$tab.closeOpenPage({ path: "/bpm/manager/model" });
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -66,8 +66,7 @@ export default {
|
||||
// 添加的提交
|
||||
createLeave(this.form).then(response => {
|
||||
this.$modal.msgSuccess("发起成功");
|
||||
this.$store.dispatch("tagsView/delView", this.$route);
|
||||
this.$router.push({ path: "/bpm/oa/leave"});
|
||||
this.$tab.closeOpenPage({ path: "/bpm/oa/leave" });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ export default {
|
||||
}).then(response => {
|
||||
this.$modal.msgSuccess("发起流程成功");
|
||||
// 关闭当前窗口
|
||||
this.$store.dispatch("tagsView/delView", this.$route);
|
||||
this.$tab.closeOpenPage();
|
||||
this.$router.go(-1);
|
||||
}).catch(() => {
|
||||
conf.disabled = false; // 表单开启
|
||||
|
@ -302,7 +302,7 @@ export default {
|
||||
}).then(response => {
|
||||
this.$modal.msgSuccess("发起流程成功");
|
||||
// 关闭当前窗口
|
||||
this.$store.dispatch("tagsView/delView", this.$route);
|
||||
this.$tab.closeOpenPage();
|
||||
this.$router.go(-1);
|
||||
}).catch(() => {
|
||||
conf.disabled = false; // 表单开启
|
||||
|
@ -64,8 +64,7 @@ export default {
|
||||
});
|
||||
},
|
||||
close() {
|
||||
this.$store.dispatch("tagsView/delView", this.$route);
|
||||
this.$router.push({ path: "/index" });
|
||||
this.$tab.closePage();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -68,8 +68,7 @@ export default {
|
||||
});
|
||||
},
|
||||
close() {
|
||||
this.$store.dispatch("tagsView/delView", this.$route);
|
||||
this.$router.push({ path: "/index" });
|
||||
this.$tab.closePage();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -92,8 +92,7 @@ export default {
|
||||
});
|
||||
},
|
||||
close() {
|
||||
this.$store.dispatch("tagsView/delView", this.$route);
|
||||
this.$router.push({ path: "/index" });
|
||||
this.$tab.closePage();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -211,8 +211,10 @@ export default {
|
||||
},
|
||||
/** 关闭按钮 */
|
||||
close() {
|
||||
this.$store.dispatch("tagsView/delView", this.$route);
|
||||
this.$router.push({ path: "/tool/codegen", query: { t: Date.now()}})
|
||||
this.$tab.closeOpenPage({
|
||||
path: "/tool/codegen",
|
||||
query: { t: Date.now(), pageNum: this.$route.query.pageNum } }
|
||||
);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
Loading…
Reference in New Issue
Block a user