@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    var keyValue = $.request("keyValue");
    $(function () {
        gridList();
    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/ProductManage/OrderManage/GetGridJsonMX?keyValue=" + keyValue,
            height: $(window).height() - 96,
            colModel: [
                //{ label: "主键", name: "F_Id", hidden: true, key: true },
                //{ label: '产品ID', name: 'Product_Id', hidden: true },
                //{ label: 'Product SN', name: 'Product_SN', width: 150, align: 'left' },
                //{
                //    label: 'Schedule Time', name: 'PreSellTime', width: 80, align: 'left',
                //    formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' }
                //}
                { label: "主键", name: "F_Id", hidden: true, key: true },
                { label: '产品ID', name: 'Product_Id', hidden: true },
                { label: 'Product No', name: 'ProductSN', width: 70, align: 'left' },
                { label: 'Measurement', name: 'Measurement', width: 80, align: 'left' },//尺寸
                {
                    label: 'Schedule Time', name: 'PreSellTime', width: 80, align: 'left',
                    formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' }
                },
                //{ label: 'Weight', name: 'Weight', width: 60, align: 'left' },//重量
                {
                    label: 'FinishedWeight', name: 'Weight', width: 80, align: 'left',
                    formatter: "number", formatoptions: { thousandsSeparator: ',', defaulValue: '', decimalPlaces: 3 }
                },
                {
                    label: 'RoughWeight', name: 'GrossWeight', width: 80, align: 'left',
                    formatter: "number", formatoptions: { thousandsSeparator: ',', defaulValue: '', decimalPlaces: 3 }
                },
                { label: 'Shape', name: 'Shape', width: 60, align: 'left' },//形状
                { label: 'Certificate No', name: 'CertificateNo', width: 90, align: 'left' },//证书号码
                {
                    label: 'RapaPrice', name: 'RapaPrice', width: 100, align: 'left',
                    formatter: "number", formatoptions: { thousandsSeparator: ',', defaulValue: '', decimalPlaces: 3 }
                },//国际钻石单价
                {
                    label: 'Price', name: 'Price', width: 100, align: 'left',
                    formatter: "number", formatoptions: { thousandsSeparator: ',', defaulValue: '', decimalPlaces: 3 }
                },//销售价
                { label: 'Discount', name: 'Discount', width: 80, align: 'left' },//折扣率
                {
                    label: 'Amount', name: 'Amount', width: 100, align: 'left',
                    formatter: "number", formatoptions: { thousandsSeparator: ',', defaulValue: '', decimalPlaces: 3 }
                },//实际成交价
                { label: 'WH', name: 'WHCodes', width: 50, align: 'left' },
                { label: 'Sort', name: 'Other', width: 50, align: 'left' },
                { label: 'Location', name: 'Location', width: 140, align: 'left' }
            ],
            pager: "#gridPager",
            sortname: 'PreSellTime desc,ProductSN asc',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val() },
            }).trigger('reloadGrid');
        });
    }
    function btn_details() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
        $.modalOpen({
            id: "Details",
            title: "Look",
            url: "/ProductManage/Maintain/Details?keyValue=" + keyValue,
            width: "550px",
            height: "390px",
            btn: null,
        });
    }

    function download(options) {
        var defaults = {
            method: "GET",
            url: "",
            param: []
        };
        var options = $.extend(defaults, options);
        if (options.url && options.param) {
            var $form = $('<form action="' + options.url + '" method="' + (options.method || 'post') + '"></form>');
            for (var key in options.param) {
                var $input = $('<input type="hidden" data-back="backdw" />').attr('name', key).val(options.param[key]);
                $form.append($input);
            }
            $form.appendTo('body').submit().remove();
        };
    }

    function btn_export() {
        debugger;
        var $gridList = $("#gridList");
        download({
            method: "POST",
            url: "/ProductManage/OrderManage/Export",
            param: { keyValue: keyValue }
        });
    }
</script>

<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        @*<div class="btn-group">
            <a id="NF-Export" authorize="yes" style="margin-left:3px;" class="btn btn-primary" onclick="btn_export()"><i class="fa fa-search-plus"></i>导出</a>
        </div>*@
        <script>$('.toolbar').authorizeButton()</script>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="ProductSN" style="width: 100px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    @*<div id="gridPager"></div>*@
</div>