首页 > 其他分享 >fastadmin 自定义搜索

fastadmin 自定义搜索

时间:2022-08-30 14:57:15浏览次数:57  
标签:name 自定义 filter limit fastadmin input 搜索 where id

 PHP 代码

$offset=input('offset');
$limit=input('limit');
// 获取搜索框的值
$filter=input('filter');
if($filter){
    $filter=urldecode($filter);
    $filter=json_decode($filter,TRUE);
    foreach($filter as $k=>$v){
        $where[$k]=['like',"%{$v}%"];
    }
}
$list = $this->db->name('dzy_user')
    ->field('id,name,phone,email,purview_type,wx_openid,status')
    ->where($where)
    ->order('status desc,id desc')
    ->limit($offset, $limit)
    ->select();

HTML代码

每一个搜索值必须要加这个 data-name为字段值
<input class="operate" type="hidden" data-name="name" value="="/>

<script id="customformtpl" type="text/html">
    <!--form表单必须添加form-commsearch这个类-->
    <form action="" class="form-commonsearch">
        <div style="border-radius:2px;margin-bottom:10px;background:#f5f5f5;padding:15px 20px;">
            <div class="row">
                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="form-group">
                        <label class="control-label">用户名</label>
                        <div>
                            <input class="form-control" name="name" type="text" value="">
                        </div>
                        <input class="operate" type="hidden" data-name="name" value="="/>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="form-group">
                        <label class="control-label">手机号</label>
                        <div>
                        <input class="form-control" type="text" name="phone" placeholder="手机号" value=""/>
                        </div>
                        <input class="operate" type="hidden" data-name="phone" value="="/>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="form-group">
                        <label class="control-label">邮箱</label>
                        <div>
                        <input class="form-control" type="text" name="email" placeholder="邮箱" value=""/>
                        </div>
                        <input class="operate" type="hidden" data-name="email" value="="/>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="form-group">
                        <label class="control-label">账号类型</label>
                        <div class="row">
                            <div class="col-xs-6">
                                <select class="admin form-control" name="purview_type">
                                    <option value="">请选择</option>
                                    <option value="zobu">总经办</option>
                                    <option value="unit">区域经理</option>
                                    <option value="area">督导</option>
                                    <option value="shop">大店长</option>
                                    <option value="zd_id">店长</option>
                                    <option value="other">其他</option>
                                </select>
                            </div>
                        </div>
                        <input class="operate" type="hidden" data-name="purview_type" value="="/>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="form-group">
                        <label class="control-label">状态</label>
                        <div class="row">
                            <div class="col-xs-6">
                                <select class="admin form-control" name="status">
                                    <option value="">请选择</option>
                                    <option value="0">已授权</option>
                                    <option value="3">待审核</option>
                                    <option value="1">正常</option>
                                    <option value="2">冻结</option>
                                </select>
                            </div>
                        </div>
                        <input class="operate" type="hidden" data-name="status" value="="/>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="form-group">
                        <label class="control-label"></label>
                        <div class="row">
                            <div class="col-xs-6">
                                <input type="submit" class="btn btn-success btn-block" value="提交"/>
                            </div>
                            <div class="col-xs-6">
                                <input type="reset" class="btn btn-primary btn-block" value="重置"/>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</script>

js代码

table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                showToggle: false,
                showColumns: false,
                // 必须添加这个,customformtpl与html的ID一致
                searchFormTemplate: 'customformtpl',

原文地址 :https://blog.csdn.net/qq_39521804/article/details/120260188

标签:name,自定义,filter,limit,fastadmin,input,搜索,where,id
From: https://www.cnblogs.com/zhangzhijian/p/16639299.html

相关文章