From c93f54a812afb3a5d50dd096545247b5664cde92 Mon Sep 17 00:00:00 2001 From: xiexiangrui Date: Sat, 4 Jul 2020 13:58:34 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=B8=8A=E4=BC=A0=E9=99=84=E4=BB=B6&?= =?UTF-8?q?=E5=AF=8C=E6=96=87=E6=9C=AC=E7=BC=96=E8=BE=91=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/static/ruoyi/js/ry-ui.js | 22 +- .../generator/domain/GenTableColumn.java | 2 +- .../resources/templates/tool/gen/edit.html | 2 + .../src/main/resources/vm/html/add.html.vm | 421 +++++++++++------- .../src/main/resources/vm/html/edit.html.vm | 415 ++++++++++------- .../main/resources/vm/html/list-tree.html.vm | 25 ++ .../src/main/resources/vm/html/list.html.vm | 28 ++ 7 files changed, 596 insertions(+), 319 deletions(-) diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js index b61baa16c..e8136c82b 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js @@ -1228,7 +1228,27 @@ var table = { $.modal.alertError(result.msg); } $.modal.closeLoading(); - } + }, + // 显示富文本详细内容 + seeSummernoteDetail: function(index,fild) { + table.set(); + var row = $("#" + table.options.id).bootstrapTable('getData')[index]; + console.log(row) + var content =window.atob(row[fild]); + var htmlcontent = [ + "
", + content, + "
" + ].join(''); + layer.open({ + title: false, + type: 1, + closeBtn: true, + shadeClose: true, + area: ['800px', ($(window).height() - 50)+ 'px'], + content: htmlcontent + }); + } }, // 校验封装处理 validate: { 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 a9ca64f4f..8b5ef70dd 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 @@ public class GenTableColumn extends BaseEntity /** 查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围) */ private String queryType; - /** 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件) */ + /** 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、upload附件上传、summernote 富文本) */ private String htmlType; /** 字典类型 */ diff --git a/ruoyi-generator/src/main/resources/templates/tool/gen/edit.html b/ruoyi-generator/src/main/resources/templates/tool/gen/edit.html index 8d46839da..b0b4241ef 100644 --- a/ruoyi-generator/src/main/resources/templates/tool/gen/edit.html +++ b/ruoyi-generator/src/main/resources/templates/tool/gen/edit.html @@ -520,6 +520,8 @@ + + diff --git a/ruoyi-generator/src/main/resources/vm/html/add.html.vm b/ruoyi-generator/src/main/resources/vm/html/add.html.vm index 0d32c3655..400cc6443 100644 --- a/ruoyi-generator/src/main/resources/vm/html/add.html.vm +++ b/ruoyi-generator/src/main/resources/vm/html/add.html.vm @@ -1,19 +1,37 @@ - + - + +#set($isUpload = false) +#set($isSummernote = false) +#set($isDateTime = false) #foreach($column in $columns) #if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime") - +#set($isDateTime = true) + +#break +#end +#end +#foreach($column in $columns) +#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "upload" ) +#set($isUpload = true) + +#break +#end +#end +#foreach($column in $columns) +#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "summernote") +#set($isSummernote = true) + #break #end #end -
-
+
+ #if($table.sub) -

${functionName}信息

+

${functionName}信息

