<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>病房信息页</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body>
<!--<body background="/static/layui/病房.jpg" style=" background-repeat:no-repeat ;background-size:100% 100%;
background-attachment: fixed;">-->
<div align="center">
    <br>
    <a href="start">返回导航页</a>
    <p><font size="5" face="arial" color="red">病房相关信息</font></p>
    <br>
    <br>
    <table id='tabledemo' lay-filter="test">
        <thead>
        <tr>
            <th lay-data="{field:'fangjianhao', width:100}">房间号</th>
            <th lay-data="{field:'fangjianweizhi', width:100}">房间位置</th>
            <th lay-data="{field:'fangjianshifoumanyuan', width:80, sort:true}">是否满员</th>
            <th lay-data="{fixed: 'right', width: 165, align:'center', toolbar: '#barDemo'}">操作</th>
        </tr>
        </thead>
        <tbody>
        {% for item in bingfang_list %}
            <tr>
                <td>{{ item.fangjianhao }}</td>
                <td>{{ item.fangjianweizhi }}</td>
                <td>{{ item.fangjianshifoumanyuan }}</td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
</div>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="add">添加</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>


<script src="/static/layui/layui.js"></script>
<script>

    layui.use('table', function () {
        var table = layui.table;

//转换静态表格
        table.init('test', {
            height: 1000,
            width: 600//设置高度
            , limit: 100
        });
        table.on('tool(test)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data //获得当前行数据
                , layEvent = obj.event; //获得 lay-event 对应的值
            if (layEvent === 'detail') {
                layer.msg('查看操作');
            } else if (layEvent === 'del') {
                layer.confirm('真的删除行么', function (index) {
                    location.href = '/delete_gen?type=bingfang&id=' + data.fangjianhao;
                });
            } else if (layEvent === 'edit') {
                location.href = '/update_gen?type=bingfang&id=' + data.fangjianhao ;
            } else if (layEvent === 'add') {
                location.href = '/insert_device?type=bingfang&id=' + data.fangjianhao ;
            }
        });
    });
    //监听行工具事件


</script>
</body>
</html>