diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/GenConstants.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/GenConstants.java index 69e81efa0..2cd6425f9 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/GenConstants.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/GenConstants.java @@ -76,8 +76,11 @@ public class GenConstants /** 日期控件 */ public static final String HTML_DATETIME = "datetime"; - /** 上传控件 */ - public static final String HTML_UPLOAD_IMAGE = "uploadImage"; + /** 图片上传控件 */ + public static final String HTML_IMAGE_UPLOAD = "imageUpload"; + + /** 文件上传控件 */ + public static final String HTML_FILE_UPLOAD = "fileUpload"; /** 富文本控件 */ public static final String HTML_EDITOR = "editor"; diff --git a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/domain/GenTableColumn.java b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/domain/GenTableColumn.java index 9b364b962..3300bfc68 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/domain/GenTableColumn.java +++ b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/domain/GenTableColumn.java @@ -60,7 +60,7 @@ public class GenTableColumn extends BaseEntity /** 查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围) */ private String queryType; - /** 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、upload上传控件、editor富文本控件) */ + /** 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、image图片上传控件、upload文件上传控件、editor富文本控件) */ private String htmlType; /** 字典类型 */ diff --git a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java index 815027037..41204dd98 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java +++ b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java @@ -112,10 +112,15 @@ public class GenUtils { column.setHtmlType(GenConstants.HTML_SELECT); } - // 文件字段设置上传控件 + // 图片字段设置图片上传控件 else if (StringUtils.endsWithIgnoreCase(columnName, "image")) { - column.setHtmlType(GenConstants.HTML_UPLOAD_IMAGE); + column.setHtmlType(GenConstants.HTML_IMAGE_UPLOAD); + } + // 文件字段设置文件上传控件 + else if (StringUtils.endsWithIgnoreCase(columnName, "file")) + { + column.setHtmlType(GenConstants.HTML_FILE_UPLOAD); } // 内容字段设置富文本控件 else if (StringUtils.endsWithIgnoreCase(columnName, "content")) diff --git a/ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index-tree.vue.vm b/ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index-tree.vue.vm index f12eb2f31..2f954f870 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index-tree.vue.vm +++ b/ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index-tree.vue.vm @@ -153,9 +153,13 @@ -#elseif($column.htmlType == "uploadImage") +#elseif($column.htmlType == "imageUpload") - + + +#elseif($column.htmlType == "fileUpload") + + #elseif($column.htmlType == "editor") @@ -244,8 +248,13 @@ import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${Busin 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'; +#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload") +import ImageUpload from '@/components/ImageUpload'; +#break +#end +#end +#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload") +import FileUpload from '@/components/FileUpload'; #break #end #end @@ -260,8 +269,14 @@ export default { name: "${BusinessName}", components: { #foreach($column in $columns) -#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "uploadImage") - UploadImage, +#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload") + ImageUpload, +#break +#end +#end +#foreach($column in $columns) +#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload") + FileUpload, #break #end #end diff --git a/ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index.vue.vm b/ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index.vue.vm index 4bfc5d476..b3daf7f56 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index.vue.vm +++ b/ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index.vue.vm @@ -185,9 +185,13 @@ -#elseif($column.htmlType == "uploadImage") +#elseif($column.htmlType == "imageUpload") - + + +#elseif($column.htmlType == "fileUpload") + + #elseif($column.htmlType == "editor") @@ -274,8 +278,14 @@ + + \ No newline at end of file diff --git a/ruoyi-ui/src/components/UploadImage/index.vue b/ruoyi-ui/src/components/ImageUpload/index.vue similarity index 90% rename from ruoyi-ui/src/components/UploadImage/index.vue rename to ruoyi-ui/src/components/ImageUpload/index.vue index ce540eb8d..cf772eede 100644 --- a/ruoyi-ui/src/components/UploadImage/index.vue +++ b/ruoyi-ui/src/components/ImageUpload/index.vue @@ -43,7 +43,7 @@ export default { data() { return { dialogVisible: false, - uploadImgUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的图片服务器地址 + uploadImgUrl: process.env.VUE_APP_BASE_API + "/file/upload", // 上传的图片服务器地址 headers: { Authorization: "Bearer " + getToken(), }, @@ -60,7 +60,7 @@ export default { this.$emit("input", ""); }, handleUploadSuccess(res) { - this.$emit("input", res.url); + this.$emit("input", res.data.url); this.loading.close(); }, handleBeforeUpload() { diff --git a/ruoyi-ui/src/views/tool/gen/editTable.vue b/ruoyi-ui/src/views/tool/gen/editTable.vue index fea958e3a..329fce661 100644 --- a/ruoyi-ui/src/views/tool/gen/editTable.vue +++ b/ruoyi-ui/src/views/tool/gen/editTable.vue @@ -90,7 +90,8 @@ - + +