| 123456789101112131415161718 |
- import { computed } from 'vue'
- import { useRoute, useRouter } from 'vue-router'
- import usePermissionStore from '@/store/modules/permission'
- import { ElMessage } from 'element-plus'
- import { scopeFromRoute, findAlarmMenu } from './alarmOperationsModel'
- export function useAlarmScope() {
- const route = useRoute(), router = useRouter(), permissions = usePermissionStore()
- const scope = computed(() => scopeFromRoute(route.query))
- const scopeKey = computed(() => JSON.stringify(scope.value))
- const menu = leaf => findAlarmMenu(permissions.sidebarRouters, leaf, scope.value.rootTypeId)
- const navigate = (leaf, extra = {}) => {
- const target = menu(leaf)
- if (!target) return ElMessage.warning('当前账号未配置该功能菜单')
- return router.push({ path: target.path, query: { ...target.query, ...extra } })
- }
- return { scope, scopeKey, route, menu, navigate }
- }
|