mirror of
https://github.com/pbrong/hrms.git
synced 2025-09-26 19:51:11 +08:00
version:版本更新
This commit is contained in:
264
views/staff_manage_hr.html
Executable file
264
views/staff_manage_hr.html
Executable file
@@ -0,0 +1,264 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>员工管理</title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="stylesheet" href="/static/lib/layui-v2.5.5/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="/static/css/public.css" media="all">
|
||||
</head>
|
||||
<body>
|
||||
<div class="layuimini-container">
|
||||
<div class="layuimini-main">
|
||||
|
||||
<fieldset class="table-search-fieldset">
|
||||
<legend>搜索信息</legend>
|
||||
<div style="margin: 10px 10px 10px 10px">
|
||||
<form class="layui-form layui-form-pane" action="">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">员工姓名</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="staff_name" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="layui-form-item">-->
|
||||
<!-- <div class="layui-inline">-->
|
||||
<!-- <label class="layui-form-label">部门名称</label>-->
|
||||
<!-- <div class="layui-input-inline">-->
|
||||
<!-- <input type="text" name="dep_name" autocomplete="off" class="layui-input">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<!-- <div class="layui-inline">-->
|
||||
<!-- <label class="layui-form-label">上级部门ID</label>-->
|
||||
<!-- <div class="layui-input-inline">-->
|
||||
<!-- <input type="text" name="pre_dep_id" autocomplete="off" class="layui-input">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<div class="layui-inline">
|
||||
<button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
|
||||
</div>
|
||||
<!-- </div>-->
|
||||
</fieldset>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<script type="text/html" id="toolbarDemo">
|
||||
<div class="layui-btn-container">
|
||||
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加 </button>
|
||||
<!-- <button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除 </button>-->
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
|
||||
|
||||
<script type="text/html" id="currentTableBar">
|
||||
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
|
||||
<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
|
||||
</script>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script src="/static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
|
||||
<script>
|
||||
layui.use(['form', 'table'], function () {
|
||||
var $ = layui.jquery,
|
||||
form = layui.form,
|
||||
table = layui.table;
|
||||
|
||||
table.render({
|
||||
elem: '#currentTableId',
|
||||
url: '/staff/query/all',
|
||||
toolbar: '#toolbarDemo',
|
||||
defaultToolbar: ['filter', 'exports', 'print', {
|
||||
title: '提示',
|
||||
layEvent: 'LAYTABLE_TIPS',
|
||||
icon: 'layui-icon-tips'
|
||||
}],
|
||||
cols: [[
|
||||
// {type: "checkbox", width: 50},
|
||||
{field: 'ID', width: 60, title: 'ID', sort: true},
|
||||
{field: 'staff_id', width: 150, title: '员工ID'},
|
||||
{field: 'staff_name', width: 150, title: '员工姓名'},
|
||||
{field: 'birthday', width: 150, title: '出生日期', templet: dateFormat1},
|
||||
{field: 'identity_num', width: 150, title: '身份证号'},
|
||||
{field: 'sex', width: 150, title: '性别', templet: sexFormat},
|
||||
{field: 'nation', width: 150, title: '民族'},
|
||||
{field: 'school', title: '毕业院校', minWidth: 150},
|
||||
{field: 'major', title: '毕业专业', minWidth: 150},
|
||||
{field: 'edu_level', title: '最高学历', minWidth: 150},
|
||||
{field: 'base_salary', title: '基本工资', minWidth: 150},
|
||||
{field: 'card_num', title: '银行卡号', minWidth: 150},
|
||||
{field: 'rank_id', title: '职位ID', minWidth: 150, hide:true},
|
||||
{field: 'rank_name', title: '职位名称', minWidth: 150},
|
||||
{field: 'dep_id', title: '部门ID', minWidth: 150, hide:true},
|
||||
{field: 'dep_name', title: '部门名称', minWidth: 150},
|
||||
{field: 'email', title: '电子邮箱', minWidth: 150},
|
||||
{field: 'entry_date', title: '入职时间', minWidth: 150, templet: dateFormat2},
|
||||
{title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center", fixed: 'right'}
|
||||
]],
|
||||
limits: [10, 15, 20, 25, 50, 100],
|
||||
limit: 10,
|
||||
page: true,
|
||||
skin: 'line',
|
||||
parseData: function(res){ //res 即为原始返回的数据
|
||||
var code = 0, msg = "获取数据成功"
|
||||
if (res.status != 2000) {
|
||||
code = -1
|
||||
msg = "数据不存在"
|
||||
}
|
||||
return {
|
||||
"code": code, //解析接口状态
|
||||
"msg": msg, //解析提示文本
|
||||
"count": res.total, //解析数据长度
|
||||
"data": res.msg //解析数据列表
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// 性别格式化
|
||||
function sexFormat(data) {
|
||||
var sex = data.sex;
|
||||
var sexStr
|
||||
if (sex == 1) {
|
||||
sexStr = "男"
|
||||
} else {
|
||||
sexStr = "女"
|
||||
}
|
||||
return sexStr
|
||||
}
|
||||
|
||||
// 时间格式化
|
||||
function dateFormat1(data) {
|
||||
if (data.birthday != "undefined") {
|
||||
return data.birthday.slice(0, 10)
|
||||
}
|
||||
}
|
||||
|
||||
function dateFormat2(data) {
|
||||
if (data.entry_date != "undefined") {
|
||||
return data.entry_date.slice(0, 10)
|
||||
}
|
||||
}
|
||||
|
||||
// 监听搜索操作
|
||||
form.on('submit(data-search-btn)', function (data) {
|
||||
layer.msg("搜索成功");
|
||||
var staffName = data.field.staff_name;
|
||||
var reqUrl = "/staff/query_by_name/" + staffName
|
||||
if (typeof staffName == "undefined" || staffName == null || staffName == "") {
|
||||
reqUrl = "/staff/query/all"
|
||||
}
|
||||
//执行搜索重载
|
||||
table.reload('currentTableId', {
|
||||
url: reqUrl,
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
}, 'data');
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* toolbar监听事件
|
||||
*/
|
||||
table.on('toolbar(currentTableFilter)', function (obj) {
|
||||
if (obj.event === 'add') { // 监听添加操作
|
||||
var index = layer.open({
|
||||
title: '添加员工',
|
||||
type: 2,
|
||||
shade: 0.2,
|
||||
maxmin:true,
|
||||
shadeClose: true,
|
||||
area: ['80%', '80%'],
|
||||
content: '/views/staff_add.html',
|
||||
end: function(){
|
||||
//执行搜索重载
|
||||
table.reload('currentTableId', {
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
}, 'data');
|
||||
}
|
||||
});
|
||||
$(window).on("resize", function () {
|
||||
layer.full(index);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//监听表格复选框选择
|
||||
// table.on('checkbox(currentTableFilter)', function (obj) {
|
||||
// console.log(obj)
|
||||
// });
|
||||
|
||||
table.on('tool(currentTableFilter)', function (obj) {
|
||||
var staffId = obj.data.staff_id;
|
||||
// var preDepId = obj.data.pre_dep_id;
|
||||
// var depName = obj.data.dep_name;
|
||||
// var needEditDepInfo = {"dep_id":depId, "pre_dep_id": preDepId,
|
||||
// "dep_name":depName}
|
||||
if (obj.event === 'edit') {
|
||||
// 本地缓存需要编辑的员工信息
|
||||
localStorage.setItem("staff_edit_info", JSON.stringify(obj.data))
|
||||
// alert("待编辑:" + localStorage.getItem("staff_edit_info"))
|
||||
var index = layer.open({
|
||||
title: '编辑员工信息',
|
||||
type: 2,
|
||||
shade: 0.2,
|
||||
maxmin:true,
|
||||
shadeClose: true,
|
||||
area: ['80%', '80%'],
|
||||
content: '/views/staff_edit.html',
|
||||
end: function(){
|
||||
//执行搜索重载
|
||||
table.reload('currentTableId', {
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
}, 'data');
|
||||
}
|
||||
});
|
||||
$(window).on("resize", function () {
|
||||
layer.full(index);
|
||||
});
|
||||
return false;
|
||||
} else if (obj.event === 'delete') {
|
||||
layer.confirm('确认删除吗?', function () {
|
||||
// alert(JSON.stringify(obj.data))
|
||||
// alert(depId)
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: "/staff/del/" + staffId,
|
||||
async: false,
|
||||
success:function (data) {
|
||||
var resp = JSON.parse(JSON.stringify(data));
|
||||
if (resp.status == 2000) {
|
||||
layer.alert("删除员工信息成功",function(index) {
|
||||
// 重新渲染
|
||||
table.reload('currentTableId', {
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
}, 'data');
|
||||
layer.close(index)
|
||||
// alert("layer.close")
|
||||
});
|
||||
}
|
||||
},
|
||||
error:function (data) {
|
||||
console.log("error resp:" + JSON.stringify(data))
|
||||
layer.msg("系统异常");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user