update: 优化北向输出跳转

This commit is contained in:
xieyonghong 2023-02-22 16:07:24 +08:00
parent 1460ebcdbb
commit 754fe63fc1
3 changed files with 22 additions and 30 deletions

View File

@ -74,12 +74,20 @@ export const useMenuStore = defineStore({
hasMenu(code: string) { hasMenu(code: string) {
return this.menus[code]?.path return this.menus[code]?.path
}, },
jumpPage(code: string, params: Record<string, any>, query: Record<string, any>) { /**
const path = this.menus[code]?.path *
* @param name code
* @param params
* @param query
*/
jumpPage(name: string, params?: Record<string, any>, query?: Record<string, any>) {
const path = this.hasMenu(name)
if (path) { if (path) {
router.push({ router.push({
path, params, query name, params, query
}) })
} else {
console.warn(`没有找到对应的页面: ${name}`)
} }
}, },
queryMenuTree(isCommunity = false): Promise<any[]> { queryMenuTree(isCommunity = false): Promise<any[]> {

View File

@ -151,12 +151,15 @@ import {
import type { ActionsType } from '@/components/Table/index.vue'; import type { ActionsType } from '@/components/Table/index.vue';
import { getImage } from '@/utils/comm'; import { getImage } from '@/utils/comm';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import { useMenuStore } from 'store/menu'
const router = useRouter(); const router = useRouter();
const instanceRef = ref<Record<string, any>>({}); const instanceRef = ref<Record<string, any>>({});
const params = ref<Record<string, any>>({}); const params = ref<Record<string, any>>({});
const current = ref<Record<string, any>>({}); const current = ref<Record<string, any>>({});
const menuStory = useMenuStore()
const statusMap = new Map(); const statusMap = new Map();
statusMap.set('enabled', 'success'); statusMap.set('enabled', 'success');
statusMap.set('disabled', 'error'); statusMap.set('disabled', 'error');
@ -209,19 +212,14 @@ const columns = [
* 新增 * 新增
*/ */
const handleAdd = () => { const handleAdd = () => {
router.push('/iot/northbound/AliCloud/detail/:id'); menuStory.jumpPage('Northbound/AliCloud/Detail', { id: ':id'})
}; };
/** /**
* 查看 * 查看
*/ */
const handleView = (id: string) => { const handleView = (id: string) => {
router.push({ menuStory.jumpPage('Northbound/AliCloud/Detail', { id }, { type: 'view'})
path: '/iot/northbound/AliCloud/detail/' + id,
query: {
type: 'view'
}
});
}; };
const getActions = ( const getActions = (
@ -249,12 +247,7 @@ const getActions = (
}, },
icon: 'EditOutlined', icon: 'EditOutlined',
onClick: () => { onClick: () => {
router.push({ menuStory.jumpPage('Northbound/AliCloud/Detail', { id: data.id }, { type: 'edit'})
path: '/iot/northbound/AliCloud/detail/' + data.id,
query: {
type: 'edit'
}
});
}, },
}, },
{ {

View File

@ -147,11 +147,13 @@ import { query, _undeploy, _deploy, _delete, queryProductList, queryTypes } from
import type { ActionsType } from '@/components/Table/index.vue'; import type { ActionsType } from '@/components/Table/index.vue';
import { getImage } from '@/utils/comm'; import { getImage } from '@/utils/comm';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import { useMenuStore } from 'store/menu'
const router = useRouter(); const router = useRouter();
const instanceRef = ref<Record<string, any>>({}); const instanceRef = ref<Record<string, any>>({});
const params = ref<Record<string, any>>({}); const params = ref<Record<string, any>>({});
const current = ref<Record<string, any>>({}); const current = ref<Record<string, any>>({});
const menuStory = useMenuStore()
const statusMap = new Map(); const statusMap = new Map();
statusMap.set('enabled', 'success'); statusMap.set('enabled', 'success');
@ -236,20 +238,14 @@ const columns = [
* 新增 * 新增
*/ */
const handleAdd = () => { const handleAdd = () => {
router.push('/iot/northbound/DuerOS/detail/:id'); menuStory.jumpPage('Northbound/DuerOS/Detail', { id: ':id'})
}; };
/** /**
* 查看 * 查看
*/ */
const handleView = (id: string) => { const handleView = (id: string) => {
// router.push('/iot/northbound/DuerOS/detail/' + id); menuStory.jumpPage('Northbound/DuerOS/Detail', { id }, { type: 'view' })
router.push({
path: '/iot/northbound/DuerOS/detail/' + id,
query: {
type: 'view',
},
});
}; };
const getActions = ( const getActions = (
@ -277,12 +273,7 @@ const getActions = (
}, },
icon: 'EditOutlined', icon: 'EditOutlined',
onClick: () => { onClick: () => {
router.push({ menuStory.jumpPage('Northbound/DuerOS/Detail', { id: data.id }, { type: 'edit' })
path: '/iot/northbound/DuerOS/detail/' + data.id,
query: {
type: 'edit',
},
});
}, },
}, },
{ {