Browse Source

项目管理中,项目列表接口新增部门名称筛选条件

wufeng 2 years ago
parent
commit
775875e91a
1 changed files with 25 additions and 14 deletions
  1. 25 14
      app/admin/controller/Project.php

+ 25 - 14
app/admin/controller/Project.php

@@ -293,54 +293,64 @@ class Project extends Base
     public function list(){
         $page =isset($this->post['page'])&&$this->post['page']!=="" ? intval($this->post['page']):1;
         $size =isset($this->post['size'])&&$this->post['size']!==""? intval($this->post['size']):10;
-        $where=[["is_del","=",0]];
+        $where=[["p.is_del","=",0]];
         $khNo = isset($this->post['khNo']) &&$this->post['khNo']!==""? trim($this->post['khNo']):"";
         if($khNo!==""){
-            $where[]=["khNo","=",$khNo];
+            $where[]=["p.khNo","=",$khNo];
         }
         $project_name = isset($this->post['project_name']) &&$this->post['project_name']!==""? trim($this->post['project_name']):"";
         if($project_name!==""){
-            $where[]=["project_name","like","%$project_name%"];
+            $where[]=["p.project_name","like","%$project_name%"];
         }
         $status = isset($this->post['status']) &&$this->post['status']!==""? intval($this->post['status']):"";
         if($status!==""){
-            $where[]=["status","=",$status];
+            $where[]=["p.status","=",$status];
         }
         $start = isset($this->post['start'])&&$this->post['start']!=="" ? $this->post['start']:"";
         if($start!==''){
-            $where[]=["addtime",">=",$start];
+            $where[]=["p.addtime",">=",$start];
         }
         $end = isset($this->post['end'])&&$this->post['end']!=="" ? $this->post['end']:"";
         if($end!==''){
-            $where[]=["addtime","<=",$end];
+            $where[]=["p.addtime","<=",$end];
         }
         $low = isset($this->post['low'])&&$this->post['low']!=="" ? floatval($this->post['low']):"";
         if($low!==''){
-            $where[]=["budget_total",">=",$low];
+            $where[]=["p.budget_total",">=",$low];
         }
         $up = isset($this->post['up'])&&$this->post['up']!=="" ? floatval($this->post['up']):"";
         if($up!==''){
-            $where[]=["budget_total","<=",$up];
+            $where[]=["p.budget_total","<=",$up];
         }
         $companyNo = isset($this->post['companyNo'])&&$this->post['companyNo']!=="" ? trim($this->post['companyNo']):"";
         if($companyNo!==''){
-            $where[]=["companyNo","like","%$companyNo%"];
+            $where[]=["p.companyNo","like","%$companyNo%"];
         }
         $platform_id = isset($this->post['platform_id'])&&$this->post['platform_id']!=="" ? intval($this->post['platform_id']):"";
         if($platform_id!==''){
-            $where[]=["platform_id","=",$platform_id];
+            $where[]=["p.platform_id","=",$platform_id];
         }
+        $company_name = isset($this->post['company_name'])&&$this->post['company_name']!=="" ? trim($this->post['company_name']):"";
+        if($company_name!=='') $where[] = ["p.createrid", 'in', get_company_item_user_by_name($company_name)];
+
         $role=$this->checkRole();
         if(!empty($role['write'])){
-            $where[]=["createrid","in",$role['write']];
+            $where[]=["p.createrid","in",$role['write']];
         }
 //        if(!empty($role['platform'])){
-//            $where[]=["platform_id","in",$role['platform']];
+//            $where[]=["p.platform_id","in",$role['platform']];
 //        }
-        $count = Db::name('project')->where($where)->count();
+        $count = Db::name('project') ->alias('p')->where($where)->count();
         $total = ceil($count / $size);
         $page = $page >= $total ? $total : $page;
-        $list = Db::name('project')->where($where)->page($page,$size)->order("addtime desc")->select();
+        $list = Db::name('project')
+            ->alias('p')
+            ->field('p.*,u.itemid')
+            ->leftJoin('depart_user u', 'u.uid=p.createrid AND u.is_del=0')
+            ->where($where)
+            ->page($page,$size)
+            ->order("p.addtime desc")
+            ->cursor();
         $data=[];
         foreach ($list as $value){
             $info = Db::name("platform")->where(['id'=>$value['platform_id']])->find();
@@ -350,6 +360,7 @@ class Project extends Base
             $value['khName'] = isset($khinfo['companyName'])?$khinfo['companyName']:"";
             $company = Db::name("business")->where(["companyNo"=>$value['companyNo']])->find();
             $value['company'] = isset($company['company'])?$company['company']:"";
+            $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
             $data[]=$value;
         }
         return app_show(0,"获取成功",['list'=>$data,'count'=>$count]);