<!DOCTYPE html>
<html style="height: 100%;min-height: 100%;">
<head>
    <meta charset="utf-8">
    <title>打印退库管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <style>
        h3, td, th{color: #000000}
        .layui-table td, .layui-table th {border-color: #000000;height: 1px}
    </style>
</head>
<body style="background-color: #fff;height: 100%;min-height: 100%;">

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body" pad15>
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">

                    <div id="print_div">
                        <h3 align="center" style="font-weight: bold;letter-spacing:8px;"><span id="company"></span></br>成品退库单</h3>
                        <table class="layui-table" id="table_total">

                        </table>
                        <table class="layui-table">
                            <tr>
                                <td colspan="8" align="center" style="font-weight: bold;letter-spacing:8px;">退库明细</td>
                            </tr>



                            <tr id="tr_item_total"></tr>
                        </table>
                        <table class="table-embed" border='0' width='100%' height="50px">
                            <tr style="height: 80px;">
                                <td align="center">制单人签字：__________</td>
                                <td align="center">审核人签字：__________</td>
                                <td align="center">财务签字：__________</td>
                                <td align="center">总经理签字：__________</td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="../../layuiadmin/layui/layui.js?t=1"></script>
<script>
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'utils'], function() {
        var $ = layui.$;
        var utils = layui.utils;
        var admin = layui.admin;

        var ids = layui.view.getParameterByName('ids');
        var id = layui.view.getParameterByName('id');
        var cols_total = '';
        cols_total += '<tr>\n' +
            '                        <td align="right">出库单号</td>\n' +
            '                        <td id="no"></td>\n' +
            '                        <td align="right">客户</td>\n' +
            '                        <td id="customer_name"></td>\n' +
            '                        <td align="right">仓别</td>\n' +
            '                        <td id="warehouse_name"></td>\n' +
            '                    </tr>\n' +
            '                     <tr>\n' +
            '                        <td align="right">创建人</td>\n' +
            '                        <td id="create_user_name"></td>\n' +
            '                        <td align="right">创建时间</td>\n' +
            '                        <td id="create_time" colspan="3"></td>\n' +
            '                    <tr>\n' +
            '                         <td align="right">备注</td>\n' +
            '                        <td id="notes" colspan="5"></td>\n' +
            '                    </tr>';
        $('#table_total').html(cols_total);
        admin.req({
            url: '/order/deliver_return/detail/?ids=' + ids + '&id=' + id
            , done: function (data) {
                var main_data = data.data.main_data;
                var deliver_data = data.data.deliver_data;
                $('#no').html(main_data.no);
                $('#company').html(main_data.company);
                $('#create_user_name').html(main_data.create_user_name);
                $('#create_time').html(main_data.create_time);
                $('#customer_name').html(main_data.customer_name);
                $('#return_count').html(main_data.return_count);
                if (utils.isHasPermissions('goods.view_goods_cost')){
                    $('#return_cost').html(main_data.return_cost);
                    $('#total_cost').html(main_data.total_cost);
                }
                $('#total_count').html(main_data.total_count);
                $('#warehouse_name').html(main_data.warehouse_name);
                $('#notes').html(main_data.notes);
                var cols = '';
                cols += '<tr>\n' +
                    '                        <td align="left" width="60">退库单号</td>\n' +
                    '                        <td align="right" width="60">退库数量</td>';
                if (utils.isHasPermissions('goods.view_goods_cost')) {
                    cols += ' <td align="left" width="100">退库成本合计</td>';
                }
                cols += '<td align="left" width="100">退库原因</td>\n' +
                    '                    </tr>';
                $('#tr_item_total').before(cols);
                for (var n in deliver_data) {
                    var cols_data = '';
                    cols_data += "<tr>\n" +
                        "                        <td>" + deliver_data[n].no + "</td>\n" +
                        "                        <td align=\"right\">" + deliver_data[n].return_count + "</td>\n";
                    if (utils.isHasPermissions('goods.view_goods_cost')) {
                        cols_data += "                        <td align=\"right\">" + deliver_data[n].return_cost + "</td>\n";
                    }
                    cols_data += "                        <td align=\"right\">" + deliver_data[n].reason + "</td>\n" +
                        "                    </tr>";
                    $('#tr_item_total').before(cols_data);
                }
            }
        });
    });
    parent.layui.submitChild = function () {
        window.scrollTo(0,0);
        doPrint();
        parent.layui.onSubmitChild();
    };
    function doPrint() {
        document.body.innerHTML=document.getElementById('print_div').innerHTML;
        window.print();
    }
</script>
</body>
</html>

