shelf.jsp 6.3 KB
<%@ page import="com.myproject.util.StorageConstants" %>
<%@ include file="/common/taglibs.jsp" %>
<%@ page language="java" pageEncoding="UTF-8" %>

<style type="text/css">
.box{
    margin-top: 10px;
}
    .noOp{
        background-color: #e5e5e5 !important;
        cursor: auto !important;
    }
</style>

<link href="${ctx}/scripts/lobibox/css/lobibox.min.css?id=2" rel="stylesheet" type="text/css"/>

<div id="row" class="">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="box">

            <div class="form-group col-lg-12">
                <input type="text" class="form-control" id="scan-code"/>
                <span id="msg"></span>
            </div>

            <div class="form-group col-lg-12">
                <label class="control-label col-md-3">仓位</label>
                <div class="col-md-9">
                    <div class="input-group">

                        <input type="text" class="form-control" id="posName" readonly><span class="input-group-addon">
											<input type="checkbox" id="autoPos" checked>自动推荐
											</span>
                    </div>


                </div>
            </div>

            <div class="form-group col-lg-12">
                <label class="control-label col-md-3">Reel ID</label>
                <div class="col-md-9">
                    <input type="text" class="form-control" readonly id="barcode">
                </div>
            </div>


            <div class="form-group  col-lg-12">
                <label class="control-label col-md-3">Part Number</label>
                <div class="col-md-9">
                    <input type="text" class="form-control" readonly id="partNumber">
                </div>
            </div>


            <div class="form-group  col-lg-12">
                <label class="control-label col-md-3">Qty</label>
                <div class="col-md-9">
                    <input type="text" class="form-control" id="amount" readonly>
                </div>
            </div>


            <div class="col-md-offset-4 col-md-8">
                <div class="form-group  col-lg-6 col-md-6 col-sm-6 col-xs-6 ">
                    <a href="#" class="btn btn-lg green m-icon-big" id="inBtn">
                        入料 <i class="m-icon-big-swapup m-icon-white"></i>
                    </a>
                </div>

                <div class="form-group  col-lg-6 col-md-6 col-sm-6 col-xs-6 ">
                    <a href="#" class="btn btn-lg yellow m-icon-big" id="outBtn">
                        出料 <i class="m-icon-big-swapdown m-icon-white"></i>
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>
<c:set var="scripts" scope="request">
    <script type="text/javascript">
        $(".btn").addClass("noOp");

        function showError(erroMsg){
            $("#msg").text(erroMsg);
            $(".btn").addClass("noOp");
        }

        $(".btn").click(function (){
            var noOp = $(this).hasClass("noOp");
            if(!noOp){
                var pos = $("#posName").val();
                var code = $("#barcode").val();
                $.post("${ctx}/service/store/shelf/inOutPos", {cid: '${show}', code: code, pos: pos}, function (result) {
                    if(result != ''){
                        showError(result);
                    }else{
                        $("#posName").val("");
                        $("#barcode").val("");
                        $("#partNumber").val("");
                        $("#amount").val("");
                        showError("");
                    }
                });
            }
        });

        $("#autoPos").change(function () {
            if ($(this).prop("checked")) {
                $("#posName").attr('readonly',true);
            } else {
                $("#posName").attr('readonly',false);
            }
        });

        $("#posName").change(function () {
            if(!$("#autoPos").prop("checked")){
                var posName = $("#posName").val();
                $.post("${ctx}/service/store/shelf/checkPos", {cid: '${show}', pos: posName}, function (pos) {
                    if(pos){
                        var barcode = pos.barcode;
                        if(barcode){
                            $("#barcode").val(barcode.barcode);
                            $("#partNumber").val(barcode.partNumber);
                            $("#amount").val(barcode.amount);
                            showError("");
                            $("#outBtn").removeClass("noOp");
                        }
                    }else{
                        $("#posName").val("");
                        $("#posName").attr("placeholder", posName);
                        showError("未找到库位");
                    }
                });
            }
        });
        $("#scan-code").change(function () {
            var codeValue = $(this).val();
            $(this).val("");
            $("#posName").val("");
            $("#barcode").val("");
            $("#partNumber").val("");
            $("#amount").val("");
            $(this).val("");
            $(this).attr("placeholder", codeValue);

            showError("");
            $.post("${ctx}/service/store/resolveBarcode", {code: codeValue}, function (data) {
                var barcode = data.barcode;

                if(barcode != null){
                    $("#barcode").val(barcode.barcode);
                    $("#partNumber").val(barcode.partNumber);
                    $("#amount").val(barcode.amount);
                    $("#posName").val(barcode.posName);
                }
                if (data.error == null) {
                    if(barcode.posName == null || barcode.posName == ""){
                        $("#inBtn").removeClass("noOp");
                        $.post("${ctx}/service/store/shelf/nextPos", {cid: '${show}', code: barcode.barcode}, function (posResult) {
                            $("#posName").val(posResult);
                        });
                    }else{

                        $.post("${ctx}/service/store/shelf/checkPos", {cid: '${show}', pos: barcode.posName}, function (pos) {

                        });
                        $("#outBtn").removeClass("noOp");
                    }

                } else {
                    showError(data.error);
                }
            });
        })
    </script>
</c:set>