|
@@ -37,7 +37,9 @@ class ApproveInfoService
|
|
|
$info = ApproveInfo::field('user_id,is_deleted', true)
|
|
|
->where('user_id', $userid)
|
|
|
->where('is_deleted', CommonConstant::IS_DELETED_0)
|
|
|
- ->with(['moduleInfo'])
|
|
|
+ ->with([
|
|
|
+ 'moduleInfo'
|
|
|
+ ])
|
|
|
->find($id);
|
|
|
if (!$info) {
|
|
|
except('申请记录不存在或已删除');
|
|
@@ -413,15 +415,19 @@ class ApproveInfoService
|
|
|
|
|
|
$data = [];
|
|
|
foreach ($params as $value) {
|
|
|
- $data[] = [
|
|
|
- 'info_id' => $info_id,
|
|
|
- 'is_who' => $value['is_who'],
|
|
|
- 'user_id' => isset($value['user_id']) ? $value['user_id'] : '',
|
|
|
- 'name' => $value['name'],
|
|
|
- 'desc' => isset($value['desc']) ? $value['desc'] : '',
|
|
|
- ];
|
|
|
+ if (isset($value['name']) && !empty($value['name'])) {
|
|
|
+ $data[] = [
|
|
|
+ 'info_id' => $info_id,
|
|
|
+ 'is_who' => $value['is_who'],
|
|
|
+ 'user_id' => isset($value['user_id']) ? $value['user_id'] : '',
|
|
|
+ 'name' => $value['name'],
|
|
|
+ 'desc' => isset($value['desc']) ? $value['desc'] : '',
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($data) {
|
|
|
+ ApproveEvectionPeerUser::insertAll($data);
|
|
|
}
|
|
|
- ApproveEvectionPeerUser::insertAll($data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -562,7 +568,9 @@ class ApproveInfoService
|
|
|
$info['department_data'] = $department_data;
|
|
|
}
|
|
|
} else {
|
|
|
- $info->with(['moduleInfo']);
|
|
|
+ $info->with([
|
|
|
+ 'moduleInfo'
|
|
|
+ ]);
|
|
|
$info = $info->find($id);
|
|
|
}
|
|
|
$info = self::get_item($info, $type);
|
|
@@ -571,20 +579,45 @@ class ApproveInfoService
|
|
|
|
|
|
public static function get_with($list, $module, $status)
|
|
|
{
|
|
|
+ $field = 'id,info_id,status,approve_user';
|
|
|
switch ($module) {
|
|
|
case CommonConstant::MODULE_1:
|
|
|
- case CommonConstant::MODULE_2:
|
|
|
- case CommonConstant::MODULE_3:
|
|
|
- case CommonConstant::MODULE_4:
|
|
|
if (in_array($status, [CommonConstant::STATUS_2, CommonConstant::STATUS_4])) {
|
|
|
// 审批中或审批驳回 才关联 审批人信息
|
|
|
$list = $list->with([
|
|
|
- 'approveOne' => function ($query) use ($status) {
|
|
|
- $query->field('id,info_id,status,approve_user')
|
|
|
+ 'approveOne' => function ($query) use ($status, $field) {
|
|
|
+ $query->field($field)
|
|
|
->where('status', $status)
|
|
|
->with(['user' => function ($query) {
|
|
|
$query->field('userid,name');
|
|
|
}]);
|
|
|
+ },
|
|
|
+ 'applyGoods' => function ($query) {
|
|
|
+ $query->field('id,info_id,goods_name');
|
|
|
+ },
|
|
|
+ ]);
|
|
|
+ } else {
|
|
|
+ $list = $list->with([
|
|
|
+ 'applyGoods' => function ($query) {
|
|
|
+ $query->field('id,info_id,goods_name');
|
|
|
+ },
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case CommonConstant::MODULE_2:
|
|
|
+ case CommonConstant::MODULE_3:
|
|
|
+ case CommonConstant::MODULE_4:
|
|
|
+ if (in_array($status, [CommonConstant::STATUS_2, CommonConstant::STATUS_4])) {
|
|
|
+ // 审批中或审批驳回 才关联 审批人信息
|
|
|
+ $list = $list->with([
|
|
|
+ 'approveOne' => function ($query) use ($status, $field) {
|
|
|
+ $query->field($field)
|
|
|
+ ->where('status', $status)
|
|
|
+ ->with([
|
|
|
+ 'user' => function ($query) {
|
|
|
+ $query->field('userid,name');
|
|
|
+ }
|
|
|
+ ]);
|
|
|
}
|
|
|
]);
|
|
|
}
|
|
@@ -593,20 +626,22 @@ class ApproveInfoService
|
|
|
if (in_array($status, [CommonConstant::STATUS_2, CommonConstant::STATUS_4])) {
|
|
|
// 审批中或审批驳回 才关联 审批人信息
|
|
|
$list = $list->with([
|
|
|
- 'approveOne' => function ($query) use ($status) {
|
|
|
- $query->field('id,info_id,status,approve_user')
|
|
|
+ 'approveOne' => function ($query) use ($status, $field) {
|
|
|
+ $query->field($field)
|
|
|
->where('status', $status)
|
|
|
- ->with(['user' => function ($query) {
|
|
|
- $query->field('userid,name');
|
|
|
- }]);
|
|
|
+ ->with([
|
|
|
+ 'user' => function ($query) {
|
|
|
+ $query->field('userid,name');
|
|
|
+ }
|
|
|
+ ]);
|
|
|
},
|
|
|
- 'peer_user' => function ($query) {
|
|
|
+ 'peerUser' => function ($query) {
|
|
|
$query->field('id,info_id,name');
|
|
|
},
|
|
|
]);
|
|
|
} else {
|
|
|
$list = $list->with([
|
|
|
- 'peer_user' => function ($query) {
|
|
|
+ 'peerUser' => function ($query) {
|
|
|
$query->field('id,info_id,name');
|
|
|
},
|
|
|
]);
|
|
@@ -621,12 +656,14 @@ class ApproveInfoService
|
|
|
if (in_array($status, [CommonConstant::STATUS_2, CommonConstant::STATUS_4])) {
|
|
|
// 审批中或审批驳回 才关联 审批人信息
|
|
|
$list = $list->with([
|
|
|
- 'approveOne' => function ($query) use ($status) {
|
|
|
- $query->field('id,info_id,status,approve_user')
|
|
|
+ 'approveOne' => function ($query) use ($status, $field) {
|
|
|
+ $query->field($field)
|
|
|
->where('status', $status)
|
|
|
- ->with(['user' => function ($query) {
|
|
|
- $query->field('userid,name');
|
|
|
- }]);
|
|
|
+ ->with([
|
|
|
+ 'user' => function ($query) {
|
|
|
+ $query->field('userid,name');
|
|
|
+ }
|
|
|
+ ]);
|
|
|
}
|
|
|
]);
|
|
|
}
|
|
@@ -639,6 +676,13 @@ class ApproveInfoService
|
|
|
{
|
|
|
$module = $info['module'];
|
|
|
switch ($module) {
|
|
|
+ case CommonConstant::MODULE_1:
|
|
|
+ if ($type == 'detail') {
|
|
|
+ $info['applyGoods'] = $info->applyGoods()->field('id,info_id,goods_name,total_amount,goods_data')->select();
|
|
|
+ } else {
|
|
|
+ $info->applyGoods;
|
|
|
+ }
|
|
|
+ break;
|
|
|
case CommonConstant::MODULE_5:
|
|
|
if ($type == 'detail') {
|
|
|
$info['peer_user'] = $info->peerUser()->field('id,info_id,name')->select();
|