fix: route
parent
cf1d3d30e6
commit
df32ffda54
|
@ -23,7 +23,8 @@ const props = defineProps({
|
||||||
immediate: { type: Boolean, default: true },
|
immediate: { type: Boolean, default: true },
|
||||||
resultField: propTypes.string.def(''),
|
resultField: propTypes.string.def(''),
|
||||||
handleTree: { type: String, default: '' },
|
handleTree: { type: String, default: '' },
|
||||||
parent: { type: String, default: '' }
|
parent: { type: String, default: '' },
|
||||||
|
parentId: { type: Number, default: 0 }
|
||||||
})
|
})
|
||||||
const emit = defineEmits(['options-change', 'change'])
|
const emit = defineEmits(['options-change', 'change'])
|
||||||
const attrs = useAttrs()
|
const attrs = useAttrs()
|
||||||
|
@ -81,8 +82,9 @@ async function fetch() {
|
||||||
result = handleTree(result, props.handleTree)
|
result = handleTree(result, props.handleTree)
|
||||||
}
|
}
|
||||||
if (props.parent) {
|
if (props.parent) {
|
||||||
treeData.value = [{ id: 0, name: props.parent, children: [] }]
|
let tree: any = { id: props.parentId, name: props.parent, children: [] }
|
||||||
treeData.value[0].children = (result as Recordable[]) || []
|
tree.children = (result as Recordable[]) || []
|
||||||
|
treeData.value.push(tree)
|
||||||
} else {
|
} else {
|
||||||
treeData.value = (result as Recordable[]) || []
|
treeData.value = (result as Recordable[]) || []
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,7 @@ export function transformObjToRoute<T = AppRouteModule>(routeList: AppRouteModul
|
||||||
path: path,
|
path: path,
|
||||||
name: route.name,
|
name: route.name,
|
||||||
component: 'IFRAME',
|
component: 'IFRAME',
|
||||||
|
sort: route.sort,
|
||||||
meta: {
|
meta: {
|
||||||
title: route.name,
|
title: route.name,
|
||||||
icon: route.icon
|
icon: route.icon
|
||||||
|
@ -113,12 +114,18 @@ export function transformObjToRoute<T = AppRouteModule>(routeList: AppRouteModul
|
||||||
if (component.toUpperCase() === 'LAYOUT') {
|
if (component.toUpperCase() === 'LAYOUT') {
|
||||||
route.component = LayoutMap.get('LAYOUT'.toUpperCase())
|
route.component = LayoutMap.get('LAYOUT'.toUpperCase())
|
||||||
const meta = route.meta || {}
|
const meta = route.meta || {}
|
||||||
|
meta.hideMenu = !route.visible
|
||||||
|
meta.orderNo = route.sort
|
||||||
|
meta.ignoreKeepAlive = !route.keepAlive
|
||||||
meta.title = route.name
|
meta.title = route.name
|
||||||
meta.icon = route.icon
|
meta.icon = route.icon
|
||||||
route.meta = meta
|
route.meta = meta
|
||||||
} else if (component.toUpperCase() === 'IFRAME') {
|
} else if (component.toUpperCase() === 'IFRAME') {
|
||||||
route.component = LayoutMap.get('IFRAME'.toUpperCase())
|
route.component = LayoutMap.get('IFRAME'.toUpperCase())
|
||||||
const meta = route.meta || {}
|
const meta = route.meta || {}
|
||||||
|
meta.hideMenu = !route.visible
|
||||||
|
meta.orderNo = route.sort
|
||||||
|
meta.ignoreKeepAlive = !route.keepAlive
|
||||||
meta.title = route.name
|
meta.title = route.name
|
||||||
meta.icon = route.icon
|
meta.icon = route.icon
|
||||||
meta.frameSrc = route.path
|
meta.frameSrc = route.path
|
||||||
|
@ -127,6 +134,9 @@ export function transformObjToRoute<T = AppRouteModule>(routeList: AppRouteModul
|
||||||
} else {
|
} else {
|
||||||
//处理顶级非目录路由
|
//处理顶级非目录路由
|
||||||
const meta = route.meta || {}
|
const meta = route.meta || {}
|
||||||
|
meta.hideMenu = !route.visible
|
||||||
|
meta.orderNo = route.sort
|
||||||
|
meta.ignoreKeepAlive = !route.keepAlive
|
||||||
meta.title = route.name
|
meta.title = route.name
|
||||||
meta.icon = route.icon
|
meta.icon = route.icon
|
||||||
meta.single = true
|
meta.single = true
|
||||||
|
|
|
@ -10,6 +10,7 @@ export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
|
||||||
visible?: boolean
|
visible?: boolean
|
||||||
icon?: string
|
icon?: string
|
||||||
name: string
|
name: string
|
||||||
|
sort: number
|
||||||
parentId?: number
|
parentId?: number
|
||||||
meta: RouteMeta
|
meta: RouteMeta
|
||||||
component?: Component | string
|
component?: Component | string
|
||||||
|
|
|
@ -80,6 +80,7 @@ export const formSchema: FormSchema[] = [
|
||||||
label: '上级菜单',
|
label: '上级菜单',
|
||||||
field: 'parentId',
|
field: 'parentId',
|
||||||
required: true,
|
required: true,
|
||||||
|
defaultValue: 0,
|
||||||
component: 'ApiTreeSelect',
|
component: 'ApiTreeSelect',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
api: () => listSimpleMenus(),
|
api: () => listSimpleMenus(),
|
||||||
|
@ -119,7 +120,8 @@ export const formSchema: FormSchema[] = [
|
||||||
label: '显示排序',
|
label: '显示排序',
|
||||||
field: 'sort',
|
field: 'sort',
|
||||||
required: true,
|
required: true,
|
||||||
component: 'Input'
|
component: 'InputNumber',
|
||||||
|
defaultValue: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '路由地址',
|
label: '路由地址',
|
||||||
|
@ -164,12 +166,10 @@ export const formSchema: FormSchema[] = [
|
||||||
{
|
{
|
||||||
label: '显示状态',
|
label: '显示状态',
|
||||||
field: 'visible',
|
field: 'visible',
|
||||||
component: 'RadioButtonGroup',
|
component: 'Switch',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
options: [
|
checkedChildren: '显示',
|
||||||
{ label: '显示', key: true, value: true },
|
unCheckedChildren: '隐藏'
|
||||||
{ label: '隐藏', key: false, value: false }
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
helpMessage: '选择隐藏时,路由将不会出现在侧边栏,但仍然可以访问',
|
helpMessage: '选择隐藏时,路由将不会出现在侧边栏,但仍然可以访问',
|
||||||
ifShow: ({ values }) => values.type !== SystemMenuTypeEnum.BUTTON
|
ifShow: ({ values }) => values.type !== SystemMenuTypeEnum.BUTTON
|
||||||
|
@ -177,12 +177,10 @@ export const formSchema: FormSchema[] = [
|
||||||
{
|
{
|
||||||
label: '总是显示',
|
label: '总是显示',
|
||||||
field: 'alwaysShow',
|
field: 'alwaysShow',
|
||||||
component: 'RadioButtonGroup',
|
component: 'Switch',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
options: [
|
checkedChildren: '显示',
|
||||||
{ label: '显示', key: true, value: true },
|
unCheckedChildren: '隐藏'
|
||||||
{ label: '隐藏', key: false, value: false }
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
helpMessage: '选择不是时,当该菜单只有一个子菜单时,不展示自己,直接展示子菜单',
|
helpMessage: '选择不是时,当该菜单只有一个子菜单时,不展示自己,直接展示子菜单',
|
||||||
ifShow: ({ values }) => values.type !== SystemMenuTypeEnum.BUTTON
|
ifShow: ({ values }) => values.type !== SystemMenuTypeEnum.BUTTON
|
||||||
|
@ -190,12 +188,10 @@ export const formSchema: FormSchema[] = [
|
||||||
{
|
{
|
||||||
label: '是否缓存',
|
label: '是否缓存',
|
||||||
field: 'keepAlive',
|
field: 'keepAlive',
|
||||||
component: 'RadioButtonGroup',
|
component: 'Switch',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
options: [
|
checkedChildren: '缓存',
|
||||||
{ label: '缓存', key: true, value: true },
|
unCheckedChildren: '不缓存'
|
||||||
{ label: '不缓存', key: false, value: false }
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
helpMessage: '选择缓存时,则会被 `keep-alive` 缓存,必须填写「组件名称」字段',
|
helpMessage: '选择缓存时,则会被 `keep-alive` 缓存,必须填写「组件名称」字段',
|
||||||
ifShow: ({ values }) => values.type === SystemMenuTypeEnum.MENU
|
ifShow: ({ values }) => values.type === SystemMenuTypeEnum.MENU
|
||||||
|
|
Loading…
Reference in New Issue