mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	v3.8.0 新增tab对象简化页签操作
This commit is contained in:
		| @@ -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 | ||||||
|     // 缓存对象 |     // 缓存对象 | ||||||
|   | |||||||
							
								
								
									
										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) => { |   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) | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   | |||||||
| @@ -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 = [] | ||||||
|   | |||||||
| @@ -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()}}) |  | ||||||
|     }, |     }, | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -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"}); |  | ||||||
|         }); |         }); | ||||||
|       }); |       }); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -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; // 表单开启 | ||||||
|   | |||||||
| @@ -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; // 表单开启 | ||||||
|   | |||||||
| @@ -64,8 +64,7 @@ export default { | |||||||
|       }); |       }); | ||||||
|     }, |     }, | ||||||
|     close() { |     close() { | ||||||
|       this.$store.dispatch("tagsView/delView", this.$route); |       this.$tab.closePage(); | ||||||
|       this.$router.push({ path: "/index" }); |  | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -68,8 +68,7 @@ export default { | |||||||
|       }); |       }); | ||||||
|     }, |     }, | ||||||
|     close() { |     close() { | ||||||
|       this.$store.dispatch("tagsView/delView", this.$route); |       this.$tab.closePage(); | ||||||
|       this.$router.push({ path: "/index" }); |  | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -92,8 +92,7 @@ export default { | |||||||
|       }); |       }); | ||||||
|     }, |     }, | ||||||
|     close() { |     close() { | ||||||
|       this.$store.dispatch("tagsView/delView", this.$route); |       this.$tab.closePage(); | ||||||
|       this.$router.push({ path: "/index" }); |  | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -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() { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV