代码生成支持:主子表(element-ts版本)

This commit is contained in:
dataprince 2024-01-31 15:43:21 +08:00
parent ee7ef99c36
commit 1183249080
7 changed files with 223 additions and 84 deletions

View File

@ -37,15 +37,15 @@ Ruoyi-Flex已集成各种开源开发框架扫平了技术障碍可直接
## 3、前端项目 ## 3、前端项目
Ruoyi-Flex实行前后端分离仓库本项目是java后端部分目前有3个前端项目 Ruoyi-Flex实行前后端分离仓库本项目是java后端部分目前有3个前端项目
### 1flex-elementplus-ui ### 1ruoyiflex-elementplus-ts
使用elementplus、js构建项目地址: [flex-elementplus-ui](https://gitee.com/dataprince/flex-elementplus-ui)
### 2ruoyiflex-elementplus-ts
使用elementplus、typescript构建项目地址: [ruoyiflex-elementplus-ts](https://gitee.com/dataprince/ruoyiflex-elementplus-ts) 使用elementplus、typescript构建项目地址: [ruoyiflex-elementplus-ts](https://gitee.com/dataprince/ruoyiflex-elementplus-ts)
### 3ruoyiflex-antdesign-vben ### 2ruoyiflex-antdesign-vben
使用antdesign、vben、typescript构建项目地址: [ruoyiflex-antdesign-vben](https://gitee.com/dataprince/ruoyiflex-antdesign-vben) 使用antdesign、vben、typescript构建项目地址: [ruoyiflex-antdesign-vben](https://gitee.com/dataprince/ruoyiflex-antdesign-vben)
### 3flex-elementplus-ui
使用elementplus、js构建项目地址: [flex-elementplus-ui](https://gitee.com/dataprince/flex-elementplus-ui)
## 4、内置功能 ## 4、内置功能
1. 租户管理:系统内租户的管理 如:租户套餐、过期时间、用户数量、企业信息等。 1. 租户管理:系统内租户的管理 如:租户套餐、过期时间、用户数量、企业信息等。

View File

@ -75,6 +75,7 @@ public class GenTableServiceImpl extends BaseServiceImpl<GenTableMapper, GenTabl
if (params.get("beginTime") != null && params.get("endTime") != null) { if (params.get("beginTime") != null && params.get("endTime") != null) {
queryWrapper.and(GEN_TABLE.CREATE_TIME.between(params.get("beginTime"), params.get("endTime"))); queryWrapper.and(GEN_TABLE.CREATE_TIME.between(params.get("beginTime"), params.get("endTime")));
} }
queryWrapper.orderBy(GEN_TABLE.TABLE_ID.desc());
return queryWrapper; return queryWrapper;
} }

View File

@ -13,10 +13,31 @@ export interface ${BusinessName}VO extends BaseEntity {
#end #end
#if ($table.tree) #if ($table.tree)
/** /**
* 子对象 * 子对象
*/ */
children: ${BusinessName}VO[]; children: ${BusinessName}VO[];
#end #end
#if($table.sub)
/** $table.subTable.functionName信息 */
${subclassName}List: Array<${subClassName}VO>;
#end
}
export interface ${subClassName}VO extends BaseEntity {
/** 列表序号 */
index:number;
#foreach ($column in $subTable.columns)
#if($column.list)
/**
* $column.columnComment
*/
$column.javaField:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) string | number;
#elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number;
#elseif($column.javaType == 'Boolean') boolean;
#else string;
#end
#end
#end
} }
export interface ${BusinessName}Form { export interface ${BusinessName}Form {

View File

@ -22,7 +22,7 @@
</el-form-item> </el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType) #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="${column.javaField}">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable> <el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable style="width: 240px">
<el-option <el-option
v-for="dict in ${dictType}" v-for="dict in ${dictType}"
:key="dict.value" :key="dict.value"
@ -33,7 +33,7 @@
</el-form-item> </el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType) #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="${column.javaField}">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable> <el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable style="width: 240px">
<el-option label="请选择字典生成" value="" /> <el-option label="请选择字典生成" value="" />
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -157,7 +157,8 @@
<el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px"> <el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px">
#foreach($column in $columns) #foreach($column in $columns)
#set($field=$column.javaField) #set($field=$column.javaField)
#if(($column.insert || $column.edit) && !$column.pk) #if($column.insert && !$column.pk)
#if(($column.usableColumn) || (!$column.superColumn))
#set($parentheseIndex=$column.columnComment.indexOf("")) #set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1) #if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex)) #set($comment=$column.columnComment.substring(0, $parentheseIndex))
@ -177,15 +178,9 @@
/> />
</el-form-item> </el-form-item>
#elseif($column.htmlType == "input") #elseif($column.htmlType == "input")
#if(${field} == "version")
<el-form-item label="${comment}" prop="${field}" v-show="false">
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
</el-form-item>
#else
<el-form-item label="${comment}" prop="${field}"> <el-form-item label="${comment}" prop="${field}">
<el-input v-model="form.${field}" placeholder="请输入${comment}" /> <el-input v-model="form.${field}" placeholder="请输入${comment}" />
</el-form-item> </el-form-item>
#end
#elseif($column.htmlType == "imageUpload") #elseif($column.htmlType == "imageUpload")
<el-form-item label="${comment}" prop="${field}"> <el-form-item label="${comment}" prop="${field}">
<image-upload v-model="form.${field}"/> <image-upload v-model="form.${field}"/>
@ -271,6 +266,7 @@
</el-form-item> </el-form-item>
#end #end
#end #end
#end
#end #end
</el-form> </el-form>
<template #footer> <template #footer>
@ -380,11 +376,7 @@ function reset() {
#if($column.htmlType == "checkbox") #if($column.htmlType == "checkbox")
$column.javaField: []#if($foreach.count != $columns.size()),#end $column.javaField: []#if($foreach.count != $columns.size()),#end
#else #else
#if(${column.javaField} == "version")
$column.javaField: 0#if($foreach.count != $columns.size()),#end
#else
$column.javaField: null#if($foreach.count != $columns.size()),#end $column.javaField: null#if($foreach.count != $columns.size()),#end
#end
#end #end
#end #end
}; };

