|
@@ -4,9 +4,9 @@ namespace app\common\service;
|
|
|
|
|
|
use app\common\constant\CommonConstant;
|
|
|
use app\common\model\Department;
|
|
|
-use app\common\model\EvectionApprove;
|
|
|
-use app\common\model\EvectionInfo;
|
|
|
-use app\common\model\EvectionPeerUser;
|
|
|
+use app\common\model\Approve;
|
|
|
+use app\common\model\ApproveInfo;
|
|
|
+use app\common\model\ApproveEvectionPeerUser;
|
|
|
use app\common\model\User;
|
|
|
use think\Exception;
|
|
|
|
|
@@ -29,7 +29,7 @@ class ApproveInfoService
|
|
|
$userid = $user['userid'];
|
|
|
// 编辑
|
|
|
if ($id > 0) {
|
|
|
- $info = EvectionInfo::field('user_id,is_deleted', true)
|
|
|
+ $info = ApproveInfo::field('user_id,is_deleted', true)
|
|
|
->where('user_id', $userid)
|
|
|
->where('is_deleted', CommonConstant::IS_DELETED_0)
|
|
|
->find($id);
|
|
@@ -69,50 +69,31 @@ class ApproveInfoService
|
|
|
$data = array_merge($data, $save_data);
|
|
|
$info->save($data);
|
|
|
|
|
|
+ // 编辑审批
|
|
|
+ self::create_approve($id, $approve_user, $copy_user,'create');
|
|
|
+
|
|
|
// 编辑同行人员
|
|
|
self::create_peer_user($id, $params['peer_user'],'update');
|
|
|
|
|
|
- // 编辑出差审批
|
|
|
- self::create_evection_approve($id, $approve_user, $copy_user,'create');
|
|
|
+
|
|
|
} else {
|
|
|
// 添加出差申请
|
|
|
- $info = EvectionInfo::create($data);
|
|
|
+ $info = ApproveInfo::create($data);
|
|
|
+
|
|
|
+ // 添加审批
|
|
|
+ self::create_approve($info->id, $approve_user, $copy_user);
|
|
|
|
|
|
// 添加同行人员
|
|
|
self::create_peer_user($info->id, $params['peer_user']);
|
|
|
|
|
|
- // 添加出差审批
|
|
|
- self::create_evection_approve($info->id, $approve_user, $copy_user);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- protected static function create_peer_user($info_id, $params,$type = 'create')
|
|
|
- {
|
|
|
- if (!$params) {
|
|
|
- return true;
|
|
|
- }
|
|
|
|
|
|
- if($type == 'update'){
|
|
|
- EvectionPeerUser::where('info_id', $info_id)->delete();
|
|
|
- }
|
|
|
-
|
|
|
- $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'] : '',
|
|
|
- ];
|
|
|
}
|
|
|
- EvectionPeerUser::insertAll($data);
|
|
|
}
|
|
|
|
|
|
- protected static function create_evection_approve($info_id, $approve_user, $copy_user,$type = 'create')
|
|
|
+ protected static function create_approve($info_id, $approve_user, $copy_user,$type = 'create')
|
|
|
{
|
|
|
if($type == 'update'){
|
|
|
- EvectionApprove::where('info_id', $info_id)->delete();
|
|
|
+ Approve::where('info_id', $info_id)->delete();
|
|
|
}
|
|
|
|
|
|
$data = [];
|
|
@@ -143,9 +124,33 @@ class ApproveInfoService
|
|
|
'status' => CommonConstant::STATUS_0,
|
|
|
];
|
|
|
}
|
|
|
- EvectionApprove::insertAll($data);
|
|
|
+ Approve::insertAll($data);
|
|
|
}
|
|
|
|
|
|
+ protected static function create_peer_user($info_id, $params,$type = 'create')
|
|
|
+ {
|
|
|
+ if (!$params) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if($type == 'update'){
|
|
|
+ ApproveEvectionPeerUser::where('info_id', $info_id)->delete();
|
|
|
+ }
|
|
|
+
|
|
|
+ $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'] : '',
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ ApproveEvectionPeerUser::insertAll($data);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 列表
|
|
|
*
|
|
@@ -158,7 +163,7 @@ class ApproveInfoService
|
|
|
public static function get_list($status, $search, $offset, $length, $user)
|
|
|
{
|
|
|
$userid = $user['userid'];
|
|
|
- $list = EvectionInfo::field('id,status,create_at,order_no,reason,start_time,end_time')
|
|
|
+ $list = ApproveInfo::field('id,status,create_at,order_no,reason,start_time,end_time')
|
|
|
->where('user_id', $userid)
|
|
|
->where('is_deleted', CommonConstant::IS_DELETED_0)
|
|
|
->when(array_key_exists($status, CommonConstant::get_status_list()), function ($query) use ($status) {
|
|
@@ -193,7 +198,7 @@ class ApproveInfoService
|
|
|
{
|
|
|
$userid = $user['userid'];
|
|
|
if($type == 'detail'){
|
|
|
- $info = EvectionInfo::field('user_id,is_deleted', true)
|
|
|
+ $info = ApproveInfo::field('user_id,is_deleted', true)
|
|
|
->where('user_id', $userid)
|
|
|
->where('is_deleted', CommonConstant::IS_DELETED_0)
|
|
|
->with(['peer_user' => function ($query) {
|
|
@@ -209,7 +214,7 @@ class ApproveInfoService
|
|
|
$info['department'] = Department::where('dept_id', 'in', $user['department'])->field('dept_id,name')->select();
|
|
|
}
|
|
|
} else{
|
|
|
- $info = EvectionInfo::field('user_id,is_deleted', true)
|
|
|
+ $info = ApproveInfo::field('user_id,is_deleted', true)
|
|
|
->where('user_id', $userid)
|
|
|
->where('is_deleted', CommonConstant::IS_DELETED_0)
|
|
|
->with(['peer_user'])
|
|
@@ -228,7 +233,7 @@ class ApproveInfoService
|
|
|
public static function make($id, $user,$type)
|
|
|
{
|
|
|
$userid = $user['userid'];
|
|
|
- $info = EvectionInfo::field('id,status')
|
|
|
+ $info = ApproveInfo::field('id,status')
|
|
|
->where('user_id', $userid)
|
|
|
->where('is_deleted', CommonConstant::IS_DELETED_0)
|
|
|
->find($id);
|