From 8330a2ffd7a12993a872155a0dca991db045d7e2 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 25 Jun 2024 15:46:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=95=86=E5=93=81=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/product/ProductLists.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index 8ccab3a48..ef91ba000 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -81,16 +81,22 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L $this->searchWhere[] = ['cate_id', '=', $class_all]; } } - - $field = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch'; + $order = $this->request->get('order',''); + $field = $this->request->get('field',''); + if(empty($order)||empty($field)){ + $order = $this->sortOrder; + }else{ + $order = [$field => $order]; + } + $fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch'; $this->searchWhere[] = ['status', '=', 1]; $this->searchWhere[] = ['stock', '>', 0]; return StoreBranchProduct::where($this->searchWhere) - ->field($field) + ->field($fields) ->with(['className', 'unitName']) ->limit($this->limitOffset, $this->limitLength) - ->order($this->sortOrder) + ->order($order) // ->page($this->limitOffset +1,$this->limitLength) ->select()->toArray(); }