<!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 layui-inline" style="width: 100%">
            <label class="layui-form-label required" style="width: 70px">软件名称</label>
            <div class="layui-input-inline" style="width: 640px">
                <input type="text" id="rjmc" name="rjmc" lay-verify="required" lay-reqtext="设备名称不能为空"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline" style="width: 100%">
            <label class="layui-form-label required" style="width: 70px">设备型号</label>
            <div class="layui-input-inline" style="width: 640px">
                <input type="text" id="rjxh" name="rjxh" lay-verify="required" lay-reqtext="设备型号不能为空"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline" style="width: 100%">
            <label class="layui-form-label required" style="width: 70px">序号</label>
            <div class="layui-input-inline" style="width: 255px">
                <input type="number" id="xh" name="xh" min="0" autocomplete="off" lay-verify="required"
                       lay-reqtext="序号不能为空" class="layui-input">
            </div>
            <label class="layui-form-label required" style="width: 90px">单价(万元)</label>
            <div class="layui-input-inline" style="width: 255px">
                <input type="number" id="dj" name="dj" min="0" lay-verify="required" lay-reqtext="单价不能为空"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline" style="width: 100%">
            <label class="layui-form-label required" style="width: 70px">数量(套)</label>
            <div class="layui-input-inline" style="width: 255px">
                <input type="number" id="sl" name="sl" min="0" lay-verify="required" lay-reqtext="数量不能为空"
                       autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label required" style="width: 90px">总价(万元)</label>
            <div class="layui-input-inline" style="width: 255px">
                <input type="number" id="zj" name="zj" class="layui-input" readonly>
            </div>
        </div>
        <div class="layui-form-item layui-inline" style="width: 100%">
            <label class="layui-form-label" style="width: 70px">购置时间</label>
            <div class="layui-input-inline" style="width: 255px">
                <input type="text" name="gzsj" id="gzsj" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label" style="width: 100px; margin-left: -10px">使用费计取单价</label>
            <div class="layui-input-inline" style="width: 255px">
                <input type="text" name="syfjqdj" id="syfjqdj" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline" style="width: 100%">
            <label class="layui-form-label" style="width: 70px">生产国别<br>与地区</label>
            <div class="layui-input-inline" style="width: 640px">
                <input type="text" id="scgbydq" name="scgbydq" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline" style="width: 100%">
            <label class="layui-form-label" style="width: 70px">隶属单位</label>
            <div class="layui-input-inline" style="width: 640px">
                <input type="text" id="lsdw" name="lsdw" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline" style="width: 100%">
            <label class="layui-form-label" style="width: 90px; margin-left: -10px">软件主要技<br>术性能指标</label>
            <div class="layui-input-inline" style="width: 640px">
                <textarea id="rjzyjsxnzb" name="rjzyjsxnzb" class="layui-textarea"
                          style="width: 100%; height: 100px"></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>
</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', 'laydate'], function () {
        var form = layui.form,
            laydate = layui.laydate;

        //购置时间
        laydate.render({
            elem: '#gzsj',
            type: 'date',
            value: new Date()
        });

        var dj = 0,
            sl = 0;

        $("#dj").on("input", function (e) {
            //获取input输入的值
            dj = parseFloat(e.delegateTarget.value);
            if (isNaN(dj))
                $("#zj").val('');
            else if (sl != 0)
                $("#zj").val((dj * sl).toFixed(2));
        });
        $("#sl").on("input", function (e) {
            //获取input输入的值
            sl = parseFloat(e.delegateTarget.value);
            if (isNaN(sl))
                $("#zj").val('');
            else if (dj != 0)
                $("#zj").val((dj * sl).toFixed(2));
        });

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            parent.setSoftExpense(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>