查询当前人是否已审核
This commit is contained in:
@@ -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