From c1e344be0efc07702b0df22e2a2f5c18175c857c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=93=E4=B8=9A=E5=9D=91=E9=98=9F?= <1393111636@qq.com> Date: Wed, 24 Jun 2026 09:15:22 +0000 Subject: [PATCH] =?UTF-8?q?!863=20fix(generator):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E5=99=A8=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=92=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(generator): 优化代码生成器模板和逻辑 --- .../org/dromara/gen/util/TemplateEngineUtils.java | 3 +++ .../src/main/resources/fm/vue/index.vue.ftl | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ruoyi-modules/ruoyi-gen/src/main/java/org/dromara/gen/util/TemplateEngineUtils.java b/ruoyi-modules/ruoyi-gen/src/main/java/org/dromara/gen/util/TemplateEngineUtils.java index 57a42cd47..63e536dd5 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/java/org/dromara/gen/util/TemplateEngineUtils.java +++ b/ruoyi-modules/ruoyi-gen/src/main/java/org/dromara/gen/util/TemplateEngineUtils.java @@ -168,6 +168,7 @@ public class TemplateEngineUtils { boolean needDigit = false; boolean needDateField = false; boolean needSwitchField = false; + boolean needParseTime = false; String firstTreeListField = StringUtils.EMPTY; for (GenTableColumn column : genTable.getColumns()) { boolean writable = column.isInsert() || column.isEdit(); @@ -183,6 +184,7 @@ public class TemplateEngineUtils { needDigit = needDigit || writable && StringUtils.equals(column.getHtmlType(), GenConstants.HTML_INPUT_NUMBER); needDateField = needDateField || writable && StringUtils.equals(column.getHtmlType(), GenConstants.HTML_DATETIME); needSwitchField = needSwitchField || (writable || column.isList()) && StringUtils.equals(column.getHtmlType(), GenConstants.HTML_SWITCH); + needParseTime = needParseTime || column.isList() && StringUtils.equals(column.getHtmlType(), GenConstants.HTML_DATETIME); if (StringUtils.isBlank(firstTreeListField) && column.isList()) { firstTreeListField = column.getJavaField(); } @@ -202,6 +204,7 @@ public class TemplateEngineUtils { context.put("needDigit", needDigit); context.put("needDateField", needDateField); context.put("needSwitchField", needSwitchField); + context.put("needParseTime", needParseTime); context.put("firstTreeListField", firstTreeListField); } diff --git a/ruoyi-modules/ruoyi-gen/src/main/resources/fm/vue/index.vue.ftl b/ruoyi-modules/ruoyi-gen/src/main/resources/fm/vue/index.vue.ftl index 9bacf6fde..7caf600f5 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/resources/fm/vue/index.vue.ftl +++ b/ruoyi-modules/ruoyi-gen/src/main/resources/fm/vue/index.vue.ftl @@ -60,7 +60,7 @@ placeholder="请选择${column.columnLabel}" /> -<#elseif column.htmlType == "datetime" && column.queryType == "BETWEEN"> +<#elseif column.htmlType == "datetime" && column.queryType == "BETWEEN" && column.query> <#list columns as column> -<#if (column.insert || column.edit) && !column.pk>`n<#if column.htmlType == "input"> +<#if (column.insert || column.edit) && !column.pk><#if column.htmlType == "input"> @@ -380,6 +380,9 @@ import { useTableSelection } from '@/hooks/table/useTableSelection'; <#if needDict> import { useDict } from '@/utils/dict'; +<#if needParseTime> +import { parseTime } from '@/utils/ruoyi'; + import modal from '@/plugins/modal'; <#if enableExport> import { download as requestDownload } from '@/utils/request'; @@ -400,7 +403,7 @@ const { loading, withLoading } = useLoading(true); const { showSearch } = useSearchToggle(); const total = ref(0); <#list columns as column> -<#if column.htmlType == "datetime" && column.queryType == "BETWEEN"> +<#if column.htmlType == "datetime" && column.queryType == "BETWEEN" && column.query> const { dateRange: dateRange${column.capJavaField}, applyDateRange: apply${column.capJavaField}DateRange, @@ -472,7 +475,7 @@ const getList = async () => { <#if needAddDateRange> let params = queryParams.value; <#list columns as column> -<#if column.htmlType == "datetime" && column.queryType == "BETWEEN"> +<#if column.htmlType == "datetime" && column.queryType == "BETWEEN" && column.query> params = apply${column.capJavaField}DateRange(params); @@ -505,7 +508,7 @@ const { resetQuery } = useSearchReset({ initialPageSize: 10, resetExtras: () => { <#list columns as column> -<#if column.htmlType == "datetime" && column.queryType == "BETWEEN"> +<#if column.htmlType == "datetime" && column.queryType == "BETWEEN" && column.query> reset${column.capJavaField}DateRange();