var mmg;
function initSaleGrid(){
    var laydate = layui.laydate;
    laydate.render({
        elem: '#startDate'
    });
    laydate.render({
        elem: '#endDate'
    });
    var h = WST.pageHeight();
    var cols = [
            {title:' ', name:'goodsName', width: 30, renderer: function(val,item,rowIndex){
            	var thumb = item['goodsImg'];
	        	// thumb = thumb.replace('.','_thumb.');
                thumb = thumb+'?x-oss-process=image/resize,w_60,h_60';
                return "<span class='weixin'><a target='_blank' href='"+WST.U("home/goods/detail","id="+item['goodsId'])+"'><img id='img' onmouseout='toolTip()' onmouseover='toolTip()' style='height:60px;width:60px;' src='"+WST.conf.IMGURL+"/"+thumb
            	+"'><span class='imged' ><img  style='height:180px;width:180px;' src='"+WST.conf.IMGURL+"/"+item['goodsImg']+"'></span></span>";
            }},
            {title:'商品名称', name:'goodsName', width: 150},
            {title:'商品编号', name:'goodsSn', width: 80},
            {title:'所属店铺', name:'shopName', width: 150},
            {title:'订单总数', name:'orderNum', width: 80},
            {title:'浏览总数', name:'pageNum', width: 80},
            {title:'销量总数', name:'goodsNum' , width: 20},
            {title:'操作', name:'' ,width:150, align:'center', renderer: function(val,item,rowIndex){
                var h = "";
                h += "<a class='btn btn-blue' target='_blank' href='"+WST.U("home/goods/detail","id="+item['goodsId'])+"'><i class='fa fa-search'></i>查看</a> ";
                return h;
            }}
            ];
 
    mmg = $('.mmg').mmGrid({height: (h-85),indexCol: true,indexColWidth:50,  cols: cols,method:'POST',
        url: WST.U('admin/reports/topSaleGoodsByPage',WST.getParams('.ipt')), fullWidthRows: true, autoLoad: true,
        plugins: [
            $('#pg').mmPaginator({})
        ]
    });  
}
function loadGrid(){
	var params = WST.getParams('.ipt');
    params.goodsCatIdPath = WST.ITGetAllGoodsCatVals('cat_0','pgoodsCats').join('_');
    params.page = 1;
	mmg.load(params);
}
function toolTip(){
    WST.toolTip();
}