修改审批流程模块儿
This commit is contained in:
@@ -166,7 +166,6 @@ class PurchaseOrdersService
|
||||
case 'index':
|
||||
$config['order']['id'] = 'desc';
|
||||
break;
|
||||
case 'show':
|
||||
case 'update':
|
||||
$config['where']['id'] = $p['id'] ?? 0;
|
||||
break;
|
||||
@@ -214,13 +213,15 @@ class PurchaseOrdersService
|
||||
*/
|
||||
protected function afterServiceStore($res)
|
||||
{
|
||||
if ($res->status == 1) {
|
||||
$this->startApproval($res, ['resubmitted'=>0]);
|
||||
}
|
||||
// if ($res->status == 1) {
|
||||
// $this->startApproval($res, ['resubmitted'=>0]);
|
||||
// }
|
||||
|
||||
$this->startApproval($res, ['resubmitted'=>0]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function startApproval($item, $formData)
|
||||
public function startApproval($item)
|
||||
{
|
||||
$appro = new \app\common\utils\approval\service\ApprovalFlowService();
|
||||
$appro->start('purchase_orders', 'purchase_orders', $item->id, ['resubmitted'=>0], $item->buyer_id);
|
||||
@@ -229,20 +230,45 @@ class PurchaseOrdersService
|
||||
|
||||
public function serviceResubmit(Request $request, array $data = [])
|
||||
{
|
||||
$info = $this->logicShow($this->buildQueryConfig($request, 'show'));
|
||||
if ($info->status == 3) {
|
||||
$instance = \app\common\model\ApprovalInstances::where('biz_id', $info->id)->where('flow_type', 'purchase_orders')->first();
|
||||
if ( $instance === null) {
|
||||
new BusinessException('未找到审批实例');
|
||||
}
|
||||
// 审批服务
|
||||
$appro = new \app\common\utils\approval\service\ApprovalFlowService();
|
||||
// 重新提交
|
||||
$appro->resubmit($instance->id, $instance->initiator_id, ['resubmitted'=>1], $data['remark']);
|
||||
// 添加到讨论
|
||||
$appro->postDiscussion($instance->id, $instance->initiator_id, $data['remark'], true, [], 'name');
|
||||
return true;
|
||||
$p = $request->all();
|
||||
$config = [];
|
||||
$config['model'] = $this->modelClass;
|
||||
$config['where']['id'] = $p['id'];
|
||||
$config['where']['buyer_id'] = $request->user->uid;
|
||||
$info = $this->logicShow($config);
|
||||
if ($info === null) {
|
||||
throw new BusinessException('未找到采购单');
|
||||
}
|
||||
return false;
|
||||
if ($info->status != 3) {
|
||||
throw new BusinessException('该状态不能重新提交');
|
||||
}
|
||||
$instance = \app\common\model\ApprovalInstances::where('biz_id', $info->id)->where('flow_type', 'purchase_orders')->first();
|
||||
if ( $instance === null) {
|
||||
throw new BusinessException('未找到审批实例');
|
||||
}
|
||||
// 审批服务
|
||||
$appro = new \app\common\utils\approval\service\ApprovalFlowService();
|
||||
// 重新提交
|
||||
$result = $appro->resubmit($instance->id, $instance->initiator_id, ['resubmitted'=>1], $data['remark']);
|
||||
// 添加到讨论
|
||||
if (!empty($data['remark'])) {
|
||||
$appro->postDiscussion($instance->id, $instance->initiator_id, $data['remark'], false, [], 'name');
|
||||
}
|
||||
|
||||
$info->status = 1;
|
||||
$info->save();
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function updateStatus(array $data = [])
|
||||
{
|
||||
|
||||
$info = PurchaseOrders::where('id', $data['id'])->first();
|
||||
if ($info === null) {
|
||||
throw new BusinessException('未找到采购单');
|
||||
}
|
||||
$info->status = $data['status'];
|
||||
return $info->save();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user