查询当前人是否已审核
This commit is contained in:
@@ -78,7 +78,7 @@ class InvRequisitionController extends BaseController
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data, $applicant_id,$uid)
|
||||
protected function indexFormat($data, $applicant_id, $uid)
|
||||
{
|
||||
if (isset($data['id'])){
|
||||
//$data['approve'] = InvRequisitionApprove::where('requisition_id', $data['id'])->get();
|
||||
@@ -100,7 +100,7 @@ class InvRequisitionController extends BaseController
|
||||
$approve = InvRequisitionApprove::where('requisition_id', $data['id'])
|
||||
->where('approver_id', $uid)
|
||||
->first();
|
||||
$data['action'] = $approve['action']??0;
|
||||
$data['action'] = $approve['action']??3;//查询人审核状态:0待审核 1通过 2驳回 3非审核人
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -193,16 +193,15 @@ class InvRequisitionApproveService
|
||||
'approved_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
if(count($steps) == $pass){
|
||||
Db::table('inv_requisition')->where('id', $requisition->id)->update(['status'=>12]);
|
||||
// $requisition->status = 13;
|
||||
// $requisition->save();
|
||||
return ['status' => 'complete', 'msg' => '拒绝'];
|
||||
}
|
||||
//if(count($steps) == $pass){
|
||||
Db::table('inv_requisition')->where('id', $requisition->id)->update(['status'=>13]);
|
||||
return ['status' => 'complete', 'msg' => '拒绝'];
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
// 4) 通过 => 进入下一步或结束
|
||||
Db::table('inv_requisition')->where('id', $requisitionId)->update(['status'=>11]);
|
||||
$requisitionItem = Db::table('inv_requisition_item')->where('requisition_id', $requisitionId)->first();
|
||||
$item_id = Db::table('inv_item')->where('id', $requisitionItem->item_id)->first();
|
||||
$formData = ['manage_user_id'=>$item_id->manage_user_id];
|
||||
@@ -225,6 +224,7 @@ class InvRequisitionApproveService
|
||||
// }
|
||||
// $approverIds = [$invItem->manage_user_id];
|
||||
// }
|
||||
|
||||
$approver = User::where('id', array_pop($approverIds))->first();
|
||||
Db::table('inv_requisition_approve')->insertGetId([
|
||||
'requisition_id' => $requisitionId, //申请单ID
|
||||
@@ -236,7 +236,7 @@ class InvRequisitionApproveService
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);;
|
||||
|
||||
return ['status' => 'complete', 'msg' => '已通过'];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -54,9 +54,10 @@ class InvRequisitionController extends BaseController
|
||||
public function index(Request $request)
|
||||
{
|
||||
try {
|
||||
$applicant_id = $request->get('applicant_id');
|
||||
$raw = $this->service->serviceList($request);
|
||||
$uid = $request->user->uid;
|
||||
$data = $this->formatindex($raw,$uid);
|
||||
$data = $this->formatindex($raw,$applicant_id,$uid);
|
||||
// $data = $this->transformData($raw, method_exists($this, 'indexFormat')
|
||||
// ? [$this, 'indexFormat']
|
||||
// : null);
|
||||
@@ -66,9 +67,9 @@ class InvRequisitionController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
public function formatindex($p,$uid){
|
||||
public function formatindex($p,$applicant_id,$uid){
|
||||
$records = $p->getCollection()
|
||||
->map(fn($item) => $this->indexFormat($item, $uid))
|
||||
->map(fn($item) => $this->indexFormat($item, $applicant_id,$uid))
|
||||
->toArray();
|
||||
|
||||
return [
|
||||
@@ -85,7 +86,7 @@ class InvRequisitionController extends BaseController
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data, $uid)
|
||||
protected function indexFormat($data, $applicant_id, $uid)
|
||||
{
|
||||
if(isset($data['id']) && is_object($data)){
|
||||
$data = $data->toArray();
|
||||
@@ -100,12 +101,13 @@ class InvRequisitionController extends BaseController
|
||||
}
|
||||
if (isset($data['id'])){
|
||||
$data['item'] = InvRequisitionItem::where('requisition_id', $data['id'])->get();
|
||||
foreach ($data['item'] as $key => $item){
|
||||
$corpId = InvItem::where('id', $item->item_id)->value('company_id');
|
||||
$item['company_name'] = Corp::where('id', $corpId)->value('name');
|
||||
$aprove = InvRequisitionApprove::where('requisition_id', $data['id'])->where('approver_id', $uid)->orderBy('id','desc')->first();
|
||||
$item['approval_action'] = $aprove?$aprove['action']:3; //查询人审核状态:0待审核 1通过 2驳回 3非审核人
|
||||
}
|
||||
}
|
||||
|
||||
if($applicant_id != 'self' && isset($data['id'])){ //不是查询自己数据时查询是否已审核
|
||||
$approve = InvRequisitionApprove::where('requisition_id', $data['id'])
|
||||
->where('approver_id', $uid)
|
||||
->first();
|
||||
$data['action'] = $approve['action']??3;//查询人审核状态:0待审核 1通过 2驳回 3非审核人
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user