<!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">
            <label class="layui-form-label required" style="width: 60px">项目类型</label>
            <div class="layui-input-inline" style="width: 650px">
                <input type="hidden" id="xm" name="xm" th:value="${budget.xm}">
                <input type="text" id="xmmc" name="xmmc" th:value="${budget.xmmc}" class="layui-input" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 60px">父级</label>
            <div class="layui-input-inline" style="width: 650px">
                <input type="hidden" name="fj" id="fj" th:value="${budget.fj}" class="layui-input">
                <input type="text" name="fjmc" id="fjmc" th:value="${budget.fjmc}" class="layui-input" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required" style="width: 60px">预算名称</label>
            <div class="layui-input-inline" style="width: 650px">
                <input type="hidden" id="id" name="id" th:value="${budget.id}">
                <input type="text" name="mc" lay-verify="required" lay-reqtext="名称不能为空" th:value="${budget.mc}"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <!--        <div class="layui-form-item layui-inline">-->
        <!--            <label class="layui-form-label" style="width: 60px">预算金额</label>-->
        <!--            <div class="layui-input-inline" style="width: 275px">-->
        <!--                <input type="text" name="ysje" th:value="${budget.ysje}" class="layui-input" autocomplete="off">-->
        <!--            </div>-->
        <!--            <label class="layui-form-label" style="width: 60px">年份</label>-->
        <!--            <div class="layui-input-inline" style="width: 275px">-->
        <!--                <input type="text" name="nf" th:value="${budget.nf}" class="layui-input" autocomplete="off">-->
        <!--            </div>-->
        <!--        </div>-->
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label required" style="width: 60px">编码</label>
            <div class="layui-input-inline" style="width: 150px">
                <input type="text" name="bm" lay-verify="required" lay-reqtext="编码不能为空" th:value="${budget.bm}"
                       autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label" style="width: 80px">合计编码</label>
            <div class="layui-input-inline" style="width: 140px">
                <input type="text" name="hjbm" th:value="${budget.hjbm}" class="layui-input" autocomplete="off">
            </div>
            <label class="layui-form-label" style="width: 60px">排序</label>
            <div class="layui-input-inline" style="width: 140px">
                <input type="text" name="px" th:value="${budget.px}" class="layui-input" autocomplete="off">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 60px">备注</label>
            <div class="layui-input-inline" style="width: 650px">
                <textarea id="bz" name="bz" class="layui-textarea" th:text="${budget.bz}" style="height: 200px"
                          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>
</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', 'layCascader'], function () {
        var form = layui.form,
            layer = layui.layer;

        // 监听提交
        form.on('submit(saveBtn)', function (res) {
            var data = res.field;
            var index = layer.load(0, {shade: 0.1});
            AjaxUtil.post({
                url: AjaxUtil.ctx + "baseProjectbudget/doUpdate",
                data: data,
                success: function (res) {
                    layer.close(index);
                    if (0 === res.code) {
                        Message.success(1500, res.message, function () {
                            parent.setUpdateFlag();
                            var windowIndex = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(windowIndex);
                        });
                    } else {
                        Message.error(res.message, 1000);
                    }
                },
                error: function (error) {
                    layer.close(index);
                    Message.error("服务器异常！", 1000);
                }
            });
            return false;
        });

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