<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>订单管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" type="text/css" href="../../layuiadmin/style/formSelects-v4.css"/>
    <style type="text/css">
        .LAY-btns .layui-nav {
            padding-left: 0;
            padding-right: 10px;
            top: -4px;
            margin: 0 10px;
            border: 0;
            background-color: #009688;
        }

        .LAY-btns .layui-nav .layui-nav-item {
            line-height: 40px;
        }

        .LAY-btns .layui-nav .layui-nav-child {
            top: 34px;
        }

        .LAY-btns .layui-nav .layui-nav-bar {
            display: none;
        }

        .LAY-btns .layui-nav .layui-nav-child dd.layui-this a {
            color: #333;
            background-color: #fff;
        }

        .LAY-btns .layui-nav .layui-nav-child dd.layui-this a:hover {
            background-color: #f2f2f2;
            color: #000;
        }

        .seach_items {
            display: inline-block;
            margin-right: 5px;
            margin-top: 5px;
        }
    </style>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body" pad15>
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <table class="layui-hide" id="datagrid" lay-filter="datagrid-operate"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="../../layuiadmin/layui/layui.js?t=1"></script>
<script type="text/html" id="toolbarDemo">
    <form class="layui-form" lay-filter="query-form-element">
        <div class="seach_items">
            <input type="text" name="school_name" autocomplete="off" class="layui-input"
                   placeholder="学校名称"/>
        </div>
        <div class="seach_items">
            <input type="text" name="grade_name" autocomplete="off" class="layui-input"
                   placeholder="年级名称"/>
        </div>
        <div class="seach_items">
            <input type="text" name="classes_name" autocomplete="off" class="layui-input"
                   placeholder="班级名称"/>
        </div>
        <div class="seach_items">
            <input type="text" name="name" autocomplete="off" class="layui-input"
                   placeholder="学生姓名"/>
        </div>
        <div class="seach_items">
            <input type="text" name="create_user_tel" autocomplete="off" class="layui-input"
                   placeholder="添加人电话"/>
        </div>

        <button class="layui-btn layui-btn-sm" lay-submit lay-filter="query-form-element">查询
        </button>
    </form>
</script>

<script>
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
        , formSelects: 'formSelects-v4'
    }).use(['index', 'table', 'form', 'formSelects', 'upload'], function () {
        var $ = layui.$
            , table = layui.table
            , form = layui.form
            , admin = layui.admin;

        table.render({
            elem: '#datagrid'
            , url: '/option/student/'
            , toolbar: '#toolbarDemo'
            , title: '学生信息' //标题
            , cols: [[
                {field: 'name', title: '学生姓名', width: 200}
                , {field: 'school_text', title: '学校', width: 200,}
                , {field: 'grade_text', title: '年级', width: 100,}
                , {field: 'classes_text', title: '班级', width: 100,}
                , {field: 'balance', title: '余额', width: 100,}
                , {field: 'enable_text', title: '是否在用', width: 100,}
                , {field: 'create_user_text', title: '添加人', width: 200,}
                , {field: 'create_time_f', title: '添加时间', width: 200,}
            ]]
            , page: true
            , height: 'full-108'
        });
        var _params;
        form.on('submit(query-form-element)', function (data) {
            //layer.msg(JSON.stringify(data.field));
            _params = data.field;
            table.reload('datagrid', {
                where: data.field
                , page: {curr: 1}
            });
            form.val("query-form-element", data.field);
            layer.closeAll();
            return false;
        });

        //监听工具条
        table.on('tool(datagrid-operate)', function (obj) {
            var data = obj.data;
            table.editdata = data;
            if (obj.event === 'student_edit') {
                layer.open({
                    type: 2,
                    title: '修改学生班级',
                    area: ['40%', '75%'],
                    btn: ['保存', '取消'],
                    yes: function (index, dom) {
                        layui.onSubmitChild = function (data) {
                            layer.close(index);
                            table.reload('datagrid', {});
                        };
                        layui.submitChild();
                    },
                    btn2: function (index, layero) {
                        layer.close(index);//关闭当前按钮
                    },
                    content: 'student_edit.html?id=' + data.id + '&express=' + data.express
                });
            }
        });
    });
</script>
</body>
</html>

