stockCheck.jsp 4.1 KB

<%@ include file="/common/taglibs.jsp" %>
<%@ page language="java" pageEncoding="UTF-8" %>

<style type="text/css">

    .modal-body {
        position: relative;
        padding: 15px;
        height: 360px;
        overflow-y: scroll;
    }

    .td-item{
        display: block;
        padding:1px;
    }

</style>
<!-- BEGIN PAGE HEADER-->
<h3 class="page-title">
    <span id="total" style="margin-right:20px;">已盘点: 0</span><span id="ng">NG: 0</span>
</h3>


<!-- BEGIN PAGE CONTENT-->
<div class="row">
    <div class="col-md-12">

        <!-- BEGIN EXAMPLE TABLE PORTLET-->
        <div class="portlet box blue">
            <div class="portlet-title">
                <div class="caption">
                    <i class="fa fa-list-alt"></i>
                </div>
            </div>
            <div class="portlet-body">

                <table class="table table-striped table-hover table-bordered no-footer" role="grid" aria-describedby="sample_editable_1_info">
                    <thead class="dataTableHeader">
                    <tr role="row">
                        <th><fmt:message key="库位"/></th>
                        <th><fmt:message key="条码"/></th>
                        <th><fmt:message key="客户端检测"/></th>
                        <th><fmt:message key="时间"/></th>
                        <th><fmt:message key="操作"/></th>
                    </tr>
                    </thead>
                    <tbody class="dataTableBody" id="dataTableItems">

                    </tbody>
                </table>

            </div>
        </div>
        <!-- END EXAMPLE TABLE PORTLET-->
    </div>
</div>

<c:set var="scripts" scope="request">
    <script type="text/javascript">
        $(document).ready(function(){

            checkout = function(posId) {
                $("#btn"+posId).attr("disabled","true");
                $.post("${ctx}/service/store/checkout.html", {pids: posId}, function (data) {
                    alert(data);
                });
            }

            function flushItems(){
                $.post("${ctx}/service/store/qisda/stockCheckItems", {}, function (data) {
                    var itemsHtml = '';
                    var total = 0;
                    var ng = 0;
                    for(var i in data){
                        var stockCheckItem = data[i];
                        var resultColor = "bg-green";
                        var operate = "";
                        total = total + 1;
                        if(!stockCheckItem.right){
                            resultColor = "bg-red";
                            ng = ng + 1;
                            operate = "<button class='btn yellow' onclick=\"checkout('"+stockCheckItem.posId+"')\"> " +
                            "<i class='fa fa-sign-out'></i><fmt:message key='button.checkout'/></button>";
                        }
                        var trHtml = "<tr>" +
                                "<td class='"+resultColor+" td-item'>"+ stockCheckItem.posName +"</td>" +
                                "<td>"+ stockCheckItem.barcode +"</td>" +
                                "<td>"+ stockCheckItem.clientHasReel +"</td>" +
                                "<td>"+ stockCheckItem.dateStr +"</td>" +
                                "<td>"+ operate +"</td>" +
                                "</tr>";
                        if(!stockCheckItem.right){
                            itemsHtml = trHtml + itemsHtml;
                        }else{
                            itemsHtml = itemsHtml + trHtml;
                        }

                    }
                    $("#dataTableItems").html(itemsHtml);
                    $("#total").html("已盘点: " + total);
                    var ngColor = "";
                    if(ng > 0){
                        ngColor = "color: #ff0000;";
                    }
                    $("#ng").html("NG: <span style='"+ ngColor +"'>" + ng +"</span>");
                });
            }

            flushItems();

            setInterval(function(){
                flushItems();
            }, 1000);

        });
    </script>
</c:set>