change - 代码生成优化

maser
yinq 1 year ago
parent adf9f82845
commit b7288c3f66

@ -16,7 +16,6 @@ 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;
@ -89,8 +88,7 @@ public class ${ClassName}Controller extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody ${ClassName} ${className}) public AjaxResult add(@RequestBody ${ClassName} ${className})
{ {
${className}.setCreatedBy(getUsername()); ${className}.setCreateBy(getUsername());
${className}.setCreatedTime(DateUtils.getNowDate());
return toAjax(${className}Service.insert${ClassName}(${className})); return toAjax(${className}Service.insert${ClassName}(${className}));
} }
@ -102,8 +100,7 @@ public class ${ClassName}Controller extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody ${ClassName} ${className}) public AjaxResult edit(@RequestBody ${ClassName} ${className})
{ {
${className}.setUpdatedBy(getUsername()); ${className}.setUpdateBy(getUsername());
${className}.setUpdatedTime(DateUtils.getNowDate());
return toAjax(${className}Service.update${ClassName}(${className})); return toAjax(${className}Service.update${ClassName}(${className}));
} }

@ -1,7 +1,6 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
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)
@ -77,8 +76,7 @@
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,8 +85,7 @@
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" :columns="columns"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
</el-row> </el-row>
@ -111,26 +108,22 @@
#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">
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">
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">
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}" <dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
: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
@ -138,11 +131,9 @@
</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" />
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" />
v-if="columns[${foreach.index}].visible"/>
#end #end
#end #end
#end #end
@ -154,24 +145,21 @@
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>
@ -192,8 +180,7 @@
#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" <treeselect v-model="form.${treeParentCode}" :options="${businessName}Options" :normalizer="normalizer" placeholder="请选择${comment}" />
: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}">
@ -260,8 +247,7 @@
#else #else
:label="dict.value" :label="dict.value"
#end #end
>{{dict.label}} >{{dict.label}}</el-radio>
</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "radio" && $dictType) #elseif($column.htmlType == "radio" && $dictType)
@ -297,13 +283,7 @@
</template> </template>
<script> <script>
import { import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
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";
@ -361,9 +341,7 @@
#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
@ -501,54 +479,22 @@
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
this. this.#[[$]]#refs["form"].validate(valid => {
#
[[$]]
#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.$ this.form.$column.javaField = this.form.${column.javaField}.join(",");
{
column.javaField
}
.
join(",");
#end #end
#end #end
if (this.form.${ if (this.form.${pkColumn.javaField} != null) {
pkColumn.javaField update${BusinessName}(this.form).then(response => {
} this.#[[$modal]]#.msgSuccess("修改成功");
!=
null
)
{
update$
{
BusinessName
}
(this.form).then(response => {
this.
#
[[$modal]]
#.
msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} } else {
else add${BusinessName}(this.form).then(response => {
{ this.#[[$modal]]#.msgSuccess("新增成功");
add$
{
BusinessName
}
(this.form).then(response => {
this.
#
[[$modal]]
#.
msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -558,36 +504,12 @@
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
this. this.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + row.${pkColumn.javaField} + '"的数据项?').then(function() {
# 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. this.#[[$modal]]#.msgSuccess("删除成功");
# }).catch(() => {});
[[$modal]]
#.
msgSuccess("删除成功");
}).catch(() => {
});
} }
} }
}; };

@ -1,7 +1,6 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
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)
@ -51,12 +50,12 @@
<el-form-item label="${comment}"> <el-form-item label="${comment}">
<el-date-picker <el-date-picker
v-model="daterange${AttrName}" v-model="daterange${AttrName}"
style="width: 240px" style="width: 340px"
value-format="yyyy-MM-dd" value-format="yyyy-MM-dd HH:mm:ss"
type="daterange" type="datetimerange"
range-separator="-" range-separator="-"
start-placeholder="开始日期" start-placeholder="开始时间"
end-placeholder="结束日期" end-placeholder="结束时间"
></el-date-picker> ></el-date-picker>
</el-form-item> </el-form-item>
#end #end
@ -77,8 +76,7 @@
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
@ -89,8 +87,7 @@
: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
@ -101,8 +98,7 @@
: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
@ -112,8 +108,7 @@
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" :columns="columns"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
</el-row> </el-row>
@ -129,37 +124,31 @@
#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"/>
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">
v-if="columns[${foreach.index}].visible">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d} {h}:{i}:{s}') }}</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">
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">
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}" <dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
: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"/>
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">
@ -170,16 +159,14 @@
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>
@ -271,8 +258,7 @@
#else #else
:label="dict.value" :label="dict.value"
#end #end
>{{dict.label}} >{{dict.label}}</el-radio>
</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "radio" && $dictType) #elseif($column.htmlType == "radio" && $dictType)
@ -302,18 +288,13 @@
<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 type="primary" icon="el-icon-plus" size="mini" @click="handleAdd${subClassName}">添加</el-button>
添加
</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" <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDelete${subClassName}">删除</el-button>
@click="handleDelete${subClassName}">删除
</el-button>
</el-col> </el-col>
</el-row> </el-row>
<el-table :data="${subclassName}List" :row-class-name="row${subClassName}Index" <el-table :data="${subclassName}List" :row-class-name="row${subClassName}Index" @selection-change="handle${subClassName}SelectionChange" ref="${subclassName}">
@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)
@ -334,12 +315,10 @@
#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" <el-date-picker clearable v-model="scope.row.$javaField" type="date" value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择$comment" />
value-format="yyyy-MM-dd" placeholder="请选择$comment"/>
</template> </template>
</el-table-column> </el-table-column>
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && #elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" != $column.dictType)
"" != $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">
@ -352,8 +331,7 @@
</el-select> </el-select>
</template> </template>
</el-table-column> </el-table-column>
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && #elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" == $column.dictType)
"" == $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">
@ -375,13 +353,7 @@
</template> </template>
<script> <script>
import { import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
list${BusinessName},
get${BusinessName},
del${BusinessName},
add${BusinessName},
update${BusinessName}
} from "@/api/${moduleName}/${businessName}";
export default { export default {
name: "${BusinessName}", name: "${BusinessName}",
@ -446,9 +418,7 @@
#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
@ -563,65 +533,25 @@
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
this. this.#[[$]]#refs["form"].validate(valid => {
#
[[$]]
#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.$ this.form.$column.javaField = this.form.${column.javaField}.join(",");
{
column.javaField
}
.
join(",");
#end #end
#end #end
#if($table.sub) #if($table.sub)
this.form.$ this.form.${subclassName}List = this.${subclassName}List;
{
subclassName
}
List = this.$
{
subclassName
}
List;
#end #end
if (this.form.${ if (this.form.${pkColumn.javaField} != null) {
pkColumn.javaField update${BusinessName}(this.form).then(response => {
} this.#[[$modal]]#.msgSuccess("修改成功");
!=
null
)
{
update$
{
BusinessName
}
(this.form).then(response => {
this.
#
[[$modal]]
#.
msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} } else {
else add${BusinessName}(this.form).then(response => {
{ this.#[[$modal]]#.msgSuccess("新增成功");
add$
{
BusinessName
}
(this.form).then(response => {
this.
#
[[$modal]]
#.
msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -631,51 +561,21 @@
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const ${pkColumn.javaField}s = row.$ const ${pkColumn.javaField}s = row.${pkColumn.javaField} || this.ids;
{ this.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?').then(function() {
pkColumn.javaField return del${BusinessName}(${pkColumn.javaField}s);
}
||
this.ids;
this.
#
[[$modal]]
#.
confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?').then(function () {
return del$
{
BusinessName
}
(${pkColumn.javaField}s);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this. this.#[[$modal]]#.msgSuccess("删除成功");
# }).catch(() => {});
[[$modal]]
#.
msgSuccess("删除成功");
}).catch(() => {
});
}, },
#if($table.sub #if($table.sub)
)
/** ${subTable.functionName}序号 */ /** ${subTable.functionName}序号 */
row$ row${subClassName}Index({ row, rowIndex }) {
{
subClassName
}
Index({row, rowIndex})
{
row.index = rowIndex + 1; row.index = rowIndex + 1;
} },
,
/** ${subTable.functionName}添加按钮操作 */ /** ${subTable.functionName}添加按钮操作 */
handleAdd$ handleAdd${subClassName}() {
{
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})
@ -683,87 +583,31 @@
obj.$column.javaField = ""; obj.$column.javaField = "";
#end #end
#end #end
this.$ this.${subclassName}List.push(obj);
{ },
subclassName
}
List.push(obj);
}
,
/** ${subTable.functionName}删除按钮操作 */ /** ${subTable.functionName}删除按钮操作 */
handleDelete$ handleDelete${subClassName}() {
{ if (this.checked${subClassName}.length == 0) {
subClassName this.#[[$modal]]#.msgError("请先选择要删除的${subTable.functionName}数据");
} } else {
() const ${subclassName}List = this.${subclassName}List;
{ const checked${subClassName} = this.checked${subClassName};
if (this.checked${ this.${subclassName}List = ${subclassName}List.filter(function(item) {
subClassName return checked${subClassName}.indexOf(item.index) == -1
}
.
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$ handle${subClassName}SelectionChange(selection) {
{ 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>
Loading…
Cancel
Save