From abf81c250a27085f1f8dcfff0af77ee43111b7d1 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期一, 16 十一月 2020 16:35:40 +0800
Subject: [PATCH] 代码生成支持上传控件

---
 src/main/java/com/ruoyi/common/constant/GenConstants.java           |    3 +++
 src/main/resources/vm/vue/index-tree.vue.vm                         |   16 ++++++++++++++++
 src/main/resources/vm/vue/index.vue.vm                              |   22 ++++++++++++++++++++--
 src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java         |    5 +++++
 src/main/java/com/ruoyi/project/tool/gen/domain/GenTableColumn.java |    2 +-
 5 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/ruoyi/common/constant/GenConstants.java b/src/main/java/com/ruoyi/common/constant/GenConstants.java
index af7991c..0c7cfdb 100644
--- a/src/main/java/com/ruoyi/common/constant/GenConstants.java
+++ b/src/main/java/com/ruoyi/common/constant/GenConstants.java
@@ -74,6 +74,9 @@
     /** 鏃ユ湡鎺т欢 */
     public static final String HTML_DATETIME = "datetime";
 
+    /** 涓婁紶鎺т欢 */
+    public static final String HTML_UPLOAD_IMAGE = "uploadImage";
+
     /** 瀵屾枃鏈帶浠� */
     public static final String HTML_EDITOR = "editor";
 
diff --git a/src/main/java/com/ruoyi/project/tool/gen/domain/GenTableColumn.java b/src/main/java/com/ruoyi/project/tool/gen/domain/GenTableColumn.java
index 476777d..490d70a 100644
--- a/src/main/java/com/ruoyi/project/tool/gen/domain/GenTableColumn.java
+++ b/src/main/java/com/ruoyi/project/tool/gen/domain/GenTableColumn.java
@@ -59,7 +59,7 @@
     /** 鏌ヨ鏂瑰紡锛圗Q绛変簬銆丯E涓嶇瓑浜庛�丟T澶т簬銆丩T灏忎簬銆丩IKE妯$硦銆丅ETWEEN鑼冨洿锛� */
     private String queryType;
 
-    /** 鏄剧ず绫诲瀷锛坕nput鏂囨湰妗嗐�乼extarea鏂囨湰鍩熴�乻elect涓嬫媺妗嗐�乧heckbox澶嶉�夋銆乺adio鍗曢�夋銆乨atetime鏃ユ湡鎺т欢銆乪ditor瀵屾枃鏈帶浠讹級 */
+    /** 鏄剧ず绫诲瀷锛坕nput鏂囨湰妗嗐�乼extarea鏂囨湰鍩熴�乻elect涓嬫媺妗嗐�乧heckbox澶嶉�夋銆乺adio鍗曢�夋銆乨atetime鏃ユ湡鎺т欢銆乽pload涓婁紶鎺т欢銆乪ditor瀵屾枃鏈帶浠讹級 */
     private String htmlType;
 
     /** 瀛楀吀绫诲瀷 */
diff --git a/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java b/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java
index dd7ed09..3012e64 100644
--- a/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java
+++ b/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java
@@ -111,6 +111,11 @@
         {
             column.setHtmlType(GenConstants.HTML_SELECT);
         }
+        // 鏂囦欢瀛楁璁剧疆涓婁紶鎺т欢
+        else if (StringUtils.endsWithIgnoreCase(columnName, "image"))
+        {
+            column.setHtmlType(GenConstants.HTML_UPLOAD_IMAGE);
+        }
         // 鍐呭瀛楁璁剧疆瀵屾枃鏈帶浠�
         else if (StringUtils.endsWithIgnoreCase(columnName, "content"))
         {
diff --git a/src/main/resources/vm/vue/index-tree.vue.vm b/src/main/resources/vm/vue/index-tree.vue.vm
index e139a13..e433934 100644
--- a/src/main/resources/vm/vue/index-tree.vue.vm
+++ b/src/main/resources/vm/vue/index-tree.vue.vm
@@ -139,6 +139,10 @@
         <el-form-item label="${comment}" prop="${field}">
           <el-input v-model="form.${field}" placeholder="璇疯緭鍏�${comment}" />
         </el-form-item>
+#elseif($column.htmlType == "uploadImage")
+        <el-form-item label="${comment}">
+          <uploadImage v-model="form.${field}"/>
+        </el-form-item>
 #elseif($column.htmlType == "editor")
         <el-form-item label="${comment}">
           <editor v-model="form.${field}" :min-height="192"/>
@@ -226,6 +230,12 @@
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 #foreach($column in $columns)
+#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "uploadImage")
+import UploadImage from '@/components/UploadImage';
+#break
+#end
+#end
+#foreach($column in $columns)
 #if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
 import Editor from '@/components/Editor';
 #break
@@ -236,6 +246,12 @@
   name: "${BusinessName}",
   components: {
 #foreach($column in $columns)
+#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "uploadImage")
+    UploadImage,
+#break
+#end
+#end
+#foreach($column in $columns)
 #if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
     Editor,
 #break
diff --git a/src/main/resources/vm/vue/index.vue.vm b/src/main/resources/vm/vue/index.vue.vm
index 23decc6..e667b10 100644
--- a/src/main/resources/vm/vue/index.vue.vm
+++ b/src/main/resources/vm/vue/index.vue.vm
@@ -168,6 +168,10 @@
         <el-form-item label="${comment}" prop="${field}">
           <el-input v-model="form.${field}" placeholder="璇疯緭鍏�${comment}" />
         </el-form-item>
+#elseif($column.htmlType == "uploadImage")
+        <el-form-item label="${comment}">
+          <uploadImage v-model="form.${field}"/>
+        </el-form-item>
 #elseif($column.htmlType == "editor")
         <el-form-item label="${comment}">
           <editor v-model="form.${field}" :min-height="192"/>
@@ -253,6 +257,12 @@
 <script>
 import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}";
 #foreach($column in $columns)
+#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "uploadImage")
+import UploadImage from '@/components/UploadImage';
+#break
+#end
+#end
+#foreach($column in $columns)
 #if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
 import Editor from '@/components/Editor';
 #break
@@ -261,12 +271,20 @@
 
 export default {
   name: "${BusinessName}",
+  components: {
 #foreach($column in $columns)
-#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
-  components: { Editor },
+#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "uploadImage")
+    UploadImage,
 #break
 #end
 #end
+#foreach($column in $columns)
+#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
+    Editor,
+#break
+#end
+#end
+  },
   data() {
     return {
       // 閬僵灞�

--
Gitblit v1.9.3