[积分商城]商品管理-优化

This commit is contained in:
2026-03-19 16:29:48 +08:00
parent 0c51e4f8ec
commit 20d89089ca

View File

@@ -3,6 +3,8 @@
namespace app\admin\controller\mall; namespace app\admin\controller\mall;
use app\common\controller\Backend; use app\common\controller\Backend;
use support\Response;
use Webman\Http\Request;
/** /**
* 商品管理 * 商品管理
@@ -20,7 +22,7 @@ class Item extends Backend
protected array $withJoinTable = ['admin']; protected array $withJoinTable = ['admin'];
protected string|array $quickSearchField = ['id']; protected string|array $quickSearchField = ['id', 'title'];
/** 添加时自动填充 admin_id */ /** 添加时自动填充 admin_id */
protected bool $autoFillAdminId = true; protected bool $autoFillAdminId = true;
@@ -34,7 +36,7 @@ class Item extends Backend
/** /**
* 查看 * 查看
*/ */
public function index(\Webman\Http\Request $request): \support\Response public function index(Request $request): Response
{ {
$response = $this->initializeBackend($request); $response = $this->initializeBackend($request);
if ($response !== null) { if ($response !== null) {
@@ -42,8 +44,7 @@ class Item extends Backend
} }
if ($request->get('select') || $request->post('select')) { if ($request->get('select') || $request->post('select')) {
$this->_select(); return $this->select($request);
return $this->success();
} }
list($where, $alias, $limit, $order) = $this->queryBuilder(); list($where, $alias, $limit, $order) = $this->queryBuilder();
@@ -61,4 +62,29 @@ class Item extends Backend
'remark' => get_route_remark(), 'remark' => get_route_remark(),
]); ]);
} }
/**
* 远程下拉选择数据(供 remoteSelect 使用)
*/
public function select(Request $request): Response
{
$response = $this->initializeBackend($request);
if ($response !== null) {
return $response;
}
list($where, $alias, $limit, $order) = $this->queryBuilder();
$res = $this->model
->field('id,title')
->alias($alias)
->where($where)
->order($order)
->paginate($limit);
return $this->success('', [
'list' => $res->items(),
'total' => $res->total(),
'remark' => get_route_remark(),
]);
}
} }