物品下拉

This commit is contained in:
2026-01-05 10:42:08 +08:00
parent 07a40bf688
commit c38a53f053
5 changed files with 143 additions and 0 deletions
+61
View File
@@ -2,6 +2,7 @@
namespace app\common\service;
use app\common\logic\InvItemLogic;
use app\common\validate\InvItemValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\InvItem;
@@ -23,6 +24,12 @@ class InvItemService
*/
protected $validator = InvItemValidate::class;
protected $logic;
public function __construct()
{
$this->logic = (new InvItemLogic());
}
/**
* 获取验证器
*/
@@ -31,6 +38,52 @@ class InvItemService
return new $this->validator;
}
/**
* 构造 CrudUtil 查询配置
*/
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
{
$p = $request->all();
$config = [];
$config['model'] = $this->modelClass;
switch ($scene) {
case 'default':
$config['where']['status'] = 1;
$config['order']['sort'] = 'desc';
$config['order']['id'] = 'desc';
break;
case 'index':
$config['where']['status'] = 1;
// 关键字
if (isset($p['keyword']) && $p['keyword']) {
$k = '%' . $p['keyword'] . '%';
foreach (['item_name'] as $col) {
$config['orWhere'][] = [$col, 'like', $k];
}
}
$config['order']['sort'] = 'desc';
$config['order']['id'] = 'desc';
break;
case 'show':
$config['where']['id'] = $p['id'];
$config['where']['status'] = 1;
break;
case 'store':
break;
case 'update':
$config['where']['id'] = $p['id'];
break;
case 'destroy':
$config['where']['id'] = $p['id'];
break;
}
return $config;
}
/**
* 生成 8-12 位的物品编码(默认10位)
*
@@ -135,4 +188,12 @@ class InvItemService
}
return $this->changeStock($itemId, $qty, true);
}
/**
* 获取车型list
*/
public function getList()
{
return $this->logic->getList();
}
}