This commit is contained in:
parent
8bdf414948
commit
3b4192b848
|
|
@ -55,7 +55,8 @@
|
|||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['test:stu:add']"
|
||||
>新增</el-button>
|
||||
>新增
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
|
|
@ -66,7 +67,8 @@
|
|||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['test:stu:edit']"
|
||||
>修改</el-button>
|
||||
>修改
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
|
|
@ -77,7 +79,8 @@
|
|||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['test:stu:remove']"
|
||||
>删除</el-button>
|
||||
>删除
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
|
|
@ -87,17 +90,18 @@
|
|||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['test:stu:export']"
|
||||
>导出</el-button>
|
||||
>导出
|
||||
</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="stuList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="id" align="center" prop="id" />
|
||||
<el-table-column label="学生姓名" align="center" prop="name" />
|
||||
<el-table-column label="电话" align="center" prop="tel" />
|
||||
<el-table-column label="电子邮件" align="center" prop="email" />
|
||||
<el-table-column type="selection" width="55" align="center"/>
|
||||
<el-table-column label="id" align="center" prop="id"/>
|
||||
<el-table-column label="学生姓名" align="center" prop="name"/>
|
||||
<el-table-column label="电话" align="center" prop="tel"/>
|
||||
<el-table-column label="电子邮件" align="center" prop="email"/>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
|
|
@ -106,14 +110,16 @@
|
|||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['test:stu:edit']"
|
||||
>修改</el-button>
|
||||
>修改
|
||||
</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['test:stu:remove']"
|
||||
>删除</el-button>
|
||||
>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
|
@ -130,13 +136,13 @@
|
|||
<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-item label="学生姓名" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入学生姓名" />
|
||||
<el-input v-model="form.name" placeholder="请输入学生姓名"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="电话" prop="tel">
|
||||
<el-input v-model="form.tel" placeholder="请输入电话" />
|
||||
<el-input v-model="form.tel" placeholder="请输入电话"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="电子邮件" prop="email">
|
||||
<el-input v-model="form.email" placeholder="请输入电子邮件" />
|
||||
<el-input v-model="form.email" placeholder="请输入电子邮件"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
|
|
@ -148,164 +154,173 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { listStu, getStu, delStu, addStu, updateStu, exportStu } from "@/api/test/stu";
|
||||
import {listStu, getStu, delStu, addStu, updateStu, exportStu} from "@/api/test/stu";
|
||||
|
||||
export default {
|
||||
name: "Stu",
|
||||
components: {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 学生表格数据
|
||||
stuList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 创建时间时间范围
|
||||
daterangeCreateTime: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
name: null,
|
||||
tel: null,
|
||||
email: null,
|
||||
createTime: null
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询学生列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
// this.queryParams.params = {};
|
||||
// if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
|
||||
// this.queryParams.params["beginCreateTime"] = this.daterangeCreateTime[0];
|
||||
// this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1];
|
||||
// }
|
||||
listStu(this.addCreateDateRange(this.queryParams,this.daterangeCreateTime)).then(response => {
|
||||
this.stuList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
name: null,
|
||||
tel: null,
|
||||
email: null,
|
||||
createTime: null
|
||||
export default {
|
||||
name: "Stu",
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 学生表格数据
|
||||
stuList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 创建时间时间范围
|
||||
daterangeCreateTime: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
name: null,
|
||||
tel: null,
|
||||
email: null,
|
||||
createTime: null
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
name: [
|
||||
{required: true, message: "学生姓名不能为空}", trigger: "blur"},
|
||||
],
|
||||
tel: [
|
||||
{required: true, message: "电话不能为空}", trigger: "blur"},
|
||||
{pattern: /^1[0-9]{10}$/, message: '电话格式有误', trigger: "blur"},
|
||||
],
|
||||
email: [
|
||||
{required: true, message: "电子邮件不能为空}", trigger: "blur"},
|
||||
{
|
||||
pattern: /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
|
||||
message: '电子邮件格式有误',
|
||||
trigger: "blur"
|
||||
},
|
||||
],
|
||||
}
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.daterangeCreateTime = [];
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.id)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加学生";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const id = row.id || this.ids
|
||||
getStu(id).then(response => {
|
||||
this.form = response.data;
|
||||
methods: {
|
||||
/** 查询学生列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listStu(this.addCreateDateRange(this.queryParams, this.daterangeCreateTime)).then(response => {
|
||||
this.stuList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
name: null,
|
||||
tel: null,
|
||||
email: null,
|
||||
createTime: null
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.daterangeCreateTime = [];
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.id)
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "修改学生";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.id != null) {
|
||||
updateStu(this.form).then(response => {
|
||||
this.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addStu(this.form).then(response => {
|
||||
this.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
this.title = "添加学生";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const id = row.id || this.ids
|
||||
getStu(id).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改学生";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.id != null) {
|
||||
updateStu(this.form).then(response => {
|
||||
this.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addStu(this.form).then(response => {
|
||||
this.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids;
|
||||
this.$confirm('是否确认删除学生编号为"' + ids + '"的数据项?', "警告", {
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids;
|
||||
this.$confirm('是否确认删除学生编号为"' + ids + '"的数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
}).then(function () {
|
||||
return delStu(ids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.msgSuccess("删除成功");
|
||||
})
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
const queryParams = this.queryParams;
|
||||
this.$confirm('是否确认导出所有学生数据项?', "警告", {
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
const queryParams = this.queryParams;
|
||||
this.$confirm('是否确认导出所有学生数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
}).then(function () {
|
||||
return exportStu(queryParams);
|
||||
}).then(response => {
|
||||
this.download(response.msg);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -192,9 +192,6 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
||||
for (String template : templates) {
|
||||
// 渲染模板
|
||||
if (template.equals("")){
|
||||
|
||||
}
|
||||
StringWriter sw = new StringWriter();
|
||||
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
||||
tpl.merge(context, sw);
|
||||
|
|
|
|||
|
|
@ -135,6 +135,11 @@ public class ${ClassName}Controller extends HcyBaseController {
|
|||
return AjaxResult.error("${column.columnComment}不能为空!");
|
||||
}
|
||||
#end
|
||||
#if($column.isRegular != 1)
|
||||
if (!Pattern.matches("${column.regular}",${className}.get${AttrName}())){
|
||||
return AjaxResult.error("${column.columnComment}格式错误!");
|
||||
}
|
||||
#end
|
||||
#end
|
||||
try {
|
||||
ServerResult<Integer> serverResult = ${className}Service.insert${ClassName}(${className});
|
||||
|
|
@ -173,6 +178,11 @@ public class ${ClassName}Controller extends HcyBaseController {
|
|||
return AjaxResult.error("${column.columnComment}不能为空!");
|
||||
}
|
||||
#end
|
||||
#if($column.isRegular != 1)
|
||||
if (!Pattern.matches("${column.regular}",${className}.get${AttrName}())){
|
||||
return AjaxResult.error("${column.columnComment}格式错误!");
|
||||
}
|
||||
#end
|
||||
#end
|
||||
ServerResult<Integer> serverResult = ${className}Service.update${ClassName}(${className});
|
||||
if (serverResult.isStart()) {
|
||||
|
|
@ -194,6 +204,9 @@ public class ${ClassName}Controller extends HcyBaseController {
|
|||
@DeleteMapping("/{${pkColumn.javaField}s}")
|
||||
public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) {
|
||||
try {
|
||||
if (${pkColumn.javaField}s.length<0){
|
||||
return AjaxResult.error("id不能为空!");
|
||||
}
|
||||
ServerResult<Integer> serverResult = ${className}Service.delete${ClassName}ByIds(${pkColumn.javaField}s);
|
||||
if (serverResult.isStart()) {
|
||||
return AjaxResult.success();
|
||||
|
|
|
|||
|
|
@ -418,7 +418,10 @@ export default {
|
|||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
$column.javaField: [
|
||||
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }
|
||||
{ required: true, message: "${comment}不能为空}", trigger: #if($column.htmlType == "select")"change"#else"blur"#end },
|
||||
#if($column.isRegular != 1)
|
||||
{ pattern: /${column.regular}/, message: '${column.columnComment}格式有误', trigger:"blur"},
|
||||
#end
|
||||
]#if($velocityCount != $columns.size()),#end
|
||||
|
||||
#end
|
||||
|
|
@ -442,20 +445,21 @@ export default {
|
|||
this.loading = true;
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
this.queryParams.params = {};
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
#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 != this.daterange${AttrName} && '' != this.daterange${AttrName}) {
|
||||
this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0];
|
||||
this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1];
|
||||
}
|
||||
#set($VariableName= "daterange"+$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#set($variable = true)
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
list${BusinessName}(this.queryParams).then(response => {
|
||||
#if($variable)
|
||||
list${BusinessName}(this.addCreateDateRange(this.queryParams,this.$VariableName)).then(response =>{
|
||||
#else
|
||||
list${BusinessName}(this.queryParams).then(response => {
|
||||
#end
|
||||
this.${businessName}List = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
|
|
|
|||
|
|
@ -115,9 +115,15 @@ public class StuController extends HcyBaseController {
|
|||
if (stu.getTel() == null || stu.getTel()<0) {
|
||||
return AjaxResult.error("电话不能为空!");
|
||||
}
|
||||
if (!Pattern.matches("^1[0-9]{10}$",String.valueOf(stu.getTel()))){
|
||||
return AjaxResult.error("电话格式错误!");
|
||||
}
|
||||
if (stu.getEmail() == null || stu.getEmail().equals("")) {
|
||||
return AjaxResult.error("电子邮件不能为空!");
|
||||
}
|
||||
if (!Pattern.matches("^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$",stu.getEmail())){
|
||||
return AjaxResult.error("电子邮件格式错误!");
|
||||
}
|
||||
try {
|
||||
ServerResult<Integer> serverResult = stuService.insertStu(stu);
|
||||
if (serverResult.isStart()) {
|
||||
|
|
@ -146,9 +152,15 @@ public class StuController extends HcyBaseController {
|
|||
if (stu.getTel() == null || stu.getTel()<0) {
|
||||
return AjaxResult.error("电话不能为空!");
|
||||
}
|
||||
if (!Pattern.matches("^1[0-9]{10}$",String.valueOf(stu.getTel()))){
|
||||
return AjaxResult.error("电话格式错误!");
|
||||
}
|
||||
if (stu.getEmail() == null || stu.getEmail().equals("")) {
|
||||
return AjaxResult.error("电子邮件不能为空!");
|
||||
}
|
||||
if (!Pattern.matches("^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$",stu.getEmail())){
|
||||
return AjaxResult.error("电子邮件格式错误!");
|
||||
}
|
||||
ServerResult<Integer> serverResult = stuService.updateStu(stu);
|
||||
if (serverResult.isStart()) {
|
||||
return AjaxResult.success();
|
||||
|
|
@ -169,6 +181,9 @@ public class StuController extends HcyBaseController {
|
|||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
try {
|
||||
if (ids.length<0){
|
||||
return AjaxResult.error("id不能为空!");
|
||||
}
|
||||
ServerResult<Integer> serverResult = stuService.deleteStuByIds(ids);
|
||||
if (serverResult.isStart()) {
|
||||
return AjaxResult.success();
|
||||
|
|
|
|||
Loading…
Reference in New Issue