feat(admin): 优化仓库产品列表搜索功能

- 将搜索字段从 'product_id' 改为 'product_name',以支持通过产品名称搜索
- 更新搜索逻辑,使用产品名称模糊匹配来获取产品 ID 列表
- 调整搜索条件,支持通过产品名称进行精确搜索
This commit is contained in:
mkm 2025-02-08 15:44:23 +08:00
parent 5eeffb91d3
commit c14d3b8d47

View File

@ -35,7 +35,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
public function setSearch(): array
{
return [
'=' => ['warehouse_id', 'financial_pm', 'store_id','oid','supplier_id','is_pay','code'],
'=' => ['warehouse_id', 'financial_pm', 'product_id','store_id','oid','supplier_id','is_pay','code'],
'between_time' => 'create_time'
];
}
@ -52,9 +52,9 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
*/
public function lists(): array
{
if ($this->request->get('product_id')) {
$product_id = $this->request->get('product_id');
$ids = StoreProduct::where('store_name', 'like', '%' . $product_id . '%')->withTrashed()->column('id');
if ($this->request->get('product_name')) {
$product_name = $this->request->get('product_name');
$ids = StoreProduct::where('store_name', 'like', '%' . $product_name . '%')->withTrashed()->column('id');
if ($ids) {
$this->searchWhere[] = ['product_id', 'in', $ids];
$this->ids = $ids;