add.html 7.92 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="receiptId" name="receiptId" class="form-control" type="text" th:value="${receiptId}" readonly="readonly" >
<!--                <input id="companyCode" name="companyCode" type="hidden" th:value="${companyCode}" >-->
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">入库单号:</label>
            <div class="col-sm-8">
                <input id="receiptCode" name="receiptCode" class="form-control" type="text" th:value="${receiptCode}" readonly="readonly">
            </div>
        </div>
<!--        <div class="form-group">-->
<!--            <label class="col-sm-3 control-label">物料编码:</label>-->
<!--            <div class="col-sm-8">-->
<!--                <select id="materialCode" name="materialCode" class="form-control"></select>-->
<!--&lt;!&ndash;                <input id="materialCode" name="materialCode" class="form-control" type="text" onkeyup=" this.value=this.value.replace(/^\s+|\s+$/g,'')">&ndash;&gt;-->
<!--            </div>-->
<!--        </div>-->
        <div class="form-group">
            <label class="col-sm-3 control-label">物料名称:</label>

            <div class="col-sm-6">
                <input id="materialName" name="materialName" 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="materialCode" name="materialCode" 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" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">拆解整托重量:</label>
            <div class="col-sm-8">
                <input id="weight" name="weight" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">电池信息码:</label>
            <div class="col-sm-8">
                <input id="code" name="code" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">白班夜班:</label>
            <div class="col-sm-8">
                <select id="dayShift" name="dayShift" class="form-control" th:with="batteryPackType=${@dict.getType('dayShift')}">
                    <option th:each="dict : ${batteryPackType}" th:text="${dict['dictLabel']}" th:value="${dict['dictValue']}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">再生编号:</label>
            <div class="col-sm-5">
                <input id="regenerationCode" name="regenerationCode" class="form-control" type="text">
            </div>
            <button type="button" class="btn btn-sm btn-success" onclick="createCode(1)">自动生成</button>
            <button type="button" class="btn btn-sm btn-success" onclick="createCode(0)">上一个编号</button>
        </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_material = ctx + "config/material"
    var prefix = ctx + "barCode/barCodeDetail";
    $("#form-receiptDetail-add").validate({
        rules:{
            receiptId:{
                required:true
            },
            receiptCode:{
                required:true
            },
            materialCode:{
                required:true
            },
            totalQty:{
                required:true,
                number: true
            },
            code:{
                required: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 () {
        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' });
        });
        $('#materialCode').select2({
            ajax: {
                url: ctx+'config/material/getData',
                dataType: 'json',
                type: 'post',
                data: function (params) {
                    let query = {
                        materialName: params.term,
                    }
                    return query;
                }
            }
        });
    });
    //生成再生编号,v传1则自动生成,传0则是取上一个编号
    function createCode(v){
        $.ajax({
            cache : false,
            type : "POST",
            url : prefix + "/createRegenerationCode",
            data : {"status":v},
            async : false,
            error : function(request) {
                $.modal.alertError("请求失败!");
            },
            success : function(result) {
                if (result.code == web_status.SUCCESS) {
                    $("#regenerationCode").val(result.data);
                }
            }
        });
    }
    /* 选择物料 */
    function selectMaterial() {
        var url = prefix_material + '/materialSelect';
        $.modal.open("选择物料", url);
    }
</script>
</body>
</html>