diff --git a/app/admin/controller/mall/Item.php b/app/admin/controller/mall/Item.php index 7ac6d48..4a475a8 100644 --- a/app/admin/controller/mall/Item.php +++ b/app/admin/controller/mall/Item.php @@ -3,6 +3,8 @@ namespace app\admin\controller\mall; 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 string|array $quickSearchField = ['id']; + protected string|array $quickSearchField = ['id', 'title']; /** 添加时自动填充 admin_id */ 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); if ($response !== null) { @@ -42,8 +44,7 @@ class Item extends Backend } if ($request->get('select') || $request->post('select')) { - $this->_select(); - return $this->success(); + return $this->select($request); } list($where, $alias, $limit, $order) = $this->queryBuilder(); @@ -61,4 +62,29 @@ class Item extends Backend '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(), + ]); + } } \ No newline at end of file