fix: 兼容配件遗漏状态筛选问题
All checks were successful
Gitea Actions Official-website / deploy-dev (push) Successful in 3s

This commit is contained in:
2026-07-09 09:37:38 +08:00
parent 116d788ecc
commit 77e60ef482
2 changed files with 12 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ class ProductCompatParts
{ {
$params = request()->param([ $params = request()->param([
'name', 'name',
'is_show',
'page/d' => 1, 'page/d' => 1,
'size/d' => 10 'size/d' => 10
]); ]);
@@ -25,6 +26,10 @@ class ProductCompatParts
'deleted_at' 'deleted_at'
]) ])
->language(request()->lang_id) ->language(request()->lang_id)
->where(function($query) use($params) {
if (empty($params['is_show'])) return;
$query->disabled($params['is_show'] == 1 ? 0 : 1);
})
->withSearch('name', [ ->withSearch('name', [
'name' => $params['name']??null 'name' => $params['name']??null
]) ])

View File

@@ -39,6 +39,13 @@ class ProductCompatPartsModel extends ProductCompatPartsBaseModel
$query->where('name', '=', $value); $query->where('name', '=', $value);
} }
// 按状态查询
public function scopeDisabled(\think\db\Query $query, int|null $disabled)
{
if (is_null($disabled)) return;
$query->where('disabled', '=', $disabled);
}
// 查询配件类型名称搜索 // 查询配件类型名称搜索
public function searchNameAttr(\think\db\Query $query, string|null $value, array $data) public function searchNameAttr(\think\db\Query $query, string|null $value, array $data)
{ {