change - 代码生成优化

maser
yinq 1 year ago
parent aab5e83754
commit 6a53dc3f7b

@ -1,9 +1,9 @@
# 代码生成 # 代码生成
gen: gen:
# 作者 # 作者
author: ruoyi author: Yinq
# 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
packageName: com.os.system packageName: com.os.ems.base
# 自动去除表前缀默认是false # 自动去除表前缀默认是false
autoRemovePre: false autoRemovePre: false
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔) # 表前缀(生成类名不会包含表前缀,多个用逗号分隔)

@ -16,6 +16,7 @@ import com.os.common.annotation.Log;
import com.os.common.core.controller.BaseController; import com.os.common.core.controller.BaseController;
import com.os.common.core.domain.AjaxResult; import com.os.common.core.domain.AjaxResult;
import com.os.common.enums.BusinessType; import com.os.common.enums.BusinessType;
import com.os.common.utils.DateUtils;
import ${packageName}.domain.${ClassName}; import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service; import ${packageName}.service.I${ClassName}Service;
import com.os.common.utils.poi.ExcelUtil; import com.os.common.utils.poi.ExcelUtil;
@ -88,6 +89,8 @@ public class ${ClassName}Controller extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody ${ClassName} ${className}) public AjaxResult add(@RequestBody ${ClassName} ${className})
{ {
${className}.setCreatedBy(getUsername());
${className}.setCreatedTime(DateUtils.getNowDate());
return toAjax(${className}Service.insert${ClassName}(${className})); return toAjax(${className}Service.insert${ClassName}(${className}));
} }
@ -99,6 +102,8 @@ public class ${ClassName}Controller extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody ${ClassName} ${className}) public AjaxResult edit(@RequestBody ${ClassName} ${className})
{ {
${className}.setUpdatedBy(getUsername());
${className}.setUpdatedTime(DateUtils.getNowDate());
return toAjax(${className}Service.update${ClassName}(${className})); return toAjax(${className}Service.update${ClassName}(${className}));
} }

@ -40,8 +40,8 @@ public class ${ClassName} extends ${Entity}
#if($parentheseIndex != -1) #if($parentheseIndex != -1)
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
#elseif($column.javaType == 'Date') #elseif($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
#else #else
@Excel(name = "${comment}") @Excel(name = "${comment}")
#end #end

@ -3,7 +3,8 @@ insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame
values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', getdate(), '', null, '${functionName}菜单'); values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', getdate(), '', null, '${functionName}菜单');
-- 按钮父菜单ID -- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID(); DECLARE @parentId INT;
SET @parentId = SCOPE_IDENTITY();
-- 按钮 SQL -- 按钮 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)

