作者 niuyongqing

人事系统

... ... @@ -55,24 +55,7 @@ class Mechanism extends BaseController
}
/**
* 获取机构列表
*/
public function getMechanism(){
$list= Db::table('sos_user_mechanism')->select()->toArray();
echo json_encode($list);
}
/**
* 获取机构下部门列表
*/
public function getdepartment(Request $request){
$data = $request->get();
$list= Db::table('sos_user_department')->where('mechanismId',$data['id'])->select()->toArray();
echo json_encode($list);
}
/**
* @param Request $request
... ... @@ -83,7 +66,18 @@ class Mechanism extends BaseController
public function mechanism_add(Request $request)
{
$data = $request->param();
$data['password']=md5(md5($data['password']));
$row['username']=$data['username'];
$list= Db::table('sos_user_mechanism')->where($row)->select()->toArray();
if($list){
$data=[
'code'=>100,
'msg'=>'登录账号已存在'
];
return $data;
}
if(isset($data['password']) && !empty($data['password']) && $data['password']!='******'){
$data['password']=md5(md5($data['password']));
}
if(isset($data['mechanism_id']) && !empty($data['mechanism_id'])){
$data['updateTime']=time();
... ... @@ -111,22 +105,6 @@ class Mechanism extends BaseController
return $data;
}
/**
* @param Request $request
* @return \think\response\Json
* 自动生成员工编号
*/
public function generateNumber(Request $request){
$data = $request->get();
$rule_name= Db::table('sos_user_rule')->where('mechanismId',$data['id'])->find();
$rule_num= Db::table('sos_user_role')->order('id desc')->find();
$rule_number['num']=$rule_name['rule'].(substr($rule_num['personalNumber'], 2, 7)+1);
echo json_encode($rule_number);
}
}
\ No newline at end of file
... ...
... ... @@ -67,8 +67,8 @@ class Role extends BaseController
$list[$key]['department']=$val['department'] == 0? '男' : $department['departmentName'];
$list[$key]['status']=$type[$val['status']];
$list[$key]['entryTime']=date('Y-m-d H:i:s',$val['entryTime']);
$list[$key]['quitTime']=$val['quitTime'] == ''? '' : date('Y-m-d H:i:s',$val['entryTime']);
$list[$key]['entryTime']=date('Y-m-d',$val['entryTime']);
$list[$key]['quitTime']=$val['quitTime'] == ''? '' : date('Y-m-d',$val['entryTime']);
}
$result["total"] =$total;
... ... @@ -106,14 +106,18 @@ class Role extends BaseController
{
$data = $request->param();
if(isset($data['sex']) && $data['sex']=='on'){
$data['sex']=1;
}else{
$data['sex']=2;
}
$data['entryTime']=$data['entryTime'] == ''? '' :strtotime($data['entryTime']);
$data['quitTime']=$data['quitTime'] == ''? '' :strtotime($data['quitTime']);
if(isset($data['entryTime']) && !empty($data['entryTime'])){
$data['entryTime']=strtotime($data['entryTime']);
}
if(isset($data['quitTime']) && !empty($data['quitTime'])){
$data['quitTime']=strtotime($data['quitTime']);
}
if(isset($data['user_id']) && !empty($data['user_id'])){
$data['updateTime']=time();
$where['id']=$data['user_id'];
... ...
... ... @@ -3,6 +3,7 @@
namespace app\web\controller;
use think\Request;
use think\Session;
use think\Validate;
use think\Controller as thinkController;
use app\common\service\Render as RenderTrait;
... ... @@ -18,9 +19,10 @@ class BaseController extends thinkController
*/
public function _initialize()
{
if (!session('user')) {
// return Request::instance()->isAjax() ? json($this->renderError('您尚未登录系统')) : $this->redirect(url('web/passport/login'));
$user = Session::get('name');
if($user === ''){
// if (Session::get('name')) {
return Request::instance()->isAjax() ? json($this->renderError('您尚未登录系统')) : $this->redirect(url('web/index/login'));
}
}
... ... @@ -33,7 +35,7 @@ class BaseController extends thinkController
$validate = new Validate($rules, $message);
if (!$validate->check($data)) {
return $validate->getError();
return $validate->getError();
}
... ...
... ... @@ -3,9 +3,11 @@
namespace app\web\controller;
use think\Db;
use think\Request;
use think\Cookie;
use think\Session;
/**
* 首页
* Class Index
... ... @@ -23,16 +25,19 @@ class Index extends Controller
{
$data = $request->param();
$name="ybao";
$pwd="ybao888";
if($name != $data['name']){
$where['username']=$data['name'];
$list= Db::table('sos_user_admin')->where($where)->find();
if(empty($list)){
$list= Db::table('sos_user_mechanism')->where($where)->find();
}
if(empty($list)){
$data=[
'code'=>100,
'msg'=>'用户名错误'
];
return json_encode($data);
}elseif($pwd != $data['pwd']){
}elseif($list['password'] != md5(md5($data['pwd']))){
$data=[
'code'=>100,
... ... @@ -40,9 +45,11 @@ class Index extends Controller
];
return json_encode($data);
}else{
Cookie::set('name',$name);
//session('name', $name);
//Cookie::set('name',$name);
session('name', $list['username']);
// session('id', $list['id']);
$data=[
'data'=>$list['username'],
'code'=>200,
'msg'=>'验证成功'
];
... ... @@ -61,7 +68,8 @@ class Index extends Controller
*/
public function index()
{
$user=Cookie::get('name');
//$user=Cookie::get('name');
$user = Session::get('name');
if(!$user){
//重定向到指定的URL地址
$this->error('您未进行登录', 'web/index/login'); exit;
... ... @@ -73,12 +81,13 @@ class Index extends Controller
public function loginout()
{
Cookie::delete('name');
//Cookie::delete('name');
Session::clear();
$this->view->engine->layout(false);
return $this->fetch('login');
}
public function quick_menu()
public function quick_menu()
{
$this->view->engine->layout(false);
return $this->fetch('quick_menu');
... ...
... ... @@ -66,14 +66,14 @@
url:'/web/index/tologin',
onSubmit: function(){
console.log($(this))
},
success:function(data){
var arr = JSON.parse(data);
if(arr.code == 100){
$.messager.alert("提示", arr.msg);
}else{
localStorage.setItem("user",arr.data)
$.messager.alert("提示", arr.msg);
window.location.href="/";
}
... ...
... ... @@ -61,12 +61,12 @@
</div>
<div id="win" class="easyui-dialog" title="提示" style="width: 800px; padding: 10px 20px; height: auto" closed="true" buttons="#dlg-buttons">
<div id="win" class="easyui-dialog" title="提示" style="width: 500px; padding: 10px 20px; height: auto" closed="true" buttons="#dlg-buttons">
<form id="fm" name="frm" method="post" style="margin-top: 20px; margin-left: 20px;">
<table style="padding: 10px 20px;" cellspacing="10">
<tr>
<td>用户名称:</td>
<td><input class="easyui-textbox" type="text" name="name" id="name" /></td>
<td><input class="easyui-textbox" type="text" name="name" id="name" data-options="required:true,validType:'length[2,5]'"/></td>
<input class="easyui-textbox" id="user_id" name="user_id" type="hidden">
</tr>
<tr>
... ... @@ -75,7 +75,7 @@
</tr>
<tr>
<td>电话:</td>
<td><input class="easyui-textbox" type="text" name="phone" id="phone" /></td>
<td><input class="easyui-textbox" type="text" name="phone" id="phone" data-options="required:true" validType='phoneNum'"/></td>
</tr>
<tr>
<td>所属机构:</td>
... ... @@ -98,7 +98,7 @@
<!-- }-->
<!-- })-->
<!-- }">-->
<input id="cc1" name="mechanism" class="easyui-combobox" data-options="
<input id="cc1" name="mechanism" class="easyui-combobox" required="true" data-options="
valueField: 'id',
textField: 'mechanismName',
url: '/products/role/getMechanism',
... ... @@ -133,7 +133,7 @@
</tr>
<tr>
<td>所属部门:</td>
<td><input id="cc2" class="easyui-combobox" name="department" data-options="valueField:'id',textField:'departmentName'"></td>
<td><input id="cc2" class="easyui-combobox" name="department" data-options="valueField:'id',textField:'departmentName'" required="true"></td>
</tr>
<tr>
<td>个人编号:</td>
... ... @@ -143,11 +143,15 @@
</td>
</tr>
<tr>
<td>职位名称:</td>
<td><input class="easyui-textbox" type="text" name="job" id="job" data-options="required:true"/></td>
</tr>
<tr>
<td>入职时间:</td>
<!-- <td><input class="easyui-datebox" name="entryTime" id="entryTime" disabled/></td>-->
<td><input class="easyui-datebox" name="entryTime" id="entryTime" /></td>
<td><input class="easyui-datebox" name="entryTime" id="entryTime" required="true"/></td>
</tr>
<tr>
<td>离职时间:</td>
... ... @@ -155,22 +159,20 @@
</tr>
<tr>
<td>当前状态:</td>
<td><input class="easyui-combobox" style="width:160px" name="status" id="status"
<td><input class="easyui-combobox" style="width:160px" name="status" id="status"
data-options="valueField:'id',
textField:'text',
data:
[{ 'id':0,
'text':'请选择' ,
selected:true
},{ 'id':1,
[{ 'id':1,
'text':'试用期' ,
},{ 'id':2,
'text':'正式员工' ,
},{
'id':3,
'text':'已离职'
}] ,panelHeight:'auto'
"/></td>
" required="true"/></td>
</tr>
<div id="dlg-buttons" style="display: block">
... ... @@ -189,6 +191,26 @@
<script type="text/javascript" src="/assets/web/js/src/common_fu.js"></script>
<script>
$(function(){
$.extend($.fn.validatebox.defaults.rules, {
phoneNum: { //验证手机号
validator: function(value, param){
return /^1[3-8]+\d{9}$/.test(value);
},
message: '请输入正确的手机号码。'
},
comboxValidate : {
validator : function(value, param,missingMessage) {
if($('#'+param).combobox('getValue')!='' && $('#'+param).combobox('getValue')!=null){
return true;
}
return false;
},
message : "{1}"
}
});
})
var rule_id='';
//下拉框搜索
... ... @@ -263,13 +285,13 @@
arr.push({
field: 'mechanism',
title: '所属机构',
width: 200,
width: 220,
align: 'center'
});
arr.push({
field: 'department',
title: '所属部门',
width: 150,
width: 200,
align: 'center'
});
arr.push({
... ... @@ -279,6 +301,12 @@
align: 'center'
});
arr.push({
field: 'job',
title: '职位名称',
width: 150,
align: 'center'
});
arr.push({
field: 'status',
title: '当前状态',
width: 150,
... ... @@ -287,13 +315,13 @@
arr.push({
field: 'entryTime',
title: '入职时间',
width: 200,
width: 150,
align: 'center'
});
arr.push({
field: 'quitTime',
title: '离职时间',
width: 200,
width: 150,
align: 'center'
});
arr.push({
... ... @@ -314,7 +342,6 @@
//添加
$('#name_add_but').linkbutton({
onClick: function () {
addFile();
}
});
... ... @@ -324,7 +351,7 @@
$('#win').form('clear')
$('#win').dialog({
title: '新增',
width: 800,
width: 500,
height: "auto",
top:20,
closed: false,//显示对话框
... ... @@ -332,55 +359,8 @@
modal: true
});
}
// //修改
// function showUser(row){
// if(row){
// // alert(row);
// var id=row;
// var result = {
// id
// }
// $("#win").dialog("open").dialog("setTitle","人员信息修改");
//
// //ajax请求数据
// $.ajax({
// type: "post",
// data: result,
// async: false,
// url: "/products/role/getUsers",
// success: function(data) {
// var arr = JSON.parse(data);
//
// $('#user_id').textbox('setValue',arr.rows[0].id);
//
// $('#username').textbox('setValue',arr.rows[0].username);
// $('#password').textbox('setValue',arr.rows[0].password);
// $('#name').textbox('setValue',arr.rows[0].name);
// $('#personalNumber').textbox('setValue',arr.rows[0].personalNumber);
// //
// if(arr.rows[0].sex == "男") {
// $('#statusId').switchbutton('check');
// }else {
// $('#statusId').switchbutton('uncheck');
// }
// $('#phone').textbox('setValue',arr.rows[0].phone);
// $('#entryTime').textbox('setValue',arr.rows[0].entryTime);
// $('#quitTime').textbox('setValue',arr.rows[0].quitTime);
//
// $('#materialname').combobox('setValue', $('#materialname option')[2].value);
//
//
// },
// error:function(data){
// console.log(data)
// }
// });
// }
// }
//修改
function showUser(row){
if(row){
// alert(row);
var id=row;
... ... @@ -407,6 +387,7 @@
$('#username').textbox('setValue',arr.rows[0].username);
$('#password').textbox('setValue',arr.rows[0].password);
$('#name').textbox('setValue',arr.rows[0].name);
$('#job').textbox('setValue',arr.rows[0].job);
$('#personalNumber').textbox('setValue',arr.rows[0].personalNumber);
$.ajax({
url:'/products/role/getMechanism',
... ... @@ -458,24 +439,28 @@
$('#fm').form('submit', {
url:'/products/role/user_add',
onSubmit: function(){
console.log($(this))
return $(this).form('validate');
// do some check
// return false to prevent submit;
},
success:function(data){
console.log(data);
var arr = JSON.parse(data);
$.messager.alert("提示", arr.msg);
$('#dg').datagrid('reload');
// console.log(data);
//$.messager.alert('',msg);
//console.log(data);
//alert(data)
if(arr.code==200){
$('#win').dialog({
closed: true, // 隱藏列表
});
$('#dg').datagrid('reload');
}
// // console.log(data);
// //$.messager.alert('',msg);
// //console.log(data);
// //alert(data)
}
});
$('#win').dialog({
closed: true, // 隱藏列表
});
}
... ...
... ... @@ -4,19 +4,19 @@
<meta charset="UTF-8">
<title>机构列表</title>
<link rel="stylesheet" type="text/css" href="/assets/common/css/themes/gray/easyui.css" />
<link rel="stylesheet" type="text/css" href="/assets/common/css/themes/gray/menu.css" />
<link rel="stylesheet" type="text/css" href="/assets/common/css/themes/gray/menu.css" />
<link rel="stylesheet" type="text/css" href="/assets/common/css/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="/assets/web/css/jitnry.css" />
<link rel="stylesheet" type="text/css" href="/assets/web/css/common_car.css" />
<link rel="stylesheet" type="text/css" href="/assets/web/css/jitnry.css" />
<link rel="stylesheet" type="text/css" href="/assets/web/css/common_car.css" />
<script type="text/javascript" src="/assets/common/js/jquery.min.1.9.4.js"></script>
<script type="text/javascript" src="/assets/common/js/jquery.easyui.min.1.9.4.js"></script>
<script type="text/javascript" src="/assets/common/js/jquery.easyui.min.1.9.4.js"></script>
<script type="text/javascript" src="/assets/common/js/jquery.cookie.1.4.1.js"></script>
<!-- 插件调用 --->
<script type="text/javascript" src="/assets/common/js/datagrid-detailview.js"></script>
<script type="text/javascript" src="/assets/common/locale/easyui-lang-zh_CN.js"></script>
<!-- 基础 JS 调用 -->
<script type="text/javascript" src="/assets/web/js/src/easyui.base.js"></script>
<script type="text/javascript" src="/assets/web/js/src/allCity.js"></script>
<!-- 插件调用 --->
<script type="text/javascript" src="/assets/common/js/datagrid-detailview.js"></script>
<script type="text/javascript" src="/assets/common/locale/easyui-lang-zh_CN.js"></script>
<!-- 基础 JS 调用 -->
<script type="text/javascript" src="/assets/web/js/src/easyui.base.js"></script>
<script type="text/javascript" src="/assets/web/js/src/allCity.js"></script>
<style>
#fm>div {
width: 100%;
... ... @@ -30,59 +30,59 @@
</style>
</head>
<body style="margin-bottom: 54px;">
<div class="easyui-layout" data-options="fit:true">
<div data-options="split:false,region:'west',collapsible:true,footer:'#win_base_org_form_footer'" title="机构列表" id="saveBox" style="width:100%;">
<div class="easyui-panel" style="width:100%;max-width:100%;padding: 5px 5px">
<div style="margin-bottom:5px;">
<a id="name_add_but" href="#" data-options="iconCls:'icon-add'" class="my_but" style="vertical-align: middle;">新增</a>
</div>
<div class="easyui-layout" data-options="fit:true">
<div data-options="split:false,region:'west',collapsible:true,footer:'#win_base_org_form_footer'" title="机构列表" id="saveBox" style="width:100%;">
<div class="easyui-panel" style="width:100%;max-width:100%;padding: 5px 5px">
<div style="margin-bottom:5px;">
<a id="name_add_but" href="#" data-options="iconCls:'icon-add'" class="my_but" style="vertical-align: middle;">新增</a>
</div>
<table id="dg" style="width: 100%; height: 92%"
data-options="rownumbers:true,singleSelect:true,pagination:true,toolbar:'#tb'">
</table>
<div id="tb" style="padding:5px;height:auto">
<div>
机构名称: <input class="easyui-textbox" type="text" id='names' name='names'>
起始时间: <input class="easyui-datebox" id='start' name='start' style="width:180px">
截止时间: <input class="easyui-datebox" id='end' name='end' style="width:180px">
<a href="#" class="easyui-linkbutton" id="search_buttn" iconCls="icon-search">搜索</a>
<!-- <a id="derive_btn" href="/products/fu_ji_tong/to_excel" class="easyui-linkbutton" style="height:28px" data-options="iconCls:'icon-undo'">导出</a>-->
</div>
</div>
<table id="dg" style="width: 100%; height: 92%"
data-options="rownumbers:true,singleSelect:true,pagination:true,toolbar:'#tb'">
</table>
<div id="tb" style="padding:5px;height:auto">
<div>
机构名称: <input class="easyui-textbox" type="text" id='names' name='names'>
起始时间: <input class="easyui-datebox" id='start' name='start' style="width:180px">
截止时间: <input class="easyui-datebox" id='end' name='end' style="width:180px">
<a href="#" class="easyui-linkbutton" id="search_buttn" iconCls="icon-search">搜索</a>
<!-- <a id="derive_btn" href="/products/fu_ji_tong/to_excel" class="easyui-linkbutton" style="height:28px" data-options="iconCls:'icon-undo'">导出</a>-->
</div>
</div>
</div>
<div id="win" class="easyui-dialog" title="提示" style="width: 500px; padding: 10px 20px; height: auto" closed="true" buttons="#dlg-buttons">
<form id="fm" name="frm" method="post" style="margin-top: 20px; margin-left: 20px;">
<table style="padding: 10px 20px;" cellspacing="10">
<tr>
<td>登录账号:</td>
<td><input class="easyui-textbox" type="text" name="username" id="username" /></td>
<input class="easyui-textbox" id="mechanism_id" name="mechanism_id" type="hidden">
</tr>
<tr>
<td>登录密码:</td>
<td><input class="easyui-textbox" placeholder="这里输入文字" type="text" name="password" id="password" /></td>
</tr>
<tr>
<td>机构名称:</td>
<td><input class="easyui-textbox" type="text" name="mechanismName" id="mechanismName" /></td>
</tr>
<tr>
<td>编号规则:</td>
<td><input class="easyui-textbox" type="text" name="rule" id="rule" /></td>
</tr>
<div id="dlg-buttons" style="display: block">
<a id="confirm" href="javascript:void(0)" class="easyui-linkbutton c6" iconcls="icon-ok" onclick="submitForm()" style="width: 90px">提交</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#win').dialog('close')" style="width: 90px">取消</a>
</div>
</table>
</form>
</div>
</div>
<div id="win" class="easyui-dialog" title="提示" style="width: 500px; padding: 10px 20px; height: auto" closed="true" buttons="#dlg-buttons">
<form id="fm" name="frm" method="post" style="margin-top: 20px; margin-left: 20px;">
<table style="padding: 10px 20px;" cellspacing="10">
<tr>
<td>登录账号:</td>
<td><input class="easyui-textbox" type="text" name="username" id="username" data-options="required:true,validType:'length[3,10]'"/></td>
<input class="easyui-textbox" id="mechanism_id" name="mechanism_id" type="hidden">
</tr>
<tr>
<td>登录密码:</td>
<td><input class="easyui-textbox" type="text" name="password" id="password" data-options="required:true,validType:'length[5,10]'"/></td>
</tr>
<tr>
<td>机构名称:</td>
<td><input class="easyui-textbox" type="text" name="mechanismName" id="mechanismName" data-options="required:true"/></td>
</tr>
<tr>
<td>编号规则:</td>
<td><input class="easyui-textbox" type="text" name="rule" id="rule" data-options="required:true,validType:'length[0,2]'"/></td>
</tr>
<div id="dlg-buttons" style="display: block">
<a id="confirm" href="javascript:void(0)" class="easyui-linkbutton c6" iconcls="icon-ok" onclick="submitForm()" style="width: 90px">提交</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#win').dialog('close')" style="width: 90px">取消</a>
</div>
</table>
</form>
</div>
</body>
... ... @@ -188,6 +188,7 @@
}
});
function addFile(){
$('#win').form('clear')
$('#win').dialog({
title: '新增',
width: 500,
... ... @@ -200,6 +201,7 @@
}
//修改
function showUser(row){
$('#win').form('clear')
if(row){
// alert(row);
var id=row;
... ... @@ -219,6 +221,7 @@
$('#mechanism_id').textbox('setValue',arr.rows[0].id);
$('#username').textbox('setValue',arr.rows[0].username);
$('#password').textbox('setValue','******');
$('#mechanismName').textbox('setValue',arr.rows[0].mechanismName);
$('#rule').textbox('setValue',arr.rows[0].rule);
... ... @@ -242,19 +245,23 @@
// return false to prevent submit;
},
success:function(data){
console.log(data);
var arr = JSON.parse(data);
$.messager.alert("提示", arr.msg);
$('#dg').datagrid('reload');
if(arr.code==200){
$('#win').dialog({
closed: true, // 隱藏列表
});
$('#dg').datagrid('reload');
}
// console.log(data);
//$.messager.alert('',msg);
//console.log(data);
//alert(data)
}
});
$('#win').dialog({
closed: true, // 隱藏列表
});
}
... ...