View File

@ -22,7 +22,7 @@
</el-form-item> </el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType) #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="${column.javaField}">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable> <el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable style="width: 240px">
<el-option <el-option
v-for="dict in ${dictType}" v-for="dict in ${dictType}"
:key="dict.value" :key="dict.value"
@ -33,7 +33,7 @@
</el-form-item> </el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType) #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="${column.javaField}">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable> <el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable style="width: 240px">
<el-option label="请选择字典生成" value="" /> <el-option label="请选择字典生成" value="" />
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -167,7 +167,8 @@
<el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px"> <el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px">
#foreach($column in $columns) #foreach($column in $columns)
#set($field=$column.javaField) #set($field=$column.javaField)
#if(($column.insert || $column.edit) && !$column.pk) #if($column.insert && !$column.pk)
#if(($column.usableColumn) || (!$column.superColumn))
#set($parentheseIndex=$column.columnComment.indexOf("")) #set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1) #if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex)) #set($comment=$column.columnComment.substring(0, $parentheseIndex))
@ -176,15 +177,9 @@
#end #end
#set($dictType=$column.dictType) #set($dictType=$column.dictType)
#if($column.htmlType == "input") #if($column.htmlType == "input")
#if(${field} == "version")
<el-form-item label="${comment}" prop="${field}" v-show="false">
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
</el-form-item>
#else
<el-form-item label="${comment}" prop="${field}"> <el-form-item label="${comment}" prop="${field}">
<el-input v-model="form.${field}" placeholder="请输入${comment}" /> <el-input v-model="form.${field}" placeholder="请输入${comment}" />
</el-form-item> </el-form-item>
#end
#elseif($column.htmlType == "imageUpload") #elseif($column.htmlType == "imageUpload")
<el-form-item label="${comment}" prop="${field}"> <el-form-item label="${comment}" prop="${field}">
<image-upload v-model="form.${field}"/> <image-upload v-model="form.${field}"/>
@ -271,6 +266,7 @@
#end #end
#end #end
#end #end
#end
#if($table.sub) #if($table.sub)
<el-divider content-position="center">${subTable.functionName}信息</el-divider> <el-divider content-position="center">${subTable.functionName}信息</el-divider>
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
@ -283,7 +279,7 @@
</el-row> </el-row>
<el-table :data="${subclassName}List" :row-class-name="row${subClassName}Index" @selection-change="handle${subClassName}SelectionChange" ref="${subclassName}"> <el-table :data="${subclassName}List" :row-class-name="row${subClassName}Index" @selection-change="handle${subClassName}SelectionChange" ref="${subclassName}">
<el-table-column type="selection" width="50" align="center" /> <el-table-column type="selection" width="50" align="center" />
<el-table-column label="序号" align="center" prop="index" width="50"/> <el-table-column label="序号" align="center" prop="index" width="50" />
#foreach($column in $subTable.columns) #foreach($column in $subTable.columns)
#set($javaField=$column.javaField) #set($javaField=$column.javaField)
#set($parentheseIndex=$column.columnComment.indexOf("")) #set($parentheseIndex=$column.columnComment.indexOf(""))
@ -294,43 +290,43 @@
#end #end
#if($column.pk || $javaField == ${subTableFkclassName}) #if($column.pk || $javaField == ${subTableFkclassName})
#elseif($column.list && $column.htmlType == "input") #elseif($column.list && $column.htmlType == "input")
<el-table-column label="$comment" prop="${javaField}" width="150"> <el-table-column label="$comment" prop="${javaField}" width="150">
<template #default="scope"> <template #default="scope">
<el-input v-model="scope.row.$javaField" placeholder="请输入$comment" /> <el-input v-model="scope.row.$javaField" placeholder="请输入$comment" />
</template> </template>
</el-table-column> </el-table-column>
#elseif($column.list && $column.htmlType == "datetime") #elseif($column.list && $column.htmlType == "datetime")
<el-table-column label="$comment" prop="${javaField}" width="240"> <el-table-column label="$comment" prop="${javaField}" width="240">
<template #default="scope"> <template #default="scope">
<el-date-picker clearable <el-date-picker clearable
v-model="scope.row.$javaField" v-model="scope.row.$javaField"
type="date" type="date"
value-format="YYYY-MM-DD" value-format="YYYY-MM-DD"
placeholder="请选择$comment"> placeholder="请选择$comment">
</el-date-picker> </el-date-picker>
</template> </template>
</el-table-column> </el-table-column>
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" != $column.dictType) #elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" != $column.dictType)
<el-table-column label="$comment" prop="${javaField}" width="150"> <el-table-column label="$comment" prop="${javaField}" width="150">
<template #default="scope"> <template #default="scope">
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment"> <el-select v-model="scope.row.$javaField" placeholder="请选择$comment">
<el-option <el-option
v-for="dict in $column.dictType" v-for="dict in $column.dictType"
:key="dict.value" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="dict.value" :value="dict.value"
></el-option> ></el-option>
</el-select> </el-select>
</template> </template>
</el-table-column> </el-table-column>
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" == $column.dictType) #elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" == $column.dictType)
<el-table-column label="$comment" prop="${javaField}" width="150"> <el-table-column label="$comment" prop="${javaField}" width="150">
<template #default="scope"> <template #default="scope">
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment"> <el-select v-model="scope.row.$javaField" placeholder="请选择$comment">
<el-option label="请选择字典生成" value="" /> <el-option label="请选择字典生成" value="" />
</el-select> </el-select>
</template> </template>
</el-table-column> </el-table-column>
#end #end
#end #end
</el-table> </el-table>
@ -456,11 +452,7 @@ function reset() {
#if($column.htmlType == "checkbox") #if($column.htmlType == "checkbox")
$column.javaField: []#if($foreach.count != $columns.size()),#end $column.javaField: []#if($foreach.count != $columns.size()),#end
#else #else
#if(${column.javaField} == "version")
$column.javaField: 0#if($foreach.count != $columns.size()),#end
#else
$column.javaField: null#if($foreach.count != $columns.size()),#end $column.javaField: null#if($foreach.count != $columns.size()),#end
#end
#end #end
#end #end
}; };
@ -499,7 +491,7 @@ function handleSelectionChange(selection) {
function handleAdd() { function handleAdd() {
reset(); reset();
open.value = true; open.value = true;
title.value = "添加${functionName}"; title.value = '添加${functionName}';
} }
/** 修改按钮操作 */ /** 修改按钮操作 */
@ -517,7 +509,7 @@ function handleUpdate(row) {
${subclassName}List.value = response.data.${subclassName}List; ${subclassName}List.value = response.data.${subclassName}List;
#end #end
open.value = true; open.value = true;
title.value = "修改${functionName}"; title.value = '修改${functionName}';
}); });
} }

