<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%; display: flex; flex-wrap: wrap;">
            <div class="layui-form-item layui-inline" style="width: calc(50% - 35px); display: flex; align-items: center;">
                <label class="layui-form-label required" style="width: 70px; margin-right: 10px;">序号</label>
                <div class="layui-input-inline" style="width: calc(100% - 80px);">
                    <input type="text" id="xh" name="xh" autocomplete="off" class="layui-input" lay-verify="序号不能为空">
                </div>
            </div>
            <div class="layui-form-item layui-inline" style="width: calc(50% - 35px); display: flex; align-items: center;">
                <label class="layui-form-label required" style="width: 70px; margin-right: 10px;">费用用途</label>
                <div class="layui-input-inline" style="width: calc(100% - 80px);">
                    <input type="text" id="fyyt" name="fyyt" lay-verify="required" lay-reqtext="费用用途不能为空" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-inline" style="width: calc(50% - 35px); display: flex; align-items: center;">
                <label class="layui-form-label required" style="width: 70px; margin-right: 10px;">申请金额</label>
                <div class="layui-input-inline" style="width: calc(100% - 80px);">
                    <input type="text" id="sqje" name="sqje" lay-verify="required" lay-reqtext="申请金额不能为空" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-inline" style="width: calc(50% - 35px); display: flex; align-items: center;">
                <label class="layui-form-label required" style="width: 70px; margin-right: 10px;">税率</label>
                <div class="layui-input-inline" style="width: calc(100% - 80px);">
                    <input type="text" id="sl" name="sl" lay-verify="required" lay-reqtext="税率不能为空" autocomplete="off" class="layui-input" oninput="calculateBzje()">
                </div>
            </div>
            <div class="layui-form-item layui-inline" style="width: calc(50% - 35px); display: flex; align-items: center;">
                <label class="layui-form-label required" style="width: 70px; margin-right: 10px;">报账金额(含税)</label>
                <div class="layui-input-inline" style="width: calc(100% - 80px);">
                    <input type="text" id="bzje" name="bzje" lay-verify="required" lay-reqtext="报账金额(含税)不能为空" autocomplete="off" class="layui-input" oninput="calculateBhsje()">
                </div>
            </div>
            <div class="layui-form-item layui-inline" style="width: calc(50% - 35px); display: flex; align-items: center;">
                <label class="layui-form-label required" style="width: 70px; margin-right: 10px;">报账金额(不含税)</label>
                <div class="layui-input-inline" style="width: calc(100% - 80px);">
                    <input type="text" id="bhsje" name="bhsje" lay-verify="required" lay-reqtext="报账金额(不含税)不能为空" autocomplete="off" class="layui-input" oninput="calculateBzje()">
                </div>
            </div>


        </div>
        <div class="layui-form-item layui-inline" style="width: calc(50% - 35px); display: flex; align-items: center;">
            <label class="layui-form-label" style="width: 70px; margin-right: 10px;">备注</label>
            <div class="layui-input-inline" style="width: calc(100% - 80px);">
                <textarea  type="text" id="bz" name="bz" autocomplete="off" class="layui-input"></textarea>
            </div>
        </div>

        <!-- 右侧悬浮按钮 -->
        <div class="right-bottom-btn">
            <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>
    <script>
        function calculateBzje() {
            var bhsje = parseFloat(document.getElementById('bhsje').value);
            var sl = parseFloat(document.getElementById('sl').value) / 100; // assuming sl is input as percentage

            if (!isNaN(bhsje) && !isNaN(sl)) {
                var bzje = bhsje * (1 + sl);
                document.getElementById('bzje').value = bzje.toFixed(2); // Round to 2 decimal places
            }
        }

        function calculateBhsje() {
            var bzje = parseFloat(document.getElementById('bzje').value);
            var sl = parseFloat(document.getElementById('sl').value) / 100; // assuming sl is input as percentage

            if (!isNaN(bzje) && !isNaN(sl)) {
                var bhsje = bzje / (1 + sl);
                document.getElementById('bhsje').value = bhsje.toFixed(2); // Round to 2 decimal places
            }
        }
    </script>

</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 = /*[[@{/}]]*/'';
    layui.use(['form', 'tableSelect'], function () {
        var form = layui.form;
        //监听提交
        form.on('submit(saveBtn)', function (data) {
            parent.setIndirect(data.field);
            parent.setUpdateFlag();
            parent.layer.close(parent.layer.getFrameIndex(window.name));// 关闭子窗口
        });

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