<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<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, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/lib/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
        .layui-form-item label{
            width: 15%;
        }
        .layui-input-block input{
            width: 90%;
        }
        .layui-input-block textarea{
            width: 90%;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form" style="margin-left: -15px; margin-right: 20px">
    <div class="layui-form-item">
        <label class="layui-form-label required">岗位名称</label>
        <div class="layui-input-block">
            <input type="text" name="postName" lay-verify="required" lay-reqtext="岗位名称不能为空" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">岗位编码</label>
        <div class="layui-input-block">
            <input type="text" name="postCode" lay-verify="required" lay-reqtext="岗位编码不能为空" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">岗位顺序</label>
        <div class="layui-input-block">
            <input type="number" min="0" name="postSort" lay-verify="required" lay-reqtext="岗位顺序不能为空" autocomplete="off"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">岗位状态</label>
        <div class="layui-input-block">
            <input type="radio" name="status" th:each="item, itemStat: ${baseDictList}" th:value="${item.code}"
                   th:title="${item.name}" th:checked="${itemStat.index eq 0}" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea name="descript" class="layui-textarea" autocomplete="off"></textarea>
        </div>
    </div>

    <!-- 右侧悬浮按钮 -->
    <div class="right-bottom-btn">
        <button class="layui-btn" lay-submit lay-filter="saveBtn"><i
                class="layui-icon layui-icon-ok"></i>确认
        </button>
        <button class="layui-btn" lay-filter="cancleBtn"><i
                class="layui-icon layui-icon-close"></i>取消
        </button>
    </div>

</div>
<script th:src="@{/lib/jquery-3.4.1/jquery-3.4.1.min.js}" charset="utf-8"></script>
<script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
<script th:src="@{/lib/coco-message/coco-message.js}" charset="utf-8"></script>
<script th:src="@{/js/lay-config.js}" charset="utf-8"></script>
<script type="text/javascript" th:inline="javascript">
    AjaxUtil.ctx = /*[[@{/}]]*/'';
    layui.use(['form', 'layer'], function () {
        var form = layui.form,
            layer = layui.layer;

        // 监听确认按钮
        form.on('submit(saveBtn)', function (data) {
            var index = layer.alert('确认提交吗？', function () {
                var loading = layer.load(0, {shade: 0.1});
                AjaxUtil.post({
                    url: AjaxUtil.ctx + "sysPostinfo/add",
                    data: data.field,
                    success: function (res) {
                        layer.close(index);
                        layer.close(loading);
                        if (res.code === 0) {
                            layer.msg(res.message,{icon:1}, function () {
                                // 重载表格
                                parent.setUpdateFlag();
                                // 关闭弹框
                                var iframeIndex = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(iframeIndex);
                            });
                        } else {
                            layer.msg(res.message, {icon:2});
                        }
                    },
                    error: function (error) {
                        layer.msg(res.message, {icon:2});
                    }
                });
            });
            return false;
        });

        // 监听取消按钮
        $("button[lay-filter='cancleBtn']").click(function () {
            var iframeIndex = parent.layer.getFrameIndex(window.name);
            parent.layer.close(iframeIndex);
        });
    });
</script>
</body>
</html>