From e19e2fd9cc472f9a2c115fe8e794c3f0df468eac Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期四, 23 七月 2020 09:54:57 +0800
Subject: [PATCH] Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue

---
 ruoyi-ui/src/views/tool/gen/genInfoForm.vue                                        |   37 +++++++
 ruoyi-generator/src/main/resources/vm/sql/sql.vm                                   |    2 
 ruoyi-ui/src/utils/index.js                                                        |   13 +-
 ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java             |    6 +
 ruoyi-ui/src/views/tool/gen/importTable.vue                                        |    4 
 ruoyi-ui/src/utils/ruoyi.js                                                        |    6 
 ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java                  |    7 +
 ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java             |   28 +++++
 ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java                   |   53 ++++++++++
 ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java    |    2 
 ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java |    7 +
 ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java               |   38 +++++++
 ruoyi-ui/src/views/tool/gen/editTable.vue                                          |   13 ++
 ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java      |   24 ++++
 ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java          |   42 ++++++--
 ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java       |   11 ++
 16 files changed, 262 insertions(+), 31 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java
index 3519791..9ce5aca 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java
@@ -30,6 +30,11 @@
     public String dateFormat() default "";
 
     /**
+     * 濡傛灉鏄瓧鍏哥被鍨嬶紝璇疯缃瓧鍏哥殑type鍊�
+     */
+    public String dictType() default "";
+
+    /**
      * 璇诲彇鍐呭杞〃杈惧紡 (濡�: 0=鐢�,1=濂�,2=鏈煡)
      */
     public String readConverterExp() default "";
@@ -115,4 +120,4 @@
             return this.value;
         }
     }
-}
+}
\ No newline at end of file
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java
index 0e460c5..1f957e0 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java
@@ -22,6 +22,12 @@
     /** 鏍戝悕绉板瓧娈� */
     public static final String TREE_NAME = "treeName";
 
+    /** 涓婄骇鑿滃崟ID瀛楁 */
+    public static final String PARENT_MENU_ID = "parentMenuId";
+
+    /** 涓婄骇鑿滃崟鍚嶇О瀛楁 */
+    public static final String PARENT_MENU_NAME = "parentMenuName";
+
     /** 鏁版嵁搴撳瓧绗︿覆绫诲瀷 */
     public static final String[] COLUMNTYPE_STR = { "char", "varchar", "narchar", "varchar2", "tinytext", "text",
             "mediumtext", "longtext" };
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java
index 6fb6289..cdc6f6f 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java
@@ -2,7 +2,6 @@
 
 import java.util.Collection;
 import java.util.List;
-
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.core.domain.entity.SysDictData;
 import com.ruoyi.common.core.redis.RedisCache;
@@ -44,6 +43,58 @@
     }
 
     /**
+     * 鏍规嵁瀛楀吀绫诲瀷鍜屽瓧鍏稿�艰幏鍙栧瓧鍏告爣绛�
+     * 
+     * @param dictType 瀛楀吀绫诲瀷
+     * @param dictValue 瀛楀吀鍊�
+     * @return 瀛楀吀鏍囩
+     */
+    public static String getDictLabel(String dictType, String dictValue)
+    {
+        if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotEmpty(dictValue))
+        {
+            List<SysDictData> datas = getDictCache(dictType);
+            if (StringUtils.isNotEmpty(datas))
+            {
+                for (SysDictData dict : datas)
+                {
+                    if (dictValue.equals(dict.getDictValue()))
+                    {
+                        return dict.getDictLabel();
+                    }
+                }
+            }
+        }
+        return dictValue;
+    }
+
+    /**
+     * 鏍规嵁瀛楀吀绫诲瀷鍜屽瓧鍏告爣绛捐幏鍙栧瓧鍏稿��
+     * 
+     * @param dictType 瀛楀吀绫诲瀷
+     * @param dictLabel 瀛楀吀鏍囩
+     * @return 瀛楀吀鍊�
+     */
+    public static String getDictValue(String dictType, String dictLabel)
+    {
+        if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotEmpty(dictLabel))
+        {
+            List<SysDictData> datas = getDictCache(dictType);
+            if (StringUtils.isNotEmpty(datas))
+            {
+                for (SysDictData dict : datas)
+                {
+                    if (dictLabel.equals(dict.getDictLabel()))
+                    {
+                        return dict.getDictValue();
+                    }
+                }
+            }
+        }
+        return dictLabel;
+    }
+
+    /**
      * 娓呯┖瀛楀吀缂撳瓨
      */
     public static void clearDictCache()
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
index f4947e0..affb08f 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
@@ -50,6 +50,7 @@
 import com.ruoyi.common.core.text.Convert;
 import com.ruoyi.common.exception.CustomException;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.DictUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.reflect.ReflectUtils;
 
