您现在的位置是:首页 > 开发开发

webmanAdmin模糊搜索

2026-08-12 13:33:43【开发】人已围观

简介输入模糊搜索<input type="hidden" autocomplete="off" name="telephone[]" value="like"><input type="text" name="telephone[]" value="" class="layui-input">下拉选择

webman是个好东西,但教程还是缺,没有示例,使用webmanAdmin时,模糊搜索是看了源码才琢磨出来的,如下
输入模糊搜索
<input type="hidden" autocomplete="off" name="telephone[]" value="like">
<input type="text" name="telephone[]" value="" class="layui-input">
下拉选择模糊搜索
<div class="layui-input-block">
    <input type="hidden" autocomplete="off" name="book_ids[0]" value="like"><!-- 模糊搜索 -->
    <div name="book_ids[1]" id="book_ids" value="" ></div>
</div>

ayui.xmSelect.render({
    el: "#book_ids",
    name: "book_ids[1]",
    filterable: true,
    initValue: initValue,
    data: select_list["book_ids"],
    model: {"icon":"hidden","label":{"type":"text"}},
    clickClose: true,
    radio: true,
})
后台代码:
    /**
     * 查询
     * @param Request $request
     * @return Response
     * @throws BusinessException
     */
    // public function select(Request $request): Response
    // {
    //     // $data = $this->model->select(['username', 'email'])
    //     //  ->where('username', 'like', 'admin%')
    //     //  ->doFormat();
    //     //  return $this->success('ok', $data);


    //      // 1. 获取前端传递的分页参数,设置默认值
    //     $page = $request->input('page', 1);       // 当前页码
    //     $pageSize = $request->input('page_size', 15); // 每页条数
        
    //     // 2. 构建查询:指定查询列 (username, phone) 并执行分页
    //     $paginator = $this->model->select(['id','username', 'email'])
    //         ->paginate($pageSize, ['*'], 'page', $page);
        
    //     // 3. 返回 JSON 格式的分页数据
    //     return json([
    //         'code' => 0,
    //         'msg' => 'success',
    //         'count' => $paginator->total(),
    //         'data' => $paginator->items(),
    //         // 'data' => [
    //         //     'list' => $paginator->items(),       // 当前页的数据列表
    //         //     'total' => $paginator->total(),      // 数据总条数
    //         //     'page' => $paginator->currentPage(), // 当前页码
    //         //     'page_size' => $paginator->perPage(),// 每页条数
    //         // ]
    //     ]);
    //     //return parent::select($request);
    //     // [$where, $format, $limit, $field, $order] = $this->selectInput($request);
    //     // $query = $this->doSelect($where, $field, $order);
    //     // return $this->doFormat($query, $format, $limit);
    // }

很赞哦! ()

相关文章

文章评论

热评榜