|
@@ -1,16 +1,16 @@
|
|
|
<?php
|
|
|
namespace app\api\controller;
|
|
|
use AlibabaCloud\SDK\Dingtalk\Vyida_1_0\Models\GetFormDataByIDResponseBody\originator\name;
|
|
|
+use app\common\model\EvectionApprove;
|
|
|
use app\common\model\LeaveApprove;
|
|
|
use app\common\model\ApproveFlow;
|
|
|
-use app\common\model\LeaveInfo;
|
|
|
-use app\common\model\LeaveType;
|
|
|
+use app\common\model\EvectionInfo;
|
|
|
use app\common\service\ApproveService;
|
|
|
use think\Db;
|
|
|
use app\common\model\User;
|
|
|
/**
|
|
|
* @title 员工出差管理
|
|
|
- * @controller UserLeave
|
|
|
+ * @controller Evection
|
|
|
* @group base
|
|
|
*/
|
|
|
class Evection extends Base
|
|
@@ -80,45 +80,42 @@ class Evection extends Base
|
|
|
* @title 出差申请
|
|
|
* @desc 出差申请
|
|
|
* @author qc
|
|
|
- * @url /api/Evection/applyVacate
|
|
|
+ * @url /api/Evection/applyEvection
|
|
|
* @method GET
|
|
|
* @tag
|
|
|
* @header name:Authorization require:1 desc:Token
|
|
|
- * @param name:type type:int default:-- desc:出差类型id
|
|
|
- * @param name:start_date type:string default:-- desc:开始日期(格式:2022-11-01)
|
|
|
- * @param name:start_time type:string default:-- desc:开始时间(上午||下午)
|
|
|
- * @param name:end_date type:string default:-- desc:结束日期(格式:2022-11-01)
|
|
|
- * @param name:end_time type:string default:-- desc:结束时间(上午||下午)
|
|
|
+ * @param name:type type:int default:-- desc:出差类型(1市内2市外)
|
|
|
+ * @param name:reason type:string default:-- desc:出差事由
|
|
|
+ * @param name:start_time type:string default:-- desc:开始时间
|
|
|
+ * @param name:end_time type:string default:-- desc:结束时间
|
|
|
* @param name:document type:string default:-- desc:附件(文件路径)
|
|
|
* @param name:images type:string default:-- desc:图片(多张|隔开)
|
|
|
- * @param name:content type:string default:-- desc:出差详细内容(是否离深)
|
|
|
- * @param name:user_id type:int default:-- desc:出差会员id(自己出差可以不传,代为出差传出差人id)
|
|
|
+ * @param name:peer_user type:string default:-- desc:同行员工id(多个|隔开)
|
|
|
*/
|
|
|
- public function applyVacate()
|
|
|
+ public function applyEvection()
|
|
|
{
|
|
|
$request_param = input('post.');
|
|
|
- if(empty($request_param['start_date']) || empty($request_param['end_date'])) $this->error('请选择出差期');
|
|
|
+ if(empty($request_param['start_time']) || empty($request_param['end_time'])) $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 = ApproveFlow::getApproveUser(1);// 出差审批流程设置
|
|
|
+ $flow = ApproveFlow::getApproveUser(3);// 出差审批流程设置
|
|
|
$flow_user = array_column($flow,'user_id');
|
|
|
$flow_key = array_search($request_param['user_id'],$flow_user);// 出差人是否在审批流程人员中
|
|
|
|
|
|
-
|
|
|
- $copy = ApproveFlow::getCopyTo(1);
|
|
|
+ $copy = ApproveFlow::getCopyTo(3);
|
|
|
$copy_user = array_column($copy,'user_id');
|
|
|
$copy_key = array_search($request_param['user_id'],$copy_user);// 出差人是否在抄送人员中
|
|
|
|
|
|
- $flow_info = LeaveInfo::create($request_param);//生成出差记录
|
|
|
+ $flow_info = EvectionInfo::create($request_param);//生成出差记录
|
|
|
$flow_data = [];// 审批流程
|
|
|
$flow_num = 0;
|
|
|
foreach ($flow as $fk=>$fv) {
|
|
|
if($flow_key !== false && $flow_key >= $fk) continue;
|
|
|
$flow_num++;
|
|
|
$flow_data[] = [
|
|
|
- 'leave_id' => $flow_info->id,
|
|
|
+ 'eve_id' => $flow_info->id,
|
|
|
'approve_user' => $fv['user_id'],
|
|
|
'flow' =>$flow_num,
|
|
|
'create_at'=>date('Y-m-d H:i:s'),
|
|
@@ -129,17 +126,17 @@ class Evection extends Base
|
|
|
foreach ($copy as $ck=>$cv) {
|
|
|
if($copy_key !== false && $copy_key >= $ck) continue;
|
|
|
$flow_data[] = [
|
|
|
- 'leave_id' => $flow_info->id,
|
|
|
+ 'eve_id' => $flow_info->id,
|
|
|
'approve_user' => $cv['user_id'],
|
|
|
'approve_type' =>2
|
|
|
];
|
|
|
}
|
|
|
|
|
|
if(!empty($flow_data)) {
|
|
|
- LeaveInfo::where('id',$flow_info->id)->update(['approve_num'=>$flow_num]);
|
|
|
- (new LeaveApprove())->saveAll($flow_data);
|
|
|
+ EvectionInfo::where('id',$flow_info->id)->update(['approve_num'=>$flow_num]);
|
|
|
+ (new EvectionApprove())->saveAll($flow_data);
|
|
|
}else{
|
|
|
- LeaveInfo::where('id',$flow_info->id)->update(['status'=>2]);
|
|
|
+ EvectionInfo::where('id',$flow_info->id)->update(['status'=>2]);
|
|
|
}
|
|
|
$this->success('出差已提交,请等待审核',['detail'=>$flow_info->toArray()]);
|
|
|
}
|
|
@@ -148,7 +145,7 @@ class Evection extends Base
|
|
|
* @title 我的出差记录【列表】
|
|
|
* @desc 我的出差记录
|
|
|
* @author qc
|
|
|
- * @url /api/Evection/getVacateList
|
|
|
+ * @url /api/Evection/getEvectionList
|
|
|
* @method GET
|
|
|
* @tag
|
|
|
* @header name:Authorization require:1 desc:Token
|
|
@@ -157,31 +154,23 @@ class Evection extends Base
|
|
|
* @param name:type type:int default:0 desc:出差类型id
|
|
|
* @param name:status type:int default:0 desc:审批状态0全部,1审批中,2审批通过,3审批拒绝,9取消
|
|
|
* @param name:sel_time type:string default:0 desc:时间查询
|
|
|
- * @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:start_time type:string default:-- desc:开始时间
|
|
|
+ * @return name:end_time type:string default:-- desc:结束时间
|
|
|
* @return name:reason 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:type_name type:string default:-- desc:出差类型
|
|
|
+ * @return name:reason type:string default:-- desc:出差事由
|
|
|
+ * @return name:type type:int default:-- desc:出差类型(1市内2市外)
|
|
|
* @return name:status type:int default:-- desc:状态:1审批中,2审批通过,3审批拒绝,9取消
|
|
|
* @return name:user_id type:int default:-- desc:出差会员id
|
|
|
*/
|
|
|
- public function getVacateList()
|
|
|
+ public function getEvectionList()
|
|
|
{
|
|
|
- $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'];
|
|
|
- });
|
|
|
+ $list = EvectionInfo::where($sel_where)->limit($this->off_set,$this->page_num)->select()->toArray();
|
|
|
$this->success('ok',['list'=>$list]);
|
|
|
}
|
|
|
|
|
@@ -216,7 +205,7 @@ class Evection extends Base
|
|
|
public function getVacateDetail()
|
|
|
{
|
|
|
$id = input('get.id');
|
|
|
- $detail = LeaveInfo::with('approveList')->where(['user_id'=>$this->user_id])->where(['id'=>$id])
|
|
|
+ $detail = EvectionInfo::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;
|
|
@@ -254,7 +243,7 @@ class Evection extends Base
|
|
|
->alias('p')
|
|
|
->where(['p.approve_user'=>$this->user_id])
|
|
|
->where('p.status','>','0')
|
|
|
- ->leftJoin('LeaveInfo i','p.leave_id = i.id')
|
|
|
+ ->leftJoin('EvectionInfo i','p.leave_id = i.id')
|
|
|
->limit($this->off_set,$this->page_num)
|
|
|
->select()->toArray();
|
|
|
array_walk($list,function (&$v){
|
|
@@ -300,7 +289,7 @@ class Evection extends Base
|
|
|
public function cancelApply()
|
|
|
{
|
|
|
$id = input('post.id');
|
|
|
- $apply_info = LeaveInfo::where('id',$id)->where('user_id|apply_user',$this->user_id)->find();
|
|
|
+ $apply_info = EvectionInfo::where('id',$id)->where('user_id|apply_user',$this->user_id)->find();
|
|
|
if(!$apply_info)$this->error('出差记录有误');
|
|
|
$apply_info->status = 9;
|
|
|
$apply_info->save();
|