From 66540b5e561cf467ca53f133afea346a4c7a4775 Mon Sep 17 00:00:00 2001 From: LiuHao Date: Mon, 17 Jul 2023 22:15:06 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=94=9F=E6=88=90=E6=A8=A1=E7=89=88=EF=BC=8C=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E8=8C=83=E5=9B=B4=E7=BB=9F=E4=B8=80=E9=87=87=E7=94=A8addDateRa?= =?UTF-8?q?nge=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/vm/ts/types.ts.vm | 7 ++++ .../main/resources/vm/vue/index-tree.vue.vm | 39 +++++++++++-------- .../src/main/resources/vm/vue/index.vue.vm | 34 +++++++++------- 3 files changed, 49 insertions(+), 31 deletions(-) diff --git a/ruoyi-modules/ruoyi-generator/src/main/resources/vm/ts/types.ts.vm b/ruoyi-modules/ruoyi-generator/src/main/resources/vm/ts/types.ts.vm index c67454b0..06e4000c 100644 --- a/ruoyi-modules/ruoyi-generator/src/main/resources/vm/ts/types.ts.vm +++ b/ruoyi-modules/ruoyi-generator/src/main/resources/vm/ts/types.ts.vm @@ -29,6 +29,10 @@ export interface ${BusinessName}Form extends BaseEntity { } export interface ${BusinessName}Query #if(!${treeCode})extends PageQuery #end{ + /** + * 日期范围参数 + */ + params?: any; #foreach ($column in $columns) #if($column.query) /** @@ -42,3 +46,6 @@ export interface ${BusinessName}Query #if(!${treeCode})extends PageQuery #end{ #end #end } + + + diff --git a/ruoyi-modules/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm b/ruoyi-modules/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm index 2eeecd34..ac55c0c7 100644 --- a/ruoyi-modules/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm +++ b/ruoyi-modules/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm @@ -46,7 +46,7 @@ #elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}"; import { ${BusinessName}VO, ${BusinessName}Query, ${BusinessName}Form } from '@/api/${moduleName}/${businessName}/types'; -import { ComponentInternalInstance } from 'vue'; -import { ElForm, ElTable } from 'element-plus'; - type ${BusinessName}Option = { ${treeCode}: number; @@ -292,9 +289,9 @@ const showSearch = ref(true); const isExpandAll = ref(true); const loading = ref(false); -const queryFormRef = ref(ElForm); -const ${businessName}FormRef = ref(ElForm); -const ${businessName}TableRef = ref(ElTable) +const queryFormRef = ref(); +const ${businessName}FormRef = ref(); +const ${businessName}TableRef = ref() const dialog = reactive({ visible: false, @@ -304,7 +301,7 @@ const dialog = reactive({ #foreach ($column in $columns) #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) -const daterange${AttrName} = ref([]); +const dateRange${AttrName} = ref<[DateModelType, DateModelType]>(['', '']); #end #end @@ -325,9 +322,20 @@ const data = reactive>({ queryParams: { #foreach ($column in $columns) #if($column.query) + #if($column.htmlType != "datetime" || $column.queryType != "BETWEEN") $column.javaField: undefined#if($foreach.count != $columns.size()),#end + #end #end #end + params: { + #foreach ($column in $columns) + #if($column.query) + #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") + $column.javaField: undefined#if($foreach.count != $columns.size()),#end + #end + #end + #end + } }, rules: { #foreach ($column in $columns) @@ -362,10 +370,7 @@ const getList = async () => { #foreach ($column in $columns) #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) - if (null != daterange${AttrName} && '' != daterange${AttrName}) { - queryParams.value.params["begin${AttrName}"] = daterange${AttrName}.value[0]; - queryParams.value.params["end${AttrName}"] = daterange${AttrName}.value[1]; - } + proxy?.addDateRange(queryParams.value, dateRange${AttrName}.value, '${AttrName}'); #end #end const res = await list${BusinessName}(queryParams.value); @@ -394,7 +399,7 @@ const cancel = () => { // 表单重置 const reset = () => { form.value = {...initFormData} - ${businessName}FormRef.value.resetFields(); + ${businessName}FormRef.value?.resetFields(); } /** 搜索按钮操作 */ @@ -407,10 +412,10 @@ const resetQuery = () => { #foreach ($column in $columns) #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) - daterange${AttrName}.value = []; + dateRange${AttrName}.value = ['', '']; #end #end - queryFormRef.value.resetFields(); + queryFormRef.value?.resetFields(); handleQuery(); } @@ -438,7 +443,7 @@ const handleToggleExpandAll = () => { /** 展开/折叠操作 */ const toggleExpandAll = (data: ${BusinessName}VO[], status: boolean) => { data.forEach((item) => { - ${businessName}TableRef.value.toggleRowExpansion(item, status) + ${businessName}TableRef.value?.toggleRowExpansion(item, status) if (item.children && item.children.length > 0) toggleExpandAll(item.children, status) }) } @@ -467,7 +472,7 @@ const handleUpdate = (row: ${BusinessName}VO) => { /** 提交按钮 */ const submitForm = () => { - ${businessName}FormRef.value.validate(async (valid: boolean) => { + ${businessName}FormRef.value?.validate(async (valid: boolean) => { if (valid) { buttonLoading.value = true; #foreach ($column in $columns) diff --git a/ruoyi-modules/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm b/ruoyi-modules/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm index 81784c8b..5af71182 100644 --- a/ruoyi-modules/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm +++ b/ruoyi-modules/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm @@ -46,7 +46,7 @@ #elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from '@/api/${moduleName}/${businessName}'; import { ${BusinessName}VO, ${BusinessName}Query, ${BusinessName}Form } from '@/api/${moduleName}/${businessName}/types'; -import { ComponentInternalInstance } from 'vue'; -import { ElForm } from 'element-plus'; const { proxy } = getCurrentInstance() as ComponentInternalInstance; #if(${dicts} != '') @@ -280,12 +278,12 @@ const total = ref(0); #foreach ($column in $columns) #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) -const daterange${AttrName} = ref([]); +const dateRange${AttrName} = ref<[DateModelType, DateModelType]>(['', '']); #end #end -const queryFormRef = ref(ElForm); -const ${businessName}FormRef = ref(ElForm); +const queryFormRef = ref(); +const ${businessName}FormRef = ref(); const dialog = reactive({ visible: false, @@ -310,9 +308,20 @@ const data = reactive>({ pageSize: 10, #foreach ($column in $columns) #if($column.query) + #if($column.htmlType != "datetime" || $column.queryType != "BETWEEN") $column.javaField: undefined#if($foreach.count != $columns.size()),#end + #end #end #end + params: { + #foreach ($column in $columns) + #if($column.query) + #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") + $column.javaField: undefined#if($foreach.count != $columns.size()),#end + #end + #end + #end + } }, rules: { #foreach ($column in $columns) @@ -347,10 +356,7 @@ const getList = async () => { #foreach ($column in $columns) #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) - if (null != daterange${AttrName} && '' != daterange${AttrName}) { - queryParams.value.params["begin${AttrName}"] = daterange${AttrName}.value[0]; - queryParams.value.params["end${AttrName}"] = daterange${AttrName}.value[1]; - } + proxy?.addDateRange(queryParams.value, dateRange${AttrName}.value, '${AttrName}'); #end #end const res = await list${BusinessName}(queryParams.value); @@ -368,7 +374,7 @@ const cancel = () => { /** 表单重置 */ const reset = () => { form.value = {...initFormData}; - ${businessName}FormRef.value.resetFields(); + ${businessName}FormRef.value?.resetFields(); } /** 搜索按钮操作 */ @@ -382,10 +388,10 @@ const resetQuery = () => { #foreach ($column in $columns) #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) - daterange${AttrName}.value = []; + dateRange${AttrName}.value = ['', '']; #end #end - queryFormRef.value.resetFields(); + queryFormRef.value?.resetFields(); handleQuery(); } @@ -426,7 +432,7 @@ const handleUpdate = (row?: ${BusinessName}VO) => { /** 提交按钮 */ const submitForm = () => { - ${businessName}FormRef.value.validate(async (valid: boolean) => { + ${businessName}FormRef.value?.validate(async (valid: boolean) => { if (valid) { buttonLoading.value = true; #foreach ($column in $columns)