From e610ef7e740d10e1b4b18dc891f8343d86ab05d9 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Wed, 1 Nov 2023 18:36:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AE=A1=E6=89=B9=E8=A1=A8?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/OaApprove.php | 180 +++++++++++++++---------------- 1 file changed, 86 insertions(+), 94 deletions(-) diff --git a/app/api/controller/OaApprove.php b/app/api/controller/OaApprove.php index 8338dc2..e551b81 100644 --- a/app/api/controller/OaApprove.php +++ b/app/api/controller/OaApprove.php @@ -46,103 +46,16 @@ class OaApprove extends ApiController $loginAdmin = Db::name('Admin')->where(['id' => $this->uid])->find(); $this->did = $loginAdmin['did']; $param = get_params(); - $id = isset($param['id']) ? $param['id'] : 0; $type = isset($param['type']) ? $param['type'] : 0; - if($id > 0){ - $detail = Db::name('Approve')->where('id',$id)->find(); - $detail['start_time_a'] = date('Y-m-d',$detail['start_time']); - $detail['start_time_b'] = date('H:i',$detail['start_time']); - $detail['end_time_a'] = date('Y-m-d',$detail['end_time']); - $detail['end_time_b'] = date('H:i',$detail['end_time']); - $detail['detail_time'] = date('Y-m-d',$detail['detail_time']); - - $detail['days'] = floor($detail['duration']*10/80); - $detail['hours'] = (($detail['duration']*10)%80)/10; - $type = $detail['type']; - if($detail['file_ids'] !=''){ - $fileArray = Db::name('File')->where('id','in',$detail['file_ids'])->select(); - $detail['fileArray'] = $fileArray; - } + $flowType = Db::name('FlowType')->where('id', $type)->find(); + if (empty($flowType)) { + $this->apiError("审批流程不存在"); } - - // * 动态表单展示 - $flows = get_cate_department_flows($type, $this->did); - $flowMap = []; - foreach ($flows as $item) { - $flowMap[$item['id']] = $item['name']; - } - //获取审批字段 - $field = [ - 'detail_type' => [ - 'title' => '请假类型', - 'type' => 'select', - 'item' => [ - 1 => '事假', - 2 => '年假', - 3 => '调休假', - 4 => '病假', - 5 => '婚假', - 6 => '丧假', - 7 => '产假', - 8 => '陪产假', - 9 => '其他', - ], - ], - 'start_time' => [ - 'title' => '开始时间', - 'type' => 'input', - 'item' => (object)[] - ], - 'end_time' => [ - 'title' => '结束时间', - 'type' => 'input', - 'item' => (object)[] - ], - 'duration' => [ - 'title' => '请假工时', - 'type' => 'input', - 'item' => (object)[] - ], - 'content' => [ - 'title' => '请假事由', - 'type' => 'textarea', - 'item' => (object)[] - ], - 'file_ids' => [ - 'title' => '附件', - 'type' => 'input', - 'item' => (object)[] - ], - 'flow_id' => [ - 'title' => '审批流程', - 'type' => 'select', - 'item' => $flowMap - ], - 'check_admin_ids' => [ - 'title' => '审核人ID', - 'type' => 'select', - 'item' => (object)[] - ], - 'check_admin_name' => [ - 'title' => '审核人', - 'type' => 'select', - 'item' => (object)[] - ], - 'copy_uids' => [ - 'title' => '抄送人ID', - 'type' => 'select', - 'item' => (object)[] - ], - 'copy_names' => [ - 'title' => '抄送人', - 'type' => 'select', - 'item' => (object)[] - ], - ]; - $moban = Db::name('FlowType')->where('id',$type)->value('name'); + $field = $this->getFlowField($type, $this->did); $this->apiSuccess('获取成功', [ - 'type' => $type, - 'moban' => $moban, + 'type' => $type, + 'title' => $flowType['title'], + 'name' => $flowType['name'], 'field' => $field ]); } @@ -919,4 +832,83 @@ class OaApprove extends ApiController $this->apiSuccess('获取成功', $list); } + private function getFlowField($type, $did) + { + // * 动态表单展示 + $flows = get_cate_department_flows($type, $did); + $flowMap = []; + foreach ($flows as $item) { + $flowMap[$item['id']] = $item['name']; + } + //获取审批字段 + $field = [ + 'detail_type' => [ + 'title' => '请假类型', + 'type' => 'select', + 'item' => [ + 1 => '事假', + 2 => '年假', + 3 => '调休假', + 4 => '病假', + 5 => '婚假', + 6 => '丧假', + 7 => '产假', + 8 => '陪产假', + 9 => '其他', + ], + ], + 'start_time' => [ + 'title' => '开始时间', + 'type' => 'input', + 'item' => (object)[] + ], + 'end_time' => [ + 'title' => '结束时间', + 'type' => 'input', + 'item' => (object)[] + ], + 'duration' => [ + 'title' => '请假工时', + 'type' => 'input', + 'item' => (object)[] + ], + 'content' => [ + 'title' => '请假事由', + 'type' => 'textarea', + 'item' => (object)[] + ], + 'file_ids' => [ + 'title' => '附件', + 'type' => 'input', + 'item' => (object)[] + ], + 'flow_id' => [ + 'title' => '审批流程', + 'type' => 'select', + 'item' => $flowMap + ], + 'check_admin_ids' => [ + 'title' => '审核人ID', + 'type' => 'select', + 'item' => (object)[] + ], + 'check_admin_name' => [ + 'title' => '审核人', + 'type' => 'select', + 'item' => (object)[] + ], + 'copy_uids' => [ + 'title' => '抄送人ID', + 'type' => 'select', + 'item' => (object)[] + ], + 'copy_names' => [ + 'title' => '抄送人', + 'type' => 'select', + 'item' => (object)[] + ], + ]; + return $field; + } + }