View File

@ -19,7 +19,7 @@
</el-form-item> </el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType) #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="${column.javaField}">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable> <el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable style="width: 240px">
<el-option <el-option
v-for="dict in ${dictType}" v-for="dict in ${dictType}"
:key="dict.value" :key="dict.value"
@ -30,7 +30,7 @@
</el-form-item> </el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType) #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="${column.javaField}">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable> <el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable style="width: 240px">
<el-option label="请选择字典生成" value="" /> <el-option label="请选择字典生成" value="" />
</el-select> </el-select>
</el-form-item> </el-form-item>

View File

@ -19,7 +19,7 @@
</el-form-item> </el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType) #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="${column.javaField}">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable> <el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable style="width: 240px">
<el-option <el-option
v-for="dict in ${dictType}" v-for="dict in ${dictType}"
:key="dict.value" :key="dict.value"
@ -30,7 +30,7 @@
</el-form-item> </el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType) #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="${column.javaField}">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable> <el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable style="width: 240px">
<el-option label="请选择字典生成" value="" /> <el-option label="请选择字典生成" value="" />
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -47,12 +47,12 @@
<el-form-item label="${comment}" style="width: 308px"> <el-form-item label="${comment}" style="width: 308px">
<el-date-picker <el-date-picker
v-model="dateRange${AttrName}" v-model="dateRange${AttrName}"
value-format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD"
type="daterange" type="daterange"
range-separator="-" range-separator="-"
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" end-placeholder="结束日期"
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]" :default-time="[new Date(2024, 1, 1, 0, 0, 0), new Date(2024, 1, 1, 23, 59, 59)]"
/> />
</el-form-item> </el-form-item>
#end #end
@ -144,7 +144,7 @@
/> />
</el-card> </el-card>
<!-- 添加或修改${functionName}对话框 --> <!-- 添加或修改${functionName}对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body> <el-dialog :title="dialog.title" v-model="dialog.visible" width="780px" append-to-body>
<el-form ref="${businessName}FormRef" :model="form" :rules="rules" label-width="80px"> <el-form ref="${businessName}FormRef" :model="form" :rules="rules" label-width="80px">
#foreach($column in $columns) #foreach($column in $columns)
#set($field=$column.javaField) #set($field=$column.javaField)
@ -252,6 +252,78 @@
#end #end
#end #end
#end #end
#if($table.sub)
<el-divider content-position="center">${subTable.functionName}信息</el-divider>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" icon="Plus" @click="handleAdd${subClassName}">添加</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" icon="Delete" @click="handleDelete${subClassName}">删除</el-button>
</el-col>
</el-row>
<el-table :data="${subclassName}List" :row-class-name="row${subClassName}Index" @selection-change="handle${subClassName}SelectionChange" ref="${subclassName}">
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="序号" align="center" prop="index" width="50" />
#foreach($column in $subTable.columns)
#set($javaField=$column.javaField)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($column.pk || $javaField == ${subTableFkclassName})
#elseif($column.list && $column.htmlType == "input")
#if(${javaField} == "version")
<el-table-column v-if="false" label="$comment" prop="${javaField}" width="150">
<template #default="scope">
<el-input v-model="scope.row.$javaField" placeholder="请输入$comment" />
</template>
</el-table-column>
#else
<el-table-column label="$comment" prop="${javaField}" width="150">
<template #default="scope">
<el-input v-model="scope.row.$javaField" placeholder="请输入$comment" />
</template>
</el-table-column>
#end
#elseif($column.list && $column.htmlType == "datetime")
<el-table-column label="$comment" prop="${javaField}" width="240">
<template #default="scope">
<el-date-picker clearable
v-model="scope.row.$javaField"
type="date"
value-format="YYYY-MM-DD"
placeholder="请选择$comment">
</el-date-picker>
</template>
</el-table-column>
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" != $column.dictType)
<el-table-column label="$comment" prop="${javaField}" width="150">
<template #default="scope">
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment">
<el-option
v-for="dict in $column.dictType"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</template>
</el-table-column>
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" == $column.dictType)
<el-table-column label="$comment" prop="${javaField}" width="150">
<template #default="scope">
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment">
<el-option label="请选择字典生成" value="" />
</el-select>
</template>
</el-table-column>
#end
#end
</el-table>
#end
</el-form> </el-form>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
@ -273,13 +345,24 @@ const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { ${dictsNoSymbol} } = toRefs<any>(proxy?.useDict(${dicts})); const { ${dictsNoSymbol} } = toRefs<any>(proxy?.useDict(${dicts}));
#end #end
// 表格数据
const ${businessName}List = ref<${BusinessName}VO[]>([]); const ${businessName}List = ref<${BusinessName}VO[]>([]);
// 子表格数据
const ${subclassName}List = ref<${subClassName}VO[]>([]);
const buttonLoading = ref(false); const buttonLoading = ref(false);
const loading = ref(true); const loading = ref(true);
const showSearch = ref(true); const showSearch = ref(true);
// 选中数组
const ids = ref<Array<string | number>>([]); const ids = ref<Array<string | number>>([]);
#if($table.sub)
// 子表选中数据
const checked${subClassName} = ref<${subClassName}VO[]>([]);
#end
// 非单个禁用
const single = ref(true); const single = ref(true);
// 非多个禁用
const multiple = ref(true); const multiple = ref(true);
// 总条数
const total = ref(0); const total = ref(0);
#foreach ($column in $columns) #foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
@ -384,6 +467,9 @@ const cancel = () => {
/** 表单重置 */ /** 表单重置 */
const reset = () => { const reset = () => {
form.value = {...initFormData}; form.value = {...initFormData};
#if($table.sub)
${subclassName}List.value = [];
#end
${businessName}FormRef.value?.resetFields(); ${businessName}FormRef.value?.resetFields();
}; };
@ -416,22 +502,25 @@ const handleSelectionChange = (selection: ${BusinessName}VO[]) => {
const handleAdd = () => { const handleAdd = () => {
reset(); reset();
dialog.visible = true; dialog.visible = true;
dialog.title = "添加${functionName}"; dialog.title = '添加${functionName}';
}; };
/** 修改按钮操作 */ /** 修改按钮操作 */
const handleUpdate = async (row?: ${BusinessName}VO) => { const handleUpdate = async (row?: ${BusinessName}VO) => {
reset(); reset();
const _${pkColumn.javaField} = row?.${pkColumn.javaField} || ids.value[0] const _${pkColumn.javaField} = row?.${pkColumn.javaField} || ids.value[0];
const res = await get${BusinessName}(_${pkColumn.javaField}); const res = await get${BusinessName}(_${pkColumn.javaField});
Object.assign(form.value, res.data); Object.assign(form.value, res.data);
#foreach ($column in $columns) #foreach ($column in $columns)
#if($column.htmlType == "checkbox") #if($column.htmlType == "checkbox")
form.value.$column.javaField = form.value.${column.javaField}.split(","); form.value.$column.javaField = form.value.${column.javaField}.split(",");
#end #end
#end
#if($table.sub)
${subclassName}List.value = res.data.${subclassName}List;
#end #end
dialog.visible = true; dialog.visible = true;
dialog.title = "修改${functionName}"; dialog.title = '修改${functionName}';
}; };
/** 提交按钮 */ /** 提交按钮 */
@ -444,12 +533,15 @@ const submitForm = () => {
form.value.$column.javaField = form.value.${column.javaField}.join(","); form.value.$column.javaField = form.value.${column.javaField}.join(",");
#end #end
#end #end
#if($table.sub)
form.value.${subclassName}List = ${subclassName}List.value;
#end
if (form.value.${pkColumn.javaField}) { if (form.value.${pkColumn.javaField}) {
await update${BusinessName}(form.value).finally(() => buttonLoading.value = false); await update${BusinessName}(form.value).finally(() => (buttonLoading.value = false));
} else { } else {
await add${BusinessName}(form.value).finally(() => buttonLoading.value = false); await add${BusinessName}(form.value).finally(() => (buttonLoading.value = false));
} }
proxy?.#[[$modal]]#.msgSuccess("修改成功"); proxy?.#[[$modal]]#.msgSuccess('修改成功');
dialog.visible = false; dialog.visible = false;
await getList(); await getList();
} }
@ -465,6 +557,47 @@ const handleDelete = async (row?: ${BusinessName}VO) => {
await getList(); await getList();
}; };
#if($table.sub)
/** ${subTable.functionName}序号 */
const row${subClassName}Index = ({row,rowIndex}: {row: ${subClassName}VO,rowIndex: number}) => {
row.index = rowIndex + 1;
}
/** ${subTable.functionName}添加按钮操作 */
const handleAdd${subClassName} = () => {
let obj = {};
#foreach($column in $subTable.columns)
#if($column.pk || $column.javaField == ${subTableFkclassName})
#elseif($column.list && "" != $javaField)
#if(${column.javaField} == "version")
obj.$column.javaField = 0;
#else
obj.$column.javaField = "";
#end
#end
#end
${subclassName}List.value.push(obj);
}
/** ${subTable.functionName}删除按钮操作 */
const handleDelete${subClassName} = () => {
if (checked${subClassName}.value.length == 0) {
proxy.#[[$modal]]#.msgError("请先选择要删除的${subTable.functionName}数据");
} else {
const ${subclassName}s = ${subclassName}List.value;
const checked${subClassName}s = checked${subClassName}.value;
${subclassName}List.value = ${subclassName}s.filter(function(item) {
return checked${subClassName}s.indexOf(item.index) == -1
});
}
}
/** 复选框选中数据 */
const handle${subClassName}SelectionChange = (selection: ${subclassName}VO[]) => {
checked${subClassName}.value = selection.map(item => item.index)
}
#end
/** 导出按钮操作 */ /** 导出按钮操作 */
const handleExport = () => { const handleExport = () => {
proxy?.download('${moduleName}/${businessName}/export', { proxy?.download('${moduleName}/${businessName}/export', {