#@layout()
#define main()
<div>
    <script type="text/html" id="optionTpl">
        <option value="">请选择</option>
        {{#  layui.each(d, function(index, item){ }}
        <option value="{{item.id}}">{{ item.typename }}</option>
        {{#  }); }}
    </script>
    <form lay-filter="queryForm" class="query-form layui-form">
        <b>查询&nbsp;&nbsp;&nbsp;&nbsp;</b>
        <div style="padding: 5px 0px 5px 50px;">
            <label for="">读者姓名：</label>
            <input type="text" name="bean.realname" class="layui-input-inline layui-input" placeholder="">
            <label for="">读者证号：</label>
            <input type="text" name="bean.cardnumber" class="layui-input-inline layui-input" placeholder="">
            <label for="">读者类型：</label>
            <div class="layui-input-inline">
                <select name="bean.readertypeid" id="readerType">
                </select>
            </div>
            <!--<label for="">学校</label>-->
            <!--<div style="display: inline-block;" id="linkDiv"></div>-->
            <!--<input type="text" name="orgid" id="searchBtnorgid"style="display: none;" >-->
            <button lay-submit lay-filter="searchBtn" class="layui-btn layui-btn-sm">查询</button>
        </div>
    </form>

    <div class="line"></div>
    <table id="dataTable" lay-filter="mainTable"></table>
</div>
#end
#define methods()

<script>
    searchForm.init("readerType","/selectcount/readertypeList");
    //searchForm.linkage(getUrlParam("orgid")||JSON.parse(sessionStorage.loginData).orgid);

    myTable.list({
        url:"/selectcount/readerSearch",
        elem:"#dataTable",
        toolbar:"#tableHeader",
        postData:{orgid:getUrlParam("orgid")||JSON.parse(sessionStorage.loginData).orgid},
        cols: [[ //表头
            {type: 'numbers', title: '序号'}
            ,{field: 'realname', title: '读者姓名',align:'center'}
            ,{field: 'cardnumber', title: '读者证号', align:'center'}
            ,{field: 'typename', title: '读者类型', align:'center'}
            ,{field: 'orgname', title: '所在学校', align:'center'}
            ,{title: '借阅记录', align:'center',templet:function(d){
                    d.createtime = d.createtime?d.createtime.split(" ")[0]:"";
                    d.title=d.title||"";
                    if(d.createtime){
                        return "<a href='readerDetail?readerid="+d.readerid+"'>"+d.createtime+":借"+d.title+"</a>"
                    }else {
                        return "";
                    }
                }}
        ]]
    });

    // $("#searchBtnorgid").val(getUrlParam("orgid") || JSON.parse(sessionStorage.loginData).orgid);
    //searchForm.submit('submit(searchBtn)',"selectcount/readerSearch");

    form.on('submit(searchBtn)', function(data){
        data.field.token = sessionStorage.token;
        table.reload("dataTable",{
            // url:"/selectcount/collectionSearch",
            where:_extends(data.field,{
                orgid:data.field.orgid || getUrlParam("orgid")
            }),
            page: {
                curr: 1
            },
            done:function(result){
                if(result.code==200){
                    totalValue(data.field);
                    layer.msg('查询成功', { icon: 1 });
                }else {
                    layer.msg(result.msg, { icon: 5 });
                }
            }
        });
        return false;
    });

</script>
#end
