Commit 8e0415a8fea1193bd166301d3bd98d03735baa0b
1 parent
5036971f
v3.8.0 新增tab对象简化页签操作
Showing
12 changed files
with
83 additions
and
17 deletions
yudao-ui-admin/src/plugins/index.js
| 1 | +import tab from './tab' | |
| 1 | 2 | import auth from './auth' |
| 2 | 3 | import cache from './cache' |
| 3 | 4 | import modal from './modal' |
| ... | ... | @@ -5,6 +6,8 @@ import download from './download' |
| 5 | 6 | |
| 6 | 7 | export default { |
| 7 | 8 | install(Vue) { |
| 9 | + // 页签操作 | |
| 10 | + Vue.prototype.$tab = tab | |
| 8 | 11 | // 认证对象 |
| 9 | 12 | Vue.prototype.$auth = auth |
| 10 | 13 | // 缓存对象 | ... | ... |
yudao-ui-admin/src/plugins/tab.js
0 → 100644
| 1 | +import store from '@/store' | |
| 2 | +import router from '@/router'; | |
| 3 | + | |
| 4 | +export default { | |
| 5 | + // 刷新当前tab页签 | |
| 6 | + refreshPage(obj) { | |
| 7 | + const { path, query, matched } = router.currentRoute; | |
| 8 | + if (obj === undefined) { | |
| 9 | + matched.forEach((m) => { | |
| 10 | + if (m.components && m.components.default && m.components.default.name) { | |
| 11 | + if (!['Layout', 'ParentView'].includes(m.components.default.name)) { | |
| 12 | + obj = { name: m.components.default.name, path: path, query: query }; | |
| 13 | + } | |
| 14 | + } | |
| 15 | + }); | |
| 16 | + } | |
| 17 | + return store.dispatch('tagsView/delCachedView', obj).then(() => { | |
| 18 | + const { path, query } = obj | |
| 19 | + router.replace({ | |
| 20 | + path: '/redirect' + path, | |
| 21 | + query: query | |
| 22 | + }) | |
| 23 | + }) | |
| 24 | + }, | |
| 25 | + // 关闭当前tab页签,打开新页签 | |
| 26 | + closeOpenPage(obj) { | |
| 27 | + store.dispatch("tagsView/delView", router.currentRoute); | |
| 28 | + if (obj !== undefined) { | |
| 29 | + return router.push(obj); | |
| 30 | + } | |
| 31 | + }, | |
| 32 | + // 关闭指定tab页签 | |
| 33 | + closePage(obj) { | |
| 34 | + if (obj === undefined) { | |
| 35 | + return store.dispatch('tagsView/delView', router.currentRoute).then(({ lastPath }) => { | |
| 36 | + return router.push(lastPath || '/'); | |
| 37 | + }); | |
| 38 | + } | |
| 39 | + return store.dispatch('tagsView/delView', obj); | |
| 40 | + }, | |
| 41 | + // 关闭所有tab页签 | |
| 42 | + closeAllPage() { | |
| 43 | + return store.dispatch('tagsView/delAllViews'); | |
| 44 | + }, | |
| 45 | + // 关闭左侧tab页签 | |
| 46 | + closeLeftPage(obj) { | |
| 47 | + return store.dispatch('tagsView/delLeftTags', obj || router.currentRoute); | |
| 48 | + }, | |
| 49 | + // 关闭右侧tab页签 | |
| 50 | + closeRightPage(obj) { | |
| 51 | + return store.dispatch('tagsView/delRightTags', obj || router.currentRoute); | |
| 52 | + }, | |
| 53 | + // 关闭其他tab页签 | |
| 54 | + closeOtherPage(obj) { | |
| 55 | + return store.dispatch('tagsView/delOthersViews', obj || router.currentRoute); | |
| 56 | + }, | |
| 57 | + // 添加tab页签 | |
| 58 | + openPage(title, url) { | |
| 59 | + var obj = { path: url, meta: { title: title } } | |
| 60 | + store.dispatch('tagsView/addView', obj); | |
| 61 | + return router.push(url); | |
| 62 | + }, | |
| 63 | + // 修改tab页签 | |
| 64 | + updatePage(obj) { | |
| 65 | + return store.dispatch('tagsView/updateVisitedView', obj); | |
| 66 | + } | |
| 67 | +} | ... | ... |
yudao-ui-admin/src/store/modules/tagsView.js
yudao-ui-admin/src/views/bpm/form/formEditor.vue
| ... | ... | @@ -449,8 +449,7 @@ export default { |
| 449 | 449 | }, |
| 450 | 450 | /** 关闭按钮 */ |
| 451 | 451 | close() { |
| 452 | - this.$store.dispatch("tagsView/delView", this.$route); | |
| 453 | - this.$router.push({ path: "/bpm/manager/form", query: { t: Date.now()}}) | |
| 452 | + this.$tab.closeOpenPage({ path: "/bpm/manager/form" }); | |
| 454 | 453 | }, |
| 455 | 454 | encodeFields() { |
| 456 | 455 | const fields = [] | ... | ... |
yudao-ui-admin/src/views/bpm/model/modelEditor.vue
| ... | ... | @@ -111,8 +111,7 @@ export default { |
| 111 | 111 | }, |
| 112 | 112 | /** 关闭按钮 */ |
| 113 | 113 | close() { |
| 114 | - this.$store.dispatch("tagsView/delView", this.$route); | |
| 115 | - this.$router.push({ path: "/bpm/manager/model", query: { t: Date.now()}}) | |
| 114 | + this.$tab.closeOpenPage({ path: "/bpm/manager/model" }); | |
| 116 | 115 | }, |
| 117 | 116 | } |
| 118 | 117 | }; | ... | ... |
yudao-ui-admin/src/views/bpm/oa/leave/create.vue
| ... | ... | @@ -66,8 +66,7 @@ export default { |
| 66 | 66 | // 添加的提交 |
| 67 | 67 | createLeave(this.form).then(response => { |
| 68 | 68 | this.$modal.msgSuccess("发起成功"); |
| 69 | - this.$store.dispatch("tagsView/delView", this.$route); | |
| 70 | - this.$router.push({ path: "/bpm/oa/leave"}); | |
| 69 | + this.$tab.closeOpenPage({ path: "/bpm/oa/leave" }); | |
| 71 | 70 | }); |
| 72 | 71 | }); |
| 73 | 72 | } | ... | ... |
yudao-ui-admin/src/views/bpm/processInstance/create.vue
| ... | ... | @@ -146,7 +146,7 @@ export default { |
| 146 | 146 | }).then(response => { |
| 147 | 147 | this.$modal.msgSuccess("发起流程成功"); |
| 148 | 148 | // 关闭当前窗口 |
| 149 | - this.$store.dispatch("tagsView/delView", this.$route); | |
| 149 | + this.$tab.closeOpenPage(); | |
| 150 | 150 | this.$router.go(-1); |
| 151 | 151 | }).catch(() => { |
| 152 | 152 | conf.disabled = false; // 表单开启 | ... | ... |
yudao-ui-admin/src/views/bpm/processInstance/detail.vue
| ... | ... | @@ -302,7 +302,7 @@ export default { |
| 302 | 302 | }).then(response => { |
| 303 | 303 | this.$modal.msgSuccess("发起流程成功"); |
| 304 | 304 | // 关闭当前窗口 |
| 305 | - this.$store.dispatch("tagsView/delView", this.$route); | |
| 305 | + this.$tab.closeOpenPage(); | |
| 306 | 306 | this.$router.go(-1); |
| 307 | 307 | }).catch(() => { |
| 308 | 308 | conf.disabled = false; // 表单开启 | ... | ... |
yudao-ui-admin/src/views/system/user/profile/resetPwd.vue
yudao-ui-admin/src/views/system/user/profile/userInfo.vue
yudao-ui-admin/src/views/system/user/profile/userSocial.vue
yudao-ui-admin/src/views/tool/codegen/editTable.vue
| ... | ... | @@ -211,8 +211,10 @@ export default { |
| 211 | 211 | }, |
| 212 | 212 | /** 关闭按钮 */ |
| 213 | 213 | close() { |
| 214 | - this.$store.dispatch("tagsView/delView", this.$route); | |
| 215 | - this.$router.push({ path: "/tool/codegen", query: { t: Date.now()}}) | |
| 214 | + this.$tab.closeOpenPage({ | |
| 215 | + path: "/tool/codegen", | |
| 216 | + query: { t: Date.now(), pageNum: this.$route.query.pageNum } } | |
| 217 | + ); | |
| 216 | 218 | } |
| 217 | 219 | }, |
| 218 | 220 | mounted() { | ... | ... |