作者 niuyongqing

人事系统

@@ -66,15 +66,7 @@ class Mechanism extends BaseController @@ -66,15 +66,7 @@ class Mechanism extends BaseController
66 public function mechanism_add(Request $request) 66 public function mechanism_add(Request $request)
67 { 67 {
68 $data = $request->param(); 68 $data = $request->param();
69 - $row['username']=$data['username'];  
70 - $list= Db::table('sos_user_mechanism')->where($row)->select()->toArray();  
71 - if($list){  
72 - $data=[  
73 - 'code'=>100,  
74 - 'msg'=>'登录账号已存在'  
75 - ];  
76 - return $data;  
77 - } 69 +
78 if(isset($data['password']) && !empty($data['password']) && $data['password']!='******'){ 70 if(isset($data['password']) && !empty($data['password']) && $data['password']!='******'){
79 $data['password']=md5(md5($data['password'])); 71 $data['password']=md5(md5($data['password']));
80 } 72 }
@@ -85,6 +77,15 @@ class Mechanism extends BaseController @@ -85,6 +77,15 @@ class Mechanism extends BaseController
85 unset($data['mechanism_id']); 77 unset($data['mechanism_id']);
86 $res = Db::table('sos_user_mechanism')->where($where)->update($data); 78 $res = Db::table('sos_user_mechanism')->where($where)->update($data);
87 }else{ 79 }else{
  80 + $row['username']=$data['username'];
  81 + $list= Db::table('sos_user_mechanism')->where($row)->select()->toArray();
  82 + if($list){
  83 + $data=[
  84 + 'code'=>100,
  85 + 'msg'=>'登录账号已存在'
  86 + ];
  87 + return $data;
  88 + }
88 unset($data['mechanism_id']); 89 unset($data['mechanism_id']);
89 $data['createTime']=time(); 90 $data['createTime']=time();
90 91
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 namespace app\products\controller; 9 namespace app\products\controller;
10 use app\web\controller\BaseController; 10 use app\web\controller\BaseController;
11 11
  12 +use think\Cache;
12 use think\Db; 13 use think\Db;
13 use think\Request; 14 use think\Request;
14 15
@@ -16,6 +17,8 @@ class Role extends BaseController @@ -16,6 +17,8 @@ class Role extends BaseController
16 { 17 {
17 //获取用户列表 18 //获取用户列表
18 public function getUsers(Request $request){ 19 public function getUsers(Request $request){
  20 +
  21 +
19 $data = $request->param(); 22 $data = $request->param();
20 $page = isset($_POST['page']) ? intval($_POST['page']) : 1; 23 $page = isset($_POST['page']) ? intval($_POST['page']) : 1;
21 $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10; 24 $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
@@ -23,6 +26,13 @@ class Role extends BaseController @@ -23,6 +26,13 @@ class Role extends BaseController
23 $data['offset']=$offset; 26 $data['offset']=$offset;
24 $data['rows']=$rows; 27 $data['rows']=$rows;
25 $where=[]; 28 $where=[];
  29 + $user=Cache::get('name');
  30 + $user_id=Cache::get('id');
  31 +
  32 + if($user !='admin'){
  33 + $where['mechanism']=$user_id;
  34 + }
  35 +
26 if(!empty($data['id']) && isset($data['id'])){ 36 if(!empty($data['id']) && isset($data['id'])){
27 $where['id']=$data['id']; 37 $where['id']=$data['id'];
28 } 38 }
@@ -82,7 +92,14 @@ class Role extends BaseController @@ -82,7 +92,14 @@ class Role extends BaseController
82 */ 92 */
83 93
84 public function getMechanism(){ 94 public function getMechanism(){
85 - $list= Db::table('sos_user_mechanism')->select()->toArray(); 95 +
  96 + $user=Cache::get('name');
  97 + $user_id=Cache::get('id');
  98 +
  99 + if($user !='admin'){
  100 + $where['id']=$user_id;
  101 + }
  102 + $list= Db::table('sos_user_mechanism')->where($where)->select()->toArray();
86 echo json_encode($list); 103 echo json_encode($list);
87 } 104 }
88 105
@@ -21,11 +21,7 @@ @@ -21,11 +21,7 @@
21 var oltTarget, logTarget, logGridTarget; 21 var oltTarget, logTarget, logGridTarget;
22 var num = 0; 22 var num = 0;
23 var iCount; 23 var iCount;
24 - var user= localStorage.getItem("user");  
25 24
26 - if(user != 'admin'){  
27 - $('#shouUser').attr("style","display:none;");  
28 - }  
29 25
30 $(function () { 26 $(function () {
31 oltTarget = $("#operation_log_txt"); 27 oltTarget = $("#operation_log_txt");
@@ -71,16 +67,7 @@ @@ -71,16 +67,7 @@
71 title: '人员管理' 67 title: '人员管理'
72 } 68 }
73 }); 69 });
74 -  
75 -  
76 - if(user == 'admin'){  
77 - $('#main_iframe').attr('src','__MODEL__/role/index');  
78 - }else{  
79 - $('#main_iframe').attr('src','__MODEL__/Fu_ji_tong/index');  
80 - }  
81 -  
82 -  
83 - 70 + $('#main_iframe').attr('src','__MODEL__/role/index');
84 71
85 72
86 $.h.index.setOperateInfo(null, false); 73 $.h.index.setOperateInfo(null, false);
@@ -279,19 +266,14 @@ @@ -279,19 +266,14 @@
279 266
280 267
281 268
282 - <div data-options="iconCls:'icon-reload'" id="shouUser">  
283 - <span>管理员</span>  
284 - <div style="width:180px;">  
285 - <div onclick="$.h.menu.onMenuRoleManage();"><b>人员管理</b></div>  
286 - <div onclick="$.h.menu.onMenuMechanismManage();"><b>机构管理</b></div>  
287 - </div> 269 + <div data-options="iconCls:'icon-reload'" onclick="$.h.menu.onMenuRoleManage();">
  270 + <b >人员管理</b>
288 </div> 271 </div>
289 - <div data-options="iconCls:'icon-reload'">  
290 - <span>二级菜单</span>  
291 - <div style="width:180px;">  
292 - <div onclick="$.h.menu.onMenuPersonnelManage();"><b>人员管理</b></div>  
293 - <div onclick="$.h.menu.onMenuDepartmentManage();"><b>部门管理</b></div>  
294 - </div> 272 + <div data-options="iconCls:'icon-reload'" id="shouUser" onclick="$.h.menu.onMenuMechanismManage();">
  273 + <b >机构管理</b>
  274 + </div>
  275 + <div data-options="iconCls:'icon-reload'" onclick="$.h.menu.onMenuDepartmentManage();">
  276 + <b >部门管理</b>
295 </div> 277 </div>
296 </div> 278 </div>
297 </div> 279 </div>
@@ -310,5 +292,10 @@ @@ -310,5 +292,10 @@
310 </div> 292 </div>
311 293
312 </body> 294 </body>
313 - 295 +<script>
  296 + var user= localStorage.getItem("user");
  297 + if(user != 'admin'){
  298 + $('#shouUser').attr("style","display:none;");
  299 + }
  300 +</script>>
314 </html> 301 </html>