@ -1,6 +1,7 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
label-width="100px">
#foreach($column in $columns) #foreach($column in $columns)
#if($column.query) #if($column.query)
#set($dictType=$column.dictType) #set($dictType=$column.dictType)
@ -76,7 +77,8 @@
size="mini" size="mini"
@click="handleAdd" @click="handleAdd"
v-hasPermi="['${moduleName}:${businessName}:add']" v-hasPermi="['${moduleName}:${businessName}:add']"
>新增</el-button> >新增
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -85,9 +87,10 @@
icon="el-icon-sort" icon="el-icon-sort"
size="mini" size="mini"
@click="toggleExpandAll" @click="toggleExpandAll"
>展开/折叠</el-button> >展开/折叠
</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
</el-row> </el-row>
<el-table <el-table
@ -108,22 +111,26 @@
#end #end
#if($column.pk) #if($column.pk)
#elseif($column.list && $column.htmlType == "datetime") #elseif($column.list && $column.htmlType == "datetime")
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180"> <el-table-column label="${comment}" align="center" prop="${javaField}" width="180"
v-if="columns[${foreach.index}].visible">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span> <span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
#elseif($column.list && $column.htmlType == "imageUpload") #elseif($column.list && $column.htmlType == "imageUpload")
<el-table-column label="${comment}" align="center" prop="${javaField}" width="100"> <el-table-column label="${comment}" align="center" prop="${javaField}" width="100"
v-if="columns[${foreach.index}].visible">
<template slot-scope="scope"> <template slot-scope="scope">
<image-preview :src="scope.row.${javaField}" :width="50" :height="50"/> <image-preview :src="scope.row.${javaField}" :width="50" :height="50"/>
</template> </template>
</el-table-column> </el-table-column>
#elseif($column.list && "" != $column.dictType) #elseif($column.list && "" != $column.dictType)
<el-table-column label="${comment}" align="center" prop="${javaField}"> <el-table-column label="${comment}" align="center" prop="${javaField}"
v-if="columns[${foreach.index}].visible">
<template slot-scope="scope"> <template slot-scope="scope">
#if($column.htmlType == "checkbox") #if($column.htmlType == "checkbox")
<dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/> <dict-tag :options="dict.type.${column.dictType}"
:value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
#else #else
<dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField}"/> <dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField}"/>
#end #end
@ -131,9 +138,11 @@
</el-table-column> </el-table-column>
#elseif($column.list && "" != $javaField) #elseif($column.list && "" != $javaField)
#if(${foreach.index} == 1) #if(${foreach.index} == 1)
<el-table-column label="${comment}" prop="${javaField}" /> <el-table-column label="${comment}" prop="${javaField}"
v-if="columns[${foreach.index}].visible"/>
#else #else
<el-table-column label="${comment}" align="center" prop="${javaField}" /> <el-table-column label="${comment}" align="center" prop="${javaField}"
v-if="columns[${foreach.index}].visible"/>
#end #end
#end #end
#end #end
@ -145,28 +154,31 @@
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['${moduleName}:${businessName}:edit']" v-hasPermi="['${moduleName}:${businessName}:edit']"
>修改</el-button> >修改
</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-plus" icon="el-icon-plus"
@click="handleAdd(scope.row)" @click="handleAdd(scope.row)"
v-hasPermi="['${moduleName}:${businessName}:add']" v-hasPermi="['${moduleName}:${businessName}:add']"
>新增</el-button> >新增
</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['${moduleName}:${businessName}:remove']" v-hasPermi="['${moduleName}:${businessName}:remove']"
>删除</el-button> >删除
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 添加或修改${functionName}对话框 --> <!-- 添加或修改${functionName}对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="100px">
#foreach($column in $columns) #foreach($column in $columns)
#set($field=$column.javaField) #set($field=$column.javaField)
#if($column.insert && !$column.pk) #if($column.insert && !$column.pk)
@ -180,7 +192,8 @@
#set($dictType=$column.dictType) #set($dictType=$column.dictType)
#if("" != $treeParentCode && $column.javaField == $treeParentCode) #if("" != $treeParentCode && $column.javaField == $treeParentCode)
<el-form-item label="${comment}" prop="${treeParentCode}"> <el-form-item label="${comment}" prop="${treeParentCode}">
<treeselect v-model="form.${treeParentCode}" :options="${businessName}Options" :normalizer="normalizer" placeholder="请选择${comment}" /> <treeselect v-model="form.${treeParentCode}" :options="${businessName}Options"
:normalizer="normalizer" placeholder="请选择${comment}"/>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "input") #elseif($column.htmlType == "input")
<el-form-item label="${comment}" prop="${field}"> <el-form-item label="${comment}" prop="${field}">
@ -247,7 +260,8 @@
#else #else
:label="dict.value" :label="dict.value"
#end #end
>{{dict.label}}</el-radio> >{{dict.label}}
</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "radio" && $dictType) #elseif($column.htmlType == "radio" && $dictType)
@ -283,7 +297,13 @@
</template> </template>
<script> <script>
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}"; import {
list${BusinessName},
get${BusinessName},
del${BusinessName},
add${BusinessName},
update${BusinessName}
} from "@/api/${moduleName}/${businessName}";
import Treeselect from "@riophae/vue-treeselect"; import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import "@riophae/vue-treeselect/dist/vue-treeselect.css";
@ -341,11 +361,24 @@ export default {
#set($comment=$column.columnComment) #set($comment=$column.columnComment)
#end #end
$column.javaField: [ $column.javaField: [
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end } {
required: true, message: "$comment不能为空", trigger: #if($column.htmlType ==
"select" || $column.htmlType == "radio")"change"#else"blur"#end }
]#if($foreach.count != $columns.size()),#end ]#if($foreach.count != $columns.size()),#end
#end #end
#end #end
} },
columns: [
#foreach ($column in $columns)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
{key: ${foreach.index}, label: `${comment}`, visible: true},
#end
]
}; };
}, },
created() { created() {
@ -468,22 +501,54 @@ export default {
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
this.#[[$]]#refs["form"].validate(valid => { this.
#
[[$]]
#refs["form"].validate(valid => {
if (valid) { if (valid) {
#foreach($column in $columns) #foreach($column in $columns)
#if($column.htmlType == "checkbox") #if($column.htmlType == "checkbox")
this.form.$column.javaField = this.form.${column.javaField}.join(","); this.form.$column.javaField = this.form.$
{
column.javaField
}
.
join(",");
#end #end
#end #end
if (this.form.${pkColumn.javaField} != null) { if (this.form.${
update${BusinessName}(this.form).then(response => { pkColumn.javaField
this.#[[$modal]]#.msgSuccess("修改成功"); }
!=
null
)
{
update$
{
BusinessName
}
(this.form).then(response => {
this.
#
[[$modal]]
#.
msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} else { }
add${BusinessName}(this.form).then(response => { else
this.#[[$modal]]#.msgSuccess("新增成功"); {
add$
{
BusinessName
}
(this.form).then(response => {
this.
#
[[$modal]]
#.
msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -493,12 +558,36 @@ export default {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
this.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + row.${pkColumn.javaField} + '"的数据项?').then(function() { this.
return del${BusinessName}(row.${pkColumn.javaField}); #
[[$modal]]
#.
confirm('是否确认删除${functionName}编号为"' + row.$
{
pkColumn.javaField
}
+'"的数据项?'
).
then(function () {
return del$
{
BusinessName
}
(row.$
{
pkColumn.javaField
}
)
;
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.#[[$modal]]#.msgSuccess("删除成功"); this.
}).catch(() => {}); #
[[$modal]]
#.
msgSuccess("删除成功");
}).catch(() => {
});
} }
} }
}; };

@ -1,6 +1,7 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
label-width="100px">
#foreach($column in $columns) #foreach($column in $columns)
#if($column.query) #if($column.query)
#set($dictType=$column.dictType) #set($dictType=$column.dictType)
@ -76,7 +77,8 @@
size="mini" size="mini"
@click="handleAdd" @click="handleAdd"
v-hasPermi="['${moduleName}:${businessName}:add']" v-hasPermi="['${moduleName}:${businessName}:add']"
>新增</el-button> >新增
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -87,7 +89,8 @@
:disabled="single" :disabled="single"
@click="handleUpdate" @click="handleUpdate"
v-hasPermi="['${moduleName}:${businessName}:edit']" v-hasPermi="['${moduleName}:${businessName}:edit']"
>修改</el-button> >修改
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -98,7 +101,8 @@
:disabled="multiple" :disabled="multiple"
@click="handleDelete" @click="handleDelete"
v-hasPermi="['${moduleName}:${businessName}:remove']" v-hasPermi="['${moduleName}:${businessName}:remove']"
>删除</el-button> >删除
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -108,9 +112,10 @@
size="mini" size="mini"
@click="handleExport" @click="handleExport"
v-hasPermi="['${moduleName}:${businessName}:export']" v-hasPermi="['${moduleName}:${businessName}:export']"
>导出</el-button> >导出
</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange">
@ -124,31 +129,37 @@
#set($comment=$column.columnComment) #set($comment=$column.columnComment)
#end #end
#if($column.pk) #if($column.pk)
<el-table-column label="${comment}" align="center" prop="${javaField}" /> <el-table-column label="${comment}" align="center" prop="${javaField}"
v-if="columns[${foreach.index}].visible"/>
#elseif($column.list && $column.htmlType == "datetime") #elseif($column.list && $column.htmlType == "datetime")
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180"> <el-table-column label="${comment}" align="center" prop="${javaField}" width="180"
v-if="columns[${foreach.index}].visible">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span> <span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
#elseif($column.list && $column.htmlType == "imageUpload") #elseif($column.list && $column.htmlType == "imageUpload")
<el-table-column label="${comment}" align="center" prop="${javaField}" width="100"> <el-table-column label="${comment}" align="center" prop="${javaField}" width="100"
v-if="columns[${foreach.index}].visible">
<template slot-scope="scope"> <template slot-scope="scope">
<image-preview :src="scope.row.${javaField}" :width="50" :height="50"/> <image-preview :src="scope.row.${javaField}" :width="50" :height="50"/>
</template> </template>
</el-table-column> </el-table-column>
#elseif($column.list && "" != $column.dictType) #elseif($column.list && "" != $column.dictType)
<el-table-column label="${comment}" align="center" prop="${javaField}"> <el-table-column label="${comment}" align="center" prop="${javaField}"
v-if="columns[${foreach.index}].visible">
<template slot-scope="scope"> <template slot-scope="scope">
#if($column.htmlType == "checkbox") #if($column.htmlType == "checkbox")
<dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/> <dict-tag :options="dict.type.${column.dictType}"
:value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
#else #else
<dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField}"/> <dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField}"/>
#end #end
</template> </template>
</el-table-column> </el-table-column>
#elseif($column.list && "" != $javaField) #elseif($column.list && "" != $javaField)
<el-table-column label="${comment}" align="center" prop="${javaField}" /> <el-table-column label="${comment}" align="center" prop="${javaField}"
v-if="columns[${foreach.index}].visible"/>
#end #end
#end #end
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
@ -159,14 +170,16 @@
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['${moduleName}:${businessName}:edit']" v-hasPermi="['${moduleName}:${businessName}:edit']"
>修改</el-button> >修改
</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['${moduleName}:${businessName}:remove']" v-hasPermi="['${moduleName}:${businessName}:remove']"
>删除</el-button> >删除
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -181,7 +194,7 @@
<!-- 添加或修改${functionName}对话框 --> <!-- 添加或修改${functionName}对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="100px">
#foreach($column in $columns) #foreach($column in $columns)
#set($field=$column.javaField) #set($field=$column.javaField)
#if($column.insert && !$column.pk) #if($column.insert && !$column.pk)
@ -258,7 +271,8 @@
#else #else
:label="dict.value" :label="dict.value"
#end #end
>{{dict.label}}</el-radio> >{{dict.label}}
</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "radio" && $dictType) #elseif($column.htmlType == "radio" && $dictType)
@ -288,13 +302,18 @@
<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">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd${subClassName}">添加</el-button> <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd${subClassName}">
添加
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDelete${subClassName}">删除</el-button> <el-button type="danger" icon="el-icon-delete" size="mini"
@click="handleDelete${subClassName}">删除
</el-button>
</el-col> </el-col>
</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)
@ -315,10 +334,12 @@
#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 slot-scope="scope"> <template slot-scope="scope">
<el-date-picker clearable v-model="scope.row.$javaField" type="date" value-format="yyyy-MM-dd" placeholder="请选择$comment" /> <el-date-picker clearable v-model="scope.row.$javaField" type="date"
value-format="yyyy-MM-dd" placeholder="请选择$comment"/>
</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 slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment"> <el-select v-model="scope.row.$javaField" placeholder="请选择$comment">
@ -331,7 +352,8 @@
</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 slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment"> <el-select v-model="scope.row.$javaField" placeholder="请选择$comment">
@ -353,7 +375,13 @@
</template> </template>
<script> <script>
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}"; import {
list${BusinessName},
get${BusinessName},
del${BusinessName},
add${BusinessName},
update${BusinessName}
} from "@/api/${moduleName}/${businessName}";
export default { export default {
name: "${BusinessName}", name: "${BusinessName}",
@ -418,11 +446,24 @@ export default {
#set($comment=$column.columnComment) #set($comment=$column.columnComment)
#end #end
$column.javaField: [ $column.javaField: [
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end } {
required: true, message: "$comment不能为空", trigger: #if($column.htmlType ==
"select" || $column.htmlType == "radio")"change"#else"blur"#end }
]#if($foreach.count != $columns.size()),#end ]#if($foreach.count != $columns.size()),#end
#end #end
#end #end
} },
columns: [
#foreach ($column in $columns)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
{key: ${foreach.index}, label: `${comment}`, visible: true},
#end
]
}; };
}, },
created() { created() {
@ -522,25 +563,65 @@ export default {
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
this.#[[$]]#refs["form"].validate(valid => { this.
#
[[$]]
#refs["form"].validate(valid => {
if (valid) { if (valid) {
#foreach($column in $columns) #foreach($column in $columns)
#if($column.htmlType == "checkbox") #if($column.htmlType == "checkbox")
this.form.$column.javaField = this.form.${column.javaField}.join(","); this.form.$column.javaField = this.form.$
{
column.javaField
}
.
join(",");
#end #end
#end #end
#if($table.sub) #if($table.sub)
this.form.${subclassName}List = this.${subclassName}List; this.form.$
{
subclassName
}
List = this.$
{
subclassName
}
List;
#end #end
if (this.form.${pkColumn.javaField} != null) { if (this.form.${
update${BusinessName}(this.form).then(response => { pkColumn.javaField
this.#[[$modal]]#.msgSuccess("修改成功"); }
!=
null
)
{
update$
{
BusinessName
}
(this.form).then(response => {
this.
#
[[$modal]]
#.
msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} else { }
add${BusinessName}(this.form).then(response => { else
this.#[[$modal]]#.msgSuccess("新增成功"); {
add$
{
BusinessName
}
(this.form).then(response => {
this.
#
[[$modal]]
#.
msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -550,21 +631,51 @@ export default {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const ${pkColumn.javaField}s = row.${pkColumn.javaField} || this.ids; const ${pkColumn.javaField}s = row.$
this.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?').then(function() { {
return del${BusinessName}(${pkColumn.javaField}s); pkColumn.javaField
}
||
this.ids;
this.
#
[[$modal]]
#.
confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?').then(function () {
return del$
{
BusinessName
}
(${pkColumn.javaField}s);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.#[[$modal]]#.msgSuccess("删除成功"); this.
}).catch(() => {}); #
[[$modal]]
#.
msgSuccess("删除成功");
}).catch(() => {
});
}, },
#if($table.sub) #if($table.sub
)
/** ${subTable.functionName}序号 */ /** ${subTable.functionName}序号 */
row${subClassName}Index({ row, rowIndex }) { row$
{
subClassName
}
Index({row, rowIndex})
{
row.index = rowIndex + 1; row.index = rowIndex + 1;
}, }
,
/** ${subTable.functionName}添加按钮操作 */ /** ${subTable.functionName}添加按钮操作 */
handleAdd${subClassName}() { handleAdd$
{
subClassName
}
()
{
let obj = {}; let obj = {};
#foreach($column in $subTable.columns) #foreach($column in $subTable.columns)
#if($column.pk || $column.javaField == ${subTableFkclassName}) #if($column.pk || $column.javaField == ${subTableFkclassName})
@ -572,31 +683,87 @@ export default {
obj.$column.javaField = ""; obj.$column.javaField = "";
#end #end
#end #end
this.${subclassName}List.push(obj); this.$
}, {
subclassName
}
List.push(obj);
}
,
/** ${subTable.functionName}删除按钮操作 */ /** ${subTable.functionName}删除按钮操作 */
handleDelete${subClassName}() { handleDelete$
if (this.checked${subClassName}.length == 0) { {
this.#[[$modal]]#.msgError("请先选择要删除的${subTable.functionName}数据"); subClassName
} else { }
const ${subclassName}List = this.${subclassName}List; ()
const checked${subClassName} = this.checked${subClassName}; {
this.${subclassName}List = ${subclassName}List.filter(function(item) { if (this.checked${
return checked${subClassName}.indexOf(item.index) == -1 subClassName
}
.
length == 0
)
{
this.
#
[[$modal]]
#.
msgError("请先选择要删除的${subTable.functionName}数据");
}
else
{
const ${subclassName}List = this.$
{
subclassName
}
List;
const checked$
{
subClassName
}
= this.checked$
{
subClassName
}
;
this.$
{
subclassName
}
List = ${subclassName}List.filter(function (item) {
return checked$
{
subClassName
}
.
indexOf(item.index) == -1
}); });
} }
}, }
,
/** 复选框选中数据 */ /** 复选框选中数据 */
handle${subClassName}SelectionChange(selection) { handle$
this.checked${subClassName} = selection.map(item => item.index) {
}, subClassName
}
SelectionChange(selection)
{
this.checked$
{
subClassName
}
= selection.map(item => item.index)
}
,
#end #end
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport()
{
this.download('${moduleName}/${businessName}/export', { this.download('${moduleName}/${businessName}/export', {
...this.queryParams ...this.queryParams
}, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`) }, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`)
} }
} }
}; }
;
</script> </script>

@ -58,11 +58,11 @@
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
<dependency> <!-- <dependency>-->
<groupId>org.ssssssss</groupId> <!-- <groupId>org.ssssssss</groupId>-->
<artifactId>magic-api-spring-boot-starter</artifactId> <!-- <artifactId>magic-api-spring-boot-starter</artifactId>-->
<version>${magic.version}</version> <!-- <version>${magic.version}</version>-->
</dependency> <!-- </dependency>-->
<!-- Minio文件存储 --> <!-- Minio文件存储 -->
<dependency> <dependency>

Loading…
Cancel
Save