
@{
    ViewData["Title"] = "OMS订单明细";
    Layout = "~/Pages/Shared/_MainLayout.cshtml";
}

<div class="row">
    <div class="col-sm-12">
        <div class="ibox-content m-b-sm border-bottom">
            <form id="toolbar">
                <div class="form-inline" style="line-height:40px;">
                    <div class="form-group">
                        <label>月份</label>
                        <input id="month" name="month" class="form-control" style="width:130px;" placeholder="年.月" value="@(ViewBag.month)" />
                    </div>
                    <div class="form-group">
                        <label>&nbsp;</label>
                        <button type="button" class="btn btn-primary" onclick="list();"><i class="fa fa-search"></i>&nbsp;查询</button>
                        <button id="btnexport" style="display:none;" type="button" class="btn btn-success" onclick="ExportCSV()">导出</button>
                    </div>
                </div>
            </form>
        </div>

        <div class="ibox-content m-b-sm border-bottom">
            <table id="roletable" style="table-layout:fixed;"></table>
        </div>

    </div>
</div>

@section scripts{
    <script type="text/javascript">

        var tb;
        $(document).ready(function () {
            laydate.render({ elem: '#month', type: 'month' });
            list();

        })

        function list() {

            var month = $('#month').val();

            var columns = [
                { field: 'financecategoryname', title: '财务分类' },
                { field: 'platform_type', title: '平台类型' },
                { field: 'origin_order_id', title: '平台订单号', },
                { field: 'bailun_sku', title: 'SKU' },
                { field: 'amount_sales',title: '销售额' },
                { field: 'cost_product', title: '产品成本' },
                { field: 'cost_platform_fee', title: '平台费' },
                { field: 'cost_paypal_fee', title: 'paypal费' },
                { field: 'cost_fba_fee', title: 'FBA费' },
                { field: 'cost_first', title: '头程费' },
                { field: 'cost_logistics', title: '尾程费' },
                { field: 'total_fee', title: '仓储费' },
                { field: 'cost_handle_platform', title: '平台操作费' },
                { field: 'sale_profit', title: '销售利润' },
                { field: 'quantity_shipped', title: '发货数量' },
                { field: 'shipping_time', title: '发货时间' },
            ];

            var url = '@Url.Content("~/Reports/Finance/MonthSaleProfitNew_OrderDetailJson")' + '?month=' + month +'&financecategory=@(ViewBag.financecategory)';

            if (tb == undefined) {
                tb = OnlyTable("roletable", columns, url, "", {
                    loadsuccess: function (d) {
                        if (d.isexport == 1) {
                            $('#btnexport').show();
                        }
                    }
                });
            }
            else {
                tb.bootstrapTable('refresh', { url: url });
            }
        }

        function ExportCSV() {
            var month = $('#month').val();

            window.open('@Url.Content("~/Reports/Finance/ExportMonthSaleProfitNew_OrderDetail")' + '?month=' + month  +'&financecategory=@(ViewBag.financecategory)', '_blank');

        }


    </script>
}