#end #foreach($column in $columns) #set($field=$column.javaField) @@ -27,184 +45,259 @@ #end #set($dictType=$column.dictType) #if("" != $treeParentCode && $column.javaField == $treeParentCode) -
- -
-
+
+ +
+
#set($BusinessName=$businessName.substring(0,1).toUpperCase() + ${businessName.substring(1)}) #set($treeId = "${className}?.${treeCode}") - - - -
+ + +
+
#elseif($column.htmlType == "input") -
- -
- -
+
+ +
+
+
#elseif($column.htmlType == "select" && "" != $dictType) -
- -
- -
+
+ +
+
+
#elseif($column.htmlType == "select" && $dictType) -
- -
- - 代码生成请选择字典属性 -
+
+ +
+ + 代码生成请选择字典属性
+
#elseif($column.htmlType == "checkbox" && "" != $dictType) -
- -
- -
+
+ +
+
+
#elseif($column.htmlType == "checkbox" && $dictType) -
- -
- - 代码生成请选择字典属性 -
+
+ +
+ + 代码生成请选择字典属性
+
#elseif($column.htmlType == "radio" && "" != $dictType) -
- -
-
- - -
+
+ +
+
+ +
+
#elseif($column.htmlType == "radio" && $dictType) -
- -
-
- - -
- 代码生成请选择字典属性 +
+ +
+
+ +
+ 代码生成请选择字典属性
+
#elseif($column.htmlType == "datetime") -
- -
-
- - -
+
+ +
+
+ +
+
#elseif($column.htmlType == "textarea") -
- -
- +
+ +
+ +
+
+#elseif($column.htmlType == "upload") +
+ +
+
+ +
+
+#elseif($column.htmlType == "summernote" ) +
+ +
+ +
+
+
#end #end #end #end #if($table.sub) -

${subTable.functionName}信息

-
-
- - -
-
-
+

${subTable.functionName}信息

+
+
+ + +
+
+
#end - -
- -#foreach($column in $columns) -#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime") - -#break + +
+ +#if($isDateTime) + #end +#if($isUpload) + #end - +#end + } + }); + } +#end + \ No newline at end of file diff --git a/ruoyi-generator/src/main/resources/vm/html/edit.html.vm b/ruoyi-generator/src/main/resources/vm/html/edit.html.vm index 5d2ea8cb7..4eb1ef1a1 100644 --- a/ruoyi-generator/src/main/resources/vm/html/edit.html.vm +++ b/ruoyi-generator/src/main/resources/vm/html/edit.html.vm @@ -1,21 +1,39 @@ - + - +#set($isUpload = false) +#set($isSummernote = false) +#set($isDateTime = false) + #foreach($column in $columns) #if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "datetime") - +#set($isDateTime = true) + +#break +#end +#end +#foreach($column in $columns) +#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "upload") +#set($isUpload = true) + +#break +#end +#end +#foreach($column in $columns) +#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "summernote") +#set($isSummernote = true) + #break #end #end -
-
+
+ #if($table.sub) -

${functionName}信息

+

${functionName}信息

#end - + #foreach($column in $columns) #if($column.edit && !$column.pk) #if(($column.usableColumn) || (!$column.superColumn)) @@ -28,100 +46,137 @@ #set($field=$column.javaField) #set($dictType=$column.dictType) #if("" != $treeParentCode && $column.javaField == $treeParentCode) -
- -
-
+
+ +
+
#set($BusinessName=$businessName.substring(0,1).toUpperCase() + ${businessName.substring(1)}) - - - -
+ + +
+
#elseif($column.htmlType == "input") -
- -
- -
+
+ +
+
+
#elseif($column.htmlType == "select" && "" != $dictType) -
- -
- -
+
+ +
+
+
#elseif($column.htmlType == "select" && $dictType) -
- -
- - 代码生成请选择字典属性 -
+
+ +
+ + 代码生成请选择字典属性
+
#elseif($column.htmlType == "checkbox" && "" != $dictType) -
- -
- -
+
+ +
+
+
#elseif($column.htmlType == "checkbox" && $dictType) -
- -
- - 代码生成请选择字典属性 -
+
+ +
+ + 代码生成请选择字典属性
+
#elseif($column.htmlType == "radio" && "" != $dictType) -
- -
-
- - -
+
+ +
+
+ +
+
#elseif($column.htmlType == "radio" && $dictType) -
- -
-
- - -
- 代码生成请选择字典属性 +
+ +
+
+ +
+ 代码生成请选择字典属性
+
#elseif($column.htmlType == "datetime") -
- -
-
- - -
+
+ +
+
+ +
+
#elseif($column.htmlType == "textarea") -
- -
- +
+ +
+ +
+
+#elseif($column.htmlType == "upload" || $column.htmlType == "uploads") +
+ +
+
+ +
+
+#elseif($column.htmlType == "summernote" ) +
+ +
+ +
+
+
#end #end #end @@ -130,82 +185,133 @@

