Browse Source

分页优化

曹鹤洋 1 year ago
parent
commit
b16e4d694c

+ 6 - 6
application/admin/controller/QcodeBach.php

@@ -88,7 +88,7 @@ class QcodeBach extends Backend
                 $where[$k] = new \MongoDB\BSON\Regex($v);
             }
 
-            $total = $this->model->name($company_id.'_'."qcode_bach")->where($where)->select();
+            $total = $this->model->name($company_id.'_'."qcode_bach")->where($where)->count();
             $list = $this->model->name($company_id.'_'."qcode_bach")->where($where)
                 ->order($sort,$order)
                 ->limit($limit)
@@ -99,7 +99,7 @@ class QcodeBach extends Backend
                 $list[$k]['id'] = $oid['$oid'];
             }
 
-            $result = array("total" => count($total), "rows" => $list);
+            $result = array("total" => $total, "rows" => $list);
 
             return json($result);
         }
@@ -147,7 +147,7 @@ class QcodeBach extends Backend
             }
 
             $db = new QcodeLarge();
-            $total = $db->name($company_id.'_'."qcode_large")->where($where)->select();
+            $total = $db->name($company_id.'_'."qcode_large")->where($where)->count();
             $list = $db->name($company_id.'_'."qcode_large")->where($where)
                 ->order($sort,$order)
                 ->limit($limit)
@@ -169,7 +169,7 @@ class QcodeBach extends Backend
 
             }
 
-            $result = array("total" => count($total), "rows" => $list);
+            $result = array("total" => $total, "rows" => $list);
             return json($result);
         }
         return $this->view->fetch();
@@ -210,7 +210,7 @@ class QcodeBach extends Backend
             }
 
             $qcodeSmall = new QcodeSmall();
-            $total = $qcodeSmall->name($company_id.'_'."qcode_small")->where($where)->select();
+            $total = $qcodeSmall->name($company_id.'_'."qcode_small")->where($where)->count();
             $list = $qcodeSmall->name($company_id.'_'."qcode_small")->where($where)
                 ->order($sort,$order)
                 ->limit($limit)
@@ -223,7 +223,7 @@ class QcodeBach extends Backend
                 $list[$k]['l_flow'] = $req['l_flow'].'-'.$v['l_flow'];
             }
 
-            $result = array("total" => count($total), "rows" => $list);
+            $result = array("total" => $total, "rows" => $list);
 
             return json($result);
         }

+ 4 - 4
application/admin/controller/QcodeProduct.php

@@ -123,7 +123,7 @@ class QcodeProduct extends Backend
             foreach ($filter as $k => $v){
                 $where[$k] = new \MongoDB\BSON\Regex($v);
             }
-            $total = $this->model->where($where)->select();
+            $total = $this->model->where($where)->count();
             $list = $this->model->where($where)
                 ->order($sort,$order)
                 ->limit($limit)
@@ -135,7 +135,7 @@ class QcodeProduct extends Backend
             }
 
 
-            $result = array("total" => count($total), "rows" => $list);
+            $result = array("total" => $total, "rows" => $list);
 
             return json($result);
         }
@@ -184,7 +184,7 @@ class QcodeProduct extends Backend
                 ->column('product_id');
             $rows = array_values($rows);
 
-            $total = $this->model->where($where)->where('_id','in',$rows)->select();
+            $total = $this->model->where($where)->where('_id','in',$rows)->count();
 
             $list = $this->model->where($where)
                 ->where('_id','in',$rows)
@@ -197,7 +197,7 @@ class QcodeProduct extends Backend
                 $list[$k]['id'] = $oid['$oid'];
             }
 
-            $result = array("total" => count($total), "rows" => $list);
+            $result = array("total" => $total, "rows" => $list);
 
             return json($result);
         }