<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>新建</title>
    <link rel="stylesheet" th:href="@{/lib/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
    <link rel="stylesheet" th:href="@{/lib/font-awesome-4.7.0/css/font-awesome.min.css}" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>


<form class="layui-form" action="" lay-filter="formDemo">
    <div class="layui-form layuimini-form">
        <div class="layui-form-item" style="width: 100%">
            <label class="layui-form-label" style="width: 10%">编号</label>
            <div class="layui-input-inline" style="width: 70%">
                <input type="text" id="bh" name="bh" class="layui-input" readonly>
            </div>
        </div>
        <div class="layui-form-item" style="width: 100%;">
            <label class="layui-form-label" style="width: 10%">年份</label>
            <div class="layui-input-inline" style="width: 70%">
                <input type="number" id="nf" name="nf" class="layui-input" autocomplete="off">
            </div>
        </div>
        <div class="layui-form-item" style="width: 100%">
            <label class="layui-form-label required" style="width: 10%">申请名称</label>
            <div class="layui-input-inline" style="width: 70%">
                <input type="text" id="sqmc" name="sqmc" lay-verify="required" lay-reqtext="申请名称不能为空" autocomplete="off"
                       class="layui-input">
            </div>

        </div>
        <div class="layui-form-item" style="width: 100%;">
            <label class="layui-form-label required" style="width: 10%;">申请金额(元)</label>
            <div class="layui-input-inline" style="width: 70%">
                <input type="number" id="sqje" name="sqje" class="layui-input" lay-verify="required"
                       lay-reqtext="申请金额不能为空" autocomplete="off">
            </div>
        </div>

    <div class="layui-form-item" style="width: 100%;">
        <label class="layui-form-label" style="width: 10%">申请人</label>
        <div class="layui-input-inline" style="width: 70%">
            <input type="hidden" name="sqr" class="layui-input" th:value="${userInfo.userId}">
            <input type="text" name="sqrxm" class="layui-input" th:value="${userInfo.name}" readonly>
        </div>
    </div>
    <div class="layui-form-item" style="width: 100%">
        <label class="layui-form-label required" style="width: 10%">申请时间</label>
        <div class="layui-input-inline" style="width: 70%">
            <input type="text" id="sqsj" name="sqsj" class="layui-input" lay-verify="required|date"
                   lay-reqtext="申请时间不能为空" readonly>
            <tip>日期格式：yyyy-MM-dd</tip>
        </div>
    </div>
    <div class="layui-form-item layui-inline" style="width: 100%">
        <label class="layui-form-label" style="width: 10%">申请说明</label>
        <div class="layui-input-inline" style="width: 70%">
            <textarea id="sqsm" name="sqsm" class="layui-textarea" style="width: 100%;height: 150px"></textarea>
        </div>
    </div>

    <!-- 右侧悬浮按钮 -->
    <div class="right-bottom-btn" id="btnContainer">
        <button type="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>
</form>

<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="@{/lib/xm-select-v1.2.2/xm-select.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 = /*[[@{/}]]*/'';
    var travelExpense = [];//差旅费
    var updateflag = 0;//更新标志


    layui.use(['form', 'laydate'], function () {
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate;

        $("#nf").val(new Date().getFullYear());


        laydate.render({
            elem: '#sqsj',
            value: new Date()

        });
        // 调用加载费用类型的函数
        // 监听确认按钮
        form.on('submit(saveBtn)', function (data) {
            //基本信息
            var index = layer.load(0, {shade: 0.1});
            AjaxUtil.post({
                url: AjaxUtil.ctx + "staBudgetapproval/doAddImprest",
                data: data.field,
                success: function (res) {
                    layer.close(index);
                    if (res.code === 0) {
                        Message.success(1500, res.message, function () {
                            parent.setUpdateFlag();
                            //关闭当前窗口
                            var iframeIndex = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(iframeIndex);
                        });
                    } else {
                        Message.error(res.message, 1000);
                    }
                },
                error: function (error) {
                    layer.close(index);
                }
            });
            return false;
        });


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


    });


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