Commit cdeaf5b892bbf706bf365ea663203c730e6b0ad2
1 parent
00fbc7c5
feat: menu add parent
Showing
2 changed files
with
11 additions
and
5 deletions
yudao-ui-admin-vue3/src/components/UserInfo/src/UserInfo.vue
yudao-ui-admin-vue3/src/views/system/menu/index.vue
| ... | ... | @@ -42,12 +42,18 @@ const menuProps = { |
| 42 | 42 | label: 'name', |
| 43 | 43 | value: 'id' |
| 44 | 44 | } |
| 45 | -const menuOptions = ref() // 树形结构 | |
| 45 | +interface Tree { | |
| 46 | + id: number | |
| 47 | + name: string | |
| 48 | + children?: Tree[] | any[] | |
| 49 | +} | |
| 50 | +const menuOptions = ref<any[]>([]) // 树形结构 | |
| 46 | 51 | const getTree = async () => { |
| 52 | + menuOptions.value = [] | |
| 47 | 53 | const res = await MenuApi.listSimpleMenusApi() |
| 48 | - const menu = { id: 0, name: '主类目', children: [] as any[] } | |
| 54 | + let menu: Tree = { id: 0, name: '主类目', children: [] } | |
| 49 | 55 | menu.children = handleTree(res) |
| 50 | - menuOptions.value = menu | |
| 56 | + menuOptions.value.push(menu) | |
| 51 | 57 | } |
| 52 | 58 | // ========== 查询 ========== |
| 53 | 59 | const queryParams = reactive({ |
| ... | ... | @@ -268,7 +274,7 @@ onMounted(async () => { |
| 268 | 274 | node-key="id" |
| 269 | 275 | v-model="menuForm.parentId" |
| 270 | 276 | :props="menuProps" |
| 271 | - :data="menuData" | |
| 277 | + :data="menuOptions" | |
| 272 | 278 | check-strictly |
| 273 | 279 | /> |
| 274 | 280 | </el-form-item> | ... | ... |