|
@@ -14,6 +14,7 @@ use think\App;
|
|
|
use think\Db;
|
|
|
use app\common\model\User;
|
|
|
use hg\apidoc\annotation as Apidoc;
|
|
|
+
|
|
|
/**
|
|
|
* @Apidoc\Title("员工出差管理")
|
|
|
* @Apidoc\Group("api")
|
|
@@ -30,82 +31,61 @@ class Evection extends Base
|
|
|
* @Apidoc\Title("获取流程")
|
|
|
* @Apidoc\Desc("获取流程")
|
|
|
* @Apidoc\Method("POST")
|
|
|
- * @Apidoc\Returned("user_name", type="string", desc="会员名称")
|
|
|
- * @Apidoc\Returned("headimg", type="string", desc="会员头像")
|
|
|
+ * @Apidoc\Returned("approve_user", type="array", desc="审批人列表")
|
|
|
+ * @Apidoc\Returned("approve_user.name", type="string", desc="姓名")
|
|
|
+ * @Apidoc\Returned("approve_user.headimg", type="string", desc="头像")
|
|
|
+ * @Apidoc\Returned("copy_user", type="array", desc="审批人列表")
|
|
|
+ * @Apidoc\Returned("copy_user.name", type="string", desc="姓名")
|
|
|
+ * @Apidoc\Returned("copy_user.headimg", type="string", desc="头像")
|
|
|
*/
|
|
|
- public function get_data(){
|
|
|
- $data = ApproveFlowService::get_data(CommonConstant::MODULE_3,$this->user);
|
|
|
- $this->success('获取流程',$data);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Apidoc\Title("获取审批流程")
|
|
|
- * @Apidoc\Desc("获取审批流程")
|
|
|
- * @Apidoc\Method("POST")
|
|
|
- * @Apidoc\Returned("user_name", type="string", desc="会员名称")
|
|
|
- * @Apidoc\Returned("headimg", type="string", desc="会员头像")
|
|
|
- */
|
|
|
- public function getApproveFlow()
|
|
|
+ public function get_data()
|
|
|
{
|
|
|
- $list = ApproveFlow::getApproveUser(3,$this->user_id);
|
|
|
- $this->success('ok',['list'=>$list]);
|
|
|
+ $data = ApproveFlowService::get_data(CommonConstant::MODULE_3, $this->user);
|
|
|
+ $this->success('获取流程', $data);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @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(3,$this->user_id);
|
|
|
- $this->success('ok',['list'=>$list]);
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* @Apidoc\Title("出差申请")
|
|
|
* @Apidoc\Desc("出差申请")
|
|
|
* @Apidoc\Method("POST")
|
|
|
- * @Apidoc\Author("HG")
|
|
|
- * @Apidoc\Tag("出差申请")
|
|
|
- * @Apidoc\Query("type", type="int",desc="出差类型(1市内2市外)")
|
|
|
* @Apidoc\Query("reason", type="string", desc="出差事由")
|
|
|
* @Apidoc\Query("start_time", type="string", desc="开始时间")
|
|
|
* @Apidoc\Query("end_time", type="string", desc="结束时间")
|
|
|
- * @Apidoc\Query("document", type="string", desc="附件(文件路径)")
|
|
|
- * @Apidoc\Query("images", type="string", desc="图片(多张|隔开)")
|
|
|
- * @Apidoc\Query("peer_user", type="string", desc="同行员工id(多个,隔开)")
|
|
|
- * @Apidoc\Query("flow_user", type="string", desc="审批人id(多个逗号隔开)")
|
|
|
- * @Apidoc\Query("copy_user", type="string", desc="抄送人id(多个逗号隔开)")
|
|
|
+ * @Apidoc\Query("document", type="string", desc="附件(多个用英文逗号隔开)")
|
|
|
+ * @Apidoc\Query("images", type="string", desc="图片(多个用英文逗号隔开)")
|
|
|
+ * @Apidoc\Query("type", type="integer",desc="出差类型:1=市内,2=市外")
|
|
|
+ * @Apidoc\Query("is_who", type="integer",desc="是否跨关内关外:0=否,1=是")
|
|
|
+ * @Apidoc\Query("desc", type="string", desc="备注")
|
|
|
+ * @Apidoc\Query("peer_user", type="string", desc="同行员工id(多个用英文逗号隔开)")
|
|
|
+ * @Apidoc\Query("approve_user", type="string", desc="审批人id(多个用英文逗号隔开)")
|
|
|
+ * @Apidoc\Query("copy_user", type="string", desc="抄送人id(多个用英文逗号隔开)")
|
|
|
*/
|
|
|
public function applyEvection()
|
|
|
{
|
|
|
$request_param = input('post.');
|
|
|
- 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;
|
|
|
+ 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
|
|
|
$request_param['apply_date'] = date("Y-m-d");
|
|
|
|
|
|
- $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_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 = EvectionInfo::create($request_param);//生成出差记录
|
|
|
- $approve_res = ApproveFlow::getApproveData($flow_user,$copy_user,$flow_info->id);
|
|
|
+ $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)) {
|
|
|
- EvectionInfo::where('id',$flow_info->id)->update(['approve_num'=>$flow_num]);
|
|
|
+ if (!empty($flow_data)) {
|
|
|
+ EvectionInfo::where('id', $flow_info->id)->update(['approve_num' => $flow_num]);
|
|
|
(new EvectionApprove())->saveAll($flow_data);
|
|
|
- }else{
|
|
|
- EvectionInfo::where('id',$flow_info->id)->update(['status'=>2]);
|
|
|
+ } else {
|
|
|
+ EvectionInfo::where('id', $flow_info->id)->update(['status' => 2]);
|
|
|
}
|
|
|
- $this->success('出差已提交,请等待审核',['detail'=>$flow_info->toArray()]);
|
|
|
+ $this->success('出差已提交,请等待审核', ['detail' => $flow_info->toArray()]);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* @Apidoc\Title("我的出差记录(列表)")
|
|
|
* @Apidoc\Desc("我的出差记录")
|
|
@@ -130,11 +110,11 @@ class Evection extends Base
|
|
|
public function getEvectionList()
|
|
|
{
|
|
|
$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')];
|
|
|
- $list = EvectionInfo::where($sel_where)->limit($this->off_set,$this->page_num)->select()->toArray();
|
|
|
- $this->success('ok',['list'=>$list]);
|
|
|
+ $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')];
|
|
|
+ $list = EvectionInfo::where($sel_where)->limit($this->off_set, $this->page_num)->select()->toArray();
|
|
|
+ $this->success('ok', ['list' => $list]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -167,13 +147,13 @@ class Evection extends Base
|
|
|
public function getEvectionDetail()
|
|
|
{
|
|
|
$id = input('get.id');
|
|
|
- $detail = EvectionInfo::with('approveList')->where(['user_id'=>$this->user_id])->where(['id'=>$id])
|
|
|
- ->limit($this->off_set,$this->page_num)
|
|
|
+ $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;
|
|
|
- $peer_list = User::field('id,name,headimg')->where('id','in',$detail['peer_user'])->select()->toArray();
|
|
|
- $detail['peer_list'] = !empty($peer_list) ?$peer_list: null ;
|
|
|
- $this->success('ok',['detail'=>$detail]);
|
|
|
+ $detail['images_arr'] = $detail['images'] ? explode('|', $detail['images']) : null;
|
|
|
+ $peer_list = User::field('id,name,headimg')->where('id', 'in', $detail['peer_user'])->select()->toArray();
|
|
|
+ $detail['peer_list'] = !empty($peer_list) ? $peer_list : null;
|
|
|
+ $this->success('ok', ['detail' => $detail]);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -204,15 +184,15 @@ class Evection extends Base
|
|
|
{
|
|
|
$list = EvectionApprove::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('EvectionInfo i','p.info_id = i.id')
|
|
|
- ->limit($this->off_set,$this->page_num)
|
|
|
+ ->where(['p.approve_user' => $this->user_id])
|
|
|
+ ->where('p.status', '>', '0')
|
|
|
+ ->leftJoin('EvectionInfo 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;
|
|
|
+ array_walk($list, function (&$v) {
|
|
|
+ $v['images_arr'] = $v['images'] ? explode('|', $v['images']) : null;
|
|
|
});
|
|
|
- $this->success('ok',['list'=>$list]);
|
|
|
+ $this->success('ok', ['list' => $list]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -230,8 +210,8 @@ class Evection extends Base
|
|
|
$approve_id = input('post.id');
|
|
|
$status = input('post.status');
|
|
|
$remark = input('post.remark');
|
|
|
- $res = ApproveService::approveEvection($approve_id,$this->user_id,$status,$remark);
|
|
|
- if(!$res['ret_val']) $this->error($res['msg']);
|
|
|
+ $res = ApproveService::approveEvection($approve_id, $this->user_id, $status, $remark);
|
|
|
+ if (!$res['ret_val']) $this->error($res['msg']);
|
|
|
$this->success('审批完成');
|
|
|
}
|
|
|
|
|
@@ -245,18 +225,15 @@ class Evection extends Base
|
|
|
*/
|
|
|
public function cancelApply()
|
|
|
{
|
|
|
- $id = input('post.id');
|
|
|
- $apply_info = EvectionInfo::where('id',$id)->where('user_id',$this->user_id)->find();
|
|
|
- if(!$apply_info)$this->error('出差记录有误');
|
|
|
+ $id = input('post.id');
|
|
|
+ $apply_info = EvectionInfo::where('id', $id)->where('user_id', $this->user_id)->find();
|
|
|
+ if (!$apply_info) $this->error('出差记录有误');
|
|
|
$apply_info->status = 9;
|
|
|
$apply_info->save();
|
|
|
$this->success('撤销成功');
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|