From cb0a4b78ee30e49c695c565ad47b9470bfc8d321 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: Mon, 24 Feb 2020 09:28:16 +0800
Subject: [PATCH] 若依 2.1
---
ruoyi-ui/src/views/system/menu/index.vue | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/ruoyi-ui/src/views/system/menu/index.vue b/ruoyi-ui/src/views/system/menu/index.vue
index b1a5cdb..9f2d04f 100644
--- a/ruoyi-ui/src/views/system/menu/index.vue
+++ b/ruoyi-ui/src/views/system/menu/index.vue
@@ -82,6 +82,7 @@
<treeselect
v-model="form.parentId"
:options="menuOptions"
+ :normalizer="normalizer"
:show-count="true"
placeholder="选择上级菜单"
/>
@@ -173,7 +174,7 @@
</template>
<script>
-import { listMenu, getMenu, treeselect, delMenu, addMenu, updateMenu } from "@/api/system/menu";
+import { listMenu, getMenu, delMenu, addMenu, updateMenu } from "@/api/system/menu";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import IconSelect from "@/components/IconSelect";
@@ -228,16 +229,27 @@
getList() {
this.loading = true;
listMenu(this.queryParams).then(response => {
- this.menuList = response.data;
+ this.menuList = this.handleTree(response.data, "menuId");
this.loading = false;
});
},
+ /** 转换菜单数据结构 */
+ normalizer(node) {
+ if (node.children && !node.children.length) {
+ delete node.children;
+ }
+ return {
+ id: node.menuId,
+ label: node.menuName,
+ children: node.children
+ };
+ },
/** 查询菜单下拉树结构 */
getTreeselect() {
- treeselect().then(response => {
+ listMenu().then(response => {
this.menuOptions = [];
- const menu = { id: 0, label: '主类目', children: [] };
- menu.children = response.data;
+ const menu = { menuId: 0, menuName: '主类目', children: [] };
+ menu.children = this.handleTree(response.data, "menuId");
this.menuOptions.push(menu);
});
},
--
Gitblit v1.9.2