菜单表单

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 { export interface CommonTreeNode {
value: string; value: string;
label: string; label: string;
children: Array<CommonTreeNode>; children?: Array<CommonTreeNode>;
isLeaf?: boolean;
} }

View File

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

View File

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