This commit is contained in:
parent
3b4192b848
commit
eb5f3e8884
|
|
@ -55,8 +55,7 @@
|
|||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['test:stu:add']"
|
||||
>新增
|
||||
</el-button>
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
|
|
@ -67,8 +66,7 @@
|
|||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['test:stu:edit']"
|
||||
>修改
|
||||
</el-button>
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
|
|
@ -79,8 +77,7 @@
|
|||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['test:stu:remove']"
|
||||
>删除
|
||||
</el-button>
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
|
|
@ -90,18 +87,17 @@
|
|||
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
|
||||
|
|
@ -110,20 +106,18 @@
|
|||
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>
|
||||
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
|
|
@ -136,13 +130,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">
|
||||
|
|
@ -154,173 +148,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: {
|
||||
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"
|
||||
},
|
||||
],
|
||||
}
|
||||
};
|
||||
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"},
|
||||
],
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
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;
|
||||
});
|
||||
},
|
||||
created() {
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
name: null,
|
||||
tel: null,
|
||||
email: null,
|
||||
createTime: null,
|
||||
createBy: null,
|
||||
updateTime: null,
|
||||
updateBy: null
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
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();
|
||||
/** 重置按钮操作 */
|
||||
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;
|
||||
this.open = true;
|
||||
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();
|
||||
});
|
||||
}
|
||||
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>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import java.util.Date;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
|
|
@ -48,6 +49,11 @@ public class BaseEntity implements Serializable {
|
|||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 参数
|
||||
*/
|
||||
private String parameter;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
|
|
@ -65,6 +71,15 @@ public class BaseEntity implements Serializable {
|
|||
*/
|
||||
private Map<String, Object> params;
|
||||
|
||||
public void setParameter(String parameter) {
|
||||
if (parameter != null || parameter.equals("")) {
|
||||
this.parameter = parameter;
|
||||
JSONObject jsonObject = JSONObject.parseObject(parameter);
|
||||
params = new HashMap<>();
|
||||
params.put("",jsonObject.get(""));
|
||||
}
|
||||
}
|
||||
|
||||
public String getSearchValue() {
|
||||
return searchValue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@ import com.hchyun.common.constant.ReturnConstants;
|
|||
import com.hchyun.common.utils.DateUtils;
|
||||
#break
|
||||
#end
|
||||
#if($column.javaField == 'updateBy' || $column.javaField == 'createBy')
|
||||
import com.hchyun.common.utils.SecurityUtils;
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
import com.hchyun.common.utils.ServerResult;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -97,7 +101,7 @@ public class ${ClassName}ServiceImpl implements ${ClassName}Service {
|
|||
${className}.setCreateTime(DateUtils.getNowDate());
|
||||
#end
|
||||
#if($column.javaField == 'createBy')
|
||||
${className}.setCreateBy(SecurityUtils.getUserId());
|
||||
${className}.setCreateBy(SecurityUtils.getUserId());
|
||||
#end
|
||||
#end
|
||||
#if($table.sub)
|
||||
|
|
@ -134,8 +138,8 @@ public class ${ClassName}ServiceImpl implements ${ClassName}Service {
|
|||
#if($column.javaField == 'updateTime')
|
||||
${className}.setUpdateTime(DateUtils.getNowDate());
|
||||
#end
|
||||
#if($column.javaField == 'createBy')
|
||||
${className}.setCreateBy(SecurityUtils.getUserId());
|
||||
#if($column.javaField == 'updateBy')
|
||||
${className}.setUpdateBy(SecurityUtils.getUserId());
|
||||
#end
|
||||
#end
|
||||
#if($table.sub)
|
||||
|
|
|
|||
|
|
@ -399,7 +399,7 @@ export default {
|
|||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
#foreach ($column in $columns)
|
||||
#if($column.query)
|
||||
#if($column.query && $column.htmlType != "datetime" && $column.queryType != "BETWEEN")
|
||||
$column.javaField: null#if($velocityCount != $columns.size()),#end
|
||||
|
||||
#end
|
||||
|
|
@ -488,6 +488,7 @@ export default {
|
|||
reset() {
|
||||
this.form = {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType != "datetime" && $column.queryType != "BETWEEN")
|
||||
#if($column.htmlType == "radio")
|
||||
$column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($velocityCount != $columns.size()),#end
|
||||
|
||||
|
|
@ -497,6 +498,7 @@ export default {
|
|||
#else
|
||||
$column.javaField: null#if($velocityCount != $columns.size()),#end
|
||||
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
};
|
||||
|
|
|
|||
|
|
@ -75,6 +75,9 @@ public class Stu extends BaseEntity
|
|||
.append("tel", getTel())
|
||||
.append("email", getEmail())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
|
||||
import com.hchyun.common.constant.ReturnConstants;
|
||||
import com.hchyun.common.utils.DateUtils;
|
||||
import com.hchyun.common.utils.SecurityUtils;
|
||||
import com.hchyun.common.utils.ServerResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -79,6 +80,7 @@ public class StuServiceImpl implements StuService {
|
|||
public ServerResult<Integer> insertStu(Stu stu) {
|
||||
try {
|
||||
stu.setCreateTime(DateUtils.getNowDate());
|
||||
stu.setCreateBy(SecurityUtils.getUserId());
|
||||
Integer renewal = stuDao.insertStu(stu);
|
||||
if (renewal >0){
|
||||
return new ServerResult<Integer>(true,renewal);
|
||||
|
|
@ -100,6 +102,8 @@ public class StuServiceImpl implements StuService {
|
|||
@Override
|
||||
public ServerResult<Integer> updateStu(Stu stu) {
|
||||
try {
|
||||
stu.setUpdateTime(DateUtils.getNowDate());
|
||||
stu.setUpdateBy(SecurityUtils.getUserId());
|
||||
Integer renewal = stuDao.updateStu(stu);
|
||||
if (renewal >0){
|
||||
return new ServerResult<Integer>(true,renewal);
|
||||
|
|
|
|||
|
|
@ -10,18 +10,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="tel" column="tel" />
|
||||
<result property="email" column="email" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectStuVo">
|
||||
select id, name, tel, email, create_time from sys_stu
|
||||
select id, name, tel, email, create_time, create_by, update_time, update_by from sys_stu
|
||||
</sql>
|
||||
|
||||
<select id="selectStuList" parameterType="Stu" resultMap="StuResult">
|
||||
<include refid="selectStuVo"/>
|
||||
<where>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="tel != null "> and tel = #{tel}</if>
|
||||
<if test="email != null and email != ''"> and email = #{email}</if>
|
||||
<if test="tel != null "> and tel like concat('%', #{tel}, '%')</if>
|
||||
<if test="email != null and email != ''"> and email like concat('%', #{email}, '%')</if>
|
||||
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
|
@ -38,12 +41,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="tel != null">tel,</if>
|
||||
<if test="email != null and email != ''">email,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null and name != ''">#{name},</if>
|
||||
<if test="tel != null">#{tel},</if>
|
||||
<if test="email != null and email != ''">#{email},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
|
@ -54,6 +63,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="tel != null">tel = #{tel},</if>
|
||||
<if test="email != null and email != ''">email = #{email},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
|
|
|||
Loading…
Reference in New Issue