wupengfei 2 years ago
parent
commit
c140abaf0e
2 changed files with 13 additions and 14 deletions
  1. 2 11
      application/api/controller/Evection.php
  2. 11 3
      application/common/model/ApproveFlow.php

+ 2 - 11
application/api/controller/Evection.php

@@ -6,6 +6,7 @@ use app\common\model\LeaveApprove;
 use app\common\model\ApproveFlow;
 use app\common\model\EvectionInfo;
 use app\common\service\ApproveService;
+use think\App;
 use think\Db;
 use app\common\model\User;
 /**
@@ -34,17 +35,7 @@ class Evection extends Base
      */
     public function getApproveFlow()
     {
-        $check_flow = ApproveFlow::where('user_id',$this->user_id)->where('type',1)->where('module',3)->find();
-        $where = [];
-        $where[] = ['l.type','=',1];
-        $where[] = ['l.module','=',3];
-        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')
-            ->select()->toArray();
+        $list = ApproveFlow::getApproveUser(3,$this->user_id);
         $this->success('ok',['list'=>$list]);
     }
 

+ 11 - 3
application/common/model/ApproveFlow.php

@@ -5,10 +5,18 @@ use think\Model;
 class ApproveFlow extends Model
 {
     // 获取审批人
-    public static function getApproveUser($module){
-        return static::where('type',1)->where('module',$module)
-            ->order('sort asc ,id asc')
+    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];
+        $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')
             ->select()->toArray();
+        return $list;
     }
 
     // 获取抄送人