Merge branch 'feature/inv' into develop
This commit is contained in:
@@ -46,23 +46,38 @@ class InvRequisitionController extends BaseController
|
||||
public function index(Request $request)
|
||||
{
|
||||
try {
|
||||
$applicant_id = $request->get('applicant_id');
|
||||
$raw = $this->service->serviceList($request);
|
||||
$data = $this->transformData($raw, method_exists($this, 'indexFormat')
|
||||
? [$this, 'indexFormat']
|
||||
: null);
|
||||
$data = $this->formatindex($raw,$applicant_id);
|
||||
// $data = $this->transformData($raw, method_exists($this, 'indexFormat')
|
||||
// ? [$this, 'indexFormat']
|
||||
// : null);
|
||||
return $this->success($data);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function formatindex($p,$applicant_id){
|
||||
$records = $p->getCollection()
|
||||
->map(fn($item) => $this->indexFormat($item, $applicant_id))
|
||||
->toArray();
|
||||
|
||||
return [
|
||||
'records' => $records,
|
||||
'total' => $p->total(),
|
||||
'current' => $p->currentPage(),
|
||||
'size' => $p->perPage(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
protected function indexFormat($data, $applicant_id)
|
||||
{
|
||||
// if (isset($data['id'])){
|
||||
// $data['approve'] = InvRequisitionApprove::where('requisition_id', $data['id'])->get();
|
||||
@@ -74,6 +89,13 @@ class InvRequisitionController extends BaseController
|
||||
if (isset($data['id'])){
|
||||
$data['item'] = InvRequisitionItem::where('requisition_id', $data['id'])->get();
|
||||
}
|
||||
|
||||
if($applicant_id != 'self' && isset($data['id'])){ //不是查询自己数据时查询是否已审核
|
||||
$approve = InvRequisitionApprove::where('requisition_id', $data['id'])
|
||||
->where('applicant_id', $applicant_id)
|
||||
->first();
|
||||
$data['action'] = $approve['action']??0;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -98,6 +120,7 @@ class InvRequisitionController extends BaseController
|
||||
$value['updated_at'] = is_int($value['updated_at'])?$value['updated_at']:strtotime($value['updated_at']);
|
||||
$data['approve'][$key]['updated_at'] = date('Y-m-d H:i:s', $value['updated_at']);
|
||||
}
|
||||
$data['approve'][$key]['action_at'] = date('Y-m-d H:i:s', $data['approve'][$key]['action_at']);
|
||||
$approve_id = $value['id'];
|
||||
}
|
||||
$data['approve_id'] = $approve_id;
|
||||
|
||||
@@ -183,7 +183,7 @@ class InvRequisitionItemReturnService
|
||||
}
|
||||
$this->processRequisitionItemReturnAttachment($res, $attachment);
|
||||
InvRequisition::where('id',$request->post('requisition_id'))->update(
|
||||
['status' => 14] //审批状态:10默认、11审批中、12已审批(待归还)、13拒绝、14申请归还、15归还审核中、16部分归还、17已全部归还、18已拒绝
|
||||
['status' => 14] //审批状态:10默认、11审批中、12已审批(待归还)、13拒绝、14申请归还、15归还审核中、16部分归还、17已全部归还、18已拒绝、19已审批(无需归还)
|
||||
);
|
||||
$this->postProcess('Store', $created);
|
||||
return $res;
|
||||
|
||||
Reference in New Issue
Block a user