|
@@ -2,7 +2,6 @@
|
|
|
|
|
|
namespace app\common\model;
|
|
|
|
|
|
-use app\common\constant\CommonConstant;
|
|
|
use think\Model;
|
|
|
|
|
|
/**
|
|
@@ -14,91 +13,94 @@ class ApproveFlow extends Model
|
|
|
/**
|
|
|
* 获取流程条件
|
|
|
*
|
|
|
- * @param $module
|
|
|
- * @param $type
|
|
|
- * @param $is_special
|
|
|
- * @param $userid
|
|
|
+ * @param integer $module 模块类型
|
|
|
+ * @param integer $type 流程类型
|
|
|
+ * @param integer $is_special 是否特殊:0=通用,1=特殊
|
|
|
+ * @param string $userid 特殊的用户userid
|
|
|
**/
|
|
|
- public static function get_where($module,$type,$is_special,$userid = ''){
|
|
|
+ public static function get_where($module, $type, $is_special, $userid = '')
|
|
|
+ {
|
|
|
return self::where('module', $module)
|
|
|
->where('type', $type)
|
|
|
->where('is_special', $is_special)
|
|
|
- ->when($userid,function ($query) use ($userid){
|
|
|
+ ->when($userid, function ($query) use ($userid) {
|
|
|
$query->where('special_user_id', $userid);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
- protected $module_desc = [
|
|
|
- '1'=> '请假',
|
|
|
- '2'=> '用车',
|
|
|
- '3'=> '出差',
|
|
|
- '4'=> '呈批',
|
|
|
- '5'=> '维修',
|
|
|
- '6'=> '学校文件',
|
|
|
- '7'=> '合同',
|
|
|
+ protected $module_desc = [
|
|
|
+ '1' => '请假',
|
|
|
+ '2' => '用车',
|
|
|
+ '3' => '出差',
|
|
|
+ '4' => '呈批',
|
|
|
+ '5' => '维修',
|
|
|
+ '6' => '学校文件',
|
|
|
+ '7' => '合同',
|
|
|
];
|
|
|
+
|
|
|
// 获取审批人
|
|
|
- public static function getApproveUser($module,$user_id){
|
|
|
- $check_flow = ApproveFlow::where('user_id',$user_id)->where('type',1)->where('module',$module)->find();
|
|
|
+ public static function getApproveUser($module, $user_id)
|
|
|
+ {
|
|
|
+ $check_flow = ApproveFlow::where('user_id', $user_id)->where('type', 1)->where('module', $module)->find();
|
|
|
$where = [];
|
|
|
- $where[] = ['l.type','=',1];
|
|
|
- $where[] = ['l.module','=',$module];
|
|
|
- if($check_flow)$where[] = ['l.sort','>',$check_flow->sort];
|
|
|
+ $where[] = ['l.type', '=', 1];
|
|
|
+ $where[] = ['l.module', '=', $module];
|
|
|
+ if ($check_flow) $where[] = ['l.sort', '>', $check_flow->sort];
|
|
|
$list = static::field('l.user_id,u.name user_name,u.headimg')->alias('l')
|
|
|
->where($where)
|
|
|
->order('l.sort asc')
|
|
|
- ->leftJoin('StoreMember u','u.id = l.user_id')
|
|
|
+ ->leftJoin('StoreMember u', 'u.id = l.user_id')
|
|
|
->select()->toArray();
|
|
|
return $list;
|
|
|
}
|
|
|
|
|
|
// 获取抄送人
|
|
|
- public static function getCopyTo($module,$user_id)
|
|
|
+ public static function getCopyTo($module, $user_id)
|
|
|
{
|
|
|
- $check_flow = ApproveFlow::where('user_id',$user_id)->where('type',2)->where('module',$module)->find();
|
|
|
+ $check_flow = ApproveFlow::where('user_id', $user_id)->where('type', 2)->where('module', $module)->find();
|
|
|
$where = [];
|
|
|
- $where[] = ['l.type','=',2];
|
|
|
- $where[] = ['l.module','=',$module];
|
|
|
- if($check_flow)$where[] = ['l.sort','>',$check_flow->sort];
|
|
|
+ $where[] = ['l.type', '=', 2];
|
|
|
+ $where[] = ['l.module', '=', $module];
|
|
|
+ if ($check_flow) $where[] = ['l.sort', '>', $check_flow->sort];
|
|
|
$list = ApproveFlow::field('l.user_id,u.name user_name,u.headimg')
|
|
|
->alias('l')
|
|
|
->where($where)
|
|
|
->order('l.sort asc')
|
|
|
- ->leftJoin('StoreMember u','u.id = l.user_id')
|
|
|
+ ->leftJoin('StoreMember u', 'u.id = l.user_id')
|
|
|
->select()->toArray();
|
|
|
- return $list;
|
|
|
+ return $list;
|
|
|
}
|
|
|
|
|
|
|
|
|
// 获取审批流程数据
|
|
|
- public static function getApproveData($flow_user,$copy_user,$info_id)
|
|
|
+ public static function getApproveData($flow_user, $copy_user, $info_id)
|
|
|
{
|
|
|
$flow_data = [];// 审批流程
|
|
|
$flow_num = 0;
|
|
|
// 审批人
|
|
|
- foreach (explode(',',$flow_user) as $fk=>$fv) {
|
|
|
- if(!$fv) continue;
|
|
|
+ foreach (explode(',', $flow_user) as $fk => $fv) {
|
|
|
+ if (!$fv) continue;
|
|
|
$flow_num++;
|
|
|
$flow_data[] = [
|
|
|
'info_id' => $info_id,
|
|
|
'approve_user' => $fv,
|
|
|
- 'flow' =>$flow_num,
|
|
|
- 'create_at'=>date('Y-m-d H:i:s'),
|
|
|
- 'start_time'=> $flow_num == 1 ? date('Y-m-d H:i:s'):null,
|
|
|
- 'status'=> $flow_num == 1 ? 1 : 0,
|
|
|
+ 'flow' => $flow_num,
|
|
|
+ 'create_at' => date('Y-m-d H:i:s'),
|
|
|
+ 'start_time' => $flow_num == 1 ? date('Y-m-d H:i:s') : null,
|
|
|
+ 'status' => $flow_num == 1 ? 1 : 0,
|
|
|
];
|
|
|
}
|
|
|
// 抄送人
|
|
|
- foreach (explode(',',$copy_user) as $ck=>$cv) {
|
|
|
- if(!$cv) continue;
|
|
|
+ foreach (explode(',', $copy_user) as $ck => $cv) {
|
|
|
+ if (!$cv) continue;
|
|
|
$flow_data[] = [
|
|
|
'info_id' => $info_id,
|
|
|
'approve_user' => $cv,
|
|
|
- 'approve_type' =>2
|
|
|
+ 'approve_type' => 2
|
|
|
];
|
|
|
}
|
|
|
- return ['flow_data'=>$flow_data,'flow_num'=>$flow_num];
|
|
|
+ return ['flow_data' => $flow_data, 'flow_num' => $flow_num];
|
|
|
}
|
|
|
|
|
|
|