Commit a948affb2d96178c4a79369f1f0a271c0d59aa32
1 parent
57b49dd5
代码生成支持富文本控件
Showing
6 changed files
with
45 additions
and
2 deletions
ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java
| ... | ... | @@ -74,6 +74,9 @@ public class GenConstants |
| 74 | 74 | /** 日期控件 */ |
| 75 | 75 | public static final String HTML_DATETIME = "datetime"; |
| 76 | 76 | |
| 77 | + /** 富文本控件 */ | |
| 78 | + public static final String HTML_EDITOR = "editor"; | |
| 79 | + | |
| 77 | 80 | /** 字符串类型 */ |
| 78 | 81 | public static final String TYPE_STRING = "String"; |
| 79 | 82 | ... | ... |
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java
| ... | ... | @@ -59,7 +59,7 @@ public class GenTableColumn extends BaseEntity |
| 59 | 59 | /** 查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围) */ |
| 60 | 60 | private String queryType; |
| 61 | 61 | |
| 62 | - /** 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件) */ | |
| 62 | + /** 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、editor富文本控件) */ | |
| 63 | 63 | private String htmlType; |
| 64 | 64 | |
| 65 | 65 | /** 字典类型 */ | ... | ... |
ruoyi-generator/src/main/java/com/ruoyi/generator/util/GenUtils.java
| ... | ... | @@ -111,6 +111,11 @@ public class GenUtils |
| 111 | 111 | { |
| 112 | 112 | column.setHtmlType(GenConstants.HTML_SELECT); |
| 113 | 113 | } |
| 114 | + // 内容字段设置富文本控件 | |
| 115 | + else if (StringUtils.endsWithIgnoreCase(columnName, "content")) | |
| 116 | + { | |
| 117 | + column.setHtmlType(GenConstants.HTML_EDITOR); | |
| 118 | + } | |
| 114 | 119 | } |
| 115 | 120 | |
| 116 | 121 | /** | ... | ... |
ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm
| ... | ... | @@ -139,6 +139,10 @@ |
| 139 | 139 | <el-form-item label="${comment}" prop="${field}"> |
| 140 | 140 | <el-input v-model="form.${field}" placeholder="请输入${comment}" /> |
| 141 | 141 | </el-form-item> |
| 142 | +#elseif($column.htmlType == "editor") | |
| 143 | + <el-form-item label="${comment}"> | |
| 144 | + <editor v-model="form.${field}" :min-height="192"/> | |
| 145 | + </el-form-item> | |
| 142 | 146 | #elseif($column.htmlType == "select" && "" != $dictType) |
| 143 | 147 | <el-form-item label="${comment}" prop="${field}"> |
| 144 | 148 | <el-select v-model="form.${field}" placeholder="请选择${comment}"> |
| ... | ... | @@ -221,10 +225,24 @@ |
| 221 | 225 | import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}"; |
| 222 | 226 | import Treeselect from "@riophae/vue-treeselect"; |
| 223 | 227 | import "@riophae/vue-treeselect/dist/vue-treeselect.css"; |
| 228 | +#foreach($column in $columns) | |
| 229 | +#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor") | |
| 230 | +import Editor from '@/components/Editor'; | |
| 231 | +#break | |
| 232 | +#end | |
| 233 | +#end | |
| 224 | 234 | |
| 225 | 235 | export default { |
| 226 | 236 | name: "${BusinessName}", |
| 227 | - components: { Treeselect }, | |
| 237 | + components: { | |
| 238 | +#foreach($column in $columns) | |
| 239 | +#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor") | |
| 240 | + Editor, | |
| 241 | +#break | |
| 242 | +#end | |
| 243 | +#end | |
| 244 | + Treeselect | |
| 245 | + }, | |
| 228 | 246 | data() { |
| 229 | 247 | return { |
| 230 | 248 | // 遮罩层 | ... | ... |
ruoyi-generator/src/main/resources/vm/vue/index.vue.vm
| ... | ... | @@ -168,6 +168,10 @@ |
| 168 | 168 | <el-form-item label="${comment}" prop="${field}"> |
| 169 | 169 | <el-input v-model="form.${field}" placeholder="请输入${comment}" /> |
| 170 | 170 | </el-form-item> |
| 171 | +#elseif($column.htmlType == "editor") | |
| 172 | + <el-form-item label="${comment}"> | |
| 173 | + <editor v-model="form.${field}" :min-height="192"/> | |
| 174 | + </el-form-item> | |
| 171 | 175 | #elseif($column.htmlType == "select" && "" != $dictType) |
| 172 | 176 | <el-form-item label="${comment}" prop="${field}"> |
| 173 | 177 | <el-select v-model="form.${field}" placeholder="请选择${comment}"> |
| ... | ... | @@ -248,9 +252,21 @@ |
| 248 | 252 | |
| 249 | 253 | <script> |
| 250 | 254 | import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}"; |
| 255 | +#foreach($column in $columns) | |
| 256 | +#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor") | |
| 257 | +import Editor from '@/components/Editor'; | |
| 258 | +#break | |
| 259 | +#end | |
| 260 | +#end | |
| 251 | 261 | |
| 252 | 262 | export default { |
| 253 | 263 | name: "${BusinessName}", |
| 264 | +#foreach($column in $columns) | |
| 265 | +#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor") | |
| 266 | + components: { Editor }, | |
| 267 | +#break | |
| 268 | +#end | |
| 269 | +#end | |
| 254 | 270 | data() { |
| 255 | 271 | return { |
| 256 | 272 | // 遮罩层 | ... | ... |
ruoyi-ui/src/views/tool/gen/editTable.vue