@@ -270,7 +271,11 @@
                         }
                         else if (StringUtils.isNotEmpty(attr.readConverterExp()))
                         {
-                            val = reverseByExp(String.valueOf(val), attr.readConverterExp());
+                            val = reverseByExp(Convert.toStr(val), attr.readConverterExp());
+                        }
+                        else if (StringUtils.isNotEmpty(attr.dictType()))
+                        {
+                            val = reverseDictByExp(attr.dictType(), Convert.toStr(val));
                         }
                         ReflectUtils.invokeSetter(entity, propertyName, val);
                     }
@@ -529,13 +534,18 @@
                 Object value = getTargetValue(vo, field, attr);
                 String dateFormat = attr.dateFormat();
                 String readConverterExp = attr.readConverterExp();
+                String dictType = attr.dictType();
                 if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
                 {
                     cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value));
                 }
                 else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
                 {
-                    cell.setCellValue(convertByExp(String.valueOf(value), readConverterExp));
+                    cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp));
+                }
+                else if (StringUtils.isNotEmpty(dictType))
+                {
+                    cell.setCellValue(convertDictByExp(dictType, Convert.toStr(value)));
                 }
                 else
                 {
@@ -667,6 +677,30 @@
     }
 
     /**
+     * 瑙f瀽瀛楀吀鍊�
+     * 
+     * @param dictType 瀛楀吀绫诲瀷
+     * @param dictValue 瀛楀吀鍊�
+     * @return 瀛楀吀鏍囩
+     */
+    public static String convertDictByExp(String dictType, String dictValue) throws Exception
+    {
+        return DictUtils.getDictLabel(dictType, dictValue);
+    }
+
+    /**
+     * 鍙嶅悜瑙f瀽鍊煎瓧鍏稿��
+     * 
+     * @param dictType 瀛楀吀绫诲瀷
+     * @param dictValue 瀛楀吀鏍囩
+     * @return 瀛楀吀鍊�
+     */
+    public static String reverseDictByExp(String dictType, String dictLabel) throws Exception
+    {
+        return DictUtils.getDictValue(dictType, dictLabel);
+    }
+
+    /**
      * 缂栫爜鏂囦欢鍚�
      */
     public String encodingFilename(String filename)
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java
index f10ea2d..7f0a629 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java
@@ -1,7 +1,11 @@
 package com.ruoyi.framework.config;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@@ -39,4 +43,24 @@
     {
         registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**");
     }
+
+    /**
+     * 璺ㄥ煙閰嶇疆
+     */
+    @Bean
+    public CorsFilter corsFilter()
+    {
+        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+        CorsConfiguration config = new CorsConfiguration();
+        config.setAllowCredentials(true);
+        // 璁剧疆璁块棶婧愬湴鍧�
+        config.addAllowedOrigin("*");
+        // 璁剧疆璁块棶婧愯姹傚ご
+        config.addAllowedHeader("*");
+        // 璁剧疆璁块棶婧愯姹傛柟娉�
+        config.addAllowedMethod("*");
+        // 瀵规帴鍙i厤缃法鍩熻缃�
+        source.registerCorsConfiguration("/**", config);
+        return new CorsFilter(source);
+    }
 }
\ No newline at end of file
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
index 32854a4..3c62330 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
@@ -12,6 +12,8 @@
 import org.springframework.security.core.userdetails.UserDetailsService;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
+import org.springframework.security.web.authentication.logout.LogoutFilter;
+import org.springframework.web.filter.CorsFilter;
 import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter;
 import com.ruoyi.framework.security.handle.AuthenticationEntryPointImpl;
 import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl;
@@ -47,6 +49,12 @@
      */
     @Autowired
     private JwtAuthenticationTokenFilter authenticationTokenFilter;
