fix: 新增菜单没有主目录 #I6Y1X2
parent
0143cd5978
commit
4ff33d87f5
|
@ -22,7 +22,8 @@ const props = defineProps({
|
||||||
params: { type: Object },
|
params: { type: Object },
|
||||||
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: '' }
|
||||||
})
|
})
|
||||||
const emit = defineEmits(['options-change', 'change'])
|
const emit = defineEmits(['options-change', 'change'])
|
||||||
const attrs = useAttrs()
|
const attrs = useAttrs()
|
||||||
|
@ -79,7 +80,13 @@ async function fetch() {
|
||||||
if (props.handleTree) {
|
if (props.handleTree) {
|
||||||
result = handleTree(result, props.handleTree)
|
result = handleTree(result, props.handleTree)
|
||||||
}
|
}
|
||||||
treeData.value = (result as Recordable[]) || []
|
if (props.parent) {
|
||||||
|
treeData.value = [{ id: 0, name: props.parent, children: [] }]
|
||||||
|
treeData.value[0].children = (result as Recordable[]) || []
|
||||||
|
} else {
|
||||||
|
treeData.value = (result as Recordable[]) || []
|
||||||
|
}
|
||||||
|
|
||||||
isFirstLoaded.value = true
|
isFirstLoaded.value = true
|
||||||
emit('options-change', treeData.value)
|
emit('options-change', treeData.value)
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,7 @@ export const formSchema: FormSchema[] = [
|
||||||
component: 'ApiTreeSelect',
|
component: 'ApiTreeSelect',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
api: () => listSimpleMenus(),
|
api: () => listSimpleMenus(),
|
||||||
|
parent: '主类目',
|
||||||
fieldNames: {
|
fieldNames: {
|
||||||
label: 'name',
|
label: 'name',
|
||||||
key: 'id',
|
key: 'id',
|
||||||
|
|
Loading…
Reference in New Issue