<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>紫光云引擎</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/common.css" />
    <style type="text/css">
        .pdtb table {
            width: 100%;
        }

        .pdtb table tr td {
            text-align: center;
        }

        .pdtb table thead th {
            background: #fff;
            text-align: center;
        }

        .checkedcss td {
            background: #66FFCC;
        }

        .uncheckedcss td {
            background: #fff;
        }
    </style>
    }
</head>

<body>
    <header class="aui-bar aui-bar-nav" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closethisWin()">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="titlelocation">盘点下载</div>
    </header>
    <section class="aui-content-padded  " id="detail" style="margin-top: 60px;">
        <script id="DotTemplate" type="text/x-dot-template">
            <div class="aui-card-list">
                <div class="aui-card-list-header aui-card-list-user">
                    <div class="aui-card-list-user-name">
                        <div class="aui-font-size-16">
                            <b>{{= it.order_number}}</b> &nbsp;
                            <span style="color:#ccc;"></span>&nbsp;
                        </div>
                        <small class="changestatus" data-id="{{= it.id}}" data-status="3">{{= getWmsPandianStatus(it.order_status)}}</small>
                    </div>
                </div>
                <div class="aui-card-list-content aui-border-t" style="margin-left: 1rem;">
                    <ul class="aui-list aui-list-noborder">
                        <div class="aui-list-item aui-padded-l-0 aui-padded-r-15" style="min-height: 1.2rem;">
                            <div class="aui-list-item-title aui-font-size-14 goods-title">创建人:{{= it.creatername}}</div>
                            <div class="aui-list-item-title aui-font-size-14 goods-title">创建时间:{{= it.create_time}}</div>
                        </div>
                        <div class="aui-list-item aui-padded-l-0 aui-padded-r-15" style="min-height: 1.2rem;">
                            <div class="aui-list-item-title aui-font-size-14 goods-title">审核人:{{= it.auditname}}</div>
                            <div class="aui-list-item-title aui-font-size-14 goods-title">审核时间:{{= it.audittime}}</div>
                        </div>
                        <div class="aui-list-item aui-padded-l-0 aui-padded-r-15" style="min-height: 1.2rem;">
                            <div class="aui-list-item-title aui-font-size-14 goods-title">种类:{{= it.totalCount}}</div>
                            <div class="aui-list-item-title aui-font-size-14 goods-title">已盘点数:{{= it.checkCount}}</div>
                        </div>
                    </ul>
                </div>
            </div>
        </script>
    </section>
    <div class="aui-content-padded pdtb" id="dispCont" style="margin-bottom: 75px;">
        <table>
            <thead>
                <tr>
                    <th>ID</th>
                    <th>料号/批次号/序号</th>
                    <th>总数</th>
                    <th>已盘点</th>
                </tr>
            </thead>
            <tbody id="con1">
                <script id="DotTemplate1" type="text/x-dot-template">
                    {{~it:value:index}} {{ if(value.isChecked == 1){ }}
                    <tr class="checkedcss">
                        {{ } else { }}
                        <tr class="uncheckedcss">
                            {{ } }}
                            <td style="width:10%">{{= index+1}}</td>
                            <td style="width:50%">
                                {{ if (value.manageMode == 1) { }} {{= value.batch}} {{ } }} {{ if (value.manageMode == 2) { }} {{= value.sn}} {{ } }} {{ if (value.manageMode == 3) { }} {{= value.inventorysn}} {{ } }}
                            </td>
                            <td style="width:20%">{{= value.totalCount}}</td>
                            <td style="width:20%">{{= value.checkCount}}</td>
                        </tr>
                        {{~}}
                </script>
            </tbody>
        </table>
    </div>
    <footer class="aui-bar aui-bar-tab" id="footer">
        <input type="hidden" name="repairstatus" class="repairstatus">
        <div class="aui-content-padded">
            <div class="aui-list-item-inner aui-list-item-center aui-list-item-btn" id="yjwx_btns">
                <div class="aui-btn aui-btn-info aui-btn-block aui-btn-sm btn_download">下载</div>

            </div>

        </div>
    </footer>
    <input type="hidden" name="" class="data_id">
    <input type="hidden" name="" class="data_json">

</body>

<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/md5.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/swipe.js"></script>
<script type="text/javascript" src="../script/SHA1.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/remotedb.js"></script>
<script type="text/javascript" src="../script/localdb.js"></script>
<script type="text/javascript" src="../script/list.js"></script>
<script type="text/javascript" src="../script/aui-tab.js"></script>
<script type="text/javascript" src="../script/aui-toast.js"></script>
<script type="text/javascript" src="../script/aui-selectbox.js"></script>
<script type="text/javascript" src="../script/aui-popup-new.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/jquery.min.js"></script>
<script type="text/javascript" src="../script/CryptoJS/core.js"></script>
<script type="text/javascript" src="../script/CryptoJS/cipher-core.js"></script>
<script type="text/javascript" src="../script/CryptoJS/mode-ecb.js"></script>
<script type="text/javascript" src="../script/CryptoJS/aes.js"></script>
<script type="text/javascript" src="../script/lang.js"></script>
<script type="text/javascript" src="../script/aui-collapse.js"></script>

<script type="text/javascript">
    var host, id, checkStatus;

    apiready = function() {
        fnReady();
        initRequire()
        ajaxsetup();
        host = $api.getStorage('host');
        id = api.pageParam.id;
        fnInitLocal();
        getDetail(id);
        if (headerHeight > 69) {
            $("#detail").attr("style", "margin-top: 84px;");
        }
    };
    // var host='http://61.177.28.246:8100';
    // ajaxsetup();
    // autologin();
    // getDetail(40);



    function getDetail(id) {
        $.ajax({
            url: host + '/wms/App/GetDetail?id=' + id,
            type: 'GET',
            success: function(result) {
                console.log(JSON.stringify(result));
                if (result.ret == 1) {
                    var testTemplate = doT.template($("#DotTemplate").text());
                    $("#detail").html(testTemplate(result.data));
                    var Template1 = doT.template($("#DotTemplate1").text());
                    result.data.detail.sort(function(a, b) {
                        if (a.isChecked > b.isChecked) return 1;
                        if (a.isChecked < b.isChecked) return -1;
                        return 0;
                    });
                    $("#con1").html(Template1(result.data.detail));
                    checkStatus = result.data.order_status;
                    $('.data_id').val(result.data.id);
                    $('.data_json').val(JSON.stringify(result.data));
                } else {
                    customToast(lang[result.msg], 2000);
                }
            },
            error: function(error) {
                console.log(JSON.stringify(error))
            }
        })
    }

    function reloadMe() {
        location.reload();
    }

    $(".btn_download").click(function() {

        if (checkStatus == '2' || checkStatus == '3') {} else {
            customToast('只有待盘点和盘点中计划可以下载', 2000);
            return;
        }

        var _this = $(this);
        var id = $('.data_id').val();
        var json = $('.data_json').val();
        console.log(id);

        fnInsertPandian(id, json, function() {
            api.toast({
                msg: '下载成功，您可前往离线盘点单查看',
                duration: 2000,
                location: 'bottom'
            });
        });
    });
</script>

</html>