+
+    /**
+     * 璺ㄥ煙杩囨护鍣�
+     */
+    @Autowired
+    private CorsFilter corsFilter;
     
     /**
      * 瑙e喅 鏃犳硶鐩存帴娉ㄥ叆 AuthenticationManager
@@ -112,6 +120,9 @@
         httpSecurity.logout().logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler);
         // 娣诲姞JWT filter
         httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
+        // 娣诲姞CORS filter
+        httpSecurity.addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class);
+        httpSecurity.addFilterBefore(corsFilter, LogoutFilter.class);
     }
 
     
diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java
index ab787dd..9c64782 100644
--- a/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java
+++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java
@@ -178,6 +178,8 @@
     private void genCode(HttpServletResponse response, byte[] data) throws IOException
     {
         response.reset();
+        response.addHeader("Access-Control-Allow-Origin", "*");
+        response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
         response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\"");
         response.addHeader("Content-Length", "" + data.length);
         response.setContentType("application/octet-stream; charset=UTF-8");
diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java
index fd3ee83..56acaf8 100644
--- a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java
+++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java
@@ -74,6 +74,12 @@
     /** 鏍戝悕绉板瓧娈� */
     private String treeName;
 
+    /** 涓婄骇鑿滃崟ID瀛楁 */
+    private String parentMenuId;
+
+    /** 涓婄骇鑿滃崟鍚嶇О瀛楁 */
+    private String parentMenuName;
+
     public Long getTableId()
     {
         return tableId;
@@ -234,6 +240,26 @@
         this.treeName = treeName;
     }
 
+    public String getParentMenuId()
+    {
+        return parentMenuId;
+    }
+
+    public void setParentMenuId(String parentMenuId)
+    {
+        this.parentMenuId = parentMenuId;
+    }
+
+    public String getParentMenuName()
+    {
+        return parentMenuName;
+    }
+
+    public void setParentMenuName(String parentMenuName)
+    {
+        this.parentMenuName = parentMenuName;
+    }
+
     public boolean isTree()
     {
         return isTree(this.tplCategory);
@@ -268,4 +294,4 @@
         }
         return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY);
     }
-}
+}
\ No newline at end of file
diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
index 1157d06..0aa26ff 100644
--- a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
+++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
@@ -337,9 +337,14 @@
             String treeCode = paramsObj.getString(GenConstants.TREE_CODE);
             String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE);
             String treeName = paramsObj.getString(GenConstants.TREE_NAME);
+            String parentMenuId = paramsObj.getString(GenConstants.PARENT_MENU_ID);
+            String parentMenuName = paramsObj.getString(GenConstants.PARENT_MENU_NAME);
+            
             genTable.setTreeCode(treeCode);
             genTable.setTreeParentCode(treeParentCode);
             genTable.setTreeName(treeName);
+            genTable.setParentMenuId(parentMenuId);
+            genTable.setParentMenuName(parentMenuName);
         }
     }
-}
+}
\ No newline at end of file
diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
index 42e4984..20fd1da 100644
--- a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
+++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
@@ -11,18 +11,16 @@
 import com.ruoyi.generator.domain.GenTable;
 import com.ruoyi.generator.domain.GenTableColumn;
 
