
@{
    ViewData["Title"] = "FBA销售订单";
    Layout = "~/Pages/Shared/_MainLayout.cshtml";
    ViewBag.Nav = new string[] { "订单", "FBA销售订单" };
}

<div class="row">
    <div class="col-sm-12">
        <div class="ibox-content m-b-sm border-bottom">
            <form id="toolbar">
                <input id="isfba" name="isfba" type="hidden" value="1" />
                <div class="form-inline" style="line-height:40px;">
                    <div class="form-group" style="display:none;">
                        <label>仓库类型：</label>
                        <select id="warehousetype" name="warehousetype" class="form-control">
                            <option value="FBA仓">FBA仓</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>仓库：</label>
                        <select id="warehousecode" name="warehousecode" class="form-control" style="width:160px;">
                            <option value="">选择仓库</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>销售员：</label>
                        <select id="seller" name="seller" class="form-control" style="width:160px;">
                            <option value="">选择销售员</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>付款时间</label>
                        <input id="start" name="start" type="text" class="form-control" style="width:130px;" value="@(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"))" />
                        <span>至</span>
                        <input id="end" name="end" type="text" class="form-control" style="width:130px;" value="@(DateTime.Now.ToString("yyyy-MM-dd"))" />
                    </div>
                    <div class="form-group">
                        <label>&nbsp;</label>
                        <input id="sku" name="sku" class="form-control" style="width:130px;" placeholder="sku编码" />
                    </div>
                    <div class="form-group">
                        <label>&nbsp;</label>
                        <input id="orderno" name="orderno" class="form-control" style="width:130px;" placeholder="平台订单号" />
                    </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>
                    </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 css{
    <style>
        .mules {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    </style>
}
@section scripts{
    <script type="text/javascript">
        var tb;
        $(document).ready(function () {
            laydate.render({ elem: '#start' });
            laydate.render({ elem: '#end' });

            var height = document.body.clientHeight;
            $("#roletable").attr("data-height", (height - 160));

            list();

            listwarehouse();

            listseller();
        })

        function list() {
            var columns = [
                {
                    field: 'transaction_id', title: '交易号', width: '160', sortable: true, formatter: function (idx, data) {
                        return '<div class="mules" title="' + data.transaction_id + '">' + data.transaction_id + '</div>';
                    }
                },
                {
                    field: 'bailun_order_id', title: '订单编号', width: '200', sortable: true, formatter: function (idx, data) {
                        return '<div class="mules" title="' + data.bailun_order_id + '">' + data.bailun_order_id + '</div>';
                    }
                },
                {
                    field: 'origin_order_id', title: '平台订单号', width: '190', sortable: true, formatter: function (idx, data) {
                        return '<div class="mules" title="' + data.origin_order_id + '">' + data.origin_order_id + '</div>';
                    }
                },
                {
                    field: 'bailun_sku', title: 'sku编码', width: '130', sortable: true, formatter: function (idx, data) {
                        return '<div class="mules" title="' + data.bailun_sku + '">' + data.bailun_sku+'</div>';
                    }
                },
                { field: '', title: '刊登sku编码', width: '130', sortable: true },
                {field: 'sku_image', title: '主图', width: '100', sortable: true, formatter: function (idx, data) {
                        return '<img src="' + data.sku_image + '" style="width:60px" />';
                    }
                },
                {
                    field: 'category_name', title: '分类名称', width: '150', sortable: true, formatter: function (idx, data) {
                        return '<div class="mules" title="' + data.category_name + '">' + data.category_name + '</div>';
                    }
                },
                {
                    field: 'sku_title_en', title: '英文标题', width: '130', sortable: true, formatter: function (idx, data) {
                        return '<div class="mules" title="' + data.sku_title_en + '">' + data.sku_title_en + '</div>';
                    }
                },
                {
                    field: 'sku_title_cn', title: '中文标题', width: '130', sortable: true, formatter: function (idx, data) {
                        return '<div class="mules" title="' + data.sku_title_cn + '">' + data.sku_title_cn + '</div>';
                    }
                },
                { field: 'color', title: '颜色', width: '90', sortable: true },
                { field: 'character', title: '规格', width: '90', sortable: true },
                { field: 'price', title: '价格', width: '100', sortable: true },
                { field: 'bailun_sku_quantity_ordered', title: '订购数量', width: '110', sortable: true },
                { field: 'amount_product', title: '合计金额', width: '100', sortable: true },
                { field: 'order_currency', title: '币种', width: '90', sortable: true },
                { field: '', title: '币种（中）', width: '100', sortable: true },
                { field: 'platform_type', title: '平台', width: '100', sortable: true },
                { field: 'website', title: '站点', width: '90', sortable: true },
                { field: 'seller_account', title: '销售帐号', width: '90', sortable: true },
                { field: 'seller_name', title: '销售员', width: '90', sortable: true },
                {
                    field: 'salecount', title: 'fba订单', width: '100', sortable: false, formatter: function (idx, data) {
                        return data.isfba == 1 ? "是" : "否";
                    }
                },
                { field: 'bailun_order_status', title: '订单状态', width: '100', sortable: true },
                { field: 'warehouse_name', title: '发货仓库', width: '110', sortable: true },
                { field: 'shipping_status', title: '发货状态', width: '140', sortable: true },
                { field: 'create_time', title: '创建时间', width: '140', sortable: true },
                { field: 'order_update_time', title: '更新时间', width: '140', sortable: true },
                { field: 'gmt_modified', title: '同步时间', width: '140', sortable: true },
            ];

            var url = '@Url.Content("~/Reports/Orders/SkuOrderListJson")' + '?' + $("#toolbar").serialize();

            if (tb == undefined) {
                tb = OnlyTable("roletable", columns, url, "",);
            }
            else {
                tb.bootstrapTable('refresh', { url: url });
            }
        }


        function listwarehouse() {
            $.submit({
                url: '@Url.Content("~/Home/ListWareHouse")',
                paramData: '',
                type:'POST',
                func: function (result) {
                    if (result != null && result != undefined) {
                        $('#warehousecode').html('<option value="">仓库不限</option>');
                        for (var i = 0; i < result.length; i++) {
                            $('#warehousecode').append('<option value="' + result[i].warehouse_code + '">' + result[i].warehouse_name + '</option>');
                        }
                    }
                }
            })
        }

        function listseller() {
            $.submit({
                url: '@Url.Content("~/Orders/ListSeller")',
                paramData: '',
                type:'POST',
                func: function (result) {
                    if (result != null && result != undefined) {
                        $('#seller').html('<option value="">选择销售员</option>');
                        for (var i = 0; i < result.length; i++) {
                            $('#seller').append('<option value="' + result[i] + '">' + result[i] + '</option>');
                        }
                    }
                }
            })
        }

    </script>

}





