<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" layout:decorator="~{/base/main}">
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-body">

        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>路由刷新</legend>
        </fieldset>

        <form class="layui-form" action="">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">选择项目</label>
                    <div class="layui-input-block">
                        <select name="projectName" id="project" lay-search="">
                            <option th:each="val:${routes}" th:value="${val}" th:text="${val}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="submit">刷新</button>
                </div>
            </div>
        </form>
    </div>
</div>


<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form', 'layedit', 'jquery', 'laydate'], function () {
        var form = layui.form, layer = layui.layer;
        var $ = layui.jquery;


        form.verify({});

        //监听提交
        form.on('submit(submit)', function (data) {
            // layer.alert(JSON.stringify(data.field), {
            //     title: '最终的提交信息'
            // });
            elab_common.postReq(urlConfig.route.refreshService, data.field, function (data) {
                var success = data.success;
                if (success) {
                    layer.alert("刷新成功 " + data.message, function (index) {
                        var i = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(i);
                        parent.$("#q_submit").click();
                    });

                } else {
                    debugger;
                    layer.alert(data.message);
                }
            }, true);
            return false;
        });

        init();

        function init() {
            form.render('select');
        }
    });

</script>

</body>
</html>