Browse Source

pc端,多个列表增加分页和搜索

lizhen_gitee 8 months ago
parent
commit
991dcee0cf

+ 9 - 2
application/company/controller/Caozuoguifan.php

@@ -22,10 +22,17 @@ class Caozuoguifan extends Apic
             $where['type_id'] = $type_id;
         }
 
-        $list = Db::name($this->table)->field('content',true)->where('company_id',$this->auth->company_id)->where($where)->select();
+        $list = Db::name($this->table)->field('content',true)->where('company_id',$this->auth->company_id)->where($where)->paginate();
+        $total = $list->total();
+        $list = $list->items();
         $list = list_domain_image($list,['image']);
 
-        $this->success(1,$list);
+        $rs = [
+            'list' => $list,
+            'total'=> $total,
+        ];
+
+        $this->success(1,$rs);
     }
 
     public function add(){

+ 9 - 2
application/company/controller/Dongtai.php

@@ -15,10 +15,17 @@ class Dongtai extends Apic
     protected $table = 'dongtai';
 
     public function index(){
-        $list = Db::name($this->table)->field('content',true)->where('company_id',$this->auth->company_id)->select();
+        $list = Db::name($this->table)->field('content',true)->where('company_id',$this->auth->company_id)->paginate();
+        $total = $list->total();
+        $list = $list->items();
         $list = list_domain_image($list,['image']);
 
-        $this->success(1,$list);
+        $rs = [
+            'list' => $list,
+            'total'=> $total,
+        ];
+
+        $this->success(1,$rs);
     }
 
     public function add(){

+ 9 - 2
application/company/controller/Password.php

@@ -15,10 +15,17 @@ class Password extends Apic
     protected $table = 'password';
 
     public function index(){
-        $list = Db::name($this->table)->where('company_id',$this->auth->company_id)->select();
+        $list = Db::name($this->table)->where('company_id',$this->auth->company_id)->paginate();
+        $total = $list->total();
+        $list = $list->items();
         $list = list_domain_image($list,['logo_image']);
 
-        $this->success(1,$list);
+        $rs = [
+            'list' => $list,
+            'total'=> $total,
+        ];
+
+        $this->success(1,$rs);
     }
 
     public function add(){

+ 17 - 2
application/company/controller/Tiaoshiweixiu.php

@@ -15,14 +15,29 @@ class Tiaoshiweixiu extends Apic
     protected $table = 'tiaoshiweixiu';
    
     public function index(){
+        $search = [];
+        $title = input('title','');
+        if(!empty($title)){
+            $search['a.title'] = ['LIKE','%'.$title.'%'];
+        }
+
         $list = Db::name($this->table)->alias('a')
             ->field('a.id,a.logo_id,a.title,a.createtime,logo.title as logo_title,logo.image as logo_image')
             ->join('tiaoshiweixiu_logo logo','a.logo_id = logo.id','LEFT')
             ->where('a.company_id',$this->auth->company_id)
-            ->select();
+            ->where($search)
+            ->paginate();
+        $total = $list->total();
+        $list = $list->items();
+
         $list = list_domain_image($list,['image']);
 
-        $this->success(1,$list);
+        $rs = [
+            'list' => $list,
+            'total'=> $total,
+        ];
+
+        $this->success(1,$rs);
     }
 
     public function add(){

+ 28 - 2
application/company/controller/Usercompany.php

@@ -15,14 +15,40 @@ class Usercompany extends Apic
     protected $table = 'user_company';
 
     public function index(){
+        $search = [];
+        $user_nickname = input('user_nickname','');
+        $projectname = input('projectname','');
+        $weituo = input('weituo','');
+        $header = input('header','');
+        if(!empty($user_nickname)){
+            $search['user.nickname'] = ['LIKE','%'.$user_nickname.'%'];
+        }
+        if(!empty($projectname)){
+            $search['a.projectname'] = ['LIKE','%'.$projectname.'%'];
+        }
+        if(!empty($weituo)){
+            $search['a.weituo'] = ['LIKE','%'.$weituo.'%'];
+        }
+        if(!empty($header)){
+            $search['a.header'] = ['LIKE','%'.$header.'%'];
+        }
+
         $list = Db::name($this->table)->alias('a')
             ->field('a.id,a.projectname,a.starttime,a.endtime,a.weituo,a.fuwujigou,a.header,a.header_mobile,user.nickname as user_nickname,user.mobile as user_mobile')
             ->join('user','a.user_id = user.id','LEFT')
             ->where('a.company_id',$this->auth->company_id)
             ->where('a.deletetime',NULL)
-            ->select();
+            ->where($search)
+            ->paginate();
+        $total = $list->total();
+        $list = $list->items();
+
+        $rs = [
+            'list' => $list,
+            'total'=> $total,
+        ];
 
-        $this->success(1,$list);
+        $this->success(1,$rs);
     }
 
     //检索未绑定过的正常用户

+ 9 - 2
application/company/controller/Zhengce.php

@@ -15,10 +15,17 @@ class Zhengce extends Apic
     protected $table = 'zhengce';
 
     public function index(){
-        $list = Db::name($this->table)->field('content',true)->where('company_id',$this->auth->company_id)->select();
+        $list = Db::name($this->table)->field('content',true)->where('company_id',$this->auth->company_id)->paginate();
+        $total = $list->total();
+        $list = $list->items();
         $list = list_domain_image($list,['image']);
 
-        $this->success(1,$list);
+        $rs = [
+            'list' => $list,
+            'total'=> $total,
+        ];
+
+        $this->success(1,$rs);
     }
 
     public function add(){