新增抄送审批记录

This commit is contained in:
yaooo 2023-11-01 15:08:19 +08:00
parent ad0e46cbe7
commit 195e273498
1 changed files with 186 additions and 0 deletions

View File

@ -323,4 +323,190 @@ class OaApprove extends ApiController
$this->apiSuccess('操作成功');
}
//发起审批记录
public function index()
{
$this->checkAuth();
$this->uid = JWT_UID;
$param = get_params();
$where = [];
if (isset($param['status'])) {
if($param['status'] == 1){
$where[] = ['check_status','<',2];
}
if($param['status'] == 2){
$where[] = ['check_status','=',2];
}
if($param['status'] == 3){
$where[] = ['check_status','>',2];
}
}
$where[] = ['admin_id','=',$this->uid];
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
$list = Db::name('Approve')
->field('f.*,a.name,d.title as department_name,t.title as flow_type')
->alias('f')
->join('Admin a', 'a.id = f.admin_id', 'left')
->join('Department d', 'd.id = f.department_id', 'left')
->join('FlowType t', 't.id = f.type', 'left')
->where($where)
->order('f.id desc')
->paginate(['list_rows' => $rows, 'query' => $param])
->each(function($item, $key){
$item['create_time'] = date('Y-m-d H:i', $item['create_time']);
$item['check_user'] = '-';
if($item['check_status']<2 && !empty($item['check_admin_ids'])){
$check_user = Db::name('Admin')->where('id','in',$item['check_admin_ids'])->column('name');
$item['check_user'] = implode(',',$check_user);
}
return $item;
});
$this->apiSuccess('获取成功', $list);
}
//我处理的审批记录
public function list()
{
$this->checkAuth();
$this->uid = JWT_UID;
$param = get_params();
$status = isset($param['status'])?$param['status']:0;
$user_id = $this->uid;
//查询条件
$map1 = [];
$map2 = [];
$map1[] = ['', 'exp', Db::raw("FIND_IN_SET('{$user_id}',f.check_admin_ids)")];
$map2[] = ['', 'exp', Db::raw("FIND_IN_SET('{$user_id}',f.flow_admin_ids)")];
if (!empty($param['type'])) {
$map1[] = ['f.type', '=', $param['type']];
$map2[] = ['f.type', '=', $param['type']];
}
if (!empty($param['uid'])) {
$map1[] = ['f.admin_id', '=', $param['uid']];
$map2[] = ['f.admin_id', '=', $param['uid']];
}
//按时间检索
if (!empty($param['apply_time'])) {
$apply_time =explode('~', $param['apply_time']);
$map1[] = ['f.create_time', 'between', [strtotime(urldecode($apply_time[0])),strtotime(urldecode($apply_time[1]))]];
$map2[] = ['f.create_time', 'between', [strtotime(urldecode($apply_time[0])),strtotime(urldecode($apply_time[1]))]];
}
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
if($status == 0){
$list = Db::name('Approve')
->field('f.*,a.name,d.title as department_name,t.title as flow_type')
->alias('f')
->join('Admin a', 'a.id = f.admin_id', 'left')
->join('Department d', 'd.id = f.department_id', 'left')
->join('FlowType t', 't.id = f.type', 'left')
->whereOr([$map1,$map2])
->order('f.id desc')
->group('f.id')
->paginate(['list_rows' => $rows, 'query' => $param])
->each(function($item, $key){
$item['create_time'] = date('Y-m-d H:i', $item['create_time']);
$item['check_user'] = '-';
if($item['check_status']<2 && !empty($item['check_admin_ids'])){
$check_user = Db::name('Admin')->where('id','in',$item['check_admin_ids'])->column('name');
$item['check_user'] = implode(',',$check_user);
}
return $item;
});
}
if($status == 1){
$list = Db::name('Approve')
->field('f.*,a.name,d.title as department_name,t.title as flow_type')
->alias('f')
->join('Admin a', 'a.id = f.admin_id', 'left')
->join('Department d', 'd.id = f.department_id', 'left')
->join('FlowType t', 't.id = f.type', 'left')
->where($map1)
->order('f.id desc')
->group('f.id')
->paginate(['list_rows' => $rows, 'query' => $param])
->each(function($item, $key){
$item['create_time'] = date('Y-m-d H:i', $item['create_time']);
$item['check_user'] = '-';
if($item['check_status']<2 && !empty($item['check_admin_ids'])){
$check_user = Db::name('Admin')->where('id','in',$item['check_admin_ids'])->column('name');
$item['check_user'] = implode(',',$check_user);
}
return $item;
});
}
if($status == 2){
$list = Db::name('Approve')
->field('f.*,a.name,d.title as department_name,t.title as flow_type')
->alias('f')
->join('Admin a', 'a.id = f.admin_id', 'left')
->join('Department d', 'd.id = f.department_id', 'left')
->join('FlowType t', 't.id = f.type', 'left')
->where($map2)
->order('f.id desc')
->group('f.id')
->paginate(['list_rows' => $rows, 'query' => $param])
->each(function($item, $key){
$item['create_time'] = date('Y-m-d H:i', $item['create_time']);
$item['check_user'] = '-';
if($item['check_status']<2 && !empty($item['check_admin_ids'])){
$check_user = Db::name('Admin')->where('id','in',$item['check_admin_ids'])->column('name');
$item['check_user'] = implode(',',$check_user);
}
return $item;
});
}
$this->apiSuccess('获取成功', $list);
}
//抄送给我的审批记录
public function copy()
{
$this->checkAuth();
$this->uid = JWT_UID;
$param = get_params();
$user_id = $this->uid;
//查询条件
$map = [];
$map[] = ['f.check_status', '=', 2];
$map[] = ['', 'exp', Db::raw("FIND_IN_SET('{$user_id}',f.copy_uids)")];
if (!empty($param['type'])) {
$map[] = ['f.type', '=', $param['type']];
}
if (!empty($param['uid'])) {
$map[] = ['f.admin_id', '=', $param['uid']];
}
//按时间检索
if (!empty($param['apply_time'])) {
$apply_time =explode('~', $param['apply_time']);
$map[] = ['f.create_time', 'between', [strtotime(urldecode($apply_time[0])),strtotime(urldecode($apply_time[1]))]];
}
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
$list = Db::name('Approve')
->field('f.*,a.name,d.title as department_name,t.title as flow_type')
->alias('f')
->join('Admin a', 'a.id = f.admin_id', 'left')
->join('Department d', 'd.id = f.department_id', 'left')
->join('FlowType t', 't.id = f.type', 'left')
->where($map)
->order('f.id desc')
->group('f.id')
->paginate(['list_rows' => $rows, 'query' => $param])
->each(function($item, $key){
$item['create_time'] = date('Y-m-d H:i', $item['create_time']);
$item['check_user'] = '-';
if($item['check_status']<2 && !empty($item['check_admin_ids'])){
$check_user = Db::name('Admin')->where('id','in',$item['check_admin_ids'])->column('name');
$item['check_user'] = implode(',',$check_user);
}
return $item;
});
$this->apiSuccess('获取成功', $list);
}
}