post['page']) && $this->post['page'] !=="" ? intval($this->post['page']):"1"; $size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']):"10"; $where =[['is_del',"=",0]]; // $resign_depart_id = isset($this->post['resign_depart_id']) && $this->post['resign_depart_id'] !== "" ? intval($this->post['resign_depart_id']) : ""; // if ($resign_depart_id !== "") { // $where = ["resign_depart_id"=>$resign_depart_id]; // } // $hand_depart_id = isset($this->post['hand_depart_id']) && $this->post['hand_depart_id'] !== "" ? intval($this->post['hand_depart_id']) : ""; // if ($hand_depart_id !== "") { // $where = ["hand_depart_id"=>$hand_depart_id]; // } $status =isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : ""; if ($status !== "") { $where[]= ["status",'=',$status]; } $resign_uid = isset($this->post['resign_uid']) && $this->post['resign_uid'] !== "" ? intval($this->post['resign_uid']) : ""; if ($resign_uid !== "") { //$where = ["resign_uid"=>$resign_uid]; $where[]= ["resign_uid",'=',$resign_uid]; } $hand_uid = isset($this->post['hand_uid']) && $this->post['hand_uid'] !== "" ? intval($this->post['hand_uid']) : ""; if ($hand_uid !== "") { // $where = ["hand_uid"=>$hand_uid]; $where[]= ["hand_uid",'=',$hand_uid]; } $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:""; if ($start !="") { // $where = ["addtime"=>Db::raw(">= '{$start}'")]; $where[]= ["addtime",'>=',$start]; } $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :""; if($end !=""){ // $where = ["addtime"=>Db::raw("<= '{$end}'")]; $where[]= ["addtime",'<=',$end]; } $role = $this->checkDataShare(); if (!empty($role[DataGroupModel::$type_全部])) $where[] = ["hand_uid", "in", $role[DataGroupModel::$type_全部]]; $count = Db::name('resign_info')->where($where)->count(); $total = ceil($count/$size); $page = $page >= $total ? $total : $page; $list = Db::name('resign_info') ->where($where) ->order("addtime desc") ->page($page,$size) ->append(['is_allow_update']) ->withAttr('is_allow_update', function ($val, $data) use ($role) { return (in_array($this->roleid, [1, 33]) || in_array($data['hand_uid'], $role[DataGroupModel::$type_可编辑])) ? 1 : 0; //是否具有编辑权限 }) ->select() ->toArray(); return app_show(0,"获取成功",['list'=>$list,'count'=>$count]); } public function create(){ $token =isset($this->post['token']) && $this->post['token'] !=="" ? trim($this->post['token']) :""; $condition=[]; $resign_id = isset($this->post['resign_uid']) && $this->post['resign_uid'] !==""? trim($this->post['resign_uid']) :""; if($resign_id==""){ return error_show(1002,"离职人id不能为空"); } $condition['id']=$resign_id; $resign_uid=GetInfoById($token,$condition); if(empty($resign_uid)||$resign_uid['code']!=0){ return error_show(1002,"离职人员信息不存在"); } $ri= isset($resign_uid["data"]['nickname']) ? $resign_uid["data"]['nickname'] : ""; $hand_id = isset($this->post['hand_uid']) && $this->post['hand_uid'] !==""? trim($this->post['hand_uid']) :""; if($hand_id==""){ return error_show(1002,"交接人名称不能为空"); } $condition['id']=$hand_id; $hand_uid = GetInfoById($token,$condition); if(empty($hand_uid)||$hand_uid['code']!=0){ return error_show(1002,"交接人员信息不存在"); } $rp= isset($hand_uid["data"]['nickname']) ? $hand_uid["data"]['nickname'] : ""; $resign_date = isset($this->post['resign_date']) && $this->post['resign_date']!== "" ? $this->post['resign_date']:date("Y-m-d H:i:s"); if($resign_date==""){ return error_show(1005,'离职日期不能为空'); } $expire_date = isset($this->post['expire_date']) && $this->post['expire_date']!== "" ? $this->post['expire_date']:date("Y-m-d H:i:s"); if($expire_date==""){ return error_show(1005,'生效时间不能为空'); } $is_hand = isset($this->post['is_hand']) && $this->post['is_hand'] !=="" ? trim($this->post['is_hand']):"0"; $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "0"; $remark = isset($this->post['remark']) && $this->post['remark'] !== "" ? intval($this->post['remark']) : ""; $data=[ "resign_uid"=>$resign_id, "hand_uid"=>$hand_id, // "resign_depart_id"=>$resign_depart_id, // "hand_depart_id"=>$hand_depart_id, "resign_name"=>$ri, "hand_name"=>$rp, "resign_date"=> $resign_date, "expire_date"=>$expire_date, "is_hand"=>$is_hand, "status"=>$status, "remark"=>$remark, "is_del"=>0, "addtime"=>date("Y-m-d H:i:s"), "updatetime"=>date("Y-m-d H:i:s"), ]; $in = Db::name('resign_info')->insertGetId($data); $stn = ["order_code"=>'',"status"=>$status,"action_remark"=>'',"action_type"=>"create"]; ActionLog::logAdd(['id'=>isset($resign_uid["data"]['id'])?$resign_uid["data"]['id']:0,'nickname'=>$ri],$stn,"LZJJ",$status,$stn); $process=["order_code"=>'',"order_id"=>$in,"order_status"=>$status,"order_type"=>'LZJJ',"before_status"=>0]; ProcessOrder::AddProcess(['id'=>isset($resign_uid["data"]['id'])?$resign_uid["data"]['id']:0,'nickname'=>$ri],$process); return $in ? error_show(0,"添加成功") : error_show(1002,"添加失败"); } public function selec(){ $id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']) :""; if($id==""){ return error_show(1002,"离职人员信息不存在"); } $rid = Db::name('resign_info')->where(['is_del'=>0,'id'=>$id])->find(); return app_show(0,"获取成功",$rid); } public function edit(){ $condition=[]; $token =isset($this->post['token']) && $this->post['token'] !=="" ? trim($this->post['token']) :""; $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :""; $eid = Db::name('resign_info')->where(['is_del'=>0,'id'=>$id])->find(); if($eid==""){ return error_show(1002,"离职信息不存在"); } $resign_id = isset($this->post['resign_uid']) && $this->post['resign_uid'] !=="" ? trim($this->post['resign_uid']):""; if($resign_id==""){ return error_show(1002,"离职人员ID不能为空"); } $condition['id']=$resign_id; $resign_uid=GetInfoById($token,$condition); if(empty($resign_uid)||$resign_uid['code']!=0){ return error_show(1002,"离职人员信息不存在"); } $rr= isset($resign_uid["data"]['nickname']) ? $resign_uid["data"]['nickname'] : ""; $resign_date = isset($this->post['resign_date']) && $this->post['resign_date']!== "" ? $this->post['resign_date']:date("Y-m-d H:i:s"); if($resign_date==""){ return error_show(1005,'离职日期不能为空'); } $hand_id = isset($this->post['hand_uid']) && $this->post['hand_uid'] !=="" ? trim($this->post['hand_uid']) :""; if($hand_id=="") { return error_show(1002, "交接人员id不能为空"); } $condition['id']=$hand_id; $hand_uid = GetInfoById($token,$condition); if(empty($hand_uid)||$hand_uid['code']!=0){ return error_show(1002,"交接人员信息不存在"); } $r= isset($hand_uid["data"]['nickname']) ? $hand_uid["data"]['nickname'] : ""; $is_hand = isset($this->post['is_hand']) && $this->post['is_hand'] !=="" ? trim($this->post['is_hand']):"0"; $str=[ "hand_name"=>$r, "resign_name"=>$rr, "id"=>$id, "resign_uid"=>$resign_id, "hand_uid"=>$hand_id, "is_hand"=>$is_hand, "resign_date"=>date('Y-m-d H:i:s'), "is_del"=>0, "updatetime"=>date('Y-m-d H:i:s'), ]; $it = Db::name('resign_info')->where(['is_del'=>0,'id'=>$id])->save($str); if($it){ $stn = ["order_code"=>$id,"status"=>0,"action_remark"=>'',"action_type"=>"edit"]; ActionLog::logAdd($this->post['token'],$stn,"LZJJ",0,$stn); $process=["order_code"=>'',"order_id"=>$id,"order_status"=>$status,"order_type"=>'LZJJ',"before_status"=>0]; ProcessOrder::AddProcess(['id'=>isset($resign_uid["data"]['id'])?$resign_uid["data"]['id']:0,'nickname'=>$ri],$process); return error_show(0,"编辑成功"); }else{ return error_show(1002,"编辑失败"); } } public function del(){ $id = isset($this->post['id']) && $this->post['id'] !=="" ? $this->post['id']:""; $fid = Db::name('resign_info')->where(['is_del'=>0,'id'=>$id])->find(); if($fid==false){ return error_show(1002,"离职人员不存在"); } $num = Db::name('resign_info')->update(['is_del'=>1,'id'=>$id,"updatetime"=>date("Y-m-d H:i:s")]); if($num){ $stn = ["order_code"=>"BH","status"=>0,"action_remark"=>'',"action_type"=>"delete"]; ActionLog::logAdd($this->post['token'],$stn,"LZJJ",0,$stn); return error_show(0,"删除成功"); }else{ return error_show(1002,"删除失败"); } } public function statu(){ $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :""; if($id==""){ return error_show(1002,"离职人id不能为空"); } $remark = isset($this->post['remark']) && $this->post['remark'] !=="" ? trim($this->post['remark']) :""; $stauts = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :""; if($stauts===""){ return error_show(1002,"状态不能为空"); } $st = Db::name('resign_info')->where(['id'=>$id,"is_del"=>0])->find(); if(empty($st)){ return error_show(1002,"离职人员信息未找到"); } $tn =$st['status']; $st['remark']=$remark; $st['status']=$stauts==3 && strtotime($st['expire_date'])>=time() ? 4 :$stauts; $st['updatetime']= date('Y-m-d H:i:s'); $sv = Db::name('resign_info')->save($st); if($sv){ $stn = ["order_code"=>$id,"status"=>$tn,"action_remark"=>'',"action_type"=>"edit"]; ActionLog::logAdd($this->post['token'],$stn,"LZJJ",$stauts,$st); $process=["order_code"=>'',"order_id"=>$id,"order_status"=>$stauts,"order_type"=>'LZJJ',"before_status"=>$tn]; ProcessOrder::AddProcess($this->post['token'],$process); return error_show(0,"状态更新成功"); }else{ return error_show(1002,"状态更新失败"); } } }