Explorar el Código

表格编辑回显遍历父级menuId

lph hace 1 año
padre
commit
4805957852
Se han modificado 1 ficheros con 11 adiciones y 5 borrados
  1. 11 5
      ruoyi-ui/src/views/tableMange/index.vue

+ 11 - 5
ruoyi-ui/src/views/tableMange/index.vue

@@ -841,6 +841,7 @@ export default {
     async getMenuList() {
       let res = await getMenuList();
       this.menus = this.handleTree(res.data, "menuId");
+      console.log(this.menus);
     },
     // 校验字段合法性(递归版)
     validateField(tableFieldList, validateParams) {
@@ -1338,6 +1339,8 @@ export default {
           this.menus,
           {}
         );
+        console.log(this.formData.routePath);
+
         if (!this.formData.routePath) {
           this.$message.warning("该表格菜单路由已经删除,请重新配置");
         }
@@ -1353,15 +1356,18 @@ export default {
     },
     // 获取父级menuId
     getParentMenuId(menuId, menus, parentItem) {
-      for (let i = 0; i < menus.length; i++) {
+      if (!menus.length) return undefined;
+      let res;
+      for (var i = 0; i < menus.length; i++) {
         let item = menus[i];
         if (item.menuId == menuId) {
-          return parentItem?.menuId;
-        } else if (item.children?.length) {
-          return this.getParentMenuId(menuId, item.children, item);
+          res = parentItem?.menuId;
+        }
+        if (item.children?.length) {
+          res = this.getParentMenuId(menuId, item.children, item);
         }
       }
-      return undefined;
+      return res;
     },
   },
   created() {},