物品领用

This commit is contained in:
2026-02-09 10:40:50 +08:00
parent 3d33a502d9
commit 25b79d6f63
7 changed files with 183 additions and 17 deletions
@@ -54,22 +54,37 @@ class InvRequisitionController extends BaseController
{
try {
$raw = $this->service->serviceList($request);
$data = $this->transformData($raw, method_exists($this, 'indexFormat')
? [$this, 'indexFormat']
: null);
$uid = $request->user->uid;
$data = $this->formatindex($raw,$uid);
// $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,$uid){
$records = $p->getCollection()
->map(fn($item) => $this->indexFormat($item, $uid))
->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, $uid)
{
if (isset($data['created_at']))
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
@@ -80,6 +95,8 @@ class InvRequisitionController extends BaseController
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非审核人
}
}
return $data;