菜单表单

This commit is contained in:
Gary Fu
2024-01-07 16:13:02 +08:00
parent 8bd8cbe46a
commit e58982688c
3 changed files with 14 additions and 5 deletions

View File

@@ -18,5 +18,6 @@ export interface CommonPage {
export interface CommonTreeNode {
value: string;
label: string;
children: Array<CommonTreeNode>;
children?: Array<CommonTreeNode>;
isLeaf?: boolean;
}

View File

@@ -28,6 +28,11 @@ export const loadMenuResult = (id, config) => {
* @return {[CommonFormOption]}
*/
export const useMenuFormOptions = (menus) => {
/**
* @type {CommonTreeNode[]}
*/
const treeData = menus ? menus.map(menu2TreeMenu) : []
const defaultExpandedKeys = treeData.map(node => node.value)
return [{
labelKey: 'menu.label.menuNameCn',
prop: 'nameCn',
@@ -41,7 +46,9 @@ export const useMenuFormOptions = (menus) => {
prop: 'parentId',
type: 'tree-select',
attrs: {
data: menus ? menus.map(menu2TreeMenu) : []
checkStrictly: true,
defaultExpandedKeys,
data: treeData
}
}, {
labelKey: 'menu.label.menuIcon',

View File

@@ -24,9 +24,10 @@ const loadMenu = async () => {
}
}
onMounted(async () => {
const menus = await loadAndParseMenus()
selectMenus.value = menus
onMounted(() => {
loadAndParseMenus().then(menus => {
selectMenus.value = menus
})
loadMenu()
})