wugg il y a 9 mois
Parent
commit
887ad86b4e

+ 1 - 34
app/bug/controller/Action.php

@@ -93,38 +93,5 @@ class Action extends Base
         }
     }
 
-    /**
-     * @return \think\response\Json
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     */
-    public function index(){
-        $post  =$this->request->post();
-        $data = Db::name("admin_menu")->where(["pid"=>0,"status"=>1,"is_del"=>0])->select();
-        $result = [];
-        if(empty($data)){
-            return app_show(0,"获取成功",$result);
-        }
-        foreach ($data as $key=>$val){
-            $val["child"]=[];
-            $result[$val['id']] =$val;
-        }
-
-        $child =Db::name("admin_menu")->where([["pid","<>",0],['status',"=",1],["is_del","=",0]])->select();
-        foreach ($child as $k=>$value){
-            // $act = PasAction::all(['menuid'=>$value['id'],"status"=>1]);
-            $act =Db::name("action")->alias("a")->leftJoin("action_list l","a.action_code=l.action_code")->field
-            ("a.*,action_name")->where(['a.menuid'=>$value['id'],"a.status"=>1])->select();
-            $act_data = Db::name("action_field")->where(['menuid'=>$value['id'],"status"=>1])->select();
-            $value['action'] = $act;
-            $value['action_data'] = $act_data;
-            if(array_key_exists($value['pid'],$result)){
-                $result[$value['pid']]["child"][]=$value;
-            }
-        }
-
-        return success("获取成功",array_values($result));
-    }
+    
 }

+ 3 - 2
app/bug/controller/Newfill.php

@@ -2,8 +2,9 @@
 
 namespace app\bug\controller;
 
-use app\bug\model\CompanyItem;use think\App;
-use think\facade\Db;use think\facade\Validate;
+use app\bug\model\CompanyItem;
+use think\App;
+use think\facade\Validate;
 class Newfill extends Base
 {
     public function __construct(App $app)

+ 2 - 2
app/bug/controller/Note.php

@@ -2,8 +2,8 @@
 
 namespace app\bug\controller;
 
-use app\bug\model\Moudel;use app\bug\model\NoteLog;
-use app\user\model\Account;use think\Exception;use think\facade\Db;
+use app\bug\model\Moudel;
+use app\user\model\Account;use think\facade\Db;
 use think\App;use think\facade\Validate;
 
 class Note extends Base

+ 6 - 7
app/bug/controller/Role.php

@@ -23,13 +23,12 @@ class Role extends Base
      * @throws \think\exception\DbException
      */
     public function  RoleList(){
-        $post  =$this->request->post();
+        $post  =$this->request->param(["status"=>"","role_name"=>"","createrId"=>"","page"=>1,"size"=>15],"post","trim");
         $condition=[];
         isset($post['status'])&&$post['status']!=="" ? $condition[]=['status',"=",$post['status']]:"";
         isset($post['role_name'])&&$post['role_name']!=="" ? $condition[]=['role_name',"like","%".$post['role_name']."%"]:"";
-        isset($post['item'])&&$post['item']!=="" ? $condition[]=["item","=",$post['item']]:"";
         isset($post['createrId'])&&$post['createrId']!=="" ? $condition[]=["createrId","=",$post['createrId']]:"";
-        $list =$this->model->with(["role_action","company_item"])->where($condition)->order("id","desc")
+        $list =$this->model->with(["role_action"])->where($condition)->order("id","desc")
         ->paginate(["list_rows"=>$post['size'],"page"=>$post['page']]);
         return success("获取成功",["list"=>$list->items(),"count"=>$list->total()]);
     }
@@ -66,7 +65,7 @@ class Role extends Base
                 "item"=>"",
             ];
 			$role = \app\bug\model\Role::create($list);
