From d0aa35e47ee48325cd43d0729e4ec82bdea23f7b Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期一, 04 九月 2023 09:43:47 +0800 Subject: [PATCH] fix 修复 代码生成页面参数缺少逗号问题 --- ruoyi-modules/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm | 109 +++++++++++++++++++----------------------------------- 1 files changed, 39 insertions(+), 70 deletions(-) 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 bfe5986..f872149 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 @@ -15,12 +15,7 @@ #end #if($column.htmlType == "input" || $column.htmlType == "textarea") <el-form-item label="${comment}" prop="${column.javaField}"> - <el-input - v-model="queryParams.${column.javaField}" - placeholder="璇疯緭鍏�${comment}" - clearable - @keyup.enter="handleQuery" - /> + <el-input v-model="queryParams.${column.javaField}" placeholder="璇疯緭鍏�${comment}" clearable @keyup.enter="handleQuery" /> </el-form-item> #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType) <el-form-item label="${comment}" prop="${column.javaField}"> @@ -51,7 +46,7 @@ #elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") <el-form-item label="${comment}" style="width: 308px"> <el-date-picker - v-model="daterange${AttrName}" + v-model="dateRange${AttrName}" value-format="YYYY-MM-DD HH:mm:ss" type="daterange" range-separator="-" @@ -75,42 +70,16 @@ <template #header> <el-row :gutter="10" class="mb8"> <el-col :span="1.5"> - <el-button - type="primary" - plain - icon="Plus" - @click="handleAdd" - v-hasPermi="['${moduleName}:${businessName}:add']" - >鏂板</el-button> + <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['${moduleName}:${businessName}:add']">鏂板</el-button> </el-col> <el-col :span="1.5"> - <el-button - type="success" - plain - icon="Edit" - :disabled="single" - @click="handleUpdate()" - v-hasPermi="['${moduleName}:${businessName}:edit']" - >淇敼</el-button> + <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['${moduleName}:${businessName}:edit']">淇敼</el-button> </el-col> <el-col :span="1.5"> - <el-button - type="danger" - plain - icon="Delete" - :disabled="multiple" - @click="handleDelete()" - v-hasPermi="['${moduleName}:${businessName}:remove']" - >鍒犻櫎</el-button> + <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['${moduleName}:${businessName}:remove']">鍒犻櫎</el-button> </el-col> <el-col :span="1.5"> - <el-button - type="warning" - plain - icon="Download" - @click="handleExport" - v-hasPermi="['${moduleName}:${businessName}:export']" - >瀵煎嚭</el-button> + <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['${moduleName}:${businessName}:export']">瀵煎嚭</el-button> </el-col> <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> </el-row> @@ -127,7 +96,7 @@ #set($comment=$column.columnComment) #end #if($column.pk) - <el-table-column label="${comment}" align="center" prop="${javaField}" v-if="${column.list}"/> + <el-table-column label="${comment}" align="center" prop="${javaField}" v-if="${column.list}" /> #elseif($column.list && $column.htmlType == "datetime") <el-table-column label="${comment}" align="center" prop="${javaField}" width="180"> <template #default="scope"> @@ -179,7 +148,7 @@ <el-form ref="${businessName}FormRef" :model="form" :rules="rules" label-width="80px"> #foreach($column in $columns) #set($field=$column.javaField) -#if($column.insert && !$column.pk) +#if(($column.insert || $column.edit) && !$column.pk) #set($parentheseIndex=$column.columnComment.indexOf("锛�")) #if($parentheseIndex != -1) #set($comment=$column.columnComment.substring(0, $parentheseIndex)) @@ -291,8 +260,6 @@ <script setup name="${BusinessName}" lang="ts"> 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} != '') @@ -311,12 +278,12 @@ #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<ElFormInstance>(); +const ${businessName}FormRef = ref<ElFormInstance>(); const dialog = reactive<DialogOption>({ visible: false, @@ -341,9 +308,20 @@ pageSize: 10, #foreach ($column in $columns) #if($column.query) - $column.javaField: undefined#if($foreach.count != $columns.size()),#end +#if($column.htmlType != "datetime" || $column.queryType != "BETWEEN") + $column.javaField: undefined, #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) @@ -378,10 +356,7 @@ #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); @@ -399,7 +374,7 @@ /** 琛ㄥ崟閲嶇疆 */ const reset = () => { form.value = {...initFormData}; - ${businessName}FormRef.value.resetFields(); + ${businessName}FormRef.value?.resetFields(); } /** 鎼滅储鎸夐挳鎿嶄綔 */ @@ -413,10 +388,10 @@ #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(); } @@ -429,35 +404,29 @@ /** 鏂板鎸夐挳鎿嶄綔 */ const handleAdd = () => { + reset(); dialog.visible = true; dialog.title = "娣诲姞${functionName}"; - nextTick(() => { - reset(); - }); } /** 淇敼鎸夐挳鎿嶄綔 */ -const handleUpdate = (row?: ${BusinessName}VO) => { - loading.value = true +const handleUpdate = async (row?: ${BusinessName}VO) => { + reset(); + const _${pkColumn.javaField} = row?.${pkColumn.javaField} || ids.value[0] + const res = await get${BusinessName}(_${pkColumn.javaField}); + Object.assign(form.value, res.data); +#foreach ($column in $columns) + #if($column.htmlType == "checkbox") + form.value.$column.javaField = form.value.${column.javaField}.split(","); + #end +#end dialog.visible = true; dialog.title = "淇敼${functionName}"; - nextTick(async () => { - reset(); - const _${pkColumn.javaField} = row?.${pkColumn.javaField} || ids.value[0] - const res = await get${BusinessName}(_${pkColumn.javaField}); - loading.value = false; - Object.assign(form.value, res.data); -#foreach ($column in $columns) -#if($column.htmlType == "checkbox") - form.value.$column.javaField = form.value.${column.javaField}.split(","); -#end -#end - }); } /** 鎻愪氦鎸夐挳 */ 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) -- Gitblit v1.9.3