add.html 6.53 KB
<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head>
    <th:block th:include="include :: header" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-receiptDetail-add">
        <div class="form-group">
            <label class="col-sm-3 control-label">库存头表id:</label>
            <div class="col-sm-8">
                <input id="inventoryHeaderId" name="inventoryHeaderId" class="form-control" type="text" th:value="${inventoryHeaderId}" readonly="readonly" >
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">库位编码:</label>
            <div class="col-sm-8">
                <input id="locationCode" name="locationCode" th:value="${locationCode}" class="form-control" type="text" readonly="readonly">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">容器编码:</label>
            <div class="col-sm-8">
                <input id="containerCode" name="containerCode" th:value="${containerCode}" class="form-control" type="text" readonly="readonly">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">物料编码:</label>

            <div class="col-sm-6">
                <input id="materialCode" name="materialCode" required class="form-control" type="text" readonly="readonly">
            </div>
            <a class="btn  btn-primary btn-rounded " onclick="selectMaterial()">
                选择物料
            </a>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">物料名称:</label>
            <div class="col-sm-8">
                <input id="materialName" name="materialName" class="form-control" type="text" readonly="readonly">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">物料规格:</label>
            <div class="col-sm-8">
                <input id="materialSpec" name="materialSpec" class="form-control" type="text" readonly="readonly">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">物料单位:</label>
            <div class="col-sm-8">
                <input id="materialUnit" name="materialUnit" class="form-control" type="text" readonly="readonly">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">数量:</label>
            <div class="col-sm-8">
                <input id="qty" name="qty" required class="form-control"  value="1" type="text" >
            </div>
        </div>

        <div class="form-group">
            <div class="form-control-static col-sm-offset-9">
                <button type="submit" class="btn btn-primary"  >提交</button>
                <button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />

<script type="text/javascript">
    var prefix = ctx + "inventory/inventoryHeaderCheckCount";
    var prefix_material = ctx + "config/material"
    $("#form-receiptDetail-add").validate({
        rules:{
            receiptId:{
                required:true
            },
            receiptCode:{
                required:true
            },
            receiptType:{
                required:true
            },
            materialCode:{
                required:true
            },
            totalQty:{
                // required:true,
                number: true
            }
        },
        submitHandler: function(form) {
            $.ajax({
                cache : true,
                type : "POST",
                url : prefix + "/add",
                data : $("#form-receiptDetail-add").serializeArray(),
                async : false,
                error : function(request) {
                    $.modal.alertError("请求失败!");
                },
                success : function(data) {
                    // $.operate.saveSuccess(data);
                    ajaxSuccess(data);
                }
            });
        }
    });
    function ajaxSuccess(result) {
        if (result.code == web_status.SUCCESS) {
            $.modal.msgSuccess(result.msg);
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
            window.parent.loadDetail();
        } else {
            $.modal.alertError(result.msg);
        }
        $.modal.closeLoading();
    }

    $(function () {
        // var type = $("#receiptType").attr("value");
        // if (type!='DCBRK') {
        //     $("#electricQuantity").attr("readonly", true);
        //     $("#batteryPackageWeight").attr("readonly", true);
        // }
        layui.use('laydate', function() {
            var laydate = layui.laydate;
            laydate.render({ elem: '#manufactureDate', theme: 'molv', format: 'yyyy-MM-dd HH:mm:ss' });
            laydate.render({ elem: '#expirationDate', theme: 'molv', format: 'yyyy-MM-dd HH:mm:ss' });
            laydate.render({ elem: '#recoveryDate', theme: 'molv', format: 'yyyy-MM-dd HH:mm:ss' });
            laydate.render({ elem: '#receiptDate', theme: 'molv', format: 'yyyy-MM-dd HH:mm:ss' });
        });
        // $('#materialCode').select2({
        //     ajax: {
        //         url: ctx+'config/material/getData',
        //         dataType: 'json',
        //         type: 'post',
        //         data: function (params) {
        //             let query = {
        //                 materialName: params.term,
        //             }
        //             return query;
        //         }
        //     }
        // });



        $('#materialCode').select2({
            ajax: {
                url: ctx+'config/material/getMaterial',
                dataType: 'json',
                type: 'post',
                data: function (params) {
                    let query = {
                        materialName: params.term,
                    }
                    return query;
                }
            }
        });
    });


    /* 选择物料 */
    function selectMaterial() {
        var url = prefix_material + '/materialSelect';
        $.modal.open("选择物料", url);
    }
</script>
</body>
</html>