mirror of
https://github.com/fugary/simple-element-plus-template.git
synced 2025-11-12 14:27:49 +00:00
菜单表单
This commit is contained in:
3
src/components/public.d.ts
vendored
3
src/components/public.d.ts
vendored
@@ -18,5 +18,6 @@ export interface CommonPage {
|
||||
export interface CommonTreeNode {
|
||||
value: string;
|
||||
label: string;
|
||||
children: Array<CommonTreeNode>;
|
||||
children?: Array<CommonTreeNode>;
|
||||
isLeaf?: boolean;
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -24,9 +24,10 @@ const loadMenu = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
const menus = await loadAndParseMenus()
|
||||
selectMenus.value = menus
|
||||
onMounted(() => {
|
||||
loadAndParseMenus().then(menus => {
|
||||
selectMenus.value = menus
|
||||
})
|
||||
loadMenu()
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user