diff --git a/app/admin/lists/store_branch_product/StoreBranchProductLists.php b/app/admin/lists/store_branch_product/StoreBranchProductLists.php index 3cd42a71..9e3459b1 100644 --- a/app/admin/lists/store_branch_product/StoreBranchProductLists.php +++ b/app/admin/lists/store_branch_product/StoreBranchProductLists.php @@ -34,7 +34,6 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI '=' => ['product_id', 'cate_id', 'store_id', 'status'], '%pipe_like%' => ['store_name_code' => 'store_name|bar_code'], '%like%' => ['store_name'], - '<=' => ['stock'], ]; } /** @@ -44,7 +43,7 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI */ public function setSortFields(): array { - return ['stock' => 'stock',]; + return ['stock' => 'stock']; } /** * @notes 设置默认排序 @@ -52,7 +51,7 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI */ public function setDefaultOrder(): array { - return ['sort' => 'desc', 'stock' => 'desc', 'id' => 'desc']; + return [ 'id' => 'desc','stock' => 'desc',]; } /** * @notes 获取门店列表列表 diff --git a/app/admin/lists/warehouse_product_storege/WarehouseProductStoregeLists.php b/app/admin/lists/warehouse_product_storege/WarehouseProductStoregeLists.php index 8de434d2..462241f0 100644 --- a/app/admin/lists/warehouse_product_storege/WarehouseProductStoregeLists.php +++ b/app/admin/lists/warehouse_product_storege/WarehouseProductStoregeLists.php @@ -10,13 +10,14 @@ use app\common\model\store_category\StoreCategory; use app\common\model\store_product\StoreProduct; use app\common\model\store_product_unit\StoreProductUnit; use app\common\model\warehouse\Warehouse; +use app\common\lists\ListsSortInterface; /** * 仓库商品存储列表 * Class WarehouseProductStoregeLists * @package app\admin\listswarehouse_product_storege */ -class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSearchInterface +class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSearchInterface,ListsSortInterface { public $ids; public $store_name; @@ -33,7 +34,23 @@ class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSe '=' => ['warehouse_id','product_id'], ]; } - + /** + * @notes 设置支持排序字段 + * @return string[] + * @remark 格式: ['前端传过来的字段名' => '数据库中的字段名']; + */ + public function setSortFields(): array + { + return ['nums' => 'nums']; + } + /** + * @notes 设置默认排序 + * @return string[] + */ + public function setDefaultOrder(): array + { + return [ 'id' => 'desc','nums' => 'desc',]; + } /** * @notes 获取仓库商品存储列表 @@ -58,7 +75,7 @@ class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSe return WarehouseProductStorege::where($this->searchWhere) ->field(['id', 'warehouse_id', 'product_id', 'nums', 'price', 'total_price', 'status']) ->limit($this->limitOffset, $this->limitLength) - ->order(['id' => 'desc']) + ->order($this->sortOrder) ->select()->each(function ($item) { $item->warehouse_name = Warehouse::where('id', $item->warehouse_id)->value('name'); $find = StoreProduct::where('id', $item->product_id)->find(); diff --git a/app/common/lists/ListsSortTrait.php b/app/common/lists/ListsSortTrait.php index 18d24975..6803de94 100644 --- a/app/common/lists/ListsSortTrait.php +++ b/app/common/lists/ListsSortTrait.php @@ -29,10 +29,10 @@ trait ListsSortTrait return $defaultOrder; } - if ($this->orderBy = 'desc') { + if ($this->orderBy == 'desc') { return [$field => 'desc']; } - if ($this->orderBy = 'asc') { + if ($this->orderBy == 'asc') { return [$field => 'asc']; } return $defaultOrder;