The resource view is made into a two-level menu

This commit is contained in:
pycook 2020-02-21 22:44:10 +08:00
parent 93ebc8d2e9
commit 8d3756566b
3 changed files with 46 additions and 35 deletions

View File

@ -5,12 +5,13 @@ import { UserLayout, BasicLayout, RouteView } from '@/layouts'
import { getPreference } from '@/api/cmdb/preference' import { getPreference } from '@/api/cmdb/preference'
const cmdbRouter = [ const cmdbRouter = [
// preference // resource views
{ {
path: '/preference', path: '/resource_views',
component: () => import('@/views/cmdb/preference'), component: RouteView,
name: 'cmdb_preference', name: 'cmdb_resource_views',
meta: { title: 'menu.preference', icon: 'book', keepAlive: true } meta: { title: 'menu.resourceViews', icon: 'hdd', keepAlive: true },
children: []
}, },
// relation views // relation views
{ {
@ -44,6 +45,13 @@ const cmdbRouter = [
hidden: true hidden: true
}] }]
}, },
// preference
{
path: '/preference',
component: () => import('@/views/cmdb/preference'),
name: 'cmdb_preference',
meta: { title: 'menu.preference', icon: 'star', keepAlive: true }
},
// batch // batch
{ {
path: '/batch', path: '/batch',
@ -52,7 +60,7 @@ const cmdbRouter = [
meta: { 'title': 'menu.batch', icon: 'upload', keepAlive: true } meta: { 'title': 'menu.batch', icon: 'upload', keepAlive: true }
}, },
{ {
path: '/config//ci_types', path: '/config/ci_types',
name: 'cmdb_ci_type', name: 'cmdb_ci_type',
component: RouteView, component: RouteView,
redirect: '/ci_types', redirect: '/ci_types',
@ -147,20 +155,21 @@ function copyArray (arr) {
export const generatorDynamicRouter = () => { export const generatorDynamicRouter = () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// cmdb 订阅的模型 // sub menu of the resource view
getPreference().then(res => { getPreference().then(res => {
const routers = copyArray(asyncRouterMap) const routers = copyArray(asyncRouterMap)
routers[0].children = copyArray(cmdbRouter) routers[0].children = copyArray(cmdbRouter)
for (let i = 0; i < res.length; i++) { let resourceMenus = []
const item = res[i] res.forEach(item => {
routers[0].children.unshift({ resourceMenus.push({
path: `/instances/types/${item.id}`, path: `/instances/types/${item.id}`,
component: () => import(`@/views/cmdb/ci/index`), component: () => import(`@/views/cmdb/ci/index`),
name: `cmdb_${item.id}`, name: `cmdb_${item.id}`,
meta: { title: item.alias, icon: 'table', keepAlive: true, typeId: item.id }, meta: { title: item.alias, icon: 'table', keepAlive: true, typeId: item.id },
hideChildrenInMenu: true hideChildrenInMenu: true
}) })
} });
routers[0].children[0].children = resourceMenus
resolve(routers) resolve(routers)
}) })
@ -183,7 +192,7 @@ const asyncRouterMap = [
] ]
/** /**
* 基础路由 * basic route
* @type { *[] } * @type { *[] }
*/ */
export const constantRouterMap = [ export const constantRouterMap = [

View File

@ -4,15 +4,16 @@ export default {
antLocale: enUS, antLocale: enUS,
menu: { menu: {
preference: 'Preference', preference: 'Preference',
relationViews: 'Relation Views', resourceViews: 'Resource views',
treeViews: 'Tree Views', relationViews: 'Relation views',
batch: 'Batch Import', treeViews: 'Tree views',
batch: 'Batch import',
ciType: 'Modeling', ciType: 'Modeling',
acl: 'Authorization', acl: 'Authorization',
ciModelManager: 'CI Type', ciModelManager: 'CI Type',
ciPropertyRep: 'Attributes', ciPropertyRep: 'Attributes',
ciRelationType: 'Relation Type', ciRelationType: 'Relation Type',
ciRelationViewDefine: 'Relation View Define', ciRelationViewDefine: 'Relation view define',
aclUsersManager: 'Users', aclUsersManager: 'Users',
aclRolesManager: 'Roles', aclRolesManager: 'Roles',
aclResourceManager: 'Resources', aclResourceManager: 'Resources',
@ -35,7 +36,7 @@ export default {
upload: 'Upload', upload: 'Upload',
download: 'Download', download: 'Download',
batchUpdate: 'Batch update', batchUpdate: 'Batch update',
displayFields: 'Display Fields' displayFields: 'Display fields'
}, },
tip: { tip: {
sourceCode: 'view on', sourceCode: 'view on',
@ -51,9 +52,9 @@ export default {
create: 'Create', create: 'Create',
clear: 'Clear', clear: 'Clear',
modify: 'Modify', modify: 'Modify',
unselectedAttribute: 'Unselect Attributes', unselectedAttribute: 'Unselect attributes',
selectedAttribute: 'Selected Attributes', selectedAttribute: 'Selected attributes',
noData: 'No Data', noData: 'No data',
addSuccess: 'Add successfully', addSuccess: 'Add successfully',
updateSuccess: 'Update successfully', updateSuccess: 'Update successfully',
saveSuccess: 'Save successfully', saveSuccess: 'Save successfully',
@ -66,11 +67,11 @@ export default {
error: 'Error', error: 'Error',
other: 'Other', other: 'Other',
requestFailed: 'Request error, please try again later', requestFailed: 'Request error, please try again later',
pleaseSelect: 'please select', pleaseSelect: 'Please select',
selectAll: 'Select all' selectAll: 'Select all'
}, },
ci: { ci: {
batchOperate: 'Batch Operation', batchOperate: 'Batch operation',
confirmBatchUpdate: 'Confirm batch modification?', confirmBatchUpdate: 'Confirm batch modification?',
batchUpdate: 'Batch update', batchUpdate: 'Batch update',
batchUpdateSuccess: 'Batch update successfully', batchUpdateSuccess: 'Batch update successfully',
@ -81,7 +82,7 @@ export default {
time: 'Time', time: 'Time',
user: 'User', user: 'User',
batchUpdateTip: 'Just fill in the fields that need to be modified!', batchUpdateTip: 'Just fill in the fields that need to be modified!',
selectLevel: '- - directory level selection - -', selectLevel: '- - Directory level selection - -',
displayFieldDefine: 'Display Fields Define' displayFieldDefine: 'Display Fields Define'
}, },
table: { table: {
@ -91,8 +92,8 @@ export default {
preference: { preference: {
cancelSubscribeConfirm: 'Really want to unsubscribe ?', cancelSubscribeConfirm: 'Really want to unsubscribe ?',
subscribeSuccess: 'Subscribe successfully', subscribeSuccess: 'Subscribe successfully',
subscribeModel: 'Subscribe Model', subscribeModel: 'Subscribe model',
resourceView: 'Resource View', resourceView: 'Resource view',
subFormTip: 'You can either define a tree view or subscribe to a resource view, which will be presented separately in sidebar' subFormTip: 'You can either define a tree view or subscribe to a resource view, which will be presented separately in sidebar'
}, },
batch: { batch: {
@ -110,12 +111,12 @@ export default {
}, },
ciType: { ciType: {
add: 'Add', add: 'Add',
addAttribute: 'Add Attribute', addAttribute: 'Add attribute',
addAttribute1: 'Add Attribute', addAttribute1: 'Add attribute',
moreAttribute: 'More Attributes', moreAttribute: 'More attributes',
bindAttribute: 'Bind Attribute', bindAttribute: 'Bind attribute',
editModel: 'Edit Model', editModel: 'Edit model',
modelName: 'Model Name', modelName: 'Model name',
name: 'Name', name: 'Name',
alias: 'Alias', alias: 'Alias',
type: 'Type', type: 'Type',
@ -140,12 +141,12 @@ export default {
requiredCheck: 'Required check', requiredCheck: 'Required check',
defaultShowAttribute: 'Default display attributes', defaultShowAttribute: 'Default display attributes',
attributeGroup: 'Attribute grouping & sorting', attributeGroup: 'Attribute grouping & sorting',
addGroup: 'Add Group', addGroup: 'Add group',
deleteGroup: 'Delete Group', deleteGroup: 'Delete group',
up: 'Up', up: 'Up',
down: 'Down', down: 'Down',
moveSuccess: 'Move successfully', moveSuccess: 'Move successfully',
moveFailed: 'Move Failed', moveFailed: 'Move failed',
groupNameExisted: 'The group name already exists', groupNameExisted: 'The group name already exists',
moreAttributeCannotSort: 'More attributes cannot be sorted. If you need to sort, add them to other groups!', moreAttributeCannotSort: 'More attributes cannot be sorted. If you need to sort, add them to other groups!',
newCIType: 'New CI Type', newCIType: 'New CI Type',
@ -172,7 +173,7 @@ export default {
associatedChildRole: 'Associated child role', associatedChildRole: 'Associated child role',
associatedSuccess: 'Associated with success', associatedSuccess: 'Associated with success',
name: 'Name', name: 'Name',
roleName: 'Role Name', roleName: 'Role name',
description: 'Desciption', description: 'Desciption',
resourceNameRequired: 'Please enter the resource name', resourceNameRequired: 'Please enter the resource name',
descriptionTip: 'Please enter description...', descriptionTip: 'Please enter description...',

View File

@ -4,6 +4,7 @@ export default {
antLocale: zhCN, antLocale: zhCN,
menu: { menu: {
preference: '我的订阅', preference: '我的订阅',
resourceViews: '资源视图',
relationViews: '关系视图', relationViews: '关系视图',
treeViews: '树状视图', treeViews: '树状视图',
batch: '批量导入', batch: '批量导入',