${subTable.functionName}信息

- - + +
#end - -
- -#foreach($column in $columns) -#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "datetime") - -#break + +
+ +#if($isDateTime) + #end +#if($isUpload) + #end - + } + }); + } + #end + \ No newline at end of file diff --git a/ruoyi-generator/src/main/resources/vm/html/list-tree.html.vm b/ruoyi-generator/src/main/resources/vm/html/list-tree.html.vm index 59510d3d0..2129daf70 100644 --- a/ruoyi-generator/src/main/resources/vm/html/list-tree.html.vm +++ b/ruoyi-generator/src/main/resources/vm/html/list-tree.html.vm @@ -107,6 +107,8 @@ #foreach($column in $columns) #set($dictType=$column.dictType) #set($javaField=$column.javaField) +#set($isUpload = $column.htmlType == 'upload') +#set($isSummernote = $column.htmlType == 'summernote') #set($parentheseIndex=$column.columnComment.indexOf("(")) #if($parentheseIndex != -1) #set($comment=$column.columnComment.substring(0, $parentheseIndex)) @@ -124,11 +126,34 @@ } }, #elseif($column.list && "" != $javaField) + #if($isUpload) + { + field: '${javaField}', + title: '${comment}', + formatter: function(value, row, index) { + if(row.${column.javaField}){ + return ' ' + // 如果是图片,把下面注释取消 + // return $.table.imageView(row.${column.javaField}); + } + return '' + } + }, + #elseif($isSummernote) + { + field: '${javaField}', + title: '${comment}', + formatter: function(value, row, index) { + return '' + } + }, + #else { field: '${javaField}', title: '${comment}', align: 'left' }, + #end #end #end { diff --git a/ruoyi-generator/src/main/resources/vm/html/list.html.vm b/ruoyi-generator/src/main/resources/vm/html/list.html.vm index 16b0ce511..d070350f6 100644 --- a/ruoyi-generator/src/main/resources/vm/html/list.html.vm +++ b/ruoyi-generator/src/main/resources/vm/html/list.html.vm @@ -103,6 +103,8 @@ }, #foreach($column in $columns) #set($dictType=$column.dictType) +#set($isUpload = $column.htmlType == 'upload') +#set($isSummernote = $column.htmlType == 'summernote') #set($javaField=$column.javaField) #set($parentheseIndex=$column.columnComment.indexOf("(")) #if($parentheseIndex != -1) @@ -125,10 +127,36 @@ } }, #elseif($column.list && "" != $javaField) + #if($isUpload) + { + field: '${javaField}', + title: '${comment}', + formatter: function(value, row, index) { + if(row.${column.javaField}){ + return ' ' + // 如果是图片,把下面注释取消 + // return $.table.imageView(row.${column.javaField}); + } + return '' + } + }, + #elseif($isSummernote) + { + field: '${javaField}', + title: '${comment}', + formatter: function(value, row, index) { + var actions = []; + actions.push('查看 '); + return actions.join(''); + } + }, + #else { field: '${javaField}', title: '${comment}' }, + #end + #end #end { From d0bd515ed4a312ea8a7a51f8d2dbb6ffcc0c3789 Mon Sep 17 00:00:00 2001 From: xiexiangrui Date: Sat, 4 Jul 2020 15:43:41 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=AF=8C=E6=96=87=E6=9C=AC=E4=B8=AD?= =?UTF-8?q?=E6=96=87=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/static/ruoyi/js/ry-ui.js | 3 +- .../src/main/resources/vm/html/add.html.vm | 6 ++-- .../src/main/resources/vm/html/edit.html.vm | 31 +++++++++---------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js index e8136c82b..7b81d1ce3 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js @@ -1233,8 +1233,7 @@ var table = { seeSummernoteDetail: function(index,fild) { table.set(); var row = $("#" + table.options.id).bootstrapTable('getData')[index]; - console.log(row) - var content =window.atob(row[fild]); + var content = decodeURI(window.atob(row[fild])); var htmlcontent = [ "
", content, diff --git a/ruoyi-generator/src/main/resources/vm/html/add.html.vm b/ruoyi-generator/src/main/resources/vm/html/add.html.vm index 400cc6443..ffffae77e 100644 --- a/ruoyi-generator/src/main/resources/vm/html/add.html.vm +++ b/ruoyi-generator/src/main/resources/vm/html/add.html.vm @@ -156,10 +156,10 @@
+
- + type="file" >
@@ -261,7 +261,7 @@ callbacks: { onChange: function (contents, $edittable) { // Xss 过滤掉了html 内容 ,所以用base64 保存 - $("input[name='" + this.id + "']").val(window.btoa(contents)) + $("input[name='" + this.id + "']").val(window.btoa(encodeURI(contents))); } } diff --git a/ruoyi-generator/src/main/resources/vm/html/edit.html.vm b/ruoyi-generator/src/main/resources/vm/html/edit.html.vm index 4eb1ef1a1..5c3a4255f 100644 --- a/ruoyi-generator/src/main/resources/vm/html/edit.html.vm +++ b/ruoyi-generator/src/main/resources/vm/html/edit.html.vm @@ -157,15 +157,14 @@ required#end>[[*{${field}}]]
-#elseif($column.htmlType == "upload" || $column.htmlType == "uploads") +#elseif($column.htmlType == "upload")
+
- + type="file">
@@ -182,18 +181,18 @@ #end #end #if($table.sub) -

${subTable.functionName}信息

-
-
- - -
-
-
+

${subTable.functionName}信息

+
+
+ + +
+
+
#end
@@ -267,14 +266,14 @@ $(function () { $('.summernote').each(function (i) { var content = $("input[name='" + this.id + "']").val() - content = window.atob(content); + content = decodeURI(window.atob(content)); this.innerHTML = content; $(this).summernote({ height: 100, lang: 'zh-CN', callbacks: { onChange: function (contents, $edittable) { - $("input[name='" + this.id + "']").val(window.btoa(contents)) + $("input[name='" + this.id + "']").val(window.btoa(encodeURI(contents))); } } }); From 879f46b984cb2bb163fb1b24b6a790e2220de4fe Mon Sep 17 00:00:00 2001 From: xiexiangrui Date: Sat, 4 Jul 2020 17:07:10 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=AF=8C=E6=96=87=E6=9C=AC=20=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/vm/html/add.html.vm | 29 ++++++++++++++- .../src/main/resources/vm/html/edit.html.vm | 36 ++++++++++++++++--- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/ruoyi-generator/src/main/resources/vm/html/add.html.vm b/ruoyi-generator/src/main/resources/vm/html/add.html.vm index ffffae77e..2a3405e65 100644 --- a/ruoyi-generator/src/main/resources/vm/html/add.html.vm +++ b/ruoyi-generator/src/main/resources/vm/html/add.html.vm @@ -262,7 +262,34 @@ onChange: function (contents, $edittable) { // Xss 过滤掉了html 内容 ,所以用base64 保存 $("input[name='" + this.id + "']").val(window.btoa(encodeURI(contents))); - + }, + onImageUpload: function(files) { + var _self = this; + for(var i = 0; i < files.length; i++){ + var formData = new FormData(); + formData.append('file', files[i]); + var config = { + url: '/common/upload', + type: 'post', + data: formData, + contentType: false, + processData: false, + beforeSend: function () { + $.modal.loading("正在处理中,请稍后..."); + }, + success: function(result) { + if (result.code == web_status.SUCCESS) { + $('#'+ _self.id).summernote('insertImage',result.url); + } else if (result.code == web_status.WARNING) { + $.modal.alertWarning(result.msg) + } else { + $.modal.alertError(result.msg); + } + $.modal.closeLoading(); + } + }; + $.ajax(config) + } } } }); diff --git a/ruoyi-generator/src/main/resources/vm/html/edit.html.vm b/ruoyi-generator/src/main/resources/vm/html/edit.html.vm index 5c3a4255f..1e02fdba4 100644 --- a/ruoyi-generator/src/main/resources/vm/html/edit.html.vm +++ b/ruoyi-generator/src/main/resources/vm/html/edit.html.vm @@ -265,18 +265,46 @@ #if($isSummernote) $(function () { $('.summernote').each(function (i) { - var content = $("input[name='" + this.id + "']").val() - content = decodeURI(window.atob(content)); - this.innerHTML = content; - $(this).summernote({ + $('#'+this.id).summernote({ height: 100, lang: 'zh-CN', callbacks: { onChange: function (contents, $edittable) { $("input[name='" + this.id + "']").val(window.btoa(encodeURI(contents))); + }, + onImageUpload: function(files) { + var _self = this; + for(var i = 0; i < files.length; i++){ + var formData = new FormData(); + formData.append('file', files[i]); + var config = { + url: '/common/upload', + type: 'post', + data: formData, + contentType: false, + processData: false, + beforeSend: function () { + $.modal.loading("正在处理中,请稍后..."); + }, + success: function(result) { + if (result.code == web_status.SUCCESS) { + $('#'+ _self.id).summernote('insertImage',result.url); + } else if (result.code == web_status.WARNING) { + $.modal.alertWarning(result.msg) + } else { + $.modal.alertError(result.msg); + } + $.modal.closeLoading(); + } + }; + $.ajax(config) + } } } }); + var content = $("input[name='" + this.id + "']").val() + content = decodeURI(window.atob(content)); + $('#'+this.id).summernote('code',content); }) }); #end From 84bf85409bf9e945b53bc0e188b0619951ace9da Mon Sep 17 00:00:00 2001 From: xiexiangrui Date: Sat, 4 Jul 2020 17:13:59 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-generator/src/main/resources/vm/html/add.html.vm | 1 - ruoyi-generator/src/main/resources/vm/html/edit.html.vm | 1 - 2 files changed, 2 deletions(-) diff --git a/ruoyi-generator/src/main/resources/vm/html/add.html.vm b/ruoyi-generator/src/main/resources/vm/html/add.html.vm index 2a3405e65..3a4ea26cf 100644 --- a/ruoyi-generator/src/main/resources/vm/html/add.html.vm +++ b/ruoyi-generator/src/main/resources/vm/html/add.html.vm @@ -241,7 +241,6 @@ autoReplace: true, // 自动替换预览图(maxFileCount 是前置条件) overwriteInitial: true, // 选择文件后覆盖预览图 layoutTemplates :{ - actionDelete:'', //去除上传预览的缩略图中的删除图标 actionDrag:'' // 去除预览图拖拽图标 } }).on('fileuploaded', function (event, data, previewId, index) { diff --git a/ruoyi-generator/src/main/resources/vm/html/edit.html.vm b/ruoyi-generator/src/main/resources/vm/html/edit.html.vm index 1e02fdba4..097d5477f 100644 --- a/ruoyi-generator/src/main/resources/vm/html/edit.html.vm +++ b/ruoyi-generator/src/main/resources/vm/html/edit.html.vm @@ -249,7 +249,6 @@ autoReplace: true, // 自动替换预览图(maxFileCount 是前置条件) overwriteInitial: true, // 选择文件后覆盖预览图 layoutTemplates :{ - actionDelete:'', //去除上传预览的缩略图中的删除图标 actionDrag:'' // 去除预览图拖拽图标 } }).on('fileuploaded', function (event, data, previewId, index) {