-            if($role->isEmpty()==false){
+            if($role->isEmpty())throw new \Exception('角色创建失败');
                 $role_action = [
                     "role_id"=>$role->id,
                     "action_conllect"=>$post['action'],
@@ -76,7 +75,7 @@ class Role extends Base
                 ];
                 $roleaction=RoleAction::create($role_action);
                 if($roleaction->isEmpty())throw new \Exception("权限录入失败");
-            }throw new \Exception('角色创建失败');
+           
 			$this->model->commit();
 			return success("角色创建成功");
         }catch (\Exception $e){
@@ -93,7 +92,7 @@ class Role extends Base
     public function RoleInfo(){
         $roleid  =$this->request->post("roleid/d");
         if($roleid=="")return error('roleid不能为空');
-        $info =$this->model->with(["role_action","company_item"])->findOrEmpty($roleid);
+        $info =$this->model->with(["role_action"])->findOrEmpty($roleid);
         if($info->isEmpty())return error("未找到对应的数据");
         return success("获取成功",$info);
     }
@@ -184,6 +183,6 @@ class Role extends Base
      * @throws \think\exception\DbException
      */
     public function RoleAll(){
-        return success("获取成功",$this->model->select());
+        return success("获取成功",$this->model->with(['role_action'])->select());
     }
 }

+ 1 - 1
app/bug/controller/User.php

@@ -95,7 +95,7 @@ class User extends Base
         return success("获取成功",$info);
     }
     public  function  userAll(){
-        $post  =$this->request->param(['username'=>"",'level'=>0,'itemid'=>0,'nickname'=>'',"status"=>""],"post","trim");
+        $post  =$this->request->param(['username'=>"",'level'=>0,'itemid'=>0,'nickname'=>'',"sys_status"=>""],"post","trim");
         $where=[['is_del','=',0]];
         if($post['nickname']!='') $where[]=['userInfo.nickname','like',"%{$post['nickname']}%"];
         if($post['username']!='') $where[]=['username','like',"%{$post['username']}%"];

+ 20 - 0
app/user/controller/AccountItem.php

@@ -21,6 +21,14 @@ class AccountItem extends Base{
 			]);
 		if($valid->check($param)==false) return error($valid->getError());
 		$info = $this->model->where(["account_id"=>$param['account_id']])->findOrEmpty();
+		if($param['position']==2){
+			$position=$this->model->where([['itemid',"=",$param['itemid']],['position','=',2],['account_id','<>',$param['account_id']],])
+			->findOrEmpty();
+			if($position->isEmpty()==false){
+				$position->position=1;
+				$position->save();
+			}
+		}
 		$info->account_id = $param['account_id'];
 		$info->itemid = $param['itemid'];
 		$info->position = $param['position'];
@@ -28,4 +36,16 @@ class AccountItem extends Base{
 		return $result ? success("部门设置成功"): error("部门设置失败");
 	}
 	
+	public function resetItem(){
+		$param=$this->request->param(['account_id'=>''],'post','trim');
+		$valid = Validate::rule([
+			'account_id|账户id'=>'require|number|gt:0',
+			]);
+		if($valid->check($param)==false) return error($valid->getError());
+		$info = $this->model->where(['account_id'=>$param['account_id']])->findOrEmpty();
+		if($info->position==2)return error('请先解除用户部门主管');
+		$result= $info->delete();
+		return $result ? success('部门解除成功'): error('部门解除失败');
+	}
+	
 }

+ 20 - 0
app/user/controller/Depart.php

@@ -99,4 +99,24 @@ class Depart extends Base{
 			$model=$info->save();
 			return$model==false?error('修改失败') :success('修改成功');
 	}
+	public function delete(){
+        $id = $this->request->post('id/d');
+        $items =$this->model->findOrEmpty($id);
+        if($items->isEmpty())return error('部门信息不存在');
+        $isT = \app\user\model\AccountItem::where("itemid",$id)->select();
+        if($isT->isEmpty()==false)return error("部门存在关联人员无法删除");
+        $items->is_del =1;
+        $result= $items->save();
+        return $result ? success('删除成功'): error('删除失败');
+    }
+    
+    public function deleteAccount(){
+        $id = $this->request->post('id/d');
+        $items =$this->model->findOrEmpty($id);
+        if($items->isEmpty())return error('部门信息不存在');
+        $isT = \app\user\model\AccountItem::where('itemid',$id)->select();
+        if($isT->isEmpty())return error('部门关联人员已解除');
+        $del= \app\user\model\AccountItem::where('itemid',$id)->delete();
+        return $del ? success('部门关联人员解除成功'): error('部门关联人员解除失败');
+    }
 }