物品领用审核
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\InvItem;
|
||||
use app\common\validate\InvRequisitionValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\InvRequisition;
|
||||
@@ -91,6 +92,18 @@ class InvRequisitionService
|
||||
$data['leader_id'] = $user['user']['report_to'];
|
||||
$data['status'] = InvRequisition::STATUS_LEADER;
|
||||
|
||||
//查询物品管理人是否是一个
|
||||
if(count($data['items'])>=2){
|
||||
$manage_user = [];
|
||||
foreach ($data['items'] as $item) {
|
||||
$manage_user[] = InvItem::where('id',$item['item_id'])->value('manage_user_id');
|
||||
}
|
||||
$manage_user = array_unique($manage_user);
|
||||
if(count($manage_user)>1){
|
||||
throw new BusinessException("审批实例未找到");
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -113,13 +126,36 @@ class InvRequisitionService
|
||||
$this->processRequisitionItems($created, $data['items']);
|
||||
// 处理物品申请附件
|
||||
$this->processRequisitionAttachmentItems($created, $data['attachment']);
|
||||
return $this->postProcess('Store', $created);
|
||||
$res = $this->postProcess('Store', $created);
|
||||
|
||||
$manage_user_id = InvItem::where('id',$data['items']['item_id'])->value('manage_user_id');
|
||||
$approval = [
|
||||
'id' => $res['id'], //申请单id
|
||||
'applicant_id' => $res['applicant_id'], //申请人id
|
||||
'manage_user_id' => $manage_user_id,
|
||||
];
|
||||
$this->startApproval($approval);
|
||||
|
||||
return $res;
|
||||
});
|
||||
} catch (\Throwable $e) {
|
||||
throw new BusinessException("创建物品申请失败:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动审批
|
||||
*/
|
||||
public function startApproval($requisition)
|
||||
{
|
||||
// 启动审批
|
||||
$appro = new \app\common\utils\approval\service\ApprovalFlowService();
|
||||
$formData = [
|
||||
'manage_user_id' => $requisition['manage_user_id'],
|
||||
];
|
||||
$appro->start('inv_requisition', 'inv_requisition', $requisition['id'], $formData, $requisition['applicant_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新物品申请
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user