|
@@ -0,0 +1,281 @@
|
|
|
+<?php
|
|
|
+namespace app\api\controller;
|
|
|
+use AlibabaCloud\SDK\Dingtalk\Vyida_1_0\Models\GetFormDataByIDResponseBody\originator\name;
|
|
|
+use app\common\model\LeaveApprove;
|
|
|
+use app\common\model\ApproveFlow;
|
|
|
+use app\common\model\LeaveInfo;
|
|
|
+use app\common\model\LeaveType;
|
|
|
+use app\common\service\ApproveService;
|
|
|
+use think\Db;
|
|
|
+use app\common\model\User;
|
|
|
+use hg\apidoc\annotation as Apidoc;
|
|
|
+/**
|
|
|
+ * @Apidoc\Title("员工请假管理")
|
|
|
+ * @Apidoc\Group("api")
|
|
|
+ */
|
|
|
+class UserLeave extends Base
|
|
|
+{
|
|
|
+ public function initialize()
|
|
|
+ {
|
|
|
+ parent::initialize();
|
|
|
+ parent::checkLogin();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Apidoc\Title("获取审批流程")
|
|
|
+ * @Apidoc\Desc("获取审批流程")
|
|
|
+ * @Apidoc\Method("GET")
|
|
|
+ * @Apidoc\Author("HG")
|
|
|
+ * @Apidoc\Tag("")
|
|
|
+ * @Apidoc\Returned("user_name", type="string", desc="会员名称")
|
|
|
+ * @Apidoc\Returned("headimg", type="string", desc="会员头像")
|
|
|
+ */
|
|
|
+ public function getApproveFlow()
|
|
|
+ {
|
|
|
+ $list = ApproveFlow::getApproveUser(1,$this->user_id);
|
|
|
+ $this->success('ok',['list'=>$list]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Apidoc\Title("获取抄送人流程")
|
|
|
+ * @Apidoc\Desc("获取抄送人流程")
|
|
|
+ * @Apidoc\Method("GET")
|
|
|
+ * @Apidoc\Author("HG")
|
|
|
+ * @Apidoc\Tag("")
|
|
|
+ * @Apidoc\Returned("user_name", type="string", desc="会员名称")
|
|
|
+ * @Apidoc\Returned("headimg", type="string", desc="会员头像")
|
|
|
+ */
|
|
|
+ public function getCopyFlow()
|
|
|
+ {
|
|
|
+ $list = ApproveFlow::getCopyTo(1,$this->user_id);
|
|
|
+ $this->success('ok',['list'=>$list]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Apidoc\Title("获取请假类型")
|
|
|
+ * @Apidoc\Desc("获取请假类型")
|
|
|
+ * @Apidoc\Method("GET")
|
|
|
+ * @Apidoc\Author("HG")
|
|
|
+ * @Apidoc\Tag("")
|
|
|
+ * @Apidoc\Returned("id", type="int", desc="会员id")
|
|
|
+ * @Apidoc\Returned("title", type="int", desc="类型")
|
|
|
+ */
|
|
|
+ public function getLeaveType()
|
|
|
+ {
|
|
|
+ $field = 'id,title';
|
|
|
+ $user_info = LeaveType::field($field)->where('status',1)->where('is_deleted',0)->select()->toArray();
|
|
|
+ $this->success('获取成功',['detail'=>$user_info]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Apidoc\Title("请假申请")
|
|
|
+ * @Apidoc\Desc("请假申请")
|
|
|
+ * @Apidoc\Method("GET")
|
|
|
+ * @Apidoc\Author("HG")
|
|
|
+ * @Apidoc\Tag("")
|
|
|
+ * @Apidoc\Query("type", type="int",desc="请假类型id")
|
|
|
+ * @Apidoc\Query("start_date", type="string",desc="开始日期(格式:2022-11-01)")
|
|
|
+ * @Apidoc\Query("start_time", type="string", desc="开始时间(上午||下午)")
|
|
|
+ * @Apidoc\Query("end_time", type="string", desc="结束日期(格式:2022-11-01)")
|
|
|
+ * @Apidoc\Query("title", type="string", desc="结束时间(上午||下午)")
|
|
|
+ * @Apidoc\Query("document", type="string", desc="附件(文件路径)")
|
|
|
+ * @Apidoc\Query("images", type="string", desc="图片(多张|隔开)")
|
|
|
+ * @Apidoc\Query("content", type="string", desc="呈批详细内容")
|
|
|
+ * @Apidoc\Query("user_id", type="int", desc="请假会员id(自己请假可以不传,代为请假传请假人id)")
|
|
|
+ * @Apidoc\Query("flow_user", type="string", desc="审批人id(多个逗号隔开)")
|
|
|
+ * @Apidoc\Query("copy_user", type="string", desc="抄送人id(多个逗号隔开)")
|
|
|
+ */
|
|
|
+ public function applyVacate()
|
|
|
+ {
|
|
|
+ $request_param = input('post.');
|
|
|
+ if(empty($request_param['start_date']) || empty($request_param['end_date'])) $this->error('请选择请假期');
|
|
|
+ if(empty($request_param['type'])) $this->error('请选择请假类型');
|
|
|
+ if(empty($request_param['user_id'])) $request_param['user_id'] = $this->user_id;
|
|
|
+ $request_param['apply_user'] = $this->user_id;// 申请会员id
|
|
|
+
|
|
|
+ $flow_user = isset($request_param['flow_user']) ? $request_param['flow_user']:'' ;
|
|
|
+ $copy_user = isset($request_param['copy_user']) ? $request_param['copy_user']:'' ;
|
|
|
+ if(!$flow_user) $this->error('请选择审批人');
|
|
|
+ $flow_info = LeaveInfo::create($request_param);//生成出差记录
|
|
|
+ $approve_res = ApproveFlow::getApproveData($flow_user,$copy_user,$flow_info->id);
|
|
|
+ $flow_data = $approve_res['flow_data'];// 审批流程
|
|
|
+ $flow_num = $approve_res['flow_num'];
|
|
|
+
|
|
|
+ if(!empty($flow_data)) {
|
|
|
+ LeaveInfo::where('id',$flow_info->id)->update(['approve_num'=>$flow_num]);
|
|
|
+ (new LeaveApprove())->saveAll($flow_data);
|
|
|
+ }else{
|
|
|
+ LeaveInfo::where('id',$flow_info->id)->update(['status'=>2]);
|
|
|
+ }
|
|
|
+ $this->success('请假已提交,请等待审核',['detail'=>$flow_info->toArray()]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Apidoc\Title("我的请假记录(列表)")
|
|
|
+ * @Apidoc\Desc("我的请假记录")
|
|
|
+ * @Apidoc\Method("GET")
|
|
|
+ * @Apidoc\Author("HG")
|
|
|
+ * @Apidoc\Tag("")
|
|
|
+ * @Apidoc\Query("page", type="int",desc="页数")
|
|
|
+ * @Apidoc\Query("page_num", type="string", desc="每页数量")
|
|
|
+ * @Apidoc\Query("type", type="int", desc="请假类型id")
|
|
|
+ * @Apidoc\Query("status", type="int", desc="审批状态0全部,1审批中,2审批通过,3审批拒绝,9取消")
|
|
|
+ * @Apidoc\Query("sel_time", type="string", desc="时间查询")
|
|
|
+ * @Apidoc\Returned("start_date", type="string", desc="开始日期(格式:2022-11-01)")
|
|
|
+ * @Apidoc\Returned("start_time", type="string", desc="开始时间(上午||下午)")
|
|
|
+ * @Apidoc\Returned("end_date", type="string", desc="结束日期(格式:2022-11-01)")
|
|
|
+ * @Apidoc\Returned("end_time", type="string", desc="结束时间(上午||下午)")
|
|
|
+ * @Apidoc\Returned("reason", type="string", desc="请假事由")
|
|
|
+ * @Apidoc\Returned("document", type="string", desc="附件(文件路径)")
|
|
|
+ * @Apidoc\Returned("images", type="string", desc="图片(多张|隔开)")
|
|
|
+ * @Apidoc\Returned("content", type="string", desc="维修详细内容")
|
|
|
+ * @Apidoc\Returned("type_name", type="string", desc="请假类型")
|
|
|
+ * @Apidoc\Returned("status", type="int", desc="状态:1审批中,2审批通过,3审批拒绝,9取消")
|
|
|
+ * @Apidoc\Returned("user_id", type="int", desc="请假会员id")
|
|
|
+ */
|
|
|
+ public function getVacateList()
|
|
|
+ {
|
|
|
+ $all_type = LeaveType::getAllType();
|
|
|
+ $type = array_column($all_type,null,'id');
|
|
|
+ $sel_where = [];
|
|
|
+ $sel_where[] = ['user_id','=',$this->user_id];
|
|
|
+ if(input('get.status') > 0) $sel_where[] = ['status','=',input('get.status')];
|
|
|
+ if(input('get.type') > 0) $sel_where[] = ['type','=',input('get.type')];
|
|
|
+ if(input('get.sel_time')) $sel_where[] = ['start_date|end_date','=',input('get.sel_time')];
|
|
|
+ $list = LeaveInfo::where($sel_where)->limit($this->off_set,$this->page_num)->select()->toArray();
|
|
|
+ array_walk($list,function (&$v,$k)use ($type){
|
|
|
+ $list['type_name'] = $type[$v['type']]['title'];
|
|
|
+ });
|
|
|
+ $this->success('ok',['list'=>$list]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Apidoc\Title("我的请假详情")
|
|
|
+ * @Apidoc\Desc("我的请假详情")
|
|
|
+ * @Apidoc\Method("GET")
|
|
|
+ * @Apidoc\Author("HG")
|
|
|
+ * @Apidoc\Tag("")
|
|
|
+ * @Apidoc\Query("id", type="int",require=true, desc="请假记录id")
|
|
|
+ * @Apidoc\Returned("start_date", type="string", desc="开始日期(格式:2022-11-01)")
|
|
|
+ * @Apidoc\Returned("start_time", type="string", desc="开始时间(上午||下午)")
|
|
|
+ * @Apidoc\Returned("end_date", type="string", desc="结束日期(格式:2022-11-01)")
|
|
|
+ * @Apidoc\Returned("end_time", type="string", desc="结束时间(上午||下午)")
|
|
|
+ * @Apidoc\Returned("reason", type="string", desc="请假事由")
|
|
|
+ * @Apidoc\Returned("type_name", type="string", desc="请假类型")
|
|
|
+ * @Apidoc\Returned("status", type="int", desc="状态:1审批中,2审批通过,3审批拒绝,9取消")
|
|
|
+ * @Apidoc\Returned("user_id", type="int", desc="请假会员id")
|
|
|
+ * @Apidoc\Returned("document", type="string", desc="附件(文件路径)")
|
|
|
+ * @Apidoc\Returned("images", type="string", desc="图片(多张|隔开)")
|
|
|
+ * @Apidoc\Returned("content", type="string", desc="维修详细内容")
|
|
|
+ * @Apidoc\Returned("type_name", type="string", desc="请假类型")
|
|
|
+ * @Apidoc\Returned("status", type="int", desc="状态:1审批中,2审批通过,3审批拒绝,9取消")
|
|
|
+ * @Apidoc\Returned("user_id", type="int", desc="请假会员id")
|
|
|
+ * @Apidoc\Returned("approve_list", type="array", desc="审批记录")
|
|
|
+ * @Apidoc\Returned("approve_list.status", type="int", desc="审批状态:0待审批(未到该审批人审批),1审批中(已到该审批人审批,还未审批)2审批通过3审批拒绝")
|
|
|
+ * @Apidoc\Returned("approve_list.approve_time", type="string", desc="审批时间")
|
|
|
+ * @Apidoc\Returned("approve_list.remark", type="string", desc="审批备注")
|
|
|
+ * @Apidoc\Returned("approve_list.user_name", type="string", desc="审批人")
|
|
|
+ * @Apidoc\Returned("approve_list.headimg", type="string", desc="审批人头像")
|
|
|
+ * @Apidoc\Returned("approve_list.time", type="string", desc="审批用时(上一次审批完成到本次维修的时间,单位秒)")
|
|
|
+ */
|
|
|
+ public function getVacateDetail()
|
|
|
+ {
|
|
|
+ $id = input('get.id');
|
|
|
+ $detail = LeaveInfo::with('approveList')->where(['user_id'=>$this->user_id])->where(['id'=>$id])
|
|
|
+ ->limit($this->off_set,$this->page_num)
|
|
|
+ ->find()->toArray();
|
|
|
+ $detail['images_arr'] = $detail['images'] ? explode('|',$detail['images']) : null;
|
|
|
+ $this->success('ok',['detail'=>$detail]);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @title 需要我审批的
|
|
|
+ * @desc 需要我审批的
|
|
|
+ * @author qc
|
|
|
+ * @url /api/User_leave/getApproveLeave
|
|
|
+ * @method GET
|
|
|
+ * @tag
|
|
|
+ * @header name:Authorization require:1 desc:Token
|
|
|
+ * @param name:page type:int default:-- desc:页数
|
|
|
+ * @param name:page_num type:int default:-- desc:每页数量
|
|
|
+ * @return name:id type:int default:-- desc:请假记录id
|
|
|
+ * @return name:start_date type:string default:-- desc:开始日期(格式:2022-11-01)
|
|
|
+ * @return name:start_time type:string default:-- desc:开始时间(上午||下午)
|
|
|
+ * @return name:end_date type:string default:-- desc:结束日期(格式:2022-11-01)
|
|
|
+ * @return name:end_time type:string default:-- desc:结束时间(上午||下午)
|
|
|
+ * @return name:document type:string default:-- desc:附件(文件路径)
|
|
|
+ * @return name:images type:string default:-- desc:图片(多张|隔开)
|
|
|
+ * @return name:content type:string default:-- desc:请假详细内容(是否离深)
|
|
|
+ * @return name:reason type:string default:-- desc:请假事由
|
|
|
+ * @return name:approve_status type:int default:-- desc:审批状态
|
|
|
+ * @return name:approve_time type:string default:-- desc:审批时间(1审批中2审批通过3审批拒绝)
|
|
|
+ * @return name:remark type:string default:-- desc:审批备注
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function getApproveLeave()
|
|
|
+ {
|
|
|
+ $list = LeaveApprove::field('i.*,p.status approve_status,p.approve_time,p.remark')
|
|
|
+ ->alias('p')
|
|
|
+ ->where(['p.approve_user'=>$this->user_id])
|
|
|
+ ->where('p.status','>','0')
|
|
|
+ ->leftJoin('LeaveInfo i','p.info_id = i.id')
|
|
|
+ ->limit($this->off_set,$this->page_num)
|
|
|
+ ->select()->toArray();
|
|
|
+ array_walk($list,function (&$v){
|
|
|
+ $v['images_arr'] = $v['images'] ? explode('|',$v['images']) : null;
|
|
|
+ });
|
|
|
+ $this->success('ok',['list'=>$list]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @title 审批请假记录
|
|
|
+ * @desc 审批请假记录
|
|
|
+ * @author qc
|
|
|
+ * @url /api/User_leave/approveLeave
|
|
|
+ * @method POST
|
|
|
+ * @tag
|
|
|
+ * @header name:Authorization require:1 desc:Token
|
|
|
+ * @param name:id type:string default:-- desc:请假记录id
|
|
|
+ * @param name:status type:string default:-- desc:审批状态(2审批通过3审批拒绝)
|
|
|
+ * @param name:remark type:string default:-- desc:审批备注
|
|
|
+ */
|
|
|
+ public function approveLeave()
|
|
|
+ {
|
|
|
+ $approve_id = input('post.id');
|
|
|
+ $status = input('post.status');
|
|
|
+ $remark = input('post.remark');
|
|
|
+ $res = ApproveService::approveLeave($approve_id,$this->user_id,$status,$remark);
|
|
|
+ if(!$res['ret_val']) $this->error($res['msg']);
|
|
|
+ $this->success('审批完成');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @title 撤销请假申请
|
|
|
+ * @desc 撤销请假申请
|
|
|
+ * @author qc
|
|
|
+ * @url /api/User_leave/cancelApply
|
|
|
+ * @method POST
|
|
|
+ * @tag
|
|
|
+ * @header name:Authorization require:1 desc:Token
|
|
|
+ * @param name:id type:int default:-- desc:请假记录id
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function cancelApply()
|
|
|
+ {
|
|
|
+ $id = input('post.id');
|
|
|
+ $apply_info = LeaveInfo::where('id',$id)->where('user_id|apply_user',$this->user_id)->find();
|
|
|
+ if(!$apply_info)$this->error('请假记录有误');
|
|
|
+ $apply_info->status = 9;
|
|
|
+ $apply_info->save();
|
|
|
+ $this->success('撤销成功');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|