From 684eadbcc63b369c9ae2e494fb5890fc62245e82 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期一, 11 一月 2021 09:58:41 +0800 Subject: [PATCH] Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue --- ruoyi-ui/src/views/tool/gen/genInfoForm.vue | 85 +++++++ ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java | 3 ruoyi-ui/src/views/tool/gen/index.vue | 2 ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm | 22 +- ruoyi-ui/src/views/system/user/index.vue | 28 + ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java | 51 ++++ ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java | 7 pom.xml | 2 ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java | 7 ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java | 2 ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java | 83 ++++++- ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java | 2 ruoyi-ui/src/views/tool/gen/editTable.vue | 5 ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java | 43 +++ ruoyi-generator/src/main/resources/vm/java/controller.java.vm | 4 ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java | 2 ruoyi-generator/src/main/resources/vm/vue/index.vue.vm | 91 +++++++ ruoyi-ui/src/components/RightToolbar/index.vue | 50 ++++ ruoyi-generator/src/main/resources/vm/java/sub-domain.java.vm | 76 ++++++ /dev/null | 3 sql/ry_20210108.sql | 2 ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm | 4 ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java | 7 ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml | 56 +++-- ruoyi-ui/src/components/FileUpload/index.vue | 1 25 files changed, 551 insertions(+), 87 deletions(-) diff --git a/pom.xml b/pom.xml index 3d70c1c..6f0d739 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version> - <druid.version>1.2.2</druid.version> + <druid.version>1.2.4</druid.version> <bitwalker.version>1.21</bitwalker.version> <swagger.version>2.9.2</swagger.version> <kaptcha.version>2.3.2</kaptcha.version> 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 6baaa8c..1fa328e 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 @@ -13,6 +13,9 @@ /** 鏍戣〃锛堝鍒犳敼鏌ワ級 */ public static final String TPL_TREE = "tree"; + /** 涓诲瓙琛紙澧炲垹鏀规煡锛� */ + public static final String TPL_SUB = "sub"; + /** 鏍戠紪鐮佸瓧娈� */ public static final String TREE_CODE = "treeCode"; 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 b1f36af..dcba68e 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 @@ -1059,7 +1059,7 @@ } else { - if ((Double) val % 1 > 0) + if ((Double) val % 1 != 0) { val = new BigDecimal(val.toString()); } 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 548b4b5..8195206 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 @@ -63,10 +63,12 @@ public AjaxResult getInfo(@PathVariable Long talbleId) { GenTable table = genTableService.selectGenTableById(talbleId); + List<GenTable> tables = genTableService.selectGenTableAll(); List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(talbleId); Map<String, Object> map = new HashMap<String, Object>(); map.put("info", table); map.put("rows", list); + map.put("tables", tables); return AjaxResult.success(map); } 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 f52dce5..269779c 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 @@ -28,11 +28,17 @@ @NotBlank(message = "琛ㄦ弿杩颁笉鑳戒负绌�") private String tableComment; + /** 鍏宠仈鐖惰〃鐨勮〃鍚� */ + private String subTableName; + + /** 鏈〃鍏宠仈鐖惰〃鐨勫閿悕 */ + private String subTableFkName; + /** 瀹炰綋绫诲悕绉�(棣栧瓧姣嶅ぇ鍐�) */ @NotBlank(message = "瀹炰綋绫诲悕绉颁笉鑳戒负绌�") private String className; - /** 浣跨敤鐨勬ā鏉匡紙crud鍗曡〃鎿嶄綔 tree鏍戣〃鎿嶄綔锛� */ + /** 浣跨敤鐨勬ā鏉匡紙crud鍗曡〃鎿嶄綔 tree鏍戣〃鎿嶄綔 sub涓诲瓙琛ㄦ搷浣滐級 */ private String tplCategory; /** 鐢熸垚鍖呰矾寰� */ @@ -63,6 +69,9 @@ /** 涓婚敭淇℃伅 */ private GenTableColumn pkColumn; + + /** 瀛愯〃淇℃伅 */ + private GenTable subTable; /** 琛ㄥ垪淇℃伅 */ @Valid @@ -114,6 +123,26 @@ public void setTableComment(String tableComment) { this.tableComment = tableComment; + } + + public String getSubTableName() + { + return subTableName; + } + + public void setSubTableName(String subTableName) + { + this.subTableName = subTableName; + } + + public String getSubTableFkName() + { + return subTableFkName; + } + + public void setSubTableFkName(String subTableFkName) + { + this.subTableFkName = subTableFkName; } public String getClassName() @@ -216,6 +245,16 @@ this.pkColumn = pkColumn; } + public GenTable getSubTable() + { + return subTable; + } + + public void setSubTable(GenTable subTable) + { + this.subTable = subTable; + } + public List<GenTableColumn> getColumns() { return columns; @@ -286,6 +325,16 @@ this.parentMenuName = parentMenuName; } + public boolean isSub() + { + return isSub(this.tplCategory); + } + + public static boolean isSub(String tplCategory) + { + return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory); + } + public boolean isTree() { return isTree(this.tplCategory); diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java index 23b069a..d1733b6 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java @@ -59,7 +59,7 @@ /** 鏌ヨ鏂瑰紡锛圗Q绛変簬銆丯E涓嶇瓑浜庛�丟T澶т簬銆丩T灏忎簬銆丩IKE妯$硦銆丅ETWEEN鑼冨洿锛� */ private String queryType; - /** 鏄剧ず绫诲瀷锛坕nput鏂囨湰妗嗐�乼extarea鏂囨湰鍩熴�乻elect涓嬫媺妗嗐�乧heckbox澶嶉�夋銆乺adio鍗曢�夋銆乨atetime鏃ユ湡鎺т欢銆乽pload涓婁紶鎺т欢銆乪ditor瀵屾枃鏈帶浠讹級 */ + /** 鏄剧ず绫诲瀷锛坕nput鏂囨湰妗嗐�乼extarea鏂囨湰鍩熴�乻elect涓嬫媺妗嗐�乧heckbox澶嶉�夋銆乺adio鍗曢�夋銆乨atetime鏃ユ湡鎺т欢銆乮mage鍥剧墖涓婁紶鎺т欢銆乽pload鏂囦欢涓婁紶鎺т欢銆乪ditor瀵屾枃鏈帶浠讹級 */ private String htmlType; /** 瀛楀吀绫诲瀷 */ @@ -138,6 +138,11 @@ return javaField; } + public String getCapJavaField() + { + return StringUtils.capitalize(javaField); + } + public void setIsPk(String isPk) { this.isPk = isPk; diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java index 6e89354..cb27509 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java @@ -35,6 +35,13 @@ public List<GenTable> selectDbTableListByNames(String[] tableNames); /** + * 鏌ヨ鎵�鏈夎〃淇℃伅 + * + * @return 琛ㄤ俊鎭泦鍚� + */ + public List<GenTable> selectGenTableAll(); + + /** * 鏌ヨ琛↖D涓氬姟淇℃伅 * * @param id 涓氬姟ID 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 91f7418..796b545 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 @@ -103,6 +103,17 @@ } /** + * 鏌ヨ鎵�鏈夎〃淇℃伅 + * + * @return 琛ㄤ俊鎭泦鍚� + */ + @Override + public List<GenTable> selectGenTableAll() + { + return genTableMapper.selectGenTableAll(); + } + + /** * 淇敼涓氬姟 * * @param genTable 涓氬姟淇℃伅 @@ -185,9 +196,10 @@ Map<String, String> dataMap = new LinkedHashMap<>(); // 鏌ヨ琛ㄤ俊鎭� GenTable table = genTableMapper.selectGenTableById(tableId); - // 鏌ヨ鍒椾俊鎭� - List<GenTableColumn> columns = table.getColumns(); - setPkColumn(table, columns); + // 璁剧疆涓诲瓙琛ㄤ俊鎭� + setSubTable(table); + // 璁剧疆涓婚敭鍒椾俊鎭� + setPkColumn(table); VelocityInitializer.initVelocity(); VelocityContext context = VelocityUtils.prepareContext(table); @@ -231,9 +243,10 @@ { // 鏌ヨ琛ㄤ俊鎭� GenTable table = genTableMapper.selectGenTableByName(tableName); - // 鏌ヨ鍒椾俊鎭� - List<GenTableColumn> columns = table.getColumns(); - setPkColumn(table, columns); + // 璁剧疆涓诲瓙琛ㄤ俊鎭� + setSubTable(table); + // 璁剧疆涓婚敭鍒椾俊鎭� + setPkColumn(table); VelocityInitializer.initVelocity(); @@ -276,6 +289,10 @@ List<String> tableColumnNames = tableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); + if (StringUtils.isEmpty(dbTableColumns)) + { + throw new CustomException("鍚屾鏁版嵁澶辫触锛屽師琛ㄧ粨鏋勪笉瀛樺湪"); + } List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); dbTableColumns.forEach(column -> { @@ -319,9 +336,10 @@ { // 鏌ヨ琛ㄤ俊鎭� GenTable table = genTableMapper.selectGenTableByName(tableName); - // 鏌ヨ鍒椾俊鎭� - List<GenTableColumn> columns = table.getColumns(); - setPkColumn(table, columns); + // 璁剧疆涓诲瓙琛ㄤ俊鎭� + setSubTable(table); + // 璁剧疆涓婚敭鍒椾俊鎭� + setPkColumn(table); VelocityInitializer.initVelocity(); @@ -375,6 +393,17 @@ { throw new CustomException("鏍戝悕绉板瓧娈典笉鑳戒负绌�"); } + else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) + { + if (StringUtils.isEmpty(genTable.getSubTableName())) + { + throw new CustomException("鍏宠仈瀛愯〃鐨勮〃鍚嶄笉鑳戒负绌�"); + } + else if (StringUtils.isEmpty(genTable.getSubTableFkName())) + { + throw new CustomException("瀛愯〃鍏宠仈鐨勫閿悕涓嶈兘涓虹┖"); + } + } } } @@ -382,11 +411,10 @@ * 璁剧疆涓婚敭鍒椾俊鎭� * * @param table 涓氬姟琛ㄤ俊鎭� - * @param columns 涓氬姟瀛楁鍒楄〃 */ - public void setPkColumn(GenTable table, List<GenTableColumn> columns) + public void setPkColumn(GenTable table) { - for (GenTableColumn column : columns) + for (GenTableColumn column : table.getColumns()) { if (column.isPk()) { @@ -396,7 +424,36 @@ } if (StringUtils.isNull(table.getPkColumn())) { - table.setPkColumn(columns.get(0)); + table.setPkColumn(table.getColumns().get(0)); + } + if (GenConstants.TPL_SUB.equals(table.getTplCategory())) + { + for (GenTableColumn column : table.getSubTable().getColumns()) + { + if (column.isPk()) + { + table.getSubTable().setPkColumn(column); + break; + } + } + if (StringUtils.isNull(table.getSubTable().getPkColumn())) + { + table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0)); + } + } + } + + /** + * 璁剧疆涓诲瓙琛ㄤ俊鎭� + * + * @param table 涓氬姟琛ㄤ俊鎭� + */ + public void setSubTable(GenTable table) + { + String subTableName = table.getSubTableName(); + if (StringUtils.isNotEmpty(subTableName)) + { + table.setSubTable(genTableMapper.selectGenTableByName(subTableName)); } } diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java index 0b2377a..e6267cb 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java @@ -36,6 +36,13 @@ public List<GenTable> selectDbTableListByNames(String[] tableNames); /** + * 鏌ヨ鎵�鏈夎〃淇℃伅 + * + * @return 琛ㄤ俊鎭泦鍚� + */ + public List<GenTable> selectGenTableAll(); + + /** * 鏌ヨ涓氬姟淇℃伅 * * @param id 涓氬姟ID diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java index 032beaf..3b7b3a1 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java @@ -7,7 +7,7 @@ /** * VelocityEngine宸ュ巶 * - * @author RuoYi + * @author ruoyi */ public class VelocityInitializer { 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 091a956..12702b7 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 @@ -54,7 +54,7 @@ velocityContext.put("author", genTable.getFunctionAuthor()); velocityContext.put("datetime", DateUtils.getDate()); velocityContext.put("pkColumn", genTable.getPkColumn()); - velocityContext.put("importList", getImportList(genTable.getColumns())); + velocityContext.put("importList", getImportList(genTable)); velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName)); velocityContext.put("columns", genTable.getColumns()); velocityContext.put("table", genTable); @@ -62,6 +62,10 @@ if (GenConstants.TPL_TREE.equals(tplCategory)) { setTreeVelocityContext(velocityContext, genTable); + } + if (GenConstants.TPL_SUB.equals(tplCategory)) + { + setSubVelocityContext(velocityContext, genTable); } return velocityContext; } @@ -96,6 +100,24 @@ } } + public static void setSubVelocityContext(VelocityContext context, GenTable genTable) + { + GenTable subTable = genTable.getSubTable(); + String subTableName = genTable.getSubTableName(); + String subTableFkName = genTable.getSubTableFkName(); + String subClassName = genTable.getSubTable().getClassName(); + String subTableFkClassName = StringUtils.convertToCamelCase(subTableFkName); + + context.put("subTable", subTable); + context.put("subTableName", subTableName); + context.put("subTableFkName", subTableFkName); + context.put("subTableFkClassName", subTableFkClassName); + context.put("subTableFkclassName", StringUtils.uncapitalize(subTableFkClassName)); + context.put("subClassName", subClassName); + context.put("subclassName", StringUtils.uncapitalize(subClassName)); + context.put("subImportList", getImportList(genTable.getSubTable())); + } + /** * 鑾峰彇妯℃澘淇℃伅 * @@ -119,6 +141,11 @@ else if (GenConstants.TPL_TREE.equals(tplCategory)) { templates.add("vm/vue/index-tree.vue.vm"); + } + else if (GenConstants.TPL_SUB.equals(tplCategory)) + { + templates.add("vm/vue/index.vue.vm"); + templates.add("vm/java/sub-domain.java.vm"); } return templates; } @@ -146,6 +173,10 @@ if (template.contains("domain.java.vm")) { fileName = StringUtils.format("{}/domain/{}.java", javaPath, className); + } + if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) + { + fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName()); } else if (template.contains("mapper.java.vm")) { @@ -202,12 +233,18 @@ /** * 鏍规嵁鍒楃被鍨嬭幏鍙栧鍏ュ寘 * - * @param columns 鍒楅泦鍚� + * @param genTable 涓氬姟琛ㄥ璞� * @return 杩斿洖闇�瑕佸鍏ョ殑鍖呭垪琛� */ - public static HashSet<String> getImportList(List<GenTableColumn> columns) + public static HashSet<String> getImportList(GenTable genTable) { + List<GenTableColumn> columns = genTable.getColumns(); + GenTable subGenTable = genTable.getSubTable(); HashSet<String> importList = new HashSet<String>(); + if (StringUtils.isNotNull(subGenTable)) + { + importList.add("java.util.List"); + } for (GenTableColumn column : columns) { if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType())) diff --git a/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml b/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml index 8a93c77..528e925 100644 --- a/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml +++ b/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml @@ -5,24 +5,26 @@ <mapper namespace="com.ruoyi.generator.mapper.GenTableMapper"> <resultMap type="GenTable" id="GenTableResult"> - <id property="tableId" column="table_id" /> - <result property="tableName" column="table_name" /> - <result property="tableComment" column="table_comment" /> - <result property="className" column="class_name" /> - <result property="tplCategory" column="tpl_category" /> - <result property="packageName" column="package_name" /> - <result property="moduleName" column="module_name" /> - <result property="businessName" column="business_name" /> - <result property="functionName" column="function_name" /> - <result property="functionAuthor" column="function_author" /> - <result property="genType" column="gen_type" /> - <result property="genPath" column="gen_path" /> - <result property="options" column="options" /> - <result property="createBy" column="create_by" /> - <result property="createTime" column="create_time" /> - <result property="updateBy" column="update_by" /> - <result property="updateTime" column="update_time" /> - <result property="remark" column="remark" /> + <id property="tableId" column="table_id" /> + <result property="tableName" column="table_name" /> + <result property="tableComment" column="table_comment" /> + <result property="subTableName" column="sub_table_name" /> + <result property="subTableFkName" column="sub_table_fk_name" /> + <result property="className" column="class_name" /> + <result property="tplCategory" column="tpl_category" /> + <result property="packageName" column="package_name" /> + <result property="moduleName" column="module_name" /> + <result property="businessName" column="business_name" /> + <result property="functionName" column="function_name" /> + <result property="functionAuthor" column="function_author" /> + <result property="genType" column="gen_type" /> + <result property="genPath" column="gen_path" /> + <result property="options" column="options" /> + <result property="createBy" column="create_by" /> + <result property="createTime" column="create_time" /> + <result property="updateBy" column="update_by" /> + <result property="updateTime" column="update_time" /> + <result property="remark" column="remark" /> <collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" /> </resultMap> @@ -52,7 +54,7 @@ </resultMap> <sql id="selectGenTableVo"> - select table_id, table_name, table_comment, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table + select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table </sql> <select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult"> @@ -108,7 +110,7 @@ </select> <select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult"> - SELECT t.table_id, t.table_name, t.table_comment, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, + SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort FROM gen_table t LEFT JOIN gen_table_column c ON t.table_id = c.table_id @@ -116,13 +118,21 @@ </select> <select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult"> - SELECT t.table_id, t.table_name, t.table_comment, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, + SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort FROM gen_table t LEFT JOIN gen_table_column c ON t.table_id = c.table_id where t.table_name = #{tableName} order by c.sort </select> - + + <select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult"> + SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark, + c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort + FROM gen_table t + LEFT JOIN gen_table_column c ON t.table_id = c.table_id + order by c.sort + </select> + <insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId"> insert into gen_table ( <if test="tableName != null">table_name,</if> @@ -162,6 +172,8 @@ <set> <if test="tableName != null">table_name = #{tableName},</if> <if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if> + <if test="subTableName != null">sub_table_name = #{subTableName},</if> + <if test="subTableFkName != null">sub_table_fk_name = #{subTableFkName},</if> <if test="className != null and className != ''">class_name = #{className},</if> <if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if> <if test="genType != null and genType != ''">gen_type = #{genType},</if> diff --git a/ruoyi-generator/src/main/resources/vm/java/controller.java.vm b/ruoyi-generator/src/main/resources/vm/java/controller.java.vm index 56e1bd7..4e4309d 100644 --- a/ruoyi-generator/src/main/resources/vm/java/controller.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/controller.java.vm @@ -21,7 +21,7 @@ import ${packageName}.domain.${ClassName}; import ${packageName}.service.I${ClassName}Service; import com.ruoyi.common.utils.poi.ExcelUtil; -#if($table.crud) +#if($table.crud || $table.sub) import com.ruoyi.common.core.page.TableDataInfo; #elseif($table.tree) #end @@ -44,7 +44,7 @@ */ @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')") @GetMapping("/list") -#if($table.crud) +#if($table.crud || $table.sub) public TableDataInfo list(${ClassName} ${className}) { startPage(); List<${ClassName}> list = i${ClassName}Service.queryList(${className}); diff --git a/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm b/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm index ecb3436..f149763 100644 --- a/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm @@ -32,51 +32,51 @@ #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) #if($column.query) #if($column.queryType == "EQ") -#if($javaType == 'String') +#if($javaType == 'String') if (StringUtils.isNotBlank(${className}.get$AttrName())){ lqw.eq(${ClassName}::get$AttrName ,${className}.get$AttrName()); } -#else +#else if (${className}.get$AttrName() != null){ lqw.eq(${ClassName}::get$AttrName ,${className}.get$AttrName()); } #end #elseif($queryType == "NE") -#if($javaType == 'String') +#if($javaType == 'String') if (StringUtils.isNotBlank(${className}.get$AttrName())){ lqw.ne(${ClassName}::get$AttrName ,${className}.get$AttrName()); } -#else +#else if (${className}.get$AttrName() != null){ lqw.ne(${ClassName}::get$AttrName ,${className}.get$AttrName()); } -#end +#end #elseif($queryType == "GT") -#if($javaType == 'String') +#if($javaType == 'String') if (StringUtils.isNotBlank(${className}.get$AttrName())){ lqw.gt(${ClassName}::get$AttrName ,${className}.get$AttrName()); } -#else +#else if (${className}.get$AttrName() != null){ lqw.gt(${ClassName}::get$AttrName ,${className}.get$AttrName()); } #end #elseif($queryType == "GTE") -#if($javaType == 'String') +#if($javaType == 'String') if (StringUtils.isNotBlank(${className}.get$AttrName())){ lqw.ge(${ClassName}::get$AttrName ,${className}.get$AttrName()); } -#else +#else if (${className}.get$AttrName() != null){ lqw.ge(${ClassName}::get$AttrName ,${className}.get$AttrName()); } #end #elseif($queryType == "LT") -#if($javaType == 'String') +#if($javaType == 'String') if (StringUtils.isNotBlank(${className}.get$AttrName())){ lqw.lt(${ClassName}::get$AttrName ,${className}.get$AttrName()); } -#else +#else if (${className}.get$AttrName() != null){ lqw.lt(${ClassName}::get$AttrName ,${className}.get$AttrName()); } diff --git a/ruoyi-generator/src/main/resources/vm/java/sub-domain.java.vm b/ruoyi-generator/src/main/resources/vm/java/sub-domain.java.vm new file mode 100644 index 0000000..b5e308c --- /dev/null +++ b/ruoyi-generator/src/main/resources/vm/java/sub-domain.java.vm @@ -0,0 +1,76 @@ +package ${packageName}.domain; + +#foreach ($import in $subImportList) +import ${import}; +#end +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * ${subTable.functionName}瀵硅薄 ${subTableName} + * + * @author ${author} + * @date ${datetime} + */ +public class ${subClassName} extends BaseEntity +{ + private static final long serialVersionUID = 1L; + +#foreach ($column in $subTable.columns) +#if(!$table.isSuperColumn($column.javaField)) + /** $column.columnComment */ +#if($column.list) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($parentheseIndex != -1) + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") +#elseif($column.javaType == 'Date') + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") +#else + @Excel(name = "${comment}") +#end +#end + private $column.javaType $column.javaField; + +#end +#end +#foreach ($column in $subTable.columns) +#if(!$table.isSuperColumn($column.javaField)) +#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) +#set($AttrName=$column.javaField) +#else +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +#end + public void set${AttrName}($column.javaType $column.javaField) + { + this.$column.javaField = $column.javaField; + } + + public $column.javaType get${AttrName}() + { + return $column.javaField; + } +#end +#end + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) +#foreach ($column in $subTable.columns) +#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) +#set($AttrName=$column.javaField) +#else +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +#end + .append("${column.javaField}", get${AttrName}()) +#end + .toString(); + } +} diff --git a/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm b/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm index 2f954f8..ecc0fbc 100644 --- a/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm +++ b/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm @@ -73,7 +73,7 @@ <el-col :span="1.5"> <el-button type="primary" - plain + plain icon="el-icon-plus" size="mini" @click="handleAdd" @@ -159,7 +159,7 @@ </el-form-item> #elseif($column.htmlType == "fileUpload") <el-form-item label="${comment}"> - <imageUpload v-model="form.${field}"/> + <fileUpload v-model="form.${field}"/> </el-form-item> #elseif($column.htmlType == "editor") <el-form-item label="${comment}"> diff --git a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm index c86f072..c8b3e51 100644 --- a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm +++ b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm @@ -73,7 +73,7 @@ <el-col :span="1.5"> <el-button type="primary" - plain + plain icon="el-icon-plus" size="mini" @click="handleAdd" @@ -83,7 +83,7 @@ <el-col :span="1.5"> <el-button type="success" - plain + plain icon="el-icon-edit" size="mini" :disabled="single" @@ -94,7 +94,7 @@ <el-col :span="1.5"> <el-button type="danger" - plain + plain icon="el-icon-delete" size="mini" :disabled="multiple" @@ -105,7 +105,7 @@ <el-col :span="1.5"> <el-button type="warning" - plain + plain icon="el-icon-download" size="mini" @click="handleExport" @@ -266,6 +266,38 @@ #end #end #end +#if($table.sub) + <el-divider content-position="center">${subTable.functionName}淇℃伅</el-divider> + <el-row :gutter="10" class="mb8"> + <el-col :span="1.5"> + <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd${subClassName}">娣诲姞</el-button> + </el-col> + <el-col :span="1.5"> + <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDelete${subClassName}">鍒犻櫎</el-button> + </el-col> + </el-row> + <el-table :data="${subclassName}List" :row-class-name="row${subClassName}Index" @selection-change="handle${subClassName}SelectionChange" ref="${subclassName}"> + <el-table-column type="selection" width="50" align="center" /> + <el-table-column label="搴忓彿" align="center" prop="index" width="50"/> +#foreach($column in $subTable.columns) +#set($javaField=$column.javaField) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($column.pk || $javaField == ${subTableFkclassName}) +#elseif($column.list && "" != $javaField) + <el-table-column label="$comment" prop="${javaField}"> + <template slot-scope="scope"> + <el-input v-model="scope.row.$javaField" placeholder="璇疯緭鍏�$comment" /> + </template> + </el-table-column> +#end +#end + </el-table> +#end </el-form> <div slot="footer" class="dialog-footer"> <el-button type="primary" @click="submitForm">纭� 瀹�</el-button> @@ -324,6 +356,10 @@ loading: true, // 閫変腑鏁扮粍 ids: [], +#if($table.sub) + // 瀛愯〃閫変腑鏁版嵁 + checked${subClassName}: [], +#end // 闈炲崟涓鐢� single: true, // 闈炲涓鐢� @@ -334,6 +370,10 @@ total: 0, // ${functionName}琛ㄦ牸鏁版嵁 ${businessName}List: [], +#if($table.sub) + // ${subTable.functionName}琛ㄦ牸鏁版嵁 + ${subclassName}List: [], +#end // 寮瑰嚭灞傛爣棰� title: "", // 鏄惁鏄剧ず寮瑰嚭灞� @@ -456,6 +496,9 @@ #end #end }; +#if($table.sub) + this.${subclassName}List = []; +#end this.resetForm("form"); }, /** 鎼滅储鎸夐挳鎿嶄綔 */ @@ -497,6 +540,9 @@ this.form.$column.javaField = this.form.${column.javaField}.split(","); #end #end +#if($table.sub) + this.${subclassName}List = response.data.${subclassName}List; +#end this.open = true; this.title = "淇敼${functionName}"; }); @@ -509,6 +555,9 @@ #if($column.htmlType == "checkbox") this.form.$column.javaField = this.form.${column.javaField}.join(","); #end +#end +#if($table.sub) + this.form.${subclassName}List = this.${subclassName}List; #end if (this.form.${pkColumn.javaField} != null) { update${BusinessName}(this.form).then(response => { @@ -540,6 +589,40 @@ this.msgSuccess("鍒犻櫎鎴愬姛"); }) }, +#if($table.sub) + /** ${subTable.functionName}搴忓彿 */ + row${subClassName}Index({ row, rowIndex }) { + row.index = rowIndex + 1; + }, + /** ${subTable.functionName}娣诲姞鎸夐挳鎿嶄綔 */ + handleAdd${subClassName}() { + let obj = {}; +#foreach($column in $subTable.columns) +#if($column.pk || $column.javaField == ${subTableFkclassName}) +#elseif($column.list && "" != $javaField) + obj.$column.javaField = ""; +#end +#end + this.${subclassName}List.push(obj); + }, + /** ${subTable.functionName}鍒犻櫎鎸夐挳鎿嶄綔 */ + handleDelete${subClassName}() { + if (this.checked${subClassName}.length == 0) { + this.$alert("璇峰厛閫夋嫨瑕佸垹闄ょ殑${subTable.functionName}鏁版嵁", "鎻愮ず", { confirmButtonText: "纭畾", }); + } else { + this.${subclassName}List.splice(this.checked${subClassName}[0].index - 1, 1); + } + }, + /** 鍗曢�夋閫変腑鏁版嵁 */ + handle${subClassName}SelectionChange(selection) { + if (selection.length > 1) { + this.$refs.${subclassName}.clearSelection(); + this.$refs.${subclassName}.toggleRowSelection(selection.pop()); + } else { + this.checked${subClassName} = selection; + } + }, +#end /** 瀵煎嚭鎸夐挳鎿嶄綔 */ handleExport() { const queryParams = this.queryParams; diff --git a/ruoyi-ui/src/components/FileUpload/index.vue b/ruoyi-ui/src/components/FileUpload/index.vue index 841d3ae..d19a012 100644 --- a/ruoyi-ui/src/components/FileUpload/index.vue +++ b/ruoyi-ui/src/components/FileUpload/index.vue @@ -90,6 +90,7 @@ return item; }); } else { + this.fileList = []; return []; } }, diff --git a/ruoyi-ui/src/components/RightToolbar/index.vue b/ruoyi-ui/src/components/RightToolbar/index.vue index 73d2dcc..9bf9722 100644 --- a/ruoyi-ui/src/components/RightToolbar/index.vue +++ b/ruoyi-ui/src/components/RightToolbar/index.vue @@ -1,4 +1,3 @@ -<!-- @author Shiyn/ huangmx 20200807浼樺寲--> <template> <div class="top-right-btn"> <el-row> @@ -8,31 +7,74 @@ <el-tooltip class="item" effect="dark" content="鍒锋柊" placement="top"> <el-button size="mini" circle icon="el-icon-refresh" @click="refresh()" /> </el-tooltip> + <el-tooltip class="item" effect="dark" content="鏄鹃殣鍒�" placement="top" v-if="columns"> + <el-button size="mini" circle icon="el-icon-menu" @click="showColumn()" /> + </el-tooltip> </el-row> + <el-dialog :title="title" :visible.sync="open" append-to-body> + <el-transfer + :titles="['鏄剧ず', '闅愯棌']" + v-model="value" + :data="columns" + @change="dataChange" + ></el-transfer> + </el-dialog> </div> </template> <script> export default { name: "RightToolbar", data() { - return {}; + return { + // 鏄鹃殣鏁版嵁 + value: [], + // 寮瑰嚭灞傛爣棰� + title: "鏄剧ず/闅愯棌", + // 鏄惁鏄剧ず寮瑰嚭灞� + open: false, + }; }, props: { showSearch: { type: Boolean, default: true, }, + columns: { + type: Array, + }, }, methods: { - //鎼滅储 + // 鎼滅储 toggleSearch() { this.$emit("update:showSearch", !this.showSearch); }, - //鍒锋柊 + // 鍒锋柊 refresh() { this.$emit("queryTable"); + }, + // 鍙充晶鍒楄〃鍏冪礌鍙樺寲 + dataChange(data) { + for (var item in this.columns) { + const key = this.columns[item].key; + this.columns[item].visible = !data.includes(key); + } + }, + // 鎵撳紑鏄鹃殣鍒梔ialog + showColumn() { + this.open = true; }, }, }; </script> +<style lang="scss" scoped> +::v-deep .el-transfer__button { + border-radius: 50%; + padding: 12px; + display: block; + margin-left: 0px; +} +::v-deep .el-transfer__button:first-child { + margin-bottom: 10px; +} +</style> diff --git a/ruoyi-ui/src/layout/components/global.js b/ruoyi-ui/src/layout/components/global.js deleted file mode 100644 index 5d2b5b3..0000000 --- a/ruoyi-ui/src/layout/components/global.js +++ /dev/null @@ -1,3 +0,0 @@ -import Vue from 'vue' -const global = new Vue() -export default global diff --git a/ruoyi-ui/src/views/system/user/index.vue b/ruoyi-ui/src/views/system/user/index.vue index 394acce..1a06eb3 100644 --- a/ruoyi-ui/src/views/system/user/index.vue +++ b/ruoyi-ui/src/views/system/user/index.vue @@ -135,17 +135,17 @@ v-hasPermi="['system:user:export']" >瀵煎嚭</el-button> </el-col> - <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar> </el-row> <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange"> <el-table-column type="selection" width="50" align="center" /> - <el-table-column label="鐢ㄦ埛缂栧彿" align="center" prop="userId" /> - <el-table-column label="鐢ㄦ埛鍚嶇О" align="center" prop="userName" :show-overflow-tooltip="true" /> - <el-table-column label="鐢ㄦ埛鏄电О" align="center" prop="nickName" :show-overflow-tooltip="true" /> - <el-table-column label="閮ㄩ棬" align="center" prop="dept.deptName" :show-overflow-tooltip="true" /> - <el-table-column label="鎵嬫満鍙风爜" align="center" prop="phonenumber" width="120" /> - <el-table-column label="鐘舵��" align="center"> + <el-table-column label="鐢ㄦ埛缂栧彿" align="center" key="userId" prop="userId" v-if="columns[0].visible" /> + <el-table-column label="鐢ㄦ埛鍚嶇О" align="center" key="userName" prop="userName" v-if="columns[1].visible" :show-overflow-tooltip="true" /> + <el-table-column label="鐢ㄦ埛鏄电О" align="center" key="nickName" prop="nickName" v-if="columns[2].visible" :show-overflow-tooltip="true" /> + <el-table-column label="閮ㄩ棬" align="center" key="deptName" prop="dept.deptName" v-if="columns[3].visible" :show-overflow-tooltip="true" /> + <el-table-column label="鎵嬫満鍙风爜" align="center" key="phonenumber" prop="phonenumber" v-if="columns[4].visible" width="120" /> + <el-table-column label="鐘舵��" align="center" key="status" v-if="columns[5].visible"> <template slot-scope="scope"> <el-switch v-model="scope.row.status" @@ -155,7 +155,7 @@ ></el-switch> </template> </el-table-column> - <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" width="160"> + <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" v-if="columns[6].visible" width="160"> <template slot-scope="scope"> <span>{{ parseTime(scope.row.createTime) }}</span> </template> @@ -418,6 +418,16 @@ status: undefined, deptId: undefined }, + // 鍒椾俊鎭� + columns: [ + { key: 0, label: `鐢ㄦ埛缂栧彿`, visible: true }, + { key: 1, label: `鐢ㄦ埛鍚嶇О`, visible: true }, + { key: 2, label: `鐢ㄦ埛鏄电О`, visible: true }, + { key: 3, label: `閮ㄩ棬`, visible: true }, + { key: 4, label: `鎵嬫満鍙风爜`, visible: true }, + { key: 5, label: `鐘舵�乣, visible: true }, + { key: 6, label: `鍒涘缓鏃堕棿`, visible: true } + ], // 琛ㄥ崟鏍¢獙 rules: { userName: [ @@ -662,4 +672,4 @@ } } }; -</script> \ No newline at end of file +</script> diff --git a/ruoyi-ui/src/views/tool/gen/editTable.vue b/ruoyi-ui/src/views/tool/gen/editTable.vue index 62a8314..94d0ef3 100644 --- a/ruoyi-ui/src/views/tool/gen/editTable.vue +++ b/ruoyi-ui/src/views/tool/gen/editTable.vue @@ -113,7 +113,7 @@ </el-table> </el-tab-pane> <el-tab-pane label="鐢熸垚淇℃伅" name="genInfo"> - <gen-info-form ref="genInfo" :info="info" :menus="menus"/> + <gen-info-form ref="genInfo" :info="info" :tables="tables" :menus="menus"/> </el-tab-pane> </el-tabs> <el-form label-width="100px"> @@ -144,6 +144,8 @@ activeName: "cloum", // 琛ㄦ牸鐨勯珮搴� tableHeight: document.documentElement.scrollHeight - 245 + "px", + // 琛ㄤ俊鎭� + tables: [], // 琛ㄥ垪淇℃伅 cloumns: [], // 瀛楀吀淇℃伅 @@ -161,6 +163,7 @@ getGenTable(tableId).then(res => { this.cloumns = res.data.rows; this.info = res.data.info; + this.tables = res.data.tables; }); /** 鏌ヨ瀛楀吀涓嬫媺鍒楄〃 */ getDictOptionselect().then(response => { diff --git a/ruoyi-ui/src/views/tool/gen/genInfoForm.vue b/ruoyi-ui/src/views/tool/gen/genInfoForm.vue index bd4a2d8..27d6a22 100644 --- a/ruoyi-ui/src/views/tool/gen/genInfoForm.vue +++ b/ruoyi-ui/src/views/tool/gen/genInfoForm.vue @@ -4,9 +4,10 @@ <el-col :span="12"> <el-form-item prop="tplCategory"> <span slot="label">鐢熸垚妯℃澘</span> - <el-select v-model="info.tplCategory"> + <el-select v-model="info.tplCategory" @change="tplSelectChange"> <el-option label="鍗曡〃锛堝鍒犳敼鏌ワ級" value="crud" /> <el-option label="鏍戣〃锛堝鍒犳敼鏌ワ級" value="tree" /> + <el-option label="涓诲瓙琛紙澧炲垹鏀规煡锛�" value="sub" /> </el-select> </el-form-item> </el-col> @@ -126,8 +127,8 @@ </span> <el-select v-model="info.treeCode" placeholder="璇烽�夋嫨"> <el-option - v-for="column in info.columns" - :key="column.columnName" + v-for="(column, index) in info.columns" + :key="index" :label="column.columnName + '锛�' + column.columnComment" :value="column.columnName" ></el-option> @@ -144,8 +145,8 @@ </span> <el-select v-model="info.treeParentCode" placeholder="璇烽�夋嫨"> <el-option - v-for="column in info.columns" - :key="column.columnName" + v-for="(column, index) in info.columns" + :key="index" :label="column.columnName + '锛�' + column.columnComment" :value="column.columnName" ></el-option> @@ -162,8 +163,47 @@ </span> <el-select v-model="info.treeName" placeholder="璇烽�夋嫨"> <el-option - v-for="column in info.columns" - :key="column.columnName" + v-for="(column, index) in info.columns" + :key="index" + :label="column.columnName + '锛�' + column.columnComment" + :value="column.columnName" + ></el-option> + </el-select> + </el-form-item> + </el-col> + </el-row> + <el-row v-show="info.tplCategory == 'sub'"> + <h4 class="form-header">鍏宠仈淇℃伅</h4> + <el-col :span="12"> + <el-form-item> + <span slot="label"> + 鍏宠仈瀛愯〃鐨勮〃鍚� + <el-tooltip content="鍏宠仈瀛愯〃鐨勮〃鍚嶏紝 濡傦細sys_user" placement="top"> + <i class="el-icon-question"></i> + </el-tooltip> + </span> + <el-select v-model="info.subTableName" placeholder="璇烽�夋嫨" @change="subSelectChange"> + <el-option + v-for="(table, index) in tables" + :key="index" + :label="table.tableName + '锛�' + table.tableComment" + :value="table.tableName" + ></el-option> + </el-select> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item> + <span slot="label"> + 瀛愯〃鍏宠仈鐨勫閿悕 + <el-tooltip content="瀛愯〃鍏宠仈鐨勫閿悕锛� 濡傦細user_id" placement="top"> + <i class="el-icon-question"></i> + </el-tooltip> + </span> + <el-select v-model="info.subTableFkName" placeholder="璇烽�夋嫨"> + <el-option + v-for="(column, index) in subColumns" + :key="index" :label="column.columnName + '锛�' + column.columnComment" :value="column.columnName" ></el-option> @@ -185,6 +225,10 @@ type: Object, default: null }, + tables: { + type: Array, + default: null + }, menus: { type: Array, default: [] @@ -192,6 +236,7 @@ }, data() { return { + subColumns: [], rules: { tplCategory: [ { required: true, message: "璇烽�夋嫨鐢熸垚妯℃澘", trigger: "blur" } @@ -212,6 +257,11 @@ }; }, created() {}, + watch: { + 'info.subTableName': function(val) { + this.setSubTableColumns(val); + } + }, methods: { /** 杞崲鑿滃崟鏁版嵁缁撴瀯 */ normalizer(node) { @@ -223,6 +273,27 @@ label: node.menuName, children: node.children }; + }, + /** 閫夋嫨瀛愯〃鍚嶈Е鍙� */ + subSelectChange(value) { + this.info.subTableFkName = ''; + }, + /** 閫夋嫨鐢熸垚妯℃澘瑙﹀彂 */ + tplSelectChange(value) { + if(value !== 'sub') { + this.info.subTableName = ''; + this.info.subTableFkName = ''; + } + }, + /** 璁剧疆鍏宠仈澶栭敭 */ + setSubTableColumns(value) { + for (var item in this.tables) { + const name = this.tables[item].tableName; + if (value === name) { + this.subColumns = this.tables[item].columns; + break; + } + } } } }; diff --git a/ruoyi-ui/src/views/tool/gen/index.vue b/ruoyi-ui/src/views/tool/gen/index.vue index 7025796..9d29399 100644 --- a/ruoyi-ui/src/views/tool/gen/index.vue +++ b/ruoyi-ui/src/views/tool/gen/index.vue @@ -84,7 +84,7 @@ </el-row> <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange"> - <el-table-column type="selection" width="55"></el-table-column> + <el-table-column type="selection" align="center" width="55"></el-table-column> <el-table-column label="搴忓彿" type="index" width="50" align="center"> <template slot-scope="scope"> <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span> diff --git a/sql/ry_20201128.sql b/sql/ry_20210108.sql similarity index 99% rename from sql/ry_20201128.sql rename to sql/ry_20210108.sql index a838c55..6d1716d 100644 --- a/sql/ry_20201128.sql +++ b/sql/ry_20210108.sql @@ -633,6 +633,8 @@ table_id bigint(20) not null auto_increment comment '缂栧彿', table_name varchar(200) default '' comment '琛ㄥ悕绉�', table_comment varchar(500) default '' comment '琛ㄦ弿杩�', + sub_table_name varchar(64) default null comment '鍏宠仈瀛愯〃鐨勮〃鍚�', + sub_table_fk_name varchar(64) default null comment '瀛愯〃鍏宠仈鐨勫閿悕', class_name varchar(100) default '' comment '瀹炰綋绫诲悕绉�', tpl_category varchar(200) default 'crud' comment '浣跨敤鐨勬ā鏉匡紙crud鍗曡〃鎿嶄綔 tree鏍戣〃鎿嶄綔锛�', package_name varchar(100) comment '鐢熸垚鍖呰矾寰�', -- Gitblit v1.9.3