-/**
- * 浠g爜鐢熸垚妯℃澘澶勭悊
- * 
- * @author ruoyi
- */
 public class VelocityUtils
 {
     /** 椤圭洰绌洪棿璺緞 */
     private static final String PROJECT_PATH = "main/java";
 
     /** mybatis绌洪棿璺緞 */
-    private static final String MYBATIS_PATH = "main/resources/mapper";
+    private static final String MYBATIS_PATH = "main/resources/mybatis";
+
+    /** 榛樿涓婄骇鑿滃崟锛岀郴缁熷伐鍏� */
+    private static final String DEFAULT_PARENT_MENU_ID = "3";
 
     /**
      * 璁剧疆妯℃澘鍙橀噺淇℃伅
@@ -55,11 +53,20 @@
         velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
         velocityContext.put("columns", genTable.getColumns());
         velocityContext.put("table", genTable);
+        setMenuVelocityContext(velocityContext, genTable);
         if (GenConstants.TPL_TREE.equals(tplCategory))
         {
             setTreeVelocityContext(velocityContext, genTable);
         }
         return velocityContext;
+    }
+
+    public static void setMenuVelocityContext(VelocityContext context, GenTable genTable)
+    {
+        String options = genTable.getOptions();
+        JSONObject paramsObj = JSONObject.parseObject(options);
+        String parentMenuId = getParentMenuId(paramsObj);
+        context.put("parentMenuId", parentMenuId);
     }
 
     public static void setTreeVelocityContext(VelocityContext context, GenTable genTable)
@@ -225,6 +232,21 @@
     }
 
     /**
+     * 鑾峰彇涓婄骇鑿滃崟ID瀛楁
+     * 
+     * @param options 鐢熸垚鍏朵粬閫夐」
+     * @return 涓婄骇鑿滃崟ID瀛楁
+     */
+    public static String getParentMenuId(JSONObject paramsObj)
+    {
+        if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID))
+        {
+            return paramsObj.getString(GenConstants.PARENT_MENU_ID);
+        }
+        return DEFAULT_PARENT_MENU_ID;
+    }
+
+    /**
      * 鑾峰彇鏍戠紪鐮�
      * 
      * @param options 鐢熸垚鍏朵粬閫夐」
@@ -236,7 +258,7 @@
         {
             return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE));
         }
-        return "";
+        return StringUtils.EMPTY;
     }
 
     /**
@@ -251,7 +273,7 @@
         {
             return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
         }
-        return "";
+        return StringUtils.EMPTY;
     }
 
     /**
@@ -266,7 +288,7 @@
         {
             return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
         }
-        return "";
+        return StringUtils.EMPTY;
     }
 
     /**
@@ -295,4 +317,4 @@
         }
         return num;
     }
-}
+}
\ No newline at end of file
diff --git a/ruoyi-generator/src/main/resources/vm/sql/sql.vm b/ruoyi-generator/src/main/resources/vm/sql/sql.vm
index 5ceea08..bfd7194 100644
--- a/ruoyi-generator/src/main/resources/vm/sql/sql.vm
+++ b/ruoyi-generator/src/main/resources/vm/sql/sql.vm
@@ -1,6 +1,6 @@
 -- 鑿滃崟 SQL
 insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
-values('${functionName}', '3', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${functionName}鑿滃崟');
+values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${functionName}鑿滃崟');
 
 -- 鎸夐挳鐖惰彍鍗旾D
 SELECT @parentId := LAST_INSERT_ID();
diff --git a/ruoyi-ui/src/utils/index.js b/ruoyi-ui/src/utils/index.js
index ad317bd..918580f 100644
--- a/ruoyi-ui/src/utils/index.js
+++ b/ruoyi-ui/src/utils/index.js
@@ -1,14 +1,16 @@
+import { parseTime } from './ruoyi'
+
 /**
  * 琛ㄦ牸鏃堕棿鏍煎紡鍖�
  */
 export function formatDate(cellValue) {
   if (cellValue == null || cellValue == "") return "";
-  var date = new Date(cellValue)
+  var date = new Date(cellValue) 
   var year = date.getFullYear()
   var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
-  var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
-  var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
-  var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
+  var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate() 
+  var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours() 
+  var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes() 
   var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
   return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds
 }
@@ -328,7 +330,7 @@
     ? val => map[val.toLowerCase()]
     : val => map[val]
 }
-
+ 
 export const exportDefault = 'export default '
 
 export const beautifierConf = {
@@ -385,3 +387,4 @@
 export function isNumberStr(str) {
   return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str)
 }
+ 
diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js
index 4d63f96..2388082 100644
--- a/ruoyi-ui/src/utils/ruoyi.js
+++ b/ruoyi-ui/src/utils/ruoyi.js
@@ -68,10 +68,10 @@
 // 鍥炴樉鏁版嵁瀛楀吀
 export function selectDictLabel(datas, value) {
 	var actions = [];
-	Object.keys(datas).map((key) => {
+	Object.keys(datas).some((key) => {
 		if (datas[key].dictValue == ('' + value)) {
 			actions.push(datas[key].dictLabel);
-			return false;
+			return true;
 		}
 	})
 	return actions.join('');
@@ -131,4 +131,4 @@
 	});
 	return treeData != '' ? treeData : data;
   }
-  
\ No newline at end of file
+  
diff --git a/ruoyi-ui/src/views/tool/gen/editTable.vue b/ruoyi-ui/src/views/tool/gen/editTable.vue
index 39a8c66..f1ce9d7 100644
--- a/ruoyi-ui/src/views/tool/gen/editTable.vue
+++ b/ruoyi-ui/src/views/tool/gen/editTable.vue
@@ -110,7 +110,7 @@
         </el-table>
       </el-tab-pane>
       <el-tab-pane label="鐢熸垚淇℃伅" name="genInfo">
-        <gen-info-form ref="genInfo" :info="info" />
+        <gen-info-form ref="genInfo" :info="info" :menus="menus"/>
       </el-tab-pane>
     </el-tabs>
     <el-form label-width="100px">
@@ -124,9 +124,11 @@
 <script>
 import { getGenTable, updateGenTable } from "@/api/tool/gen";
 import { optionselect as getDictOptionselect } from "@/api/system/dict/type";
+import { listMenu as getMenuTreeselect } from "@/api/system/menu";
 import basicInfoForm from "./basicInfoForm";
 import genInfoForm from "./genInfoForm";
 import Sortable from 'sortablejs'
+
 export default {
   name: "GenEdit",
   components: {
@@ -143,6 +145,8 @@
       cloumns: [],
       // 瀛楀吀淇℃伅
       dictOptions: [],
+      // 鑿滃崟淇℃伅
+      menus: [],
       // 琛ㄨ缁嗕俊鎭�
       info: {}
     };
@@ -159,6 +163,10 @@
       getDictOptionselect().then(response => {
         this.dictOptions = response.data;
       });
+      /** 鏌ヨ鑿滃崟涓嬫媺鍒楄〃 */
+      getMenuTreeselect().then(response => {
+        this.menus = this.handleTree(response.data, "menuId");
+      });
     }
   },
   methods: {
@@ -174,7 +182,8 @@
           genTable.params = {
             treeCode: genTable.treeCode,
             treeName: genTable.treeName,
-            treeParentCode: genTable.treeParentCode
+            treeParentCode: genTable.treeParentCode,
+            parentMenuId: genTable.parentMenuId
           };
           updateGenTable(genTable).then(res => {
             this.msgSuccess(res.msg);
diff --git a/ruoyi-ui/src/views/tool/gen/genInfoForm.vue b/ruoyi-ui/src/views/tool/gen/genInfoForm.vue
index 9cb3139..c23e7e0 100644
--- a/ruoyi-ui/src/views/tool/gen/genInfoForm.vue
+++ b/ruoyi-ui/src/views/tool/gen/genInfoForm.vue
@@ -58,6 +58,18 @@
           <el-input v-model="info.functionName" />
         </el-form-item>
       </el-col>
+
+      <el-col :span="12">
+        <el-form-item prop="functionName">
+          <span slot="label">
+            涓婄骇鑿滃崟
+            <el-tooltip content="鍒嗛厤鍒版寚瀹氳彍鍗曚笅锛屼緥濡� 绯荤粺绠$悊" placement="top">
+              <i class="el-icon-question"></i>
+            </el-tooltip>
+          </span>
+          <treeselect :append-to-body="true" v-model="info.parentMenuId" :options="menus" :normalizer="normalizer" :show-count="true" placeholder="璇烽�夋嫨绯荤粺鑿滃崟"/>
+        </el-form-item>
+      </el-col>
     </el-row>
 
     <el-row v-show="info.tplCategory == 'tree'">
@@ -120,13 +132,21 @@
   </el-form>
 </template>
 <script>
+import Treeselect from "@riophae/vue-treeselect";
+import "@riophae/vue-treeselect/dist/vue-treeselect.css";
+
 export default {
   name: "BasicInfoForm",
+  components: { Treeselect },
   props: {
     info: {
       type: Object,
       default: null
-    }
+    },
+    menus: {
+      type: Array,
+      default: []
+    },
   },
   data() {
     return {
@@ -149,6 +169,19 @@
       }
     };
   },
-  created() {}
+  created() {},
+  methods: {
+    /** 杞崲鑿滃崟鏁版嵁缁撴瀯 */
+    normalizer(node) {
+      if (node.children && !node.children.length) {
+        delete node.children;
+      }
+      return {
+        id: node.menuId,
+        label: node.menuName,
+        children: node.children
+      };
+    }
+  }
 };
 </script>
diff --git a/ruoyi-ui/src/views/tool/gen/importTable.vue b/ruoyi-ui/src/views/tool/gen/importTable.vue
index a2a8a4d..56b2c0c 100644
--- a/ruoyi-ui/src/views/tool/gen/importTable.vue
+++ b/ruoyi-ui/src/views/tool/gen/importTable.vue
@@ -28,8 +28,8 @@
     <el-row>
       <el-table @row-click="clickRow" ref="table" :data="dbTableList" @selection-change="handleSelectionChange" height="260px">
         <el-table-column type="selection" width="55"></el-table-column>
-        <el-table-column prop="tableName" label="琛ㄥ悕绉�"></el-table-column>
-        <el-table-column prop="tableComment" label="琛ㄦ弿杩�"></el-table-column>
+        <el-table-column prop="tableName" label="琛ㄥ悕绉�" :show-overflow-tooltip="true"></el-table-column>
+        <el-table-column prop="tableComment" label="琛ㄦ弿杩�" :show-overflow-tooltip="true"></el-table-column>
         <el-table-column prop="createTime" label="鍒涘缓鏃堕棿"></el-table-column>
         <el-table-column prop="updateTime" label="鏇存柊鏃堕棿"></el-table-column>
       </el-table>

--
Gitblit v1.9.3