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 {
|
export interface CommonTreeNode {
|
||||||
value: string;
|
value: string;
|
||||||
label: string;
|
label: string;
|
||||||
children: Array<CommonTreeNode>;
|
children?: Array<CommonTreeNode>;
|
||||||
|
isLeaf?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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',
|
||||||
|
|||||||
@